/* Page frame: sticky landscape stage + scrolling panel, live meters, navigation, buttons. */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.12; letter-spacing: -.01em; margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.app {
    display: grid;
    grid-template-columns: minmax(380px, 46%) 1fr;
    min-height: 100dvh;
}

/* ---------- Stage ---------- */
.stage {
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow: hidden;
    isolation: isolate;
    background: var(--fjord-700);
}

.brand {
    position: absolute;
    top: 20px;
    left: 24px;
    display: flex;
    gap: 12px;
    align-items: center;
    color: #10262f;
    font-size: 15px;
    line-height: 1.2;
    animation: fade-down var(--dur-med) var(--ease-out) backwards .9s;
}
.brand strong { display: block; font-family: var(--font-display); font-size: 19px; }
.brand-by { font-size: 13px; opacity: .75; letter-spacing: .04em; text-transform: uppercase; }
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(160deg, #fff 0 38%, transparent 38%), linear-gradient(200deg, var(--fjord-500), var(--fjord-900));
    box-shadow: inset 0 0 0 2px rgb(255 255 255 / .6);
}
@media (prefers-color-scheme: dark) { .brand { color: #e8efef; } }

/* ---------- Live meters ---------- */
.meters {
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 18px;
    padding: 14px 18px 22px;
    border-radius: var(--radius-l);
    background: color-mix(in oklab, var(--surface) 78%, transparent);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    box-shadow: var(--shadow-2);
    animation: rise-in var(--dur-med) var(--ease-out) backwards 1.1s;
}
.meters-title { grid-column: 1 / -1; margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }

.meter { display: grid; gap: 4px; min-width: 0; }
.meter-label { font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter-value { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; }
.meter-unit { font-size: 11px; font-weight: 500; color: var(--text-muted); margin-left: 3px; }
.meter-track {
    grid-column: 1 / -1;
    position: relative;
    height: 10px;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: visible;
}
.meter-fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--zone-good);
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform var(--dur-slow) var(--ease-spring), background-color var(--dur-med) var(--ease-out);
}
.meter[data-zone="mid"] .meter-fill { background: var(--zone-mid); }
.meter[data-zone="high"] .meter-fill { background: var(--zone-high); }
.meter-tick {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 2px;
    border-radius: 2px;
    background: var(--text);
    opacity: .55;
}
.meter-tick::after {
    content: attr(data-label);
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    color: var(--text-muted);
}

/* ---------- Panel & views ---------- */
.panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: clamp(24px, 5vw, 64px) clamp(16px, 5vw, 72px) 0;
}
.view { width: 100%; max-width: 680px; margin: 0 auto; }
.view[hidden] { display: none; }

.view-intro { margin-block: auto; padding-block: 24px 48px; }
.eyebrow { margin: 0 0 14px; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.view-intro h1 { font-size: clamp(40px, 6vw, 68px); }
.view-intro h1 em { font-style: italic; color: var(--accent); }
.lead { font-size: clamp(17px, 1.6vw, 20px); color: var(--text-muted); margin: 20px 0 28px; max-width: 34em; }
.facts { display: flex; flex-wrap: wrap; gap: 10px; padding: 0; margin: 0 0 32px; list-style: none; }
.facts li { padding: 8px 14px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow-1); font-size: 14px; }
.view-intro > * { animation: rise-in var(--dur-med) var(--ease-out) backwards; }
.view-intro > :nth-child(2) { animation-delay: 80ms; }
.view-intro > :nth-child(3) { animation-delay: 160ms; }
.view-intro > :nth-child(4) { animation-delay: 240ms; }
.view-intro > :nth-child(5) { animation-delay: 320ms; }

.credits { margin: auto auto 0; padding: 40px 0 24px; max-width: 680px; width: 100%; font-size: 13px; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: 99px;
    font: 600 15px/1 var(--font-sans);
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast), box-shadow var(--dur-fast);
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px color-mix(in oklab, var(--accent) 35%, transparent); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent), #000 12%); }
.btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-large { min-height: 56px; padding: 0 30px; font-size: 17px; }
.btn[disabled] { opacity: .35; pointer-events: none; }

/* ---------- Progress rail ---------- */
.rail { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 28px; }
.rail-theme { display: grid; gap: 8px; align-content: start; }
.rail-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); transition: color var(--dur-med); }
.rail-theme[data-state="active"] .rail-label { color: var(--accent); }
.rail-segments { display: flex; gap: 4px; }
.rail-segment {
    flex: 1;
    height: 6px;
    border: 0;
    padding: 0;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: hidden;
    cursor: pointer;
    position: relative;
}
.rail-segment::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur-med) var(--ease-out);
}
.rail-segment[data-state="done"]::after, .rail-segment[data-state="active"]::after { transform: scaleX(1); }
.rail-segment[data-state="active"] { box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent); }

/* ---------- Pager ---------- */
.pager {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 24px -16px 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: color-mix(in oklab, var(--bg) 86%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
}
.pager-count { font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

@keyframes rise-in { from { opacity: 0; transform: translateY(18px); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- Small screens: landscape becomes a header band ---------- */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .stage { position: relative; height: auto; min-height: 0; display: grid; }
    .stage .scene { position: relative; height: var(--scene-h); }
    .meters {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        gap: 10px;
        margin: -28px 12px 0;
        padding: 12px 14px;
        border-radius: var(--radius-m);
    }
    .meters-title { font-size: 11px; }
    .meter-value { font-size: 15px; }
    .meter-unit { display: none; }
    .meter-track { height: 6px; }
    .meter-tick::after { display: none; }
    .brand { top: 14px; left: 16px; }
    .panel { padding-top: 28px; }
    .rail { gap: 6px; }
    .rail-label { font-size: 11px; }
}

@media (max-width: 900px) {
    /* The landscape scrolls away, the meter strip (overlapping it by 28px) sticks 8px from the top */
    .app { --scene-h: clamp(220px, 34vh, 340px); }
    .stage { overflow: visible; position: sticky; top: calc(36px - var(--scene-h)); z-index: 10; }
}
