/* =====================================================================
   Main page recipe list: the "recipe journal" card (index-enhanced.html).
   Markup comes from createRecipeCard in search-filter.js. One recipe per
   row: photo | the recipe in the cook's own words | facts and community.
   Loaded after styles.css and search-filter.css; the id-plus-classes
   selectors are what outrank their !important grid rules.
   ===================================================================== */
#recipes {
    --rj-green: var(--primary-color, #1f4836);
    --rj-green-2: #2d5a44;
    --rj-gold: #bf9b30;
    --rj-gold-ink: #6b5210;
    --rj-gold-soft: #f6ecc9;
    --rj-sage-soft: #e8eee0;
    --rj-cream: #f5efe1;
    --rj-paper: #fffdf7;
    --rj-ink: #24302a;
    --rj-muted: #6b7263;
    --rj-line: #e2dccb;
    --rj-serif: var(--heading-font, 'Cormorant Garamond', Georgia, serif);
    --rj-sans: var(--body-font, 'Inter', -apple-system, 'Segoe UI', sans-serif);
}

#recipes #recipes-heading {
    max-width: 1100px;
    margin: 1.5rem auto 0.9rem;
    padding: 0 16px;
    text-align: left;
    font-family: var(--rj-serif);
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--rj-green);
}

#recipes-container.recipe-showcase.recipe-showcase {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
    width: 100% !important;
    max-width: 1100px !important;
    margin: 0 auto 2rem !important;
    padding: 0 16px !important;
    box-sizing: border-box;
}
#recipes-container .recipe-card-wrapper { margin: 0 !important; width: 100%; }

/* ---- The card ---- */
.rj {
    display: grid;
    grid-template-columns: 190px minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    padding: 14px;
    border-radius: 16px;
    background: var(--rj-paper);
    box-shadow: 0 2px 12px rgba(31, 72, 54, 0.08);
    font-family: var(--rj-sans);
    color: var(--rj-ink);
    text-align: left;
}

/* Photo */
.rj-photo {
    position: relative;
    display: block;
    aspect-ratio: 1;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #e9e4d6;
}
.rj-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rj-photo-empty { display: none; }
.rj-photo-none .rj-photo-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    padding: 10px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--rj-gold-ink);
    background: repeating-linear-gradient(135deg, #f6ecc9 0 10px, #f1e3b6 10px 20px);
}
.rj-photo-none .rj-photo-empty b { font-family: var(--rj-serif); font-size: 2rem; color: var(--rj-gold); line-height: 1; }
.rj-new,
.rj-cooked {
    position: absolute;
    z-index: 1;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
}
.rj-new { left: 8px; top: 8px; background: var(--rj-green); color: #fff; letter-spacing: 0.06em; text-transform: uppercase; }
.rj-cooked { left: 8px; bottom: 8px; background: var(--rj-gold); color: #1d2a23; }

/* The recipe, in the cook's own words */
.rj-mid { display: grid; gap: 8px; align-content: start; min-width: 0; }
.rj-title { margin: 0; font-family: var(--rj-serif); font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
.rj-title a { color: var(--rj-green); text-decoration: none; }
.rj-title a:hover { text-decoration: underline; text-underline-offset: 4px; }
.rj-who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.8rem; }
.rj-cook { display: inline-flex; align-items: center; gap: 8px; color: var(--rj-ink); text-decoration: none; }
.rj-cook b { font-weight: 700; }
.rj-cook:hover b { color: var(--rj-green); text-decoration: underline; }
.rj-roots { color: var(--rj-muted); }
.rj-roots:empty { display: none; }
/* Every cook looks the same: their photo, or their initial. */
.rj-av {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: 50%;
    object-fit: cover;
    display: inline-grid;
    place-items: center;
    background: var(--rj-sage-soft);
    color: var(--rj-green);
    border: 1px solid rgba(31, 72, 54, 0.18);
    font: 700 0.85rem var(--rj-serif);
}
.rj-av-sm { width: 22px; height: 22px; font-size: 0.7rem; }
.rj-desc {
    margin: 0;
    font-family: var(--rj-serif);
    font-size: 1.08rem;
    line-height: 1.4;
    color: var(--rj-ink);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rj-credit { margin: 0; display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 10px; font-size: 0.8rem; }
.rj-credit i { margin-top: 3px; }
.rj-credit em { font-family: var(--rj-serif); font-size: 1rem; }
.rj-credit a { color: inherit; font-weight: 600; }
.rj-insp { background: var(--rj-gold-soft); color: #4f3d0c; }
.rj-remix { background: var(--rj-sage-soft); color: #2f4a2a; }
.rj-src { background: #eef1f4; color: #33465a; }
.rj-full {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 2px;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--rj-green);
    color: #fff !important;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
}
.rj-full:hover { background: var(--rj-green-2); }

/* Facts and the community */
.rj-side { display: grid; gap: 9px; align-content: start; min-width: 0; padding-left: 16px; border-left: 1px dashed var(--rj-line); }
.rj-side h4 { margin: 0; font-family: var(--rj-sans); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--rj-muted); }
.rj-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 0.78rem; color: var(--rj-muted); }
.rj-country { font-weight: 700; color: var(--rj-green); }
.rj-dots { display: inline-flex; gap: 2px; margin-right: 4px; vertical-align: 1px; }
.rj-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--rj-line); }
.rj-dots i.on { background: var(--rj-gold); }
.rj-comm { display: grid; gap: 4px; font-size: 0.8rem; }
.rj-comm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rj-comm a { color: var(--rj-green); font-weight: 600; }
.rj-more { color: var(--rj-muted); }
.rj-stars { color: var(--rj-gold); letter-spacing: 1px; font-size: 0.78rem; }
.rj-stars span { color: var(--rj-line); }
.rj-note { margin: 0; font-family: var(--rj-serif); font-style: italic; font-size: 1rem; color: var(--rj-ink); }
.rj-first { color: var(--rj-green); font-weight: 600; text-decoration: none; }
.rj-first:hover { text-decoration: underline; }

.rj .rj-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.rj .rj-acts .action-btn,
.rj .rj-acts .rj-made {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    margin: 0 !important;
    padding: 4px 11px !important;
    border-radius: 999px !important;
    border: 1px solid var(--rj-line) !important;
    background: #fff !important;
    color: var(--rj-green) !important;
    font: 600 0.74rem var(--rj-sans) !important;
    box-shadow: none !important;
    text-decoration: none;
    cursor: pointer;
    width: auto !important;
}
.rj .rj-acts .action-btn:hover { border-color: var(--rj-green) !important; }
.rj .rj-acts .btn-favorite.active { background: #f8e3dc !important; border-color: #e6b8a8 !important; color: #9a3a23 !important; }
.rj .rj-acts .btn-weekly-menu.active { background: var(--rj-sage-soft) !important; border-color: #b9c9a8 !important; }
.rj .rj-acts .rj-made { background: var(--rj-green) !important; border-color: var(--rj-green) !important; color: #fff !important; }

.rj a:focus-visible,
.rj button:focus-visible { outline: 2px solid var(--rj-gold); outline-offset: 2px; }

/* ---- Narrower screens ---- */
@media (max-width: 960px) {
    .rj { grid-template-columns: 150px minmax(0, 1fr); }
    .rj-side { grid-column: 1 / -1; padding: 10px 0 0; border-left: 0; border-top: 1px dashed var(--rj-line); }
}
@media (max-width: 768px) {
    /* styles.css turns the list into two tiles per row on phones; journal
       cards stay one per row. */
    #recipes-container.recipe-showcase.recipe-showcase { grid-template-columns: minmax(0, 1fr) !important; gap: 12px !important; padding: 0 12px !important; }
}
/* Phones: the "compact journal" card. The middle and side columns dissolve
   (display: contents) so their pieces can be placed on one grid: a small
   photo beside the title, cook and facts; two lines in the cook's own
   words; the credit and community note; then one row of icon buttons and
   "See the full recipe". About 2½ recipes fit on a screen instead of one. */
@media (max-width: 600px) {
    .rj {
        grid-template-columns: 92px minmax(0, 1fr);
        grid-template-areas:
            "photo title"
            "photo who"
            "photo facts"
            "desc  desc"
            "credit credit"
            "comm  comm"
            "foot  foot";
        grid-template-rows: auto auto 1fr;
        gap: 0 11px;
        padding: 12px;
        border-radius: 14px;
    }
    .rj-mid,
    .rj-side { display: contents; }
    .rj-side h4 { display: none; }

    .rj-photo { grid-area: photo; align-self: start; aspect-ratio: 1; border-radius: 10px; }
    .rj-photo-none .rj-photo-empty { font-size: 0; }
    .rj-photo-none .rj-photo-empty b { font-size: 1.7rem; }
    .rj-new { left: 5px; top: 5px; padding: 2px 7px; font-size: 0.55rem; }
    .rj-cooked { left: 5px; bottom: 5px; padding: 2px 7px; font-size: 0.6rem; }

    .rj-title { grid-area: title; font-size: 1.2rem; line-height: 1.15; }
    .rj-who { grid-area: who; margin-top: 4px; flex-wrap: nowrap; min-width: 0; font-size: 0.74rem; }
    .rj-who .rj-cook { flex: 0 0 auto; gap: 6px; }
    .rj-who .rj-av { width: 22px; height: 22px; font-size: 0.7rem; }
    .rj-roots { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .rj-facts { grid-area: facts; align-self: start; margin-top: 4px; gap: 2px 10px; font-size: 0.7rem; }

    .rj-desc { grid-area: desc; margin-top: 10px; -webkit-line-clamp: 2; font-size: 0.98rem; line-height: 1.35; }
    .rj-credit { grid-area: credit; margin-top: 8px; padding: 5px 9px; font-size: 0.72rem; }
    .rj-credit em { font-size: 0.9rem; }
    .rj-comm,
    .rj-side > .rj-comm { grid-area: comm; margin-top: 8px; font-size: 0.72rem; }
    .rj-note { font-size: 0.95rem; }

    /* One row: Favorite, Weekly menu and Share as round icons on the left,
       "See the full recipe" on the right. The labels stay in the buttons for
       screen readers; only their visible size is zero. */
    .rj .rj-acts,
    .rj-full { grid-area: foot; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--rj-line); }
    .rj .rj-acts { flex-wrap: nowrap; gap: 6px; align-self: center; }
    .rj-full { justify-self: end; align-self: end; border-top: 0; padding: 7px 13px; margin: 0 0 1px; font-size: 0.76rem; }
    #recipes-container .rj .rj-acts .action-btn {
        width: 32px !important;
        height: 32px;
        padding: 0 !important;
        justify-content: center;
        font-size: 0 !important;
        gap: 0;
    }
    #recipes-container .rj .rj-acts .action-btn i { font-size: 0.85rem; }
    /* "Be the first to cook this" already leads to the same place. */
    .rj .rj-acts .rj-made { display: none !important; }
}
