/* ==================================================
   Tokens
   ================================================== */

:root {

    --void: #060810;
    --deep: #0a0f1c;
    --deep-2: #0d1522;

    --glass: rgba(255, 255, 255, 0.055);
    --glass-strong: rgba(255, 255, 255, 0.09);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-highlight: rgba(255, 255, 255, 0.5);

    --text: #eef3f6;
    --text-muted: #93a1b0;
    --text-faint: #5c6a79;

    --accent: #55e6c9;
    --accent-soft: rgba(85, 230, 201, 0.35);
    --accent-dim: rgba(85, 230, 201, 0.12);
    --violet: #8c7cf6;
    --ember: #ff8f66;

    --shadow-1: rgba(255, 255, 255, 0.25);
    --shadow-2: rgba(0, 0, 0, 0.55);
    --blob-opacity: 0.55;
    --blob-opacity-c: 0.18;
    --grain-opacity: 0.5;
    --grain-blend: overlay;

    --radius-lg: 30px;
    --radius-md: 18px;
    --radius-sm: 12px;

    --font-display: "Space Grotesk", "Inter", sans-serif;
    --font-body: "Inter", sans-serif;
    --font-mono: "JetBrains Mono", monospace;

}


html[data-theme="light"] {

    color-scheme: light;

    --void: #eef1f6;
    --deep: #ffffff;
    --deep-2: #f7f9fc;

    --glass: rgba(20, 30, 48, 0.045);
    --glass-strong: rgba(20, 30, 48, 0.075);
    --glass-border: rgba(20, 30, 48, 0.12);
    --glass-highlight: rgba(255, 255, 255, 0.7);

    --text: #101722;
    --text-muted: #4d5867;
    --text-faint: #8892a0;

    --accent: #0fa98e;
    --accent-soft: rgba(15, 169, 142, 0.28);
    --accent-dim: rgba(15, 169, 142, 0.10);
    --violet: #6d59e0;
    --ember: #e1662f;

    --shadow-1: rgba(255, 255, 255, 0.6);
    --shadow-2: rgba(30, 40, 60, 0.16);
    --blob-opacity: 0.32;
    --blob-opacity-c: 0.14;
    --grain-opacity: 0.25;
    --grain-blend: multiply;

}


* {
    box-sizing: border-box;
}


::selection {
    background: var(--accent-soft);
    color: #04120f;
}


html {
    color-scheme: dark;
}


body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--void);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.4s ease, color 0.4s ease;
}


/* ==================================================
   Ambient liquid backdrop
   ================================================== */

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse 120% 80% at 50% -10%, var(--deep-2), var(--void) 55%);
    transition: background 0.4s ease;
}

.backdrop__filter {
    position: absolute;
    width: 0;
    height: 0;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: var(--blob-opacity);
    will-change: transform, filter;
}

.blob--a {
    width: 46vw;
    height: 46vw;
    top: -14vw;
    left: -10vw;
    background: radial-gradient(circle at 35% 35%, var(--accent), transparent 68%);
    animation: driftA 9s ease-in-out infinite, hueShift 5s ease-in-out infinite;
}

.blob--b {
    width: 38vw;
    height: 38vw;
    bottom: -16vw;
    right: -8vw;
    background: radial-gradient(circle at 60% 40%, var(--violet), transparent 70%);
    animation: driftB 10.5s ease-in-out infinite, hueShift 6s ease-in-out infinite 0.4s;
}

.blob--c {
    width: 26vw;
    height: 26vw;
    top: 38%;
    left: 55%;
    background: radial-gradient(circle at 50% 50%, var(--ember), transparent 72%);
    opacity: var(--blob-opacity-c);
    animation: driftC 13s ease-in-out infinite, hueShift 6.5s ease-in-out infinite 0.8s;
}

@keyframes driftA {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(7vw, 9vw) scale(1.12); }
}

@keyframes driftB {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(-6vw, -7vw) scale(1.08); }
}

@keyframes driftC {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(-9vw, 6vw) scale(0.9); }
}

@keyframes hueShift {
    0%, 100% { filter: blur(80px) hue-rotate(0deg); }
    50%      { filter: blur(80px) hue-rotate(45deg); }
}

.grain {
    position: absolute;
    inset: -10%;
    filter: url(#liquidGrain);
    opacity: var(--grain-opacity);
    mix-blend-mode: var(--grain-blend);
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .blob {
        animation: none !important;
    }
}


/* ==================================================
   Layout
   ================================================== */

.container {
    position: relative;
    z-index: 1;
    width: min(1040px, 92%);
    margin: 0 auto;
    padding: 64px 0 100px;
}


/* ==================================================
   Hero
   ================================================== */

.hero {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.hero__lens {
    position: relative;
    width: 100%;
    padding: 56px 48px 48px;
    border-radius: 40px;
    text-align: center;

    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.015) 55%);
    backdrop-filter: blur(30px) saturate(160%);
    -webkit-backdrop-filter: blur(30px) saturate(160%);
    border: 1px solid var(--glass-border);
    box-shadow:
        inset 0 1px 0 var(--shadow-1),
        inset 0 -40px 60px -40px var(--accent-dim),
        0 30px 80px -20px var(--shadow-2);
    overflow: hidden;
}

.hero__lens::before {
    content: "";
    position: absolute;
    top: -60%;
    left: 10%;
    width: 60%;
    height: 140%;
    background: radial-gradient(ellipse, var(--shadow-1), transparent 65%);
    transform: rotate(-18deg);
    pointer-events: none;
}

.hero__eyebrow {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    padding: 6px 14px;
    border: 1px solid var(--accent-soft);
    border-radius: 999px;
    background: var(--accent-dim);
    margin-bottom: 24px;
}

.hero__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(48px, 9vw, 92px);
    line-height: 0.96;
    letter-spacing: -0.03em;
    background: linear-gradient(120deg, var(--text) 20%, var(--accent) 65%, var(--violet) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero__sub {
    max-width: 480px;
    margin: 22px auto 0;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.6;
}


/* ==================================================
   Glass cards
   ================================================== */

.card {
    position: relative;
    background: linear-gradient(160deg, var(--glass-strong), var(--glass) 60%);
    backdrop-filter: blur(26px) saturate(150%);
    -webkit-backdrop-filter: blur(26px) saturate(150%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 22px;
    box-shadow:
        inset 0 1px 0 var(--shadow-1),
        0 20px 50px -20px var(--shadow-2);
    overflow: hidden;

    /* Scroll-reveal baseline state — toggled to .is-visible by
       an IntersectionObserver in effects.js as each panel
       swims into view. */
    opacity: 0;
    transform: translateY(46px) scale(0.96);
    filter: blur(10px);
    transition:
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        background 0.4s ease,
        border-color 0.4s ease,
        box-shadow 0.4s ease;
}

.card.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        420px circle at var(--mx, 50%) var(--my, 0%),
        var(--shadow-1),
        transparent 55%
    );
    pointer-events: none;
    transition: opacity 0.25s ease;
    opacity: 0;
}

.card:hover::after {
    opacity: 1;
}

.card__head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
}

.card__index {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    letter-spacing: 0.08em;
}

.card h2 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 21px;
    letter-spacing: -0.01em;
}

.results .card:nth-of-type(2) { transition-delay: 0.02s; }
.results .card:nth-of-type(3) { transition-delay: 0.08s; }
.results .card:nth-of-type(4) { transition-delay: 0.14s; }
.results .card:nth-of-type(5) { transition-delay: 0.20s; }
.results .card:nth-of-type(6) { transition-delay: 0.26s; }
.results .card:nth-of-type(7) { transition-delay: 0.32s; }

@media (prefers-reduced-motion: reduce) {
    .card {
        opacity: 1;
        transform: none;
        filter: none;
        transition: none;
    }
}


/* ==================================================
   Form
   ================================================== */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.full-width {
    grid-column: span 2;
}

label {
    margin-bottom: 9px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

input,
select {
    width: 100%;
    height: 50px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 0 16px;
    font-family: var(--font-mono);
    font-size: 15px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 52%),
                       linear-gradient(135deg, var(--text-muted) 48%, transparent 50%);
    background-position: calc(100% - 20px) center, calc(100% - 15px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

select option {
    background: var(--deep-2);
    color: var(--text);
}

input::placeholder {
    color: var(--text-faint);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(85, 230, 201, 0.06);
    box-shadow: 0 0 0 4px var(--accent-dim);
}

.input-unit {
    position: relative;
}

.input-unit input {
    padding-right: 55px;
}

.input-unit span {
    position: absolute;
    right: 16px;
    top: 15px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 13px;
}

button {
    margin-top: 30px;
    width: 100%;
    height: 56px;
    border: 1px solid var(--accent-soft);
    border-radius: 999px;
    background: linear-gradient(120deg, rgba(85, 230, 201, 0.22), rgba(140, 124, 246, 0.18));
    color: var(--text);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 0 rgba(85, 230, 201, 0);
}

button:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 30px -8px var(--accent-soft);
}

button:active {
    transform: translateY(0);
}


/* ==================================================
   Results toolbar + export button
   ================================================== */

.results__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    padding: 0 4px;
}

.results__toolbar-label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.btn-ghost {
    margin-top: 0;
    width: auto;
    height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-ghost:hover {
    transform: translateY(-2px);
    border-color: var(--accent-soft);
    background: var(--accent-dim);
}

.btn-ghost svg {
    flex-shrink: 0;
    color: var(--accent);
}


/* ==================================================
   Controls dock — language + theme switches
   ================================================== */

.controls-dock {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border-radius: 999px;
    background: linear-gradient(160deg, var(--glass-strong), var(--glass) 60%);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 var(--shadow-1), 0 10px 30px -12px var(--shadow-2);
    transition: background 0.4s ease, border-color 0.4s ease;
}

.controls-dock__divider {
    width: 1px;
    height: 20px;
    background: var(--glass-border);
    flex-shrink: 0;
}

.lang-switch,
.theme-switch {
    display: flex;
    align-items: center;
    gap: 2px;
}

.lang-switch button,
.theme-switch button {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    width: auto;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    line-height: 1;
    cursor: pointer;
    border-radius: 999px;
    transition: background 0.2s ease, color 0.2s ease;
}

.lang-switch button {
    height: 32px;
    min-width: 34px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0 4px;
}

.theme-switch button {
    width: 32px;
    height: 32px;
}

.theme-switch button svg {
    display: block;
    flex-shrink: 0;
}

.lang-switch button.is-active,
.theme-switch button.is-active {
    background: var(--accent-dim);
    color: var(--accent);
}

.lang-switch button:hover:not(.is-active),
.theme-switch button:hover:not(.is-active) {
    color: var(--text);
    background: rgba(127, 127, 127, 0.12);
}

@media (max-width: 700px) {

    .controls-dock {
        top: 12px;
        right: 12px;
        gap: 4px;
        padding: 4px;
    }

    .lang-switch button {
        height: 28px;
        min-width: 30px;
        font-size: 10.5px;
    }

    .theme-switch button {
        width: 28px;
        height: 28px;
    }

    .controls-dock__divider {
        height: 16px;
    }

}


/* ==================================================
   Stat tiles (BMI / Calories) — linear, not circular
   ================================================== */

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.stat-tile {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 22px 24px 20px;
}

.stat-tile__label {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 10px;
}

.stat-tile__value-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.stat-tile__value-row strong {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    text-shadow: 0 0 18px var(--accent-soft);
    line-height: 1;
}

.stat-tile__value-row small {
    font-size: 12px;
    color: var(--text-muted);
}

/* Single fill bar (BMI) */

.stat-bar {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: visible;
}

.stat-bar__fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--violet), var(--accent));
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-bar__marker {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text);
    border: 2px solid var(--void);
    box-shadow: 0 0 0 3px var(--accent-soft);
    transform: translate(-50%, -50%);
    transition: left 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-bar__ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 9px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.02em;
    color: var(--text-faint);
}

/* Stacked composition bar (calories: base vs. exercise) */

.stat-bar--stacked {
    display: flex;
    overflow: hidden;
}

.stat-bar__segment {
    height: 100%;
    width: 0%;
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-bar__segment--base {
    background: linear-gradient(90deg, var(--violet), var(--accent));
    border-radius: 999px 0 0 999px;
}

.stat-bar__segment--exercise {
    background: var(--ember);
    border-radius: 0 999px 999px 0;
}

.stat-bar__legend {
    display: flex;
    gap: 18px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.stat-bar__legend b {
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 600;
    margin-left: 4px;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.dot--base {
    background: var(--accent);
}

.dot--exercise {
    background: var(--ember);
}


/* ==================================================
   Nutrient list
   ================================================== */

.nutrient-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.nutrient {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    min-height: 76px;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.nutrient:hover {
    transform: translateY(-3px);
    border-color: rgba(85, 230, 201, 0.3);
    background: rgba(85, 230, 201, 0.045);
}

.nutrient-name {
    flex: 1 1 120px;
    min-width: 0;
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
    overflow-wrap: break-word;
}

.nutrient-info {
    flex: 0 1 auto;
    max-width: 100%;
    margin-left: auto;
    text-align: right;
}

.nutrient-value {
    display: block;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 16px;
    line-height: 1.25;
    color: var(--accent);
    text-shadow: 0 0 12px rgba(85, 230, 201, 0.25);
    white-space: normal;
    overflow-wrap: break-word;
}

.reference-container {
    display: block;
    margin-top: 5px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.02em;
    line-height: 1.35;
    color: var(--text-faint);
    white-space: normal;
    overflow-wrap: break-word;
    text-align: right;
}


/* ==================================================
   Tooltip (kept for structural compatibility)
   ================================================== */

.tooltip {
    position: relative;
    display: inline-block;
    color: var(--text-muted);
    font-weight: 600;
    cursor: help;
    border-bottom: 1px dotted var(--text-faint);
}

.tooltip-text {
    position: absolute;
    visibility: hidden;
    opacity: 0;
    z-index: 1000;
    width: 280px;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    padding: 12px 14px;
    background: rgba(10, 15, 25, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: var(--text);
    border-radius: 10px;
    text-align: left;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.tooltip-text strong {
    display: block;
    margin-bottom: 3px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(10, 15, 25, 0.95) transparent transparent transparent;
}


/* ==================================================
   Error
   ================================================== */

.error {
    color: var(--ember);
    margin-top: 16px;
    font-size: 14px;
    min-height: 1px;
}


/* ==================================================
   Hidden
   ================================================== */

.hidden {
    display: none;
}


/* ==================================================
   Reference card
   ================================================== */

.reference-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.reference-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
}

.reference-item strong {
    min-width: 55px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
}

.reference-item span {
    color: var(--text-muted);
    font-size: 13px;
}

.reference-note {
    margin-top: 22px;
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1.6;
}


/* ==================================================
   Mobile
   ================================================== */

@media (max-width: 700px) {

    .container {
        padding: 40px 0 70px;
    }

    .hero__lens {
        padding: 40px 24px 34px;
        border-radius: 30px;
    }

    .card {
        padding: 22px;
        border-radius: 24px;
    }

    .form-grid,
    .reference-list {
        grid-template-columns: 1fr;
    }

    .dial-grid,
    .stat-grid {
        grid-template-columns: 1fr;
        max-width: 320px;
        margin: 0 auto;
    }

    .full-width {
        grid-column: span 1;
    }

    .nutrient-list {
        grid-template-columns: 1fr;
    }

    .nutrient {
        min-height: 70px;
    }

    .nutrient-name {
        padding-right: 12px;
    }

    .tooltip-text {
        left: auto;
        right: -10px;
        transform: none;
    }

    .tooltip-text::after {
        left: auto;
        right: 12px;
        transform: none;
    }

}
