/* What Should I Eat? : warm diner placemat look, solid colours only. */

:root {
    --bg: #F6EDDC;
    --surface: #FFFBF3;
    --ink: #2B1C13;
    --muted: #6A5444;
    --line: #DCCBB1;
    --edge: #2B1C13;
    --shadow: #DCC7A6;
    --focus: #1F5FAD;

    --tomato: #C63E27;
    --tomato-press: #A5311D;
    --on-tomato: #FFF8EE;
    --saffron: #E39B2D;
    --herb: #3C7A4B;
    --plum: #8A3E68;
    --teal: #2C7C83;
    --error: #B3261E;

    --slice-0: #F4A68F;
    --slice-1: #F5C46E;
    --slice-2: #A8CF9F;
    --slice-3: #DDB0CB;
    --slice-ink: #2B1C13;
    --rim: #2B1C13;
    --stud: #F5C46E;

    --c-breakfast: #B46A0C;
    --c-lunch: #3C7A4B;
    --c-dinner: #8A3E68;
    --c-snack: #C63E27;
    --c-dessert: #B0457E;
    --c-drink: #2C7C83;
    --c-quick-bite: #5E52A8;
    --c-favourites: #C63E27;

    --texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='3' cy='3' r='1.2' fill='%232B1C13' fill-opacity='.08'/%3E%3C/svg%3E");

    --font-body: 'Rethink Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Young Serif', Georgia, 'Times New Roman', serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #19120E;
        --surface: #251B15;
        --ink: #F5EADB;
        --muted: #C5B19C;
        --line: #4A3A2F;
        --edge: #6E5A4A;
        --shadow: #0B0705;
        --focus: #8FC2FF;
        --tomato: #EC6A50;
        --tomato-press: #D9553B;
        --on-tomato: #1D120C;
        --saffron: #F0B04A;
        --herb: #78B585;
        --plum: #D58AB3;
        --teal: #6CC1C7;
        --error: #FF8A7A;
        --slice-0: #E98A72;
        --slice-1: #E9B45A;
        --slice-2: #8DBF84;
        --slice-3: #CF9DBB;
        --slice-ink: #1D120C;
        --rim: #EADBC5;
        --stud: #F0B04A;
        --c-breakfast: #F0B04A;
        --c-lunch: #8DC79A;
        --c-dinner: #D58AB3;
        --c-snack: #F08A72;
        --c-dessert: #E79BC4;
        --c-drink: #6CC1C7;
        --c-quick-bite: #A89CF0;
        --c-favourites: #F08A72;
        --texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='3' cy='3' r='1.2' fill='%23F5EADB' fill-opacity='.05'/%3E%3C/svg%3E");
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #19120E;
    --surface: #251B15;
    --ink: #F5EADB;
    --muted: #C5B19C;
    --line: #4A3A2F;
    --edge: #6E5A4A;
    --shadow: #0B0705;
    --focus: #8FC2FF;
    --tomato: #EC6A50;
    --tomato-press: #D9553B;
    --on-tomato: #1D120C;
    --saffron: #F0B04A;
    --herb: #78B585;
    --plum: #D58AB3;
    --teal: #6CC1C7;
    --error: #FF8A7A;
    --slice-0: #E98A72;
    --slice-1: #E9B45A;
    --slice-2: #8DBF84;
    --slice-3: #CF9DBB;
    --slice-ink: #1D120C;
    --rim: #EADBC5;
    --stud: #F0B04A;
    --c-breakfast: #F0B04A;
    --c-lunch: #8DC79A;
    --c-dinner: #D58AB3;
    --c-snack: #F08A72;
    --c-dessert: #E79BC4;
    --c-drink: #6CC1C7;
    --c-quick-bite: #A89CF0;
    --c-favourites: #F08A72;
    --texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='3' cy='3' r='1.2' fill='%23F5EADB' fill-opacity='.05'/%3E%3C/svg%3E");
    color-scheme: dark;
}

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

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image: var(--texture);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
p,
ul {
    margin: 0;
}

ul {
    padding: 0;
    list-style: none;
}

button {
    font: inherit;
    color: inherit;
}

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

.sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon,
.slice-icon,
.hub-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon {
    width: 22px;
    height: 22px;
    flex: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.page {
    max-width: 1160px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* -------------------------------------------------------------- masthead */
.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
    border-radius: 12px;
    min-width: 0;
}

.brand-mark {
    width: 44px;
    height: 44px;
    flex: none;
    fill: none;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mark-plate { stroke: var(--tomato); }
.mark-inner { stroke: var(--saffron); }
.mark-spokes { stroke: var(--herb); }
.mark-pin { fill: var(--plum); stroke: var(--plum); stroke-width: 1.6; }

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-name {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 4.5vw, 1.75rem);
    line-height: 1.15;
}

.brand-tag {
    color: var(--muted);
    font-size: 1rem;
}

.masthead-tools {
    display: flex;
    gap: 8px;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1.5px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

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

.icon-btn[aria-pressed="true"] {
    border-color: var(--tomato);
    color: var(--tomato);
}

.icon-btn .icon-on,
.icon-btn[aria-pressed="true"] .icon-off {
    display: none;
}

.icon-btn[aria-pressed="true"] .icon-on {
    display: block;
}

/* ----------------------------------------------------------------- layout */
.layout {
    display: grid;
    gap: 32px;
    padding-top: 24px;
}

.side {
    display: grid;
    gap: 28px;
    align-content: start;
}

@media (min-width: 900px) {
    .page {
        padding: 28px 32px 48px;
    }

    .layout {
        grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
        gap: 56px;
        padding-top: 36px;
        align-items: start;
    }

    .stage {
        position: sticky;
        top: 24px;
    }
}

/* ------------------------------------------------------------------ wheel */
.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.wheel-wrap {
    position: relative;
    width: min(100%, 540px);
    aspect-ratio: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.wheel-wrap.is-spinning {
    cursor: progress;
}

.wheel {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.wheel-shadow {
    fill: var(--shadow);
}

.rim {
    fill: var(--rim);
}

.slice-shape {
    stroke: var(--rim);
    stroke-width: 2.5;
    stroke-linejoin: round;
    transition: opacity 0.4s ease;
}

.tone-0 .slice-shape { fill: var(--slice-0); }
.tone-1 .slice-shape { fill: var(--slice-1); }
.tone-2 .slice-shape { fill: var(--slice-2); }
.tone-3 .slice-shape { fill: var(--slice-3); }

.slice-bed,
.slice-empty {
    fill: var(--surface);
}

.slice-text {
    fill: var(--slice-ink);
    font-family: var(--font-body);
    font-size: 17px;
    font-weight: 650;
    dominant-baseline: central;
    pointer-events: none;
}

.slice-icon {
    color: var(--slice-ink);
    stroke-width: 1.7;
}

.slice {
    transition: opacity 0.45s ease;
}

.has-pick .slice:not(.is-picked) {
    opacity: 0.42;
}

.stud {
    fill: var(--stud);
}

.hub-plate {
    fill: var(--surface);
    stroke: var(--rim);
    stroke-width: 5;
}

.hub-ring {
    fill: none;
    stroke: var(--line);
    stroke-width: 2;
}

.hub-icon {
    color: var(--tomato);
    stroke-width: 2.2;
    transition: transform 0.3s ease;
    transform-origin: 0 0;
}

.wheel-wrap:hover .hub-icon {
    transform: rotate(40deg);
}

.pointer path {
    fill: var(--tomato);
    stroke: var(--rim);
    stroke-width: 4;
    stroke-linejoin: round;
}

.wheel-wrap.is-shaking {
    animation: shake 0.42s ease;
}

@keyframes shake {
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.paw {
    position: absolute;
    top: 12%;
    right: -2%;
    width: 64px;
    height: 64px;
    color: var(--plum);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    transform: translateY(12px) rotate(-12deg) scale(0.6);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
    pointer-events: none;
}

.paw.is-visible {
    opacity: 1;
    transform: translateY(0) rotate(18deg) scale(1);
}

/* ------------------------------------------------------------- spin button */
.spin-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
    padding: 16px 36px;
    border: 2px solid var(--edge);
    border-radius: 999px;
    background: var(--tomato);
    color: var(--on-tomato);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--edge);
    transition: background-color 0.15s, transform 0.1s, box-shadow 0.1s;
}

.spin-btn .icon {
    width: 24px;
    height: 24px;
    stroke-width: 2.2;
}

@media (hover: hover) {
    .spin-btn:hover:not(:disabled) {
        background: var(--tomato-press);
    }
}

.spin-btn:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--edge);
}

.spin-btn:disabled {
    background: var(--line);
    border-color: var(--line);
    color: var(--muted);
    box-shadow: none;
    cursor: not-allowed;
}

.wheel-wrap.is-spinning ~ .spin-btn:disabled {
    background: var(--tomato);
    border-color: var(--edge);
    color: var(--on-tomato);
    box-shadow: 0 1px 0 var(--edge);
    transform: translateY(4px);
    cursor: progress;
}

.stage-hint {
    margin-top: 12px;
    color: var(--muted);
    font-size: 1rem;
}

@media (hover: none) {
    .stage-hint {
        display: none;
    }
}

/* ----------------------------------------------------------------- ticket */
.ticket {
    position: relative;
    padding: 26px 26px 24px;
    border: 2px solid var(--edge);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 6px 7px 0 var(--shadow);
}

.ticket.is-waiting {
    opacity: 0.55;
    transition: opacity 0.3s ease;
}

.ticket.is-fresh {
    animation: serve 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes serve {
    from { transform: translateY(10px) rotate(-0.6deg); opacity: 0.3; }
    to { transform: none; opacity: 1; }
}

.ticket-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.ticket-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--chip-color) 16%, var(--surface));
    color: var(--chip-color);
}

.ticket-icon .icon {
    width: 30px;
    height: 30px;
}

.ticket-eyebrow {
    color: var(--muted);
    font-size: 1rem;
    font-weight: 600;
}

.ticket-empty .ticket-eyebrow {
    margin-bottom: 6px;
}

.ticket-title {
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 5vw, 2.3rem);
    font-weight: 400;
    line-height: 1.12;
    text-wrap: balance;
}

.ticket-desc {
    margin-top: 10px;
    color: var(--muted);
    font-size: 1.06rem;
    max-width: 46ch;
}

.ticket-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.ticket-cats li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chip-color) 14%, var(--surface));
    font-size: 1rem;
    font-weight: 600;
}

.ticket-cats .icon {
    width: 20px;
    height: 20px;
    color: var(--chip-color);
}

.ticket-tags {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 2px dashed var(--line);
    color: var(--muted);
    font-size: 1rem;
}

.save-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 10px 18px 10px 14px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: transparent;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.save-btn .icon {
    color: var(--tomato);
    transition: transform 0.25s cubic-bezier(0.3, 1.8, 0.5, 1);
}

.save-btn:hover {
    border-color: var(--tomato);
}

.save-btn[aria-pressed="true"] {
    border-color: var(--tomato);
    background: color-mix(in srgb, var(--tomato) 12%, var(--surface));
}

.save-btn[aria-pressed="true"] .icon {
    fill: var(--tomato);
    transform: scale(1.12);
}

/* ------------------------------------------------------------------- menu */
.section-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    margin-bottom: 14px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 16px 8px 12px;
    border: 1.5px dashed var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.chip .icon {
    color: var(--muted);
    transition: color 0.15s;
}

.chip:hover {
    border-color: var(--chip-color);
    color: var(--ink);
}

.chip[aria-pressed="true"] {
    border-style: solid;
    border-color: var(--chip-color);
    background: color-mix(in srgb, var(--chip-color) 15%, var(--surface));
    color: var(--ink);
    font-weight: 600;
}

.chip[aria-pressed="true"] .icon,
.chip:hover .icon {
    color: var(--chip-color);
}

.chip.is-unavailable {
    opacity: 0.6;
}

.menu-count {
    margin-top: 12px;
    color: var(--muted);
    font-size: 1rem;
}

.menu-count.is-error {
    color: var(--error);
    font-weight: 600;
}

/* ------------------------------------------------------------- favourites */
.fav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fav-list:empty {
    display: none;
}

.fav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 14px 8px 10px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}

.fav .icon {
    color: var(--chip-color);
}

.fav:hover {
    border-color: var(--chip-color);
    transform: translateY(-1px);
}

.favs-empty {
    color: var(--muted);
    font-size: 1rem;
}

.favs-empty[hidden] {
    display: none;
}

/* ----------------------------------------------------------------- footer */
.foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    margin-top: 48px;
    padding-top: 20px;
    border-top: 2px solid var(--line);
    color: var(--muted);
    font-size: 1rem;
}

.foot-secret {
    color: var(--plum);
}

/* ------------------------------------------------------- toast, confetti */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    max-width: calc(100% - 32px);
    padding: 12px 20px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--bg);
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
    opacity: 0;
    transform: translate(-50%, 16px);
    transition: opacity 0.2s, transform 0.25s;
    pointer-events: none;
    z-index: 20;
}

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

.confetti {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
    z-index: 10;
}

.confetti.is-active {
    display: block;
}

/* ------------------------------------------------------------ small screens */
@media (max-width: 480px) {
    .brand-tag {
        display: none;
    }

    .brand {
        gap: 10px;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
    }

    .brand-name {
        font-size: 1.2rem;
    }

    .icon-btn {
        width: 42px;
        height: 42px;
    }

    .masthead-tools {
        gap: 6px;
    }

    .ticket {
        padding: 22px 20px 20px;
    }

    .spin-btn {
        margin-top: 22px;
    }
}

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

    #confettiToggle {
        display: none;
    }
}
