:root {
    --bg: #F8F9FA;
    --bg-elevated: #E9ECEF;
    --text: #212529;
    --brand: #0057B8;
    --brand-hover: #004590;
    --cta: #E08000;
    --cta-hover: #C46E00;
    --cta-text: #212529;
    --guide: #00F0FF;
    --success: #007A73;
    --success-soft: rgba(0, 122, 115, 0.14);
    --warn: #E08000;
    --warn-soft: rgba(224, 128, 0, 0.16);
    --border-strong: #ADB5BD;
    --shadow: 0 18px 40px rgba(33, 37, 41, 0.08);
    --font-body: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
    --font-display: "Outfit", "Atkinson Hyperlegible", sans-serif;
    --radius: 0.35rem;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.55;
    color: var(--text);
    background:
        radial-gradient(1200px 500px at 80% -10%, rgba(0, 87, 184, 0.08), transparent 60%),
        radial-gradient(900px 400px at 0% 20%, rgba(0, 240, 255, 0.07), transparent 55%),
        linear-gradient(180deg, #F1F3F5 0%, var(--bg) 40%, #EEF2F5 100%);
}

main {
    flex: 1;
}

img,
video,
canvas {
    max-width: 100%;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--cta);
    color: var(--cta-text);
    padding: 0.75rem 1rem;
    z-index: 1000;
    font-weight: 700;
}

.skip-link:focus {
    left: 0.75rem;
    top: 0.75rem;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(248, 249, 250, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--bg-elevated);
}

.site-nav {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.brand-mark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.15rem, 2.5vw, 1.45rem);
    color: var(--text) !important;
    letter-spacing: -0.02em;
}

.brand-tld {
    color: var(--brand);
}

.nav-link {
    color: var(--text) !important;
    font-weight: 700;
    font-size: 1.05rem;
}

.nav-link.active,
.nav-link:hover,
.nav-link:focus {
    color: var(--brand) !important;
}

.navbar-toggler {
    border: 2px solid var(--text);
}

.btn {
    font-family: var(--font-body);
    font-weight: 700;
    border-radius: var(--radius);
    border-width: 2px;
    padding: 0.65rem 1.25rem;
}

.btn-cta {
    background: var(--cta);
    border-color: var(--cta);
    color: var(--cta-text);
}

.btn-cta:hover,
.btn-cta:focus {
    background: var(--cta-hover);
    border-color: var(--cta-hover);
    color: var(--cta-text);
}

.btn-outline-brand {
    background: transparent;
    border-color: var(--brand);
    color: var(--brand);
}

.btn-outline-brand:hover,
.btn-outline-brand:focus {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-ghost:hover,
.btn-ghost:focus {
    background: var(--bg-elevated);
    border-color: var(--text);
    color: var(--text);
}

.btn:disabled {
    opacity: 0.55;
}

/* Hero */
.hero {
    position: relative;
    min-height: min(92vh, 860px);
    display: grid;
    align-items: end;
    overflow: hidden;
    padding: 3rem 0 0;
}

.hero-atmosphere {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 35%, rgba(248, 249, 250, 0.92) 78%, var(--bg) 100%),
        repeating-linear-gradient(
            -12deg,
            transparent,
            transparent 18px,
            rgba(0, 87, 184, 0.03) 18px,
            rgba(0, 87, 184, 0.03) 19px
        );
    pointer-events: none;
}

.hero-inner {
    position: relative;
    z-index: 2;
    max-width: 720px;
    padding-bottom: 2rem;
}

.brand-hero {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 6vw, 3.4rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
    color: var(--brand);
    margin: 0 0 0.75rem;
    animation: rise-in 0.7s ease-out both;
}

.hero-headline {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.45rem, 3.2vw, 2rem);
    margin: 0 0 0.85rem;
    animation: rise-in 0.7s ease-out 0.08s both;
}

.hero-lede {
    font-size: 1.2rem;
    max-width: 36rem;
    margin-bottom: 1.5rem;
    animation: rise-in 0.7s ease-out 0.16s both;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    animation: rise-in 0.7s ease-out 0.24s both;
}

.hero-visual {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    padding: 1rem 1rem 3rem;
}

.hero-viewfinder {
    position: relative;
    width: min(100%, 520px);
    aspect-ratio: 4 / 3;
    background:
        linear-gradient(145deg, #1a2330 0%, #2c3b4e 55%, #1e2a38 100%);
    border: 3px solid var(--text);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: viewfinder-in 0.9s ease-out 0.2s both;
}

.vf-ring {
    position: absolute;
    left: 50%;
    top: 46%;
    width: 58%;
    height: 68%;
    transform: translate(-50%, -50%);
    border: 3px solid var(--guide);
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
    animation: pulse-guide 2.8s ease-in-out infinite;
}

.vf-pupil {
    position: absolute;
    top: 42%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--guide);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.35);
}

.vf-pupil-l { left: 38%; }
.vf-pupil-r { right: 38%; }

.vf-card {
    position: absolute;
    left: 50%;
    top: 62%;
    width: 42%;
    height: 14%;
    transform: translateX(-50%);
    border: 2px solid var(--guide);
    border-left-width: 4px;
    border-right-width: 4px;
    background: rgba(0, 240, 255, 0.08);
}

@keyframes rise-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes viewfinder-in {
    from { opacity: 0; transform: translateY(28px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulse-guide {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

.section-block {
    padding: 3.5rem 0;
}

.section-elevated {
    background: var(--bg-elevated);
}

.narrow {
    max-width: 720px;
}

.section-block h2,
.page-intro h1,
.results-heading {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.step-block {
    background: var(--bg);
    padding: 1.5rem 1.35rem;
    border-left: 4px solid var(--brand);
    height: 100%;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin-bottom: 0.75rem;
    background: var(--brand);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
}

.step-block h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.page-intro {
    padding: 2.75rem 0 1.25rem;
}

.page-intro-compact {
    padding-bottom: 0.5rem;
}

.page-intro h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin-bottom: 0.75rem;
}

.lede {
    font-size: 1.2rem;
    max-width: 40rem;
}

.content-list {
    padding-left: 1.2rem;
}

.content-list li {
    margin-bottom: 0.65rem;
}

.site-footer {
    margin-top: auto;
    padding: 2rem 0;
    background: var(--bg-elevated);
    border-top: 2px solid #DEE2E6;
    font-size: 1rem;
}

.footer-note {
    color: #495057;
    font-size: 0.98rem;
}

/* Measure UI */
.measure-section {
    padding: 1rem 0 3rem;
}

.measure-layout {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 992px) {
    .measure-layout {
        grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.85fr);
        align-items: start;
    }
}

.viewfinder-panel,
.results-panel {
    background: var(--bg-elevated);
    padding: 1rem;
}

.viewfinder {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #111827;
    border: 3px solid var(--text);
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

.viewfinder video {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.viewfinder canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* Video is mirrored in JS onto this canvas — no CSS mirror */
}

.viewfinder-guide {
    position: absolute;
    left: 50%;
    top: 48%;
    width: min(62%, 280px);
    aspect-ratio: 3 / 4;
    transform: translate(-50%, -50%);
    border: 3px solid var(--guide);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.85;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.viewfinder-guide.is-ready {
    border-color: var(--success);
    box-shadow: 0 0 0 4px var(--success-soft);
}

.viewfinder-guide.is-warn {
    border-color: var(--warn);
    box-shadow: 0 0 0 4px var(--warn-soft);
}

.status-pill {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    right: 0.75rem;
    max-width: calc(100% - 1.5rem);
    padding: 0.55rem 0.85rem;
    background: rgba(248, 249, 250, 0.94);
    border: 2px solid var(--text);
    font-weight: 700;
    font-size: 1rem;
    pointer-events: none;
}

.status-pill.is-ready {
    border-color: var(--success);
    color: var(--success);
}

.status-pill.is-warn {
    border-color: var(--warn);
    color: #8A4B00;
}

.measure-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.9rem;
}

.hint-line {
    margin: 0.85rem 0 0;
    font-size: 1.05rem;
}

.results-heading {
    font-size: 1.45rem;
    margin-bottom: 1rem;
}

.metric {
    background: var(--bg);
    padding: 1rem 1.1rem;
    margin-bottom: 0.75rem;
    border-left: 4px solid var(--brand);
}

.metric-label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.metric-value {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--brand);
    line-height: 1;
}

.metric-value-sm {
    font-size: 1.8rem;
}

.metric-unit {
    font-weight: 700;
    margin-left: 0.2rem;
}

.metric-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    border-left-color: var(--success);
}

.result-note {
    font-size: 0.98rem;
    color: #495057;
}

.checklist {
    margin: 1rem 0 0;
    padding-left: 1.2rem;
}

.checklist li {
    margin-bottom: 0.4rem;
}

.alignment-legend {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 2px solid #DEE2E6;
    display: grid;
    gap: 0.45rem;
    font-size: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.swatch {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--text);
    flex-shrink: 0;
}

.swatch-cyan { background: var(--guide); }
.swatch-teal { background: var(--success); }
.swatch-amber { background: var(--warn); }

.sample-log {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 2px solid #DEE2E6;
}

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

.sample-log-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.sample-averages {
    background: var(--bg);
    border-left: 4px solid var(--success);
    padding: 0.85rem 1rem;
    margin-bottom: 0.85rem;
}

.sample-avg-label {
    font-weight: 700;
    margin: 0 0 0.55rem;
}

.sample-avg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.sample-avg-value {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--brand);
    line-height: 1.1;
}

.sample-table-wrap {
    overflow-x: auto;
    background: var(--bg);
}

.sample-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.98rem;
}

.sample-table th,
.sample-table td {
    padding: 0.45rem 0.55rem;
    text-align: left;
    border-bottom: 1px solid #DEE2E6;
    white-space: nowrap;
}

.sample-table th:last-child,
.sample-table td.sample-actions {
    text-align: right;
    width: 2.5rem;
}

.btn-remove-sample {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    padding: 0;
    border: 2px solid var(--text);
    background: var(--bg);
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius);
}

.btn-remove-sample:hover,
.btn-remove-sample:focus {
    background: var(--warn);
    border-color: var(--warn);
    color: var(--text);
    outline: none;
}

.sample-table th {
    font-weight: 700;
    background: #DEE2E6;
}

.sample-table tbody tr:last-child td {
    border-bottom: none;
}

.sample-empty-row td {
    color: #495057;
    white-space: normal;
    font-size: 0.95rem;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.95rem;
}

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