/*
 * Curry Calculator v2 — warm and playful, but not noisy.
 *
 * Everything themes from the custom properties below. No webfonts: the
 * CloudFront CSP is font-src 'self' and a self-hosted face is not worth the
 * bytes for a page this small, so this leans on system stacks.
 */

:root {
    --paprika: #c1440e;
    --paprika-deep: #96340a;
    --turmeric: #e8a33d;
    --coriander: #4c7a34;

    --bg: #fdf5e9;
    --bg-tint: #f7e8d2;
    --surface: #fffdf9;
    --ink: #2e1f14;
    --ink-soft: #6d5847;
    --line: #e6d5bd;
    --shadow: 22px 22px 55px -30px rgba(70, 40, 15, 0.45);

    --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --serif: ui-serif, Georgia, "Times New Roman", serif;

    --radius: 18px;
    --measure: 62rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #17110c;
        --bg-tint: #221913;
        --surface: #241b14;
        --ink: #f6e9da;
        --ink-soft: #bfa892;
        --line: #3b2c21;
        --paprika: #f2743a;
        --paprika-deep: #ffa070;
        --shadow: 22px 22px 55px -30px rgba(0, 0, 0, 0.8);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0 1.25rem 4rem;
    font-family: var(--sans);
    font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
    line-height: 1.55;
    color: var(--ink);
    /* A soft warmth at the top, like light through a takeaway window. */
    background:
        radial-gradient(120% 80% at 50% -10%, var(--bg-tint) 0%, transparent 60%),
        var(--bg);
    min-height: 100vh;
}

main,
.masthead {
    max-width: var(--measure);
    margin-inline: auto;
}

/* The page now ends with the results grid, so main carries the trailing
   breathing room the footer used to provide. */
main {
    padding-bottom: 4rem;
}

/* --- accessibility ------------------------------------------------------ */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 0.7rem 1rem;
    background: var(--paprika);
    color: #fff;
    border-radius: 0 0 var(--radius) 0;
    z-index: 10;
}

.skip-link:focus {
    left: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 3px solid var(--paprika);
    outline-offset: 3px;
    border-radius: 6px;
}

/* --- masthead ----------------------------------------------------------- */

.masthead {
    text-align: center;
    padding: 3rem 0 2.5rem;
}

/* The artwork sits on a "plate": a warm ring that turns a flat SVG into the
   centrepiece without needing new illustration. */
.plate {
    width: clamp(9rem, 26vw, 12.5rem);
    aspect-ratio: 1;
    margin: 0 auto 1.5rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 25%, var(--surface), var(--bg-tint));
    box-shadow:
        0 0 0 1px var(--line),
        0 0 0 10px color-mix(in srgb, var(--turmeric) 18%, transparent),
        var(--shadow);
}

.plate img {
    width: 68%;
    height: auto;
}

h1 {
    margin: 0;
    font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3.6rem);
    line-height: 1.05;
    letter-spacing: -0.025em;
    color: var(--paprika);
}

/* --- control ------------------------------------------------------------ */

.control {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1.5rem, 1rem + 2vw, 2.5rem);
    text-align: center;
}

.control-heading {
    margin: 0 0 1.25rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.75rem, 3vw, 1.5rem);
}

.step {
    width: 3.25rem;
    height: 3.25rem;
    flex: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--paprika);
    background: var(--bg-tint);
    border: 1px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 120ms ease, background-color 120ms ease;
}

.step:hover {
    background: color-mix(in srgb, var(--turmeric) 30%, var(--bg-tint));
}

.step:active {
    transform: scale(0.92);
}

#people {
    width: 5.5ch;
    padding: 0.2rem 0;
    font-family: inherit;
    font-size: clamp(2.8rem, 2rem + 3vw, 4rem);
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-bottom: 3px solid var(--turmeric);
    border-radius: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* The spinners fight the custom stepper buttons — drop them. */
#people::-webkit-outer-spin-button,
#people::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hint {
    margin: 1.25rem 0 0.75rem;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.preset {
    min-width: 2.9rem;
    padding: 0.45rem 0.85rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.preset:hover {
    color: var(--paprika);
    border-color: var(--paprika);
    background: color-mix(in srgb, var(--paprika) 8%, transparent);
}

/* --- results ------------------------------------------------------------ */

.results {
    margin-top: 3rem;
}

.section-label {
    margin: 0 0 1.25rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

#headcount-echo {
    color: var(--paprika);
}

/* Six tiles that share the row width rather than one dish per full-width row:
   a 16rem track floor lands on three columns at full measure, two on a tablet
   and one on a phone, so a card is never mostly empty space. */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: clamp(0.7rem, 1.5vw, 1rem);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Stacked and centred — artwork, then number, then dish name. align-content
   centres the stack in a card that a taller sibling has stretched, so the row
   stays even without fixed heights. */
.card {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.4rem;
    padding: clamp(1.1rem, 3vw, 1.5rem) 1rem;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card img {
    width: clamp(3.25rem, 9vw, 4.25rem);
    height: clamp(3.25rem, 9vw, 4.25rem);
    margin-bottom: 0.35rem;
    object-fit: contain;
}

.count {
    font-size: clamp(2rem, 1.5rem + 1.6vw, 2.6rem);
    font-weight: 700;
    line-height: 1;
    color: var(--paprika);
    font-variant-numeric: tabular-nums;
}

.dish {
    font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
    color: var(--ink-soft);
}

/* Only fires on cards whose number actually changed — see pulse() in app.js. */
@keyframes bump {
    0%   { transform: none; }
    35%  { transform: translateY(-4px) scale(1.05); }
    100% { transform: none; }
}

.card.is-changed .count {
    animation: bump 320ms ease;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    margin-top: 1.75rem;
}

#copy {
    padding: 0.7rem 1.4rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: var(--paprika);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 120ms ease, transform 120ms ease;
}

#copy:hover {
    background: var(--paprika-deep);
}

#copy:active {
    transform: scale(0.97);
}

@media (prefers-color-scheme: dark) {
    #copy {
        color: #1b120c;
    }
}

.copy-status {
    font-size: 0.9rem;
    color: var(--coriander);
}

/* --- motion ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
