/* Base styles ported from eagombar.uk */
@keyframes fadeIn {
    0% {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes skeleton-pulse {

    0%,
    to {
        opacity: 0.3;
    }

    50% {
        opacity: 0.5;
    }
}

@font-face {
    font-family: "Fira Code";
    src:
        url(/static/fonts/FiraCode-VF.woff2) format("woff2-variations");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: light dark;
    --radius: 20px;
    --width: 1200px;
    --min-width: 600px;
    --foreground: light-dark(#071c02, #e0e0e0);
    --background: light-dark(#e3e3e3, #222222);
    --surface: light-dark(rgba(249, 249, 249, 0.8), rgba(28, 28, 28, 0.8));
    --surface-solid: light-dark(rgba(249, 249, 249), rgba(28, 28, 28));
    --primary: #ff6b6b;
    /* Hover states: colour and timing shared by every interactive element */
    --hover-text: var(--primary);
    --hover-ease: 0.2s ease;
    --muted-text: light-dark(#c5c5c5, #999999);
    --shadow-primary: light-dark(rgba(100, 100, 100, 0.9),
            rgba(100, 100, 100, 0.3));
    --shadow-soft: light-dark(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.35));
    /* Background dots: darker than the page colour */
    --dot-colour: light-dark(#c9c9c9, #121212);
}

* {
    box-sizing: border-box;
}

html {
    /* Page still scrolls; the scrollbar itself is hidden */
    scrollbar-width: none;
    /* No double-tap or pinch zoom: allow scrolling only */
    touch-action: pan-x pan-y;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    touch-action: pan-x pan-y;
}

/* App-like feel: no grey tap flash, no text-selection callouts on controls */
a,
button,
label {
    -webkit-tap-highlight-color: transparent;
}

button,
.recipe-back-link,
.type-filter-btn,
.stepper,
.segmented,
.recipe-card {
    -webkit-user-select: none;
    user-select: none;
}

/* Keep clear of the notch / home indicator when installed */
main#content {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

@media (display-mode: standalone) {
    html {
        overscroll-behavior-y: none;
    }
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
}

body,
main#content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

body {
    justify-content: center;
    font-family: "Fira Code", Helvetica, sans-serif;
    font-style: normal;
    background-color: var(--background);
    margin: 0;
    color: var(--foreground);
}

main#content {
    width: 100%;
}

h1,
h2 {
    font-size: 1.5em;
}

h2 {
    padding: 10px;
    margin: 0;
}

/* ---------- Background: a grid of dots, darker than the page ---------- */
.background-dots {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: var(--background);
    background-image: radial-gradient(circle at center, var(--dot-colour) 1.6px, transparent 1.6px);
    background-size: 32px 32px;
    background-position: -16px -16px;
}

@media print {
    .background-dots {
        display: none;
    }
}

/* ---------- Recipe site ---------- */
/* Theme: follows the system unless the visitor picks one (data-theme set
   by the inline script in base.html). light-dark() follows color-scheme. */
:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
}

main#content {
    padding-top: calc(10px + env(safe-area-inset-top));
}

/* Solid strip under the iOS status bar. Installed web apps let the page
   scroll beneath the status bar and blur it; with only a flat colour behind
   it, the blur disappears. Zero height in a normal browser tab. */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background-color: var(--background);
    z-index: 900;
    pointer-events: none;
}

:root {
    --card-radius: 14px;
    --chip-bg: light-dark(rgba(255, 107, 107, 0.12), rgba(255, 107, 107, 0.15));
    --line: light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.08));
    --muted: light-dark(#6b6b6b, #999999);
}

a {
    color: var(--primary);
}

button {
    font-family: inherit;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.content-box {
    background-color: var(--surface-solid);
    border-radius: var(--radius);
    padding: 10px 20px;
    margin: 10px 0;
}

.not-found {
    padding: 44px 24px 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.not-found-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--chip-bg);
    color: var(--primary);
    margin-bottom: 8px;
}

.not-found h1 {
    margin: 0;
    font-size: 1.5em;
}

.not-found p {
    margin: 0 0 18px;
    color: var(--muted);
}

.not-found .recipe-back-link {
    background-color: var(--background);
    box-shadow: none;
}

.recipe-page,
.recipes-page {
    width: calc(100% - 20px);
    max-width: var(--width);
    margin-bottom: 40px;
}

/* Toolbar: search, shopping list, theme toggle, category chips */
.toolbar {
    background-color: var(--surface-solid);
    border-radius: var(--radius);
    padding: 14px;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toolbar-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    background: var(--background);
    border: 2px solid transparent;
    color: var(--muted);
    cursor: text;
    transition: border-color 0.2s ease;
}

.search-field:focus-within {
    border-color: var(--primary);
    color: var(--primary);
}

.search-field svg {
    flex-shrink: 0;
}

.search-field input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    padding: 0;
    background: transparent;
    color: var(--foreground);
    font: inherit;
    font-size: 1em;
}

.search-field input::placeholder {
    color: var(--muted);
}

.search-field:has(input:focus-visible) {
    outline: none;
}

.search-field input:focus-visible {
    outline: none;
}

.icon-btn {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: var(--background);
    color: var(--foreground);
    cursor: pointer;
    transition: color var(--hover-ease);
}

.icon-btn:hover {
    color: var(--hover-text);
}

.shop-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 0.7em;
    font-weight: 600;
    line-height: 19px;
    text-align: center;
}

/* Sun in dark mode (tap for light), moon in light mode */
/* Settings dropdown (home page toolbar) */
.settings {
    position: relative;
    flex-shrink: 0;
}

.settings-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    width: max-content;
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 16px;
    background-color: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--card-radius);
    box-shadow: 0 6px 24px var(--shadow-soft);
}

.settings-menu[hidden] {
    display: none;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    font-size: 0.9em;
}

.settings-label {
    font-weight: 500;
}

.settings-hint {
    display: block;
    font-size: 0.8em;
    color: var(--muted);
    margin-top: 2px;
}

.settings-check {
    cursor: pointer;
}

.settings-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.settings-check input:disabled {
    cursor: default;
}

.settings-check:has(input:disabled) {
    cursor: default;
    opacity: 0.6;
}

/* Category chips: one scrolling row on phones, wrapping on wider screens */
.type-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.type-filter-btn {
    flex-shrink: 0;
    padding: 6px 13px;
    font-size: 0.85em;
    border: 0;
    border-radius: 999px;
    background-color: var(--background);
    color: var(--foreground);
    cursor: pointer;
    transition: background-color var(--hover-ease), color var(--hover-ease);
}

.type-filter-btn:hover {
    color: var(--hover-text);
}

.type-filter-btn.active {
    background-color: var(--primary);
    color: #fff;
}

.toolbar-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.8em;
    color: var(--muted);
}

.result-count {
    white-space: nowrap;
    margin-left: auto;
}

@media screen and (max-width: 600px) {
    .toolbar {
        padding: 10px;
        gap: 10px;
    }

    .type-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        margin: 0 -10px;
        padding: 0 10px;
    }

    .type-filters::-webkit-scrollbar {
        display: none;
    }
}

/* Card grid */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
    margin: 10px 0;
}

.recipe-card {
    display: flex;
    flex-direction: column;
    background-color: var(--surface-solid);
    border-radius: var(--card-radius);
    overflow: hidden;
    color: var(--foreground);
    text-decoration: none;
    transition: transform var(--hover-ease), box-shadow var(--hover-ease);
}

@media (hover: hover) {
    .recipe-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 14px var(--shadow-soft);
    }

    .recipe-card:hover .card-title {
        color: var(--hover-text);
    }
}

.card-image {
    aspect-ratio: 4 / 3;
    background: var(--background);
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-body {
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.card-title {
    font-size: 1.02em;
    font-weight: 600;
    margin: 0;
    padding: 0;
    line-height: 1.35;
    transition: color var(--hover-ease);
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    font-size: 0.8em;
    color: var(--muted);
}

/* Category chips on one line: app.js hides the ones that don't fit and
   shows a "+n" chip instead, so the card never grows taller. */
.card-cats {
    display: flex;
    /* Basis 0: take only the space beside the time, never push it to a new line */
    flex: 1 1 0;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
}

.card-category {
    flex-shrink: 0;
    white-space: nowrap;
    background: var(--chip-bg);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
}

.card-more {
    padding: 3px 8px;
}

.card-time {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}

/* Placeholder art, tinted per category */
.placeholder {
    --hue: 210;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--hue) 45% 45% / 0.55);
    background:
        radial-gradient(circle at 30% 25%, hsl(var(--hue) 70% 85% / 0.55), transparent 60%),
        radial-gradient(circle at 75% 80%, hsl(calc(var(--hue) + 40) 70% 80% / 0.45), transparent 55%),
        light-dark(hsl(var(--hue) 30% 94%), hsl(var(--hue) 15% 18%));
}

.placeholder[data-category="main"] {
    --hue: 18;
}

.placeholder[data-category="starter"] {
    --hue: 95;
}

.placeholder[data-category="soup"] {
    --hue: 35;
}

.placeholder[data-category="salad"] {
    --hue: 120;
}

.placeholder[data-category="side"] {
    --hue: 60;
}

.placeholder[data-category="dessert"] {
    --hue: 330;
}

.placeholder[data-category="cake"] {
    --hue: 300;
}

.placeholder[data-category="baking"] {
    --hue: 40;
}

.placeholder[data-category="breakfast"] {
    --hue: 48;
}

.placeholder[data-category="dressing"] {
    --hue: 80;
}

.placeholder[data-category="drink"] {
    --hue: 190;
}

/* Recipe page */
/* Back button: the same borderless pill everywhere. Solid with a soft shadow
   on the page background or a photo; flat grey inside a card (404 page). */
.recipe-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px 9px 14px;
    background-color: var(--surface-solid);
    border: 0;
    border-radius: 20px;
    box-shadow: 0 2px 10px var(--shadow-soft);
    color: var(--foreground);
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: color var(--hover-ease), background-color var(--hover-ease);
}

.recipe-back-link svg {
    transition: transform var(--hover-ease);
}

@media (hover: hover) {
    .recipe-back-link:hover {
        color: var(--hover-text);
    }

    .recipe-back-link:hover svg {
        transform: translateX(-2px);
    }
}

.recipe-back-link:active {
    background-color: var(--chip-bg);
}

/* On the recipe page the back button floats on the photo's top-left corner:
   a solid pill (no translucency or backdrop blur) so it stays crisp. */
.hero-media {
    position: relative;
}

.hero-media .recipe-back-link {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    /* A little stronger so it stands out on busy photos */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.recipe-hero {
    background-color: var(--surface-solid);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 0 0 10px;
}

.hero-image-btn {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: var(--background);
    cursor: zoom-in;
}

.hero-image {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 62vh;
    object-fit: cover;
}

.hero-placeholder {
    aspect-ratio: 16 / 5;
    min-height: 140px;
}

/* Desktop: photo sits beside the title instead of spanning the page */
@media screen and (min-width: 769px) {
    .recipe-hero {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
        align-items: center;
    }

    .hero-media {
        align-self: stretch;
    }

    .hero-image-btn,
    .hero-placeholder {
        height: 100%;
    }

    .hero-image {
        aspect-ratio: 4 / 3;
        height: 100%;
        max-height: 340px;
    }

    .hero-placeholder {
        aspect-ratio: 4 / 3;
        min-height: 0;
        max-height: 340px;
    }

    .recipe-info-grid {
        padding: 26px 32px;
    }
}

.recipe-info-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px 26px 24px;
}

.recipe-category-chip {
    align-self: flex-start;
    background: var(--chip-bg);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    text-decoration: none;
}

.recipe-title {
    margin: 0;
    font-size: 1.8em;
    line-height: 1.25;
}

.recipe-description {
    color: var(--muted);
    margin: 0;
    line-height: 1.6;
}

.recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px 30px;
    margin-top: 6px;
}

.recipe-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.75em;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 1.05em;
    font-weight: 500;
}

.info-value a {
    color: var(--primary);
    text-decoration: none;
}

.info-value a:hover {
    text-decoration: underline;
}

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

.recipe-tags li {
    font-size: 0.75em;
    border: 1px solid var(--muted-text);
    border-radius: 20px;
    padding: 2px 10px;
    color: var(--muted);
}

/* Controls */
.stepper {
    display: inline-flex;
    align-items: center;
    border: 2px solid var(--muted-text);
    border-radius: 20px;
    overflow: hidden;
}

.stepper-btn {
    transition: color var(--hover-ease);
    width: 34px;
    height: 30px;
    border: 0;
    background: transparent;
    color: var(--foreground);
    font-size: 1.2em;
    cursor: pointer;
}

.stepper-btn:hover {
    color: var(--hover-text);
}

.stepper-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.stepper-value {
    min-width: 2.6em;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.segmented {
    display: inline-flex;
    border: 2px solid var(--muted-text);
    border-radius: 20px;
    overflow: hidden;
}

.segmented button {
    border: 0;
    background: transparent;
    color: var(--foreground);
    padding: 7px 12px;
    font-size: 0.85em;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.segmented button[aria-checked="true"] {
    background: var(--primary);
    color: #fff;
}

.reset-btn {
    border: 0;
    background: none;
    color: var(--primary);
    font-size: 0.85em;
    cursor: pointer;
    padding: 4px;
}

/* Ingredients + method */
.recipe-details-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr);
    gap: 10px;
    margin: 10px 0;
    align-items: start;
}

.recipe-ingredients-box,
.recipe-instructions-box {
    background-color: var(--surface-solid);
    border-radius: var(--radius);
    padding: 22px 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.section-header h2 {
    margin: 0;
    padding: 0;
    font-size: 1.3em;
}

/* Fixed-height single line: buttons keep their space when hidden, so
   ticking an item or changing servings never shifts the list below. */
.ingredients-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8em;
    color: var(--muted);
    margin: -4px 0 6px;
    height: 1.8em;
    white-space: nowrap;
}

.ingredients-tools .scale-note {
    margin-right: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ingredients-tools .reset-btn {
    font-size: 1em;
    padding: 0;
    flex-shrink: 0;
    line-height: 1.8em;
}

.ingredients-tools .reset-btn+.reset-btn {
    margin-left: 14px;
}

.reset-btn.is-hidden {
    visibility: hidden;
}

.ingredient-group {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin: 18px 0 6px;
}

.ingredients-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ingredient {
    border-bottom: 1px solid var(--line);
    scroll-margin-top: 160px;
}

.ingredient:last-child {
    border-bottom: 0;
}

.ingredient label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 0;
    cursor: pointer;
    line-height: 1.45;
}

.check {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
}

.ing-amount {
    font-weight: 600;
}

.ing-amount:empty {
    display: none;
}

.ing-prep,
.ing-note {
    color: var(--muted);
}

.ingredient.checked .item-text {
    text-decoration: line-through;
    opacity: 0.5;
}

.ingredient.flash {
    animation: flash 1.2s ease;
}

@keyframes flash {

    0%,
    40% {
        background: var(--chip-bg);
    }

    100% {
        background: transparent;
    }
}

.method {
    line-height: 1.7;
}

.method>ol {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.method>ol>li {
    counter-increment: step;
    position: relative;
    padding: 0 0 12px 26px;
}

/* Small step number in a narrow gutter instead of a big badge */
.method>ol>li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 18px;
    text-align: right;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9em;
}

.method h2,
.method h3 {
    font-size: 1.1em;
    padding: 0;
    margin: 20px 0 8px;
}

.method p {
    margin: 0 0 10px;
}

.method>ol>li>p {
    margin: 0 0 6px;
}

.ing-ref {
    font: inherit;
    color: var(--primary);
    background: var(--chip-bg);
    border: 0;
    border-radius: 6px;
    /* Shorter than the text line so chips on consecutive lines don't touch */
    line-height: 1.35;
    padding: 1px 5px;
    margin: 0 1px;
    vertical-align: baseline;
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.ing-ref[aria-expanded="true"] {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
}

.recipe-source {
    color: var(--muted);
    font-size: 0.85em;
    margin: 16px 6px;
    font-style: italic;
}

/* Ingredient popover */
.ing-popover {
    position: absolute;
    z-index: 200;
    max-width: min(320px, calc(100vw - 24px));
    background: var(--surface-solid);
    color: var(--foreground);
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 6px 24px var(--shadow-primary);
    font-size: 0.92em;
    line-height: 1.45;
}

.ing-popover .pop-amount {
    font-weight: 700;
    color: var(--primary);
}

.ing-popover .pop-prep {
    color: var(--muted);
    display: block;
    margin-top: 2px;
}

.ing-popover .pop-link {
    display: block;
    margin-top: 6px;
    font-size: 0.85em;
    border: 0;
    background: none;
    color: var(--primary);
    padding: 0;
    cursor: pointer;
}

/* Lightbox (ported) */
.lightbox {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    cursor: zoom-out;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-image {
    max-width: 94%;
    max-height: 92%;
    object-fit: contain;
    border-radius: 10px;
    transform: scale(0.94);
    transition: transform 0.3s ease;
}

.lightbox.active .lightbox-image {
    transform: scale(1);
}

@media screen and (max-width: 768px) {
    .recipe-details-grid {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 480px) {
    .recipe-title {
        font-size: 1.45em;
    }

    .recipe-info-grid {
        padding: 18px;
    }

    .recipe-page,
    .recipes-page {
        width: calc(100% - 12px);
    }

    .recipe-ingredients-box,
    .recipe-instructions-box {
        padding: 16px 14px;
        border-radius: var(--card-radius);
    }

    .recipe-hero {
        border-radius: var(--card-radius);
    }

    .recipe-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .card-body {
        padding: 10px 12px 12px;
    }

    .card-title {
        font-size: 0.9em;
    }

    .card-meta {
        font-size: 0.72em;
        flex-wrap: wrap;
        gap: 4px;
    }

    /* Step number on its own line above the step: full width for the text */
    .method>ol>li {
        padding-left: 0;
        padding-bottom: 14px;
    }

    .method>ol>li::before {
        position: static;
        display: block;
        width: auto;
        text-align: center;
        line-height: 1.4;
        margin-bottom: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    ::after,
    ::before {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {

    .stepper,
    .ingredients-tools,
    .recipe-back-link,
    .hero-image-btn,
    .hero-placeholder,
    .check {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .recipe-hero,
    .recipe-ingredients-box,
    .recipe-instructions-box {
        background: none;
    }

    .recipe-details-grid {
        grid-template-columns: 1fr 2fr;
    }
}

/* ---------- Shopping list ---------- */
/* Category chip on the left, shopping-list button on the right, one row */
.recipe-info-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.recipe-category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.recipe-info-top .recipe-category-chip {
    align-self: center;
}

.shop-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    /* Keep the taller button from pushing the title down */
    margin: -8px 0;
}

/* Shopping-list toggle: a white trolley on red. Empty until the recipe is on
   the list; then the veg drops in one by one and the badge turns to a tick. */
.shop-btn {
    --shop-btn-bg: var(--primary);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--shop-btn-bg);
    color: #fff;
    cursor: pointer;
    transition: background-color var(--hover-ease), transform 0.12s ease;
}

.shop-btn .trolley {
    overflow: visible;
}

.shop-btn .trolley-basket {
    fill: var(--shop-btn-bg);
    transition: fill var(--hover-ease);
}

@media (hover: hover) {
    .shop-btn:hover {
        --shop-btn-bg: color-mix(in srgb, var(--primary) 86%, #000);
    }
}

.shop-btn:active {
    transform: scale(0.94);
}

/* Veg: hidden above the basket, then dropped in with a small bounce */
.shop-btn .veg {
    opacity: 0;
    transform: translateY(-9px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.shop-btn.in-list .veg {
    opacity: 1;
    transform: none;
    transition: opacity 0.15s ease, transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.shop-btn.in-list .veg-greens {
    transition-delay: 0.05s;
}

.shop-btn.in-list .veg-pepper {
    transition-delay: 0.1s;
}

.shop-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: var(--primary);
    box-shadow: 0 0 0 2px var(--surface-solid), 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: background-color var(--hover-ease), color var(--hover-ease);
}

.shop-badge .badge-added,
.shop-btn.in-list .shop-badge .badge-add {
    display: none;
}

.shop-btn.in-list .shop-badge .badge-added {
    display: block;
}

.shop-btn.in-list .shop-badge {
    background: #2e9d57;
    color: #fff;
}

/* Share button beside the shopping trolley */
.recipe-tools {
    display: flex;
    gap: 4px;
}

.recipe-tool {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
    transition: color var(--hover-ease), background-color var(--hover-ease);
}

.recipe-tool[hidden] {
    display: none;
}

@media (hover: hover) {
    .recipe-tool:hover {
        color: var(--hover-text);
    }
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 1000;
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--foreground);
    color: var(--background);
    font-size: 0.9em;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.shop-view {
    font-size: 0.85em;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}

.shop-view:hover {
    text-decoration: underline;
}

@media print {
    .shop-actions {
        display: none;
    }
}

.shopping-page .recipe-back-link {
    margin-bottom: 10px;
}

.shop-box {
    background-color: var(--surface-solid);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin: 0 0 10px;
}

.shop-box h1 {
    font-size: 1.5em;
    margin: 0;
    padding: 0;
}

.shop-box h2 {
    font-size: 1.15em;
}

.shop-empty {
    color: var(--muted);
    margin: 6px 0 0;
    line-height: 1.6;
}

.shop-progress {
    font-size: 0.8em;
    color: var(--muted);
}

.shop-recipes {
    list-style: none;
    margin: 0;
    padding: 0;
}

.shop-recipe {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.shop-recipe:last-child {
    border-bottom: 0;
}

.shop-recipe-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--foreground);
    text-decoration: none;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    transition: color var(--hover-ease);
}

.shop-recipe-title:hover {
    color: var(--hover-text);
}

.shop-thumb {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--chip-bg);
}

.shop-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shop-recipe-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.shop-recipe-meta {
    font-size: 0.8em;
    color: var(--muted);
    white-space: nowrap;
}

.shop-remove {
    transition: color var(--hover-ease), background-color var(--hover-ease);
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.95em;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
}

.shop-remove:hover {
    background: var(--chip-bg);
    color: var(--hover-text);
}

.shop-from {
    display: block;
    font-size: 0.75em;
    color: var(--muted);
    margin-top: 1px;
}

.shop-item.checked .item-text {
    transition: opacity 0.15s ease;
}

.shop-done-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    line-height: 1.45;
}

.shop-done-row .item-text {
    flex: 1;
    min-width: 0;
    text-decoration: line-through;
    opacity: 0.5;
}

.shop-restore {
    transition: color var(--hover-ease), border-color var(--hover-ease);
    flex-shrink: 0;
    border: 2px solid var(--muted-text);
    background: transparent;
    color: var(--foreground);
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 0.78em;
    cursor: pointer;
}

.shop-restore:hover {
    border-color: var(--hover-text);
    color: var(--hover-text);
}

/* Kitchen staples: under To buy, quieter than the list above */
.shop-staples {
    margin-top: 14px;
    padding-top: 4px;
    border-top: 1px solid var(--line);
}

.shop-staples .ingredient-group {
    margin-top: 14px;
    margin-bottom: 2px;
}

.shop-staples-hint {
    font-size: 0.8em;
    color: var(--muted);
    margin: 0 0 4px;
}

.shop-staples .item-text {
    opacity: 0.75;
}

.shop-item.has-remove {
    display: flex;
    align-items: center;
    gap: 6px;
}

.shop-item.has-remove label {
    flex: 1;
    min-width: 0;
}

/* Add-your-own-item button, floating at the bottom centre */
.shopping-page {
    padding-bottom: 80px;
}

.shop-add-fab {
    position: fixed;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 50;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 6px 18px var(--shadow-soft), 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: background-color var(--hover-ease), transform 0.15s ease;
}

@media (hover: hover) {
    .shop-add-fab:hover {
        background: color-mix(in srgb, var(--primary) 86%, #000);
    }
}

.shop-add-fab:active {
    transform: translateX(-50%) scale(0.94);
}

.shop-dialog {
    border: 0;
    border-radius: var(--radius);
    padding: 22px 24px 18px;
    width: min(400px, calc(100% - 32px));
    background: var(--surface-solid);
    color: var(--foreground);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

.shop-dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
}

.shop-dialog[open] {
    animation: shop-dialog-in 0.18s ease-out;
}

@keyframes shop-dialog-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
}

.shop-dialog h2 {
    font-size: 1.15em;
    margin: 0 0 14px;
    padding: 0;
}

.shop-field {
    display: block;
    margin-bottom: 12px;
}

.shop-field span {
    display: block;
    font-size: 0.8em;
    color: var(--muted);
    margin-bottom: 4px;
}

.shop-field em {
    font-style: normal;
}

.shop-field input {
    width: 100%;
    font: inherit;
    color: inherit;
    padding: 10px 14px;
    border-radius: 12px;
    border: 2px solid var(--line);
    background: var(--background);
    outline: none;
    transition: border-color var(--hover-ease);
}

.shop-field input:focus-visible {
    border-color: var(--primary);
}

.shop-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.shop-dialog-btn {
    font: inherit;
    font-size: 0.9em;
    padding: 8px 18px;
    border-radius: 16px;
    border: 0;
    cursor: pointer;
    background: var(--chip-bg);
    color: var(--foreground);
    transition: background-color var(--hover-ease), color var(--hover-ease);
}

.shop-dialog-btn:hover {
    color: var(--hover-text);
}

.shop-dialog-btn.primary {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.shop-dialog-btn.primary:hover {
    background: color-mix(in srgb, var(--primary) 86%, #000);
    color: #fff;
}

@media print {
    .shop-add-fab,
    .shop-dialog {
        display: none !important;
    }
}

@media screen and (max-width: 480px) {
    .shop-box {
        padding: 16px 14px;
        border-radius: var(--card-radius);
    }
}
