/* Design system: warm café palette, espresso ink, caramel accent, Fraunces display face,
   dark "ticket" result card, cup-shaped size picker, steppers, gentle motion. No Starbucks green or marks.
   Inner pages reuse these tokens and components. */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg: #f6f1e8;
    --surface: #ffffff;
    --ink: #2b1d14;
    --ink-soft: #3d2b20;
    --text: #2b1d14;
    --muted: #6f6158;
    --line: #e7ddd1;
    --chip: #efe6da;
    --chip-hover: #e6dacb;
    --accent: #b5622f;
    --accent-dark: #8f4a1f;
    --accent-soft: #f7e8dc;
    --cream: #f6f1e8;
    --caramel-light: #f0c08a;
    --sage: #a9bfae;
    --warn-bg: #fff3d6;
    --warn-text: #6b4a00;
    --radius: 18px;
    --radius-sm: 12px;
    --gutter: 16px;
    --shadow: 0 10px 30px rgba(43, 29, 20, 0.07);
    --display: "Fraunces", Georgia, "Times New Roman", serif;
    --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body, h1, h2, h3, p, ul, table, button, input, select, legend, fieldset {
    margin: 0;
    padding: 0;
    font-family: var(--sans);
}

body {
    background-color: var(--bg);
    background-image: radial-gradient(circle at 15% 0%, rgba(240, 192, 138, 0.25), transparent 45%);
    color: var(--text);
    line-height: 1.5;
    padding: 0 0 56px;
    -webkit-font-smoothing: antialiased;
}

h2, h3 { letter-spacing: -0.01em; }
a { color: var(--accent-dark); }

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

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes flash { from { background-color: rgba(240, 192, 138, 0.35); } to { background-color: transparent; } }
.hero > *, .calculator, .category-card, .faq, .about { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.hero > *:nth-child(2) { animation-delay: 0.05s; }
.hero > *:nth-child(3) { animation-delay: 0.1s; }
.hero > *:nth-child(4) { animation-delay: 0.15s; }
.calculator { animation-delay: 0.2s; }
.is-flash { animation: flash 0.9s ease-out; }

/* ---------- header: text logo + nav ---------- */
.site-header {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    padding: 14px var(--gutter);
    margin-bottom: 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.site-nav {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.logo {
    font-family: var(--display);
    font-size: 21px;
    font-weight: 700;
    font-style: normal;
    letter-spacing: -0.01em;
    min-height: 36px;
    line-height: 36px;
    background-color: var(--ink);
    padding: 0 12px;
    border-radius: 10px;
    margin: 0;
}
.logo a { color: #fff; text-decoration: none; }

.nav-links { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.nav-links a {
    display: block;
    height: 32px;
    line-height: 32px;
    padding: 0 12px;
    background-color: transparent;
    border-radius: 999px;
    color: var(--ink);
    font-size: 0.92em;
    text-decoration: none;
    transition: background-color 0.25s, color 0.25s;
}
.nav-links a.curr { background-color: var(--chip); color: var(--accent-dark); font-weight: 700; }
.nav-links a:hover { background-color: var(--chip-hover); }

main { max-width: 1080px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- hero ---------- */
.hero { padding: 8px 0 28px; max-width: 760px; }
.eyebrow {
    font-size: 0.78em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}
.hero-title {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(2.1rem, 5.2vw, 3.6rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}
.hero-title em { font-style: italic; color: var(--accent-dark); }
.hero-sub { font-size: 1.05em; color: var(--ink-soft); max-width: 600px; margin-bottom: 8px; }
.disclaimer { font-size: 0.82em; color: var(--muted); }

/* ---------- calculator: builder + ticket ---------- */
.calculator {
    display: grid;
    gap: 20px;
    margin-bottom: 40px;
}

.builder {
    background-color: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    display: grid;
    gap: 22px;
    align-content: start;
}
.step { display: grid; gap: 10px; border: 0; min-width: 0; }
.step-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.76em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
.step-no { font-family: var(--display); font-size: 1.25em; font-weight: 700; color: var(--accent); letter-spacing: 0; }
.step-steppers { grid-template-columns: repeat(2, max-content); column-gap: 28px; align-items: end; }

.select-wrap { position: relative; }
.select-wrap select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    font-size: 1em;
    padding: 12px 42px 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background-color: #fff;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.select-wrap::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select:disabled { opacity: 0.5; }

/* cups: height grows with the ounces */
.cup-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.cup {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    flex: 1 1 64px;
    min-width: 64px;
    max-width: 112px;
    padding: 10px 6px 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background-color: #fff;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.25s, transform 0.25s;
}
.cup svg { width: 30px; margin-bottom: 4px; transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), color 0.2s; }
.cup-name { font-weight: 700; font-size: 0.9em; color: var(--ink); }
.cup-oz { font-size: 0.72em; color: var(--muted); }
.cup:hover { border-color: var(--accent); transform: translateY(-1px); }
.cup.is-active { border-color: var(--accent); background-color: var(--accent-soft); color: var(--accent-dark); box-shadow: 0 6px 16px rgba(181, 98, 47, 0.16); }
.cup.is-active svg { transform: translateY(-3px) scale(1.06); }
.cup:has(input:focus-visible), .chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* chips: milk (radio) and extras (checkbox) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background-color: #fff;
    cursor: pointer;
    font-size: 0.92em;
    color: var(--ink);
    transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
}
.chip::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--line);
    transition: background-color 0.2s, transform 0.25s;
}
.chip:hover { border-color: var(--accent); }
.chip.is-active { border-color: var(--accent); background-color: var(--accent-soft); font-weight: 600; }
.chip.is-active::before { background-color: var(--accent); transform: scale(1.25); }
.chip.is-disabled { opacity: 0.45; cursor: not-allowed; }
.chip.is-disabled:hover { border-color: var(--line); }

/* steppers */
.stepper {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background-color: #fff;
    width: max-content;
    transition: opacity 0.2s;
}
.stepper button {
    width: 42px;
    border: 0;
    border-radius: 0;
    background-color: #fff;
    color: var(--ink);
    font-size: 1.25em;
    font-weight: 500;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}
.stepper button:hover:not(:disabled) { background-color: var(--accent-soft); color: var(--accent-dark); }
.stepper button:active:not(:disabled) { background-color: var(--chip-hover); }
.stepper input {
    width: 58px;
    text-align: center;
    font-size: 1.05em;
    font-weight: 700;
    border: 0;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-radius: 0;
    padding: 10px 0;
    color: var(--ink);
    -moz-appearance: textfield;
    font-variant-numeric: tabular-nums;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; background-color: var(--accent-soft); }
.stepper.is-disabled { opacity: 0.45; }

/* ticket: the dark result card */
.ticket {
    background-color: var(--ink);
    color: var(--cream);
    border-radius: var(--radius);
    padding: 22px;
    display: grid;
    gap: 16px;
    align-content: start;
    box-shadow: 0 18px 40px rgba(43, 29, 20, 0.22);
}
.ticket-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ticket-title { font-weight: 700; font-size: 1.05em; }
.ticket-badge {
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
    background-color: rgba(246, 241, 232, 0.12);
    color: var(--cream);
    transition: background-color 0.3s, color 0.3s;
}
.ticket-badge:empty { display: none; }
.ticket-badge.is-custom { background-color: var(--accent); color: #fff; }

.ticket-cal { display: flex; align-items: baseline; gap: 10px; line-height: 1; }
.ticket-cal .num {
    font-family: var(--display);
    font-weight: 900;
    font-size: clamp(3.6rem, 9vw, 5rem);
    letter-spacing: -0.03em;
    color: var(--caramel-light);
    font-variant-numeric: tabular-nums;
}
.ticket-cal .unit { font-size: 1em; color: rgba(246, 241, 232, 0.7); font-weight: 600; }

.split { display: grid; gap: 8px; }
.split.is-empty { display: none; }
.split-title { font-size: 0.74em; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(246, 241, 232, 0.6); }
.split-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background-color: rgba(246, 241, 232, 0.12); }
.split-bar .seg { display: block; height: 100%; transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.seg-carbs { background-color: var(--caramel-light); }
.seg-fat { background-color: var(--cream); }
.seg-protein { background-color: var(--sage); }
.split-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.82em; color: rgba(246, 241, 232, 0.85); }
.split-legend li { display: inline-flex; align-items: center; gap: 6px; }
.split-legend li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background-color: currentColor; }
.split-legend .seg-carbs { color: var(--caramel-light); }
.split-legend .seg-fat { color: var(--cream); }
.split-legend .seg-protein { color: var(--sage); }

.panel { width: 100%; border-collapse: collapse; font-size: 0.95em; }
.panel td { padding: 8px 0; border-bottom: 1px solid rgba(246, 241, 232, 0.16); }
.panel tr:last-child td { border-bottom: 0; }
.panel td:first-child { color: rgba(246, 241, 232, 0.8); }
.panel td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.panel .is-missing td:last-child { color: rgba(246, 241, 232, 0.5); font-weight: normal; font-size: 0.88em; }
.panel tr.is-flash { animation: flash 0.9s ease-out; }

.notes { list-style: none; display: grid; gap: 6px; }
.notes:empty { display: none; }
.notes li {
    background-color: rgba(240, 192, 138, 0.14);
    color: var(--caramel-light);
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.86em;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ticket button {
    color: var(--cream);
    border: 1px solid rgba(246, 241, 232, 0.45);
    background-color: transparent;
}
.ticket button:hover { background-color: var(--cream); color: var(--ink); border-color: var(--cream); }
.ticket button.primary { background-color: var(--accent); border-color: var(--accent); color: #fff; }
.ticket button.primary:hover { background-color: var(--caramel-light); border-color: var(--caramel-light); color: var(--ink); }
.ticket .source-line { color: rgba(246, 241, 232, 0.55); }

.source-line { font-size: 0.78em; word-break: break-word; }

/* ---------- buttons (outline by default, filled on hover) ---------- */
button {
    color: var(--accent-dark);
    border: 1px solid var(--accent);
    background-color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: background-color 0.25s, color 0.25s, border-color 0.25s, transform 0.2s;
}
button:hover { background-color: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }
button:active { transform: translateY(1px); }

/* ---------- categories ---------- */
.categories { display: grid; gap: 16px; margin-bottom: 40px; }
.category-card {
    background-color: var(--surface);
    padding: 20px 22px 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: grid;
    gap: 6px;
    align-content: start;
    transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.3s;
}
.category-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(43, 29, 20, 0.12); }
.cat-facts { font-size: 0.76em; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-dark); font-weight: 700; }
.category-card h2 { font-family: var(--display); font-weight: 700; font-size: 1.35em; line-height: 1.2; }
.category-card h2 a { color: var(--ink); text-decoration: none; transition: color 0.2s; }
.category-card h2 a:hover { color: var(--accent-dark); }
.category-card p:not(.cat-facts) { color: var(--muted); margin-bottom: 10px; font-size: 0.95em; }
.category-card > a { text-decoration: none; justify-self: start; }

/* ---------- inner pages: tool heading, content sections, size table ---------- */
.inner-hero .hero-title { margin-bottom: 10px; }
.tool { margin-bottom: 40px; }
.section-title { font-family: var(--display); font-size: 1.6em; font-weight: 700; margin-bottom: 14px; }
.content {
    background-color: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.content h2 { font-family: var(--display); font-size: 1.5em; font-weight: 700; margin-bottom: 10px; }
.content p { color: var(--ink-soft); margin-bottom: 10px; font-size: 0.98em; }
.content ul, .content ol { padding-left: 22px; color: var(--ink-soft); display: grid; gap: 6px; margin: 6px 0 4px; }
.content ol li::marker { font-weight: 700; color: var(--accent-dark); }
.related { list-style: none; padding-left: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.related li a {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background-color: var(--chip);
    color: var(--ink);
    text-decoration: none;
    transition: background-color 0.25s;
}
.related li a:hover { background-color: var(--chip-hover); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.size-table { width: 100%; border-collapse: collapse; font-size: 0.95em; font-variant-numeric: tabular-nums; }
.size-table th, .size-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.size-table th[scope="row"], .size-table thead th:first-child { text-align: left; white-space: normal; }
.size-table thead th { font-size: 0.78em; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.size-table tbody tr:hover { background-color: var(--accent-soft); }
.size-table th[scope="row"] { font-weight: 600; color: var(--ink); }
.size-table .muted { font-weight: 400; color: var(--muted); font-size: 0.85em; }
.size-table .muted a { color: var(--muted); }
.teaser { margin-bottom: 24px; }
.teaser h2 a { color: var(--ink); text-decoration: none; }
.teaser h2 a:hover { color: var(--accent-dark); }
.teaser > a { text-decoration: none; }

/* ---------- FAQ and about ---------- */
.about, .faq {
    background-color: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.about h2, .faq h2 { font-family: var(--display); font-size: 1.6em; margin-bottom: 12px; }
.faq-item { padding: 12px 0; border-top: 1px solid var(--line); }
.faq-item:last-child { padding-bottom: 0; }
.faq h3 { font-size: 1.02em; margin-bottom: 4px; }
.faq p { color: var(--ink-soft); font-size: 0.95em; }
.about p { margin-bottom: 10px; font-size: 0.95em; color: var(--ink-soft); }
.estimate-details summary { cursor: pointer; font-weight: 700; font-size: 0.95em; padding: 4px 0; }
.estimate-status { list-style: none; display: grid; gap: 6px; margin-top: 8px; font-size: 0.9em; color: var(--muted); }

.site-footer { text-align: center; color: var(--muted); font-size: 0.85em; margin-top: 24px; padding: 0 var(--gutter); }
.site-footer p { margin-bottom: 4px; }
.site-footer a { color: var(--ink); }

/* ---------- wider screens ---------- */
@media (min-width: 640px) {
    .categories { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
    .calculator { grid-template-columns: 1.15fr 0.85fr; gap: 24px; align-items: start; }
    .builder { padding: 28px; }
    .ticket { position: sticky; top: 84px; padding: 26px; }
    .categories { grid-template-columns: repeat(3, 1fr); }
    .hero { padding: 16px 0 36px; }
}

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

@media print {
    body { background: #fff; padding: 0; }
    .site-header { position: static; border: 0; }
    .nav-links, .hero, .builder, .actions, .categories, .faq, .site-footer { display: none; }
    .calculator { display: block; }
    .ticket { background: #fff; color: #000; box-shadow: none; border: 1px solid #000; position: static; }
    .ticket-cal .num, .notes li, .split-legend, .panel td:first-child, .ticket .source-line { color: #000; }
    .about { box-shadow: none; }
}

/* ---------- food items, pending options, button links, tap targets, phone layout ---------- */
/* Food items have no customizations: hide the drink-only steps. */
.builder.is-food .drink-only { display: none; }

/* Options the calculator cannot count yet stay selectable but say so. */
.chip.is-pending { border-style: dashed; }
.chip-note { font-size: 0.78em; font-weight: 400; color: var(--muted); }
.ticket-badge.is-pending:not(.is-custom) { background-color: var(--warn-bg); color: var(--warn-text); }

/* Links styled as buttons (a <button> inside an <a> is invalid and takes two tab stops). */
.button-link {
    display: inline-block;
    color: var(--accent-dark);
    border: 1px solid var(--accent);
    background-color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95em;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.25s, color 0.25s, border-color 0.25s;
}
.button-link:hover { background-color: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }

/* Tap targets of at least 44 px. */
.chip { min-height: 44px; }
.stepper button { width: 44px; min-height: 44px; }

/* Phones: a small calories bar while the form is on screen and the result is not (ui.js toggles .is-shown). */
.mini-result { display: none; }
@media (max-width: 899px) {
    .mini-result.is-shown {
        position: fixed;
        left: var(--gutter);
        right: var(--gutter);
        bottom: 12px;
        z-index: 20;
        display: flex;
        align-items: baseline;
        gap: 8px;
        padding: 12px 16px;
        border-radius: var(--radius-sm);
        background-color: var(--ink);
        color: var(--cream);
        text-decoration: none;
        box-shadow: 0 10px 30px rgba(43, 29, 20, 0.25);
    }
    .mini-cal { font-family: var(--display); font-weight: 900; font-size: 1.5em; line-height: 1; }
    .mini-unit { font-weight: 600; opacity: 0.7; }
    .mini-badge { flex: 1; min-width: 0; font-size: 0.82em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mini-go { font-size: 0.82em; font-weight: 700; color: var(--caramel-light); }
    body { padding-bottom: 72px; }
    /* One scrollable row of nav links instead of four wrapped rows under the sticky header. */
    .nav-links { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links a { flex: 0 0 auto; }
}
@media print {
    .mini-result { display: none !important; }
}
