/* Public site of the lab: patient results at /r and legal pages. Light, minimal; --accent comes from the installation. */
@font-face {
    font-family: "Figtree";
    src: url("../fonts/figtree.woff2") format("woff2");
    font-weight: 300 900;
    font-display: swap;
}

:root {
    color-scheme: light;
    --on-accent: #ffffff;
    --bg: #fafaf9;
    --surface: #ffffff;
    --ink: #111418;
    --text: #3b4048;
    --muted: #6b7079;          /* 4.9:1 on white */
    --line: #ebebea;
    --line-strong: #dcdcda;
    --soft: #f4f4f2;
    --danger: #b42318;
    --danger-soft: #fdf3f2;
    --radius: 14px;
    --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; display: flex; flex-direction: column;
    font-family: var(--font); font-size: 1rem; line-height: 1.6; letter-spacing: -0.003em;
    background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
body.embed { background: var(--surface); }
main { flex: 1; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
h1, h2 { color: var(--ink); margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 5vw, 2.25rem); font-weight: 600; letter-spacing: -0.03em; }
h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.012em; }
p { margin: 0; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.wrap { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 420px; padding-top: 56px; padding-bottom: 48px; }
.page { padding-top: 40px; padding-bottom: 56px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.eyebrow { font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }

.skip { position: absolute; left: 12px; top: -48px; padding: 10px 14px; background: var(--surface); color: var(--ink); border-radius: 10px; z-index: 10; }
.skip:focus { top: 12px; }

/* Top bar */
.topbar { background: rgba(255, 255, 255, .88); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; backdrop-filter: saturate(1.4) blur(10px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.brand img { max-height: 38px; max-width: 160px; width: auto; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: .95rem; }
.topnav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.topnav form { margin: 0; }
.navlink {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 999px;
    background: none; border: 0; font: inherit; font-weight: 500; font-size: .925rem; color: var(--muted);
    text-decoration: none; cursor: pointer; transition: background-color .2s, color .2s;
}
.navlink:hover { background: var(--soft); color: var(--ink); }
.navlink.is-active { color: var(--ink); }
.embed .topbar { position: static; backdrop-filter: none; background: var(--surface); }
.embed .topbar-inner { min-height: 52px; }

/* Buttons */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 12px 22px; border-radius: 999px; border: 1px solid var(--accent);
    background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
    text-decoration: none; white-space: nowrap; cursor: pointer; transition: filter .2s, background-color .2s, border-color .2s;
}
.button:hover { filter: brightness(.9); color: var(--on-accent); }
.button:disabled { opacity: .7; cursor: progress; }
.button.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.button.ghost:hover { filter: none; border-color: var(--ink); }
.button.small { min-height: 44px; padding: 8px 16px; font-size: .9rem; }
.button.block { width: 100%; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }

/* Login */
.login { padding: 36px 28px 32px; }
.login h1 { margin-top: 20px; font-size: 1.75rem; }
.login > .muted { margin-top: 8px; }
.login-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--accent); }
.embed .narrow { padding-top: 20px; }
.embed .login { border: 0; padding: 8px 4px; }

.form { display: grid; gap: 20px; margin-top: 28px; }
.field { display: grid; gap: 8px; }
.field label { font-weight: 500; font-size: .925rem; color: var(--ink); }
.form input {
    width: 100%; min-height: 52px; padding: 12px 16px; font: inherit; font-size: 1.0625rem; letter-spacing: .02em;
    color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
    transition: border-color .2s, box-shadow .2s;
}
.form input::placeholder { color: #a3a7ad; }
.form input:hover { border-color: #c4c5c3; }
.form input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgba(17, 20, 24, .06); }
.form input[aria-invalid="true"] { border-color: var(--danger); }
.input-group { position: relative; }
.input-group input { padding-right: 96px; }
.input-addon {
    position: absolute; right: 6px; top: 6px; bottom: 6px; min-width: 80px; padding: 0 12px; border: 0; border-radius: 8px;
    background: transparent; color: var(--muted); font: inherit; font-weight: 500; font-size: .875rem; cursor: pointer;
}
.input-addon:hover { background: var(--soft); color: var(--ink); }
.help { font-size: .85rem; color: var(--muted); line-height: 1.55; }
.help strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.form .button { margin-top: 4px; }

.alert, .notice { display: flex; gap: 10px; align-items: flex-start; margin-top: 24px; padding: 12px 14px; border-radius: 12px; font-size: .925rem; }
.alert { background: var(--danger-soft); color: var(--danger); }
.notice { background: var(--soft); color: var(--ink); }
.alert .i, .notice .i { margin-top: 2px; }
.narrow > .small { margin-top: 20px; }
.narrow > .consent { margin-top: 8px; font-size: .8rem; }
.consent a { color: var(--muted); }

/* Results list */
.page-head { margin-bottom: 28px; }
.page-head .muted { margin-top: 6px; }
.reports { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.report { position: relative; display: flex; align-items: center; gap: 20px; padding: 20px 24px; border: 0; border-radius: 0; background: none; }
.report + .report { border-top: 1px solid var(--line); }
.report:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.report:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.report:only-child { border-radius: var(--radius); }
.report:hover { background: #fcfcfb; }
.date {
    flex: none; display: grid; align-content: center; width: 56px; padding-right: 20px; border-right: 1px solid var(--line);
    line-height: 1.1; text-align: left; box-sizing: content-box;
}
.date-day { font-size: 1.6rem; font-weight: 500; letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.date-month { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.report-body { flex: 1; min-width: 0; }
.report h2 { font-size: 1rem; font-weight: 600; }
.report h2 a { color: var(--ink); text-decoration: none; }
.stretched::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; color: var(--muted); font-size: .875rem; }
.meta span + span::before { content: "·"; margin-right: 10px; }
.report-actions { display: flex; align-items: center; gap: 8px; }
.report-actions .button { position: relative; z-index: 1; }
.chevron { color: #a3a7ad; display: grid; transition: transform .2s, color .2s; }
.report:hover .chevron { color: var(--ink); transform: translateX(2px); }
.view-hint { display: none; }

.empty { text-align: center; padding: 56px 24px; }
.empty-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--muted); margin-bottom: 16px; }
.empty .muted { margin-top: 6px; }

/* Report detail */
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: .925rem; font-weight: 500; color: var(--muted); text-decoration: none; margin: -12px 0 12px; }
.back:hover { color: var(--ink); }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.report-head .muted { margin-top: 8px; }
.study { padding: 24px 24px 8px; margin-bottom: 16px; }
.study h2 { margin-bottom: 12px; }

.results { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .95rem; }
.results th, .results td { text-align: left; padding: 13px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.results th + th, .results td { padding-left: 16px; }
.results tbody tr:last-child > * { border-bottom: 0; }
.results thead th { color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; padding-top: 0; padding-bottom: 10px; }
.results thead th:first-child { width: 40%; }
.results thead th:last-child { width: 26%; }
.results .name { font-weight: 400; color: var(--ink); }
.results .section th { padding: 20px 0 8px; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.results .value { font-variant-numeric: tabular-nums; }
.results .number { font-weight: 600; color: var(--ink); }
.results .unit { color: var(--muted); margin-left: 4px; font-size: .875rem; }
.results .range { color: var(--muted); font-variant-numeric: tabular-nums; }
.range-label { display: none; }
.flagged .number { color: var(--danger); }
.flag {
    display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; padding: 1px 8px; border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger);
    font-size: .75rem; font-weight: 600; white-space: nowrap; vertical-align: 1px;
}
.flag .i { width: 12px; height: 12px; stroke-width: 2.25; }
.critical .flag { background: var(--danger); border-color: var(--danger); color: #fff; }
.notes { color: var(--muted); font-size: .875rem; padding: 12px 0 16px; border-top: 1px solid var(--line); }

.disclaimer { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; color: var(--muted); font-size: .85rem; }
.disclaimer .i { margin-top: 2px; width: 16px; height: 16px; }

/* Legal pages */
.legal { max-width: 720px; padding-top: 56px; padding-bottom: 64px; }
.legal-head { padding-bottom: 32px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.legal-head .muted { margin-top: 12px; font-size: .9rem; }
.legal-body section { padding: 28px 0 0; }
.legal-body h2 { font-size: 1.125rem; margin-bottom: 12px; }
.legal-body p, .legal-body li { font-size: 1rem; line-height: 1.75; }
.legal-body p + p { margin-top: 12px; }
.legal-body ul { margin: 12px 0; padding-left: 1.25rem; }
.legal-body li + li { margin-top: 6px; }
.legal-body li::marker { color: var(--muted); }
.legal-body strong { color: var(--ink); font-weight: 600; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); font-size: .925rem; }
.legal-nav a { color: var(--muted); text-decoration: none; }
.legal-nav a:hover, .legal-nav a[aria-current="page"] { color: var(--ink); }

.footer { padding: 28px 0 36px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.footer-links a { color: var(--muted); text-decoration: none; padding: 6px 0; }
.footer-links a:hover { color: var(--ink); }

@media (max-width: 640px) {
    .narrow { padding-top: 32px; }
    .login { padding: 28px 20px 24px; }
    .report { align-items: flex-start; flex-wrap: wrap; gap: 16px; padding: 18px; }
    .date { width: 44px; padding-right: 16px; }
    .date-day { font-size: 1.4rem; }
    .report-actions { width: 100%; }
    .report-actions .button { flex: 1; }
    .chevron { display: none; }
    .view-hint { display: inline-flex; flex: 1; }
    .report-head { flex-direction: column; align-items: stretch; }

    /* Each result becomes a block: name and value on one line, reference below. */
    .study { padding: 20px 18px 4px; }
    .results { table-layout: auto; }
    .results thead { display: none; }
    .results tbody tr:not(.section) { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
    .results tbody tr:last-child { border-bottom: 0; }
    .results tbody tr > * { display: block; padding: 0 !important; border: 0; }
    .results .section, .results .section th { display: block; }
    .results .section th { padding: 18px 0 4px !important; }
    .results .value { text-align: right; }
    .results .range { grid-column: 1 / -1; font-size: .85rem; }
    .range-label { display: inline; margin-right: 6px; }
    .range-label::after { content: ":"; }
    .flag { display: flex; width: max-content; margin: 6px 0 0 auto; }
    .legal { padding-top: 36px; }
}

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