/* ── Design Tokens ─────────────────────────── */
:root {
    --bg:      #0f1117;
    --bg2:     #181b24;
    --bg3:     #1e2230;
    --fg:      #e8e6e1;
    --fg2:     #a09d96;
    --accent:  #4ecdc4;
    --accent2: #45b7aa;
    --accent-glow: rgba(78, 205, 196, 0.12);
    --radius:    12px;
    --radius-lg: 20px;
}

/* ── Reset & Base ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    font-weight: 300;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent2); text-decoration: underline; }

/* ── Typography ────────────────────────────── */
.serif { font-family: 'DM Serif Display', serif; font-weight: 400; }

h1, h2, h3 {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    line-height: 1.2;
}

/* ── Layout ────────────────────────────────── */
.page-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ── Section Labels ────────────────────────── */
.section-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
}

.section-title {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: 0.5rem;
}

.section-desc {
    color: var(--fg2);
    font-size: 1rem;
    margin-bottom: 2rem;
}

/* ── Cards ─────────────────────────────────── */
.card {
    background: var(--bg2);
    border-radius: var(--radius-lg);
    border: 1px solid var(--bg3);
    padding: 1.5rem;
    transition: border-color 0.25s;
}

.card:hover {
    border-color: rgba(78, 205, 196, 0.2);
}

/* ── Badges ────────────────────────────────── */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.badge--accent {
    background: var(--accent-glow);
    color: var(--accent);
}

.badge--muted {
    background: rgba(160, 157, 150, 0.1);
    color: var(--fg2);
}

/* ── Stat Bar ──────────────────────────────── */
.stat-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.stat {
    text-align: center;
    padding: 1.25rem 1rem;
    background: var(--bg2);
    border-radius: var(--radius);
    border: 1px solid var(--bg3);
    flex: 1 1 100px;
    min-width: 100px;
}

.stat-value {
    display: block;
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 0.15rem;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--fg2);
}

/* ══════════════════════════════════════════════
   HOMEPAGE
   ══════════════════════════════════════════════ */

.site-header {
    padding: 4rem 0 2rem;
    text-align: center;
}

.site-header h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    background: linear-gradient(135deg, var(--fg) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
}

.site-header .tagline {
    color: var(--fg2);
    font-size: 1.05rem;
    max-width: 420px;
    margin: 0 auto;
}

/* Recipe Grid */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0 4rem;
}

.recipe-card {
    display: block;
    text-decoration: none;
    color: inherit;
}

.recipe-card:hover { text-decoration: none; }

.recipe-card .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.recipe-card h2 {
    font-size: 1.35rem;
    margin-bottom: 0.4rem;
    color: var(--fg);
}

.recipe-card .recipe-desc {
    color: var(--fg2);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    flex: 1;
}

.recipe-card .recipe-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════════════
   RECIPE PAGE — SHARED
   ══════════════════════════════════════════════ */

.recipe-header {
    padding-top: 2rem;
    margin-bottom: 1rem;
}

.recipe-header .back-link {
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg2);
    display: inline-block;
    margin-bottom: 1.5rem;
    transition: color 0.15s;
}

.recipe-header .back-link:hover { color: var(--accent); text-decoration: none; }

.recipe-header h1 {
    font-size: clamp(2rem, 6vw, 3.2rem);
    margin-bottom: 0.4rem;
}

.recipe-header .recipe-tagline {
    color: var(--fg2);
    font-size: 1rem;
    max-width: 560px;
}

/* Mode Toggle */
.mode-toggle {
    display: inline-block;
    padding: 0.75rem 2rem;
    border: 1.5px solid var(--accent);
    border-radius: 100px;
    color: var(--accent);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    background: transparent;
    cursor: pointer;
    transition: all 0.25s;
    margin: 1.5rem 0;
}

.mode-toggle:hover {
    background: var(--accent);
    color: var(--bg);
}

/* ══════════════════════════════════════════════
   RECIPE PAGE — READING MODE
   ══════════════════════════════════════════════ */

/* Ingredient List (consolidated) */
.ingredient-section {
    margin: 2rem 0;
}

.ingredient-group-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--fg2);
    margin: 1.25rem 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--bg3);
}

.ingredient-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.35rem 0;
}

.ingredient-weight {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    min-width: 3.5rem;
    text-align: right;
    color: var(--fg);
    flex-shrink: 0;
}

.ingredient-name {
    color: var(--fg2);
    font-size: 0.95rem;
}

.ingredient-note {
    color: var(--fg2);
    font-size: 0.8rem;
    font-style: italic;
    opacity: 0.7;
}

/* Stage Cards — Reading Mode */
.stages-section {
    margin: 2.5rem 0;
}

.stage-card {
    background: var(--bg2);
    border-radius: var(--radius-lg);
    border: 1px solid var(--bg3);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    transition: border-color 0.25s;
}

.stage-card:hover {
    border-color: rgba(78, 205, 196, 0.15);
}

.stage-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stage-header h3 {
    font-size: 1.25rem;
}

.stage-badge {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 0.25rem 0.7rem;
    border-radius: 100px;
    background: var(--accent-glow);
    color: var(--accent);
    letter-spacing: 0.03em;
}

.stage-ingredients {
    margin: 0.75rem 0;
    padding: 0.75rem 0;
    border-top: 1px solid var(--bg3);
    border-bottom: 1px solid var(--bg3);
}

.stage-action {
    color: var(--fg2);
    font-size: 0.93rem;
    line-height: 1.7;
    margin-top: 0.75rem;
}

.stage-action strong { color: var(--fg); font-weight: 500; }

.stage-substep {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--bg3);
}

.stage-substep-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg2);
    margin-bottom: 0.4rem;
}

/* Variations */
.variations-section {
    margin: 2.5rem 0;
}

.variation-card {
    background: var(--bg2);
    border-radius: var(--radius);
    border: 1px solid var(--bg3);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
}

.variation-card h4 {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: 1.05rem;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

.variation-card p {
    color: var(--fg2);
    font-size: 0.9rem;
}

/* Scaling Table */
.scaling-section {
    margin: 2.5rem 0;
}

.scaling-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.scaling-table th {
    text-align: left;
    font-weight: 500;
    color: var(--fg2);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--bg3);
}

.scaling-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(30, 34, 48, 0.5);
    color: var(--fg2);
}

.scaling-table td:first-child {
    color: var(--fg);
}

.scaling-table td:not(:first-child) {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.scaling-table tr:hover td {
    background: rgba(78, 205, 196, 0.03);
}

/* Notes */
.notes-section {
    margin: 2.5rem 0;
}

.note-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--bg3);
}

.note-item:last-child { border-bottom: none; }

.note-item strong {
    color: var(--fg);
    font-weight: 500;
    display: block;
    margin-bottom: 0.25rem;
}

.note-item p {
    color: var(--fg2);
    font-size: 0.9rem;
    line-height: 1.65;
}

/* ══════════════════════════════════════════════
   RECIPE PAGE — COOKING MODE
   ══════════════════════════════════════════════ */

/* Hide/show based on mode */
body:not(.cooking-mode) .cook-only { display: none; }
body.cooking-mode .read-only { display: none; }

body.cooking-mode {
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
}

body.cooking-mode .cook-only {
    position: fixed;
    inset: 0;
    z-index: 100;
}

/* Cooking mode wrapper */
.cook-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: absolute;
    inset: 0;
}

/* Stage Indicator Strip */
.stage-indicator {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--bg3);
    flex-shrink: 0;
}

.stage-pill {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--bg3);
    background: transparent;
    color: var(--fg2);
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.stage-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.stage-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}

.stage-pill.completed {
    border-color: var(--accent2);
    color: var(--accent2);
}

/* Cook Content Area */
.cook-content {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
}

.cook-stage-name {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(1.5rem, 5vw, 2rem);
    text-align: center;
    margin-bottom: 0.25rem;
}

.cook-stage-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--fg2);
    text-align: center;
    margin-bottom: 1rem;
}

/* Timer */
.timer-section {
    text-align: center;
    padding: 1rem 0;
}

.timer-display {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(3rem, 12vw, 5rem);
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-bottom: 0.75rem;
    transition: color 0.3s;
}

.timer-display.timer-done {
    animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {
    0%, 100% { color: var(--accent); }
    50% { color: var(--fg); }
}

.timer-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.timer-btn {
    padding: 0.5rem 1.5rem;
    border-radius: 100px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.timer-btn--start {
    background: var(--accent);
    color: var(--bg);
    border: 1.5px solid var(--accent);
}

.timer-btn--start:hover {
    background: var(--accent2);
    border-color: var(--accent2);
}

.timer-btn--start.running {
    background: transparent;
    color: var(--accent);
}

.timer-btn--reset {
    background: transparent;
    color: var(--fg2);
    border: 1.5px solid var(--bg3);
}

.timer-btn--reset:hover {
    border-color: var(--fg2);
    color: var(--fg);
}

/* Cook Ingredients */
.cook-ingredients {
    padding: 1rem 0;
    border-top: 1px solid var(--bg3);
    margin-top: 0.5rem;
}

.cook-ingredient-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.4rem 0;
}

.cook-ingredient-weight {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 1.3rem;
    min-width: 4rem;
    text-align: right;
    color: var(--fg);
    flex-shrink: 0;
}

.cook-ingredient-name {
    font-size: 1.05rem;
    color: var(--fg2);
}

/* Marker data elements (hidden, read by JS) */
.cook-stage > .marker { display: none; }

/* Progress Bar */
.progress-bar {
    position: relative;
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    margin-top: 1rem;
    overflow: visible;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s linear;
}

.progress-marker {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--fg2);
    transform: translate(-50%, -50%);
    z-index: 1;
    transition: border-color 0.2s, background 0.2s;
}

.progress-marker.passed {
    border-color: var(--accent);
    background: var(--accent);
}

/* Event Alert */
.event-alert {
    text-align: center;
    margin-top: 0.75rem;
    min-height: 2rem;
}

.event-alert-hint {
    font-size: 0.8rem;
    color: var(--fg2);
}

.event-alert-countdown {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
    animation: alertPulse 0.6s ease-in-out infinite;
}

.event-alert-now {
    font-size: 1.4rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bg);
    background: var(--accent);
    padding: 0.3rem 1.2rem;
    border-radius: 100px;
    display: inline-block;
    animation: alertFlash 0.5s ease-in-out infinite;
}

@keyframes alertPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes alertFlash {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.04); }
}

/* Cook Action */
.cook-action {
    padding: 1rem 0;
    border-top: 1px solid var(--bg3);
    color: var(--fg2);
    font-size: 0.95rem;
    line-height: 1.7;
}

.cook-action strong { color: var(--fg); font-weight: 500; }

/* Bottom Navigation */
.cook-bottom-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: var(--bg2);
    border-top: 1px solid var(--bg3);
    gap: 0.5rem;
}

.cook-nav-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    border-radius: 100px;
    border: 1.5px solid var(--bg3);
    background: transparent;
    color: var(--fg2);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.cook-nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

.cook-nav-btn:disabled:hover {
    border-color: var(--bg3);
    color: var(--fg2);
}

.cook-exit-btn {
    padding: 0.6rem 1.2rem;
    border: 1.5px solid var(--bg3);
    border-radius: 100px;
    background: transparent;
    color: var(--fg2);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    min-height: 44px;
    letter-spacing: 0.04em;
}

.cook-exit-btn:hover { color: var(--fg); border-color: var(--fg2); }

/* ══════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════ */

.site-footer {
    text-align: center;
    padding: 3rem 1.25rem;
    color: var(--fg2);
    font-size: 0.85rem;
    border-top: 1px solid var(--bg3);
    margin-top: 2rem;
}

.site-footer a { color: var(--accent); }

/* ══════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════ */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    opacity: 0;
}

.animate-in.visible {
    animation: fadeInUp 0.45s ease-out forwards;
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */

@media (min-width: 640px) {
    .cook-ingredient-row {
        gap: 1rem;
    }

    .stage-ingredients .ingredient-row {
        max-width: 360px;
    }

    .cook-ingredients {
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 420px) {
    .stat-bar { gap: 0.75rem; }
    .stat { padding: 1rem 0.5rem; min-width: 80px; }
    .stat-value { font-size: 1.25rem; }
    .stage-pill { width: 28px; height: 28px; font-size: 0.7rem; }
    .timer-display { font-size: 2.75rem; }
    .cook-ingredient-weight { font-size: 1.15rem; min-width: 3.5rem; }
    .cook-ingredient-name { font-size: 0.95rem; }
    .recipe-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════
   PRINT
   ══════════════════════════════════════════════ */

@media print {
    body { background: white; color: #1a1a1a; }
    .cook-only, .mode-toggle, .site-footer { display: none; }
    .card, .stage-card, .variation-card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
    .section-label, .stage-label { color: #666; }
    .badge, .stage-badge { border: 1px solid #999; background: #f5f5f5; color: #333; }
    .ingredient-weight, .cook-ingredient-weight { color: #1a1a1a; }
    a { color: inherit; }
}
