/* ============================================================================
   Recipes page
   Everything is prefixed `rc-` so it can't collide with the generic `.header`,
   `.recipe-details` or `.recipe-section` rules other pages ship globally.
   ========================================================================= */

.rc-recipes { max-width: 1200px; }

/* ---- Hero ---- */
.rc-hero {
    padding: var(--space-8) 0 var(--space-5);
}

.rc-hero h1 {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: var(--weight-extrabold);
    letter-spacing: -0.03em;
    color: var(--color-text);
    margin: 0 0 var(--space-2);
}

.rc-hero-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin: 0;
    color: var(--color-text-secondary);
    font-size: var(--text-base);
}

.rc-hero-count {
    padding: 2px 10px;
    border-radius: var(--radius-full);
    background: var(--color-primary-subtle);
    color: var(--color-link);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
}

/* ---- Toolbar: search, categories, filters ---- */
.rc-toolbar {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.rc-search { position: relative; }

.rc-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

.rc-search input {
    width: 100%;
    min-height: 48px;
    padding: 12px 44px 12px 42px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg-elevated);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 16px;   /* 16px stops iOS zooming on focus */
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}

.rc-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.rc-search input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.rc-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.rc-search-clear:hover { background: var(--color-bg-sunken); color: var(--color-text); }

/* Category chips scroll sideways on small screens instead of wrapping into a
   tall block that pushes results off the first screen. */
.rc-cats {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
}

.rc-cats::-webkit-scrollbar { display: none; }

.rc-chip,
.rc-toggle,
.rc-saved-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    min-height: 38px;
    padding: 6px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-bg-elevated);
    color: var(--color-text-secondary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out);
}

.rc-chip:hover,
.rc-toggle:hover,
.rc-saved-toggle:hover { border-color: var(--color-text-muted); color: var(--color-text); }

.rc-chip[aria-pressed="true"],
.rc-toggle[aria-pressed="true"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.rc-chip-count {
    min-width: 1.5em;
    padding: 0 6px;
    border-radius: var(--radius-full);
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.rc-chip-count:empty { display: none; }

.rc-chip[aria-pressed="true"] .rc-chip-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.rc-chip:focus-visible,
.rc-toggle:focus-visible,
.rc-saved-toggle:focus-visible,
.rc-fav:focus-visible,
.rc-filters summary:focus-visible,
.rc-link-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Filter drawer */
.rc-filters {
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    background: var(--color-bg-elevated);
}

.rc-filters summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-4);
    list-style: none;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    border-radius: var(--radius-lg);
}

.rc-filters summary::-webkit-details-marker { display: none; }

.rc-filters summary svg { width: 18px; height: 18px; color: var(--color-text-muted); }

.rc-filters summary::after {
    content: "";
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: rotate(45deg) translateY(-2px);
    transition: transform var(--duration-fast) var(--ease-out);
}

.rc-filters[open] summary::after { transform: rotate(-135deg) translateY(-2px); }

.rc-filter-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: #fff;
    font-size: 11px;
    line-height: 20px;
    text-align: center;
}

.rc-filter-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4) var(--space-6);
    padding: var(--space-2) var(--space-4) var(--space-4);
    border-top: 1px solid var(--color-border-subtle);
}

.rc-filter-group {
    margin: 0;
    padding: 0;
    border: none;
    min-width: 0;
}

.rc-filter-group legend {
    padding: var(--space-3) 0 var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

.rc-toggle-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.rc-toggle { min-height: 34px; padding: 4px 12px; font-size: var(--text-xs); }

.rc-filter-numbers {
    display: flex;
    gap: var(--space-3);
    align-items: flex-end;
    padding-top: var(--space-3);
}

.rc-filter-numbers label {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

.rc-filter-numbers input {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-elevated);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 16px;
    text-transform: none;
    letter-spacing: normal;
}

.rc-filter-numbers input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

/* ---- Results bar ---- */
.rc-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    min-height: 38px;
}

.rc-results-count {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
}

.rc-results-actions { display: flex; align-items: center; gap: var(--space-3); }

.rc-link-btn {
    border: none;
    background: none;
    padding: 6px 4px;
    color: var(--color-link);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.rc-saved-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.rc-saved-toggle[aria-pressed="true"] {
    background: var(--color-warning-subtle);
    border-color: var(--color-warning-border);
    color: var(--color-warning);
}

.rc-saved-toggle[aria-pressed="true"] svg { fill: currentColor; }

/* ---- Grid & cards ---- */
.rc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.rc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-5);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-xl);
    background: var(--color-bg-elevated);
    min-width: 0;
    transition: transform var(--duration-base) var(--ease-out),
                box-shadow var(--duration-base) var(--ease-out),
                border-color var(--duration-base) var(--ease-out);
}

.rc-card--breakfast { --rc-accent: #E0A33B; }
.rc-card--lunch { --rc-accent: var(--color-primary); }
.rc-card--dinner { --rc-accent: #5B6CC8; }
.rc-card--snack { --rc-accent: #C2688A; }
.rc-card--post_workout { --rc-accent: #2F8FB3; }
.rc-card--trail { --rc-accent: #8A6A3E; }

.rc-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.rc-card:focus-within { box-shadow: 0 0 0 2px var(--color-primary); }

.rc-card-top {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 32px;
}

.rc-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--color-bg-sunken);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
}

.rc-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--rc-accent, var(--color-primary));
}

.rc-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
}

.rc-time svg { width: 14px; height: 14px; }

/* The save star sits above the stretched card link. */
.rc-fav {
    position: relative;
    z-index: 2;
    margin-left: auto;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.rc-fav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.rc-fav:hover { background: var(--color-bg-sunken); color: var(--color-warning); }
.rc-fav.is-saved { color: var(--color-warning); }
.rc-fav.is-saved svg { fill: currentColor; }
.rc-fav:disabled { opacity: 0.6; cursor: progress; }

.rc-card-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    line-height: var(--leading-snug);
    color: var(--color-text);
}

.rc-card-link { color: inherit; text-decoration: none; }
.rc-card-link:focus { outline: none; }

/* Stretch the title link over the whole card, so the card is one big target
   while the save button (z-index 2) stays independently clickable. */
.rc-card-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}

.rc-card-desc {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rc-macros {
    margin-top: auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    margin-bottom: 0;
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    background: var(--color-bg-sunken);
}

.rc-macros div { display: flex; flex-direction: column-reverse; gap: 2px; text-align: center; min-width: 0; }

.rc-macros dt {
    font-size: 10px;
    font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

.rc-macros dd {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rc-card-per {
    margin: calc(-1 * var(--space-2)) 0 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.rc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rc-tags li {
    padding: 2px 9px;
    border-radius: var(--radius-full);
    background: var(--color-primary-subtle);
    color: var(--color-link);
    font-size: 11px;
    font-weight: var(--weight-semibold);
}

/* Skeleton while loading */
.rc-card--skeleton { min-height: 230px; }
.rc-card--skeleton span {
    display: block;
    height: 14px;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg, var(--color-bg-sunken) 0%, var(--color-border-subtle) 50%, var(--color-bg-sunken) 100%);
    background-size: 200% 100%;
    animation: rc-shimmer 1.2s linear infinite;
}
.rc-card--skeleton span:nth-child(1) { width: 30%; }
.rc-card--skeleton span:nth-child(2) { width: 75%; height: 20px; }
.rc-card--skeleton span:nth-child(3) { width: 100%; height: 56px; margin-top: auto; }

@keyframes rc-shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
    .rc-card, .rc-card:hover { transition: none; transform: none; }
    .rc-card--skeleton span { animation: none; }
}

/* ---- Empty, error, more ---- */
.rc-empty {
    padding: var(--space-10) var(--space-6);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-xl);
    text-align: center;
    color: var(--color-text-secondary);
}

.rc-empty-title { margin: 0 0 var(--space-1); font-weight: var(--weight-semibold); color: var(--color-text); }
.rc-empty-sub { margin: 0 0 var(--space-4); font-size: var(--text-sm); }

.rc-error {
    grid-column: 1 / -1;
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    background: var(--color-error-subtle);
    color: var(--color-error);
    text-align: center;
}

.rc-more { display: flex; justify-content: center; margin-bottom: var(--space-10); }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .rc-hero { padding-top: var(--space-5); }
    .rc-hero h1 { font-size: var(--text-2xl); }
    .rc-grid { grid-template-columns: 1fr; gap: var(--space-3); }
    .rc-card { padding: var(--space-4); }
    .rc-filter-body { grid-template-columns: 1fr; }
    .rc-cats { margin: 0 calc(-1 * var(--space-4)); padding-left: var(--space-4); padding-right: var(--space-4); }
}

/* ---- Dark mode ---- */
[data-theme="dark"] .rc-card--breakfast { --rc-accent: #F0B85A; }
[data-theme="dark"] .rc-card--dinner { --rc-accent: #8C9BEA; }
[data-theme="dark"] .rc-card--snack { --rc-accent: #E08AAB; }
[data-theme="dark"] .rc-card--post_workout { --rc-accent: #5DB5D6; }
[data-theme="dark"] .rc-card--trail { --rc-accent: #C49A63; }
