/* ============================================================
   Coffee Recipes — Full Redesign CSS
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ---------- Base ---------- */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light mode — warm cream palette */
body.light-mode {
    background:
        radial-gradient(ellipse at top right, rgba(240, 169, 85, 0.22), transparent 45%),
        linear-gradient(170deg, #fdf6ed 0%, #f4ede2 100%);
}

body.light-mode .app-header {
    background: color-mix(in srgb, #fdf6ed 90%, transparent);
    border-bottom-color: rgba(180, 130, 70, 0.12);
}

/* ---------- Steam Canvas ---------- */

#steamCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ---------- Container ---------- */

.container {
    position: relative;
    z-index: 1;
    width: min(640px, 100%);
    display: grid;
    gap: 14px;
    padding-bottom: 36px;
}

/* ---------- Recipe Selector ---------- */

.recipe-selector-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border-dark);
    margin: 0 -4px;
}

.recipe-selector-wrap::-webkit-scrollbar {
    display: none;
}

body.light-mode .recipe-selector-wrap {
    border-bottom-color: var(--border-light);
}

.recipe-selector {
    display: flex;
    position: relative;
    min-width: max-content;
    padding: 4px 4px 0;
}

.recipe-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 18px 10px;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: var(--muted-dark);
    transition: color 0.22s ease;
    white-space: nowrap;
}

body.light-mode .recipe-pill {
    color: var(--muted-light);
}

.recipe-pill.active {
    color: var(--accent);
}

.pill-emoji {
    font-size: 1.45rem;
    line-height: 1;
    display: block;
    transition: transform 0.22s ease;
}

.recipe-pill:hover .pill-emoji,
.recipe-pill:focus-visible .pill-emoji {
    transform: scale(1.18) rotate(-6deg);
}

.recipe-pill.active .pill-emoji {
    transform: scale(1.08);
}

.pill-label {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.selector-indicator {
    position: absolute;
    bottom: 0;
    height: 2.5px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    will-change: left, width;
}

/* ---------- Hero Section ---------- */

.hero-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 6px 0 2px;
    text-align: center;
}

.hero-title {
    margin: 0;
    font-size: clamp(1.85rem, 6vw, 2.65rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.method-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 13px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
    border: 1.5px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

/* ---------- Stats Strip ---------- */

.stats-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 6px 12px;
    border-radius: 16px;
    border: 1.5px solid;
    text-align: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.18s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    box-shadow: 0 6px 22px color-mix(in srgb, var(--accent) 12%, transparent);
}

body.dark-mode .stat-item {
    background: var(--surface-dark);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

body.light-mode .stat-item {
    background: var(--surface-light);
    border-color: var(--border-light);
    box-shadow: var(--shadow-light);
}

.stat-icon {
    font-size: 0.82rem;
    color: var(--accent);
    opacity: 0.78;
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.25;
    word-break: break-word;
    hyphens: auto;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-dark);
}

body.light-mode .stat-label {
    color: var(--muted-light);
}

/* ---------- Water Section ---------- */

.water-section {
    border-radius: 18px;
    border: 1.5px solid;
    padding: 1.05rem 1.15rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 11px;
}

body.dark-mode .water-section {
    background: var(--surface-dark);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

body.light-mode .water-section {
    background: var(--surface-light);
    border-color: var(--border-light);
    box-shadow: var(--shadow-light);
}

.water-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.water-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    opacity: 0.85;
}

.water-nudge-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-shrink: 0;
}

.water-adjust {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    border: 1.5px solid;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
    flex-shrink: 0;
}

body.dark-mode .water-adjust {
    background: var(--input-bg-dark);
    color: var(--text-dark);
    border-color: var(--border-dark);
}

body.light-mode .water-adjust {
    background: var(--input-bg-light);
    color: var(--text-light);
    border-color: var(--border-light);
}

.water-adjust:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.water-adjust:active {
    transform: scale(0.88);
}

#waterInput {
    width: 62px;
    height: 30px;
    border-radius: 9px;
    border: 1.5px solid;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
    /* Hide spin buttons */
    -moz-appearance: textfield;
}

#waterInput::-webkit-outer-spin-button,
#waterInput::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

body.dark-mode #waterInput {
    background: var(--input-bg-dark);
    color: var(--text-dark);
    border-color: var(--border-dark);
}

body.light-mode #waterInput {
    background: var(--input-bg-light);
    color: var(--text-light);
    border-color: var(--border-light);
}

#waterInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

/* Range Slider */

.water-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 100px;
    outline: none;
    cursor: pointer;
    border: none;
    background: linear-gradient(
        to right,
        var(--accent) 0%,
        var(--accent) var(--slider-pct, 8%),
        rgba(255, 255, 255, 0.12) var(--slider-pct, 8%),
        rgba(255, 255, 255, 0.12) 100%
    );
}

body.light-mode .water-slider {
    background: linear-gradient(
        to right,
        var(--accent) 0%,
        var(--accent) var(--slider-pct, 8%),
        rgba(0, 0, 0, 0.1) var(--slider-pct, 8%),
        rgba(0, 0, 0, 0.1) 100%
    );
}

.water-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent),
                0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.water-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.2);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent),
                0 4px 14px rgba(0, 0, 0, 0.35);
}

.water-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
    cursor: grab;
}

.water-callout {
    margin: 0;
    font-size: 0.83rem;
    text-align: center;
    color: var(--muted-dark);
}

body.light-mode .water-callout {
    color: var(--muted-light);
}

.water-callout strong {
    color: var(--accent);
    font-weight: 700;
}

/* ---------- Timer Section ---------- */

.timer-section {
    border-radius: 18px;
    border: 1.5px solid;
    overflow: hidden;
    transition: border-color 0.28s ease, box-shadow 0.28s ease;
}

body.dark-mode .timer-section {
    background: var(--surface-dark);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

body.light-mode .timer-section {
    background: var(--surface-light);
    border-color: var(--border-light);
    box-shadow: var(--shadow-light);
}

.timer-section.is-running {
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent),
                var(--shadow-dark);
}

body.light-mode .timer-section.is-running {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent),
                var(--shadow-light);
}

.timer-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.88rem 1.1rem;
    background: none;
    border: none;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    color: inherit;
    transition: background 0.15s ease;
}

body.dark-mode .timer-toggle-btn:hover {
    background: var(--surface-strong-dark);
}

body.light-mode .timer-toggle-btn:hover {
    background: var(--surface-strong-light);
}

.timer-toggle-left {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--accent);
}

.timer-chevron {
    font-size: 0.72rem;
    color: var(--muted-dark);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode .timer-chevron {
    color: var(--muted-light);
}

.timer-section.open .timer-chevron {
    transform: rotate(180deg);
}

.timer-body {
    padding: 4px 1.1rem 1.15rem;
    display: grid;
    gap: 14px;
}

.timer-body[aria-hidden="true"] {
    display: none;
}

.timer-display {
    font-family: 'SF Mono', ui-monospace, 'Fira Code', 'Courier New', monospace;
    font-size: clamp(3rem, 13vw, 4.6rem);
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.05em;
    line-height: 1;
    padding: 8px 0 4px;
    transition: color 0.3s ease;
}

body.dark-mode .timer-display {
    color: var(--text-dark);
}

body.light-mode .timer-display {
    color: var(--text-light);
}

.timer-section.is-running .timer-display {
    color: var(--accent);
}

.timer-step-hint {
    font-size: 0.8rem;
    text-align: center;
    font-style: italic;
    min-height: 1.1em;
    color: var(--muted-dark);
}

body.light-mode .timer-step-hint {
    color: var(--muted-light);
}

.timer-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.timer-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0.58rem 1.25rem;
    border-radius: 12px;
    border: 1.5px solid;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.timer-btn:active {
    transform: scale(0.95);
}

.timer-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    min-width: 95px;
    justify-content: center;
}

.timer-btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 82%, #fff);
    border-color: color-mix(in srgb, var(--accent) 82%, #fff);
}

body.dark-mode .timer-btn-ghost {
    background: var(--surface-strong-dark);
    border-color: var(--border-dark);
    color: var(--text-dark);
}

body.light-mode .timer-btn-ghost {
    background: var(--surface-strong-light);
    border-color: var(--border-light);
    color: var(--text-light);
}

body.dark-mode .timer-btn-ghost:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border-dark));
}

body.light-mode .timer-btn-ghost:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border-light));
}

/* ---------- Steps Box ---------- */

.steps-box {
    border-radius: 18px;
    border: 1.5px solid;
    padding: 1.1rem 1.15rem 1.15rem;
}

body.dark-mode .steps-box {
    background: var(--surface-dark);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

body.light-mode .steps-box {
    background: var(--surface-light);
    border-color: var(--border-light);
    box-shadow: var(--shadow-light);
}

.steps-box h3 {
    margin: 0 0 0.95rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    opacity: 0.85;
    text-align: center;
}

/* ---------- Steps List ---------- */

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: step-counter;
    display: grid;
    gap: 0;
}

.steps li {
    counter-increment: step-counter;
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 12px;
    align-items: start;
    padding: 11px 0;
    border-bottom: 1px solid;
    line-height: 1.55;
    font-size: 0.91rem;
    border-radius: 8px;
    animation: stepAppear 0.38s ease both;
    animation-delay: calc(var(--step-i, 0) * 50ms);
    transition: background 0.25s ease, border-bottom-color 0.25s ease,
                outline-color 0.25s ease;
}

body.dark-mode .steps li {
    color: color-mix(in srgb, var(--text-dark) 86%, transparent);
    border-bottom-color: var(--border-dark);
}

body.light-mode .steps li {
    color: color-mix(in srgb, var(--text-light) 86%, transparent);
    border-bottom-color: var(--border-light);
}

.steps li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.steps li:first-child {
    padding-top: 0;
}

/* Timer active-step highlight */
.steps li.active-step {
    background: color-mix(in srgb, var(--accent) 9%, transparent);
    border-radius: 10px;
    border-bottom-color: transparent !important;
    outline: 1.5px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

.steps li::before {
    content: counter(step-counter);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
    border: 1.5px solid color-mix(in srgb, var(--accent) 28%, transparent);
    margin-top: 2px;
    transition: background 0.28s ease, color 0.28s ease,
                transform 0.28s ease, border-color 0.28s ease;
}

.steps li.active-step::before {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: scale(1.12);
}

.step-text {
    display: block;
    line-height: 1.55;
}

/* Step chips (inline ⏱ time / 🌡 temp callouts) */
.step-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.73rem;
    font-weight: 600;
    padding: 0 7px;
    border-radius: 100px;
    margin: 0 2px;
    vertical-align: middle;
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
    white-space: nowrap;
    line-height: 1;
    height: 1.35rem;
    box-sizing: border-box;
}


/* ---------- Animations ---------- */

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

.recipe-content-fade {
    animation: contentFadeIn 0.3s ease both;
}

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

/* ---------- Responsive ---------- */

/* Stats: 2×2 on anything narrower than 600px */
@media (max-width: 600px) {
    .stats-strip {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-value {
        font-size: 0.85rem;
    }
}

/* Water header stacks vertically on very narrow screens */
@media (max-width: 400px) {
    .water-header {
        flex-direction: column;
        align-items: flex-start;
    }

    #waterInput {
        width: 56px;
    }
}

@media (max-width: 380px) {
    .recipe-pill {
        padding: 8px 12px 10px;
    }

    .pill-label {
        font-size: 0.74rem;
    }

    .hero-title {
        font-size: 1.65rem;
    }

    .timer-display {
        font-size: 2.8rem;
    }
}
