/* ==========================================================================
   MLS distortions: project page styles
   Same tokens as amanks-20.github.io. No frameworks, no web fonts.
   Sections: Tokens · Base · Nav · Header · Buttons · Sections · Figures
             · Cards · Steps · Math · Tables · Explorer · Stats · BibTeX · Footer
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
    --bg: #ffffff;
    --bg-alt: #f5f5f7;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --line: #d2d2d7;
    --link: #0066cc;
    --accent: #bf4800;
    --nav-bg: rgba(255, 255, 255, 0.72);
    --left: #d93636;            /* left scanner (red, as in the thesis figures) */
    --right: #2f5bd3;           /* right scanner (blue) */
    --object: #6fc3df;
    --mapper: #f4a6c8;
    --radius: 18px;
    --width: 760px;
    --wide: 1000px;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --bg-alt: #161617;
        --text: #f5f5f7;
        --muted: #a1a1a6;
        --line: #424245;
        --link: #2997ff;
        --accent: #ff9f0a;
        --nav-bg: rgba(22, 22, 23, 0.72);
        --left: #ff6b6b;
        --right: #6e9bff;
        --object: #4fb3d4;
        --mapper: #c86a96;
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 64px; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.53;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
p { margin: 0 0 1em; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.022em; line-height: 1.15; }
strong { font-weight: 600; }

.wrap { max-width: var(--width); margin: 0 auto; padding: 0 22px; }
.wide { max-width: var(--wide); margin: 0 auto; padding: 0 22px; }
.muted { color: var(--muted); }

/* ---------- Nav ---------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--nav-bg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--line);
}

.nav .wide {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 52px;
}

.nav-name { color: var(--text); font-weight: 600; font-size: 15px; white-space: nowrap; }
.nav-name:hover { text-decoration: none; }
.nav-name span { color: var(--muted); font-weight: 400; }

.nav-links {
    display: flex;
    gap: 22px;
    font-size: 13px;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { color: var(--text); opacity: 0.8; white-space: nowrap; }
.nav-links a:hover { opacity: 1; text-decoration: none; }

/* Phones without JS: name on top, links scroll sideways underneath */
@media (max-width: 720px) {
    .nav:not(.has-toggle) .wide { flex-direction: column; align-items: flex-start; gap: 2px; padding-top: 10px; padding-bottom: 8px; }
    .nav:not(.has-toggle) .nav-links { width: 100%; gap: 18px; padding-bottom: 2px; }
}

/* Menu button: hidden on wider screens */
.nav-toggle { display: none; }

/* Phones with JS: three-line button opens a full-screen menu (as on amanks-20.github.io) */
@media (max-width: 720px) {
    .nav.has-toggle .wide { min-height: 48px; }

    .nav-toggle {
        display: block;
        position: relative;
        width: 44px;
        height: 44px;
        margin-right: -12px;
        padding: 0;
        border: 0;
        background: none;
        color: var(--text);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-toggle span {
        position: absolute;
        left: 13px;
        width: 18px;
        height: 1.5px;
        border-radius: 1px;
        background: currentColor;
        transition: transform 0.3s ease, opacity 0.2s ease, top 0.3s ease;
    }
    .nav-toggle span:nth-child(1) { top: 16px; }
    .nav-toggle span:nth-child(2) { top: 21.25px; }
    .nav-toggle span:nth-child(3) { top: 26.5px; }

    .nav.is-open .nav-toggle span:nth-child(1) { top: 21.25px; transform: rotate(45deg); }
    .nav.is-open .nav-toggle span:nth-child(2) { opacity: 0; }
    .nav.is-open .nav-toggle span:nth-child(3) { top: 21.25px; transform: rotate(-45deg); }

    .nav.has-toggle .nav-links {
        position: fixed;
        top: 49px;
        left: 0;
        right: 0;
        height: calc(100vh - 49px);
        height: calc(100dvh - 49px);
        flex-direction: column;
        gap: 0;
        padding: 20px 22px 40px;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--bg);
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    }

    .nav.is-open .nav-links {
        visibility: visible;
        opacity: 1;
        transition: opacity 0.3s ease, visibility 0s;
    }

    .nav.has-toggle .nav-links a {
        padding: 8px 0;
        font-size: 28px;
        font-weight: 600;
        letter-spacing: -0.015em;
        line-height: 1.2;
        opacity: 0;
        transform: translateY(-8px);
        transition: opacity 0.25s ease, transform 0.25s ease;
    }

    .nav.is-open .nav-links a {
        opacity: 1;
        transform: none;
        transition-delay: calc(0.05s + var(--i, 0) * 0.03s);
    }

    /* Menu open: solid bar, no scrolling behind it */
    .nav.is-open {
        background: var(--bg);
        border-bottom-color: transparent;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    html.nav-locked { overflow: hidden; }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
    .nav-toggle span,
    .nav.has-toggle .nav-links,
    .nav.has-toggle .nav-links a { transition: none !important; }
}

/* ---------- Header ---------- */
.head { padding: 72px 0 8px; text-align: center; }

.badge {
    display: inline-block;
    margin-bottom: 18px;
    padding: 5px 14px;
    border-radius: 980px;
    background: var(--bg-alt);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}
.badge a { color: inherit; }

.head h1 {
    font-size: 48px;
    letter-spacing: -0.03em;
    line-height: 1.08;
    max-width: 880px;
    margin: 0 auto;
}

.authors { margin: 22px 0 0; font-size: 19px; }
.authors a { color: var(--text); border-bottom: 1px solid var(--line); }
.authors a:hover { text-decoration: none; border-color: var(--text); }
.authors sup { font-size: 12px; color: var(--muted); }
.affil { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.venue { margin: 6px 0 0; font-size: 15px; font-style: italic; color: var(--muted); }

@media (max-width: 640px) {
    .head { padding-top: 44px; }
    .head h1 { font-size: 32px; }
    .authors { font-size: 17px; }
}

/* ---------- Buttons ---------- */
.buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 28px 0 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 980px;
    background: var(--text);
    color: var(--bg);
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    border: 0;
    cursor: pointer;
}
.btn:hover { text-decoration: none; opacity: 0.85; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.ghost { background: var(--bg-alt); color: var(--text); }
.btn[aria-disabled="true"] { background: var(--bg-alt); color: var(--muted); cursor: default; }
.btn[aria-disabled="true"]:hover { opacity: 1; }

/* ---------- Sections ---------- */
main { padding-bottom: 40px; }
.section { padding-top: 72px; }

.section h2 {
    font-size: 32px;
    padding-bottom: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.section h3 { margin: 36px 0 10px; font-size: 21px; }

.eyebrow {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}

.lead { font-size: 21px; line-height: 1.45; letter-spacing: -0.016em; }

.note {
    margin: 20px 0;
    padding: 14px 18px;
    border-left: 3px solid var(--accent);
    background: var(--bg-alt);
    border-radius: 0 12px 12px 0;
    font-size: 15px;
}
.note p:last-child { margin: 0; }

/* ---------- Figures ---------- */
figure { margin: 28px 0; }

.fig-img {
    padding: 18px;
    border-radius: var(--radius);
    background: #ffffff;              /* thesis figures are drawn on white */
    border: 1px solid var(--line);
}
.fig-img img { margin: 0 auto; }
.fig-img.photo { padding: 0; overflow: hidden; background: #000; }

figcaption { margin-top: 10px; font-size: 14px; line-height: 1.5; color: var(--muted); }
figcaption strong { color: var(--text); }

.fig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.fig-row figure { margin: 0; }
@media (max-width: 720px) { .fig-row { grid-template-columns: 1fr; } }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 8px; }
.card { background: var(--bg-alt); border-radius: var(--radius); padding: 24px; }
.card h3 { margin: 0 0 8px; font-size: 19px; }
.card p { margin: 0; font-size: 15px; line-height: 1.5; }
.card .tag { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
@media (max-width: 760px) { .cards { grid-template-columns: 1fr; } }

/* ---------- Steps (primer) ---------- */
.steps { list-style: none; margin: 24px 0 0; padding: 0; counter-reset: step; }
.steps > li {
    position: relative;
    padding: 0 0 26px 52px;
    counter-increment: step;
}
.steps > li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: -2px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--text);
    color: var(--bg);
    font-size: 15px;
    font-weight: 600;
    line-height: 34px;
    text-align: center;
}
.steps > li::after {
    content: "";
    position: absolute;
    left: 16.5px;
    top: 38px;
    bottom: 6px;
    width: 1px;
    background: var(--line);
}
.steps > li:last-child::after { display: none; }
.steps h4 { margin: 2px 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.steps p { margin: 0 0 0.6em; }

/* FAQ */
details.faq { border-bottom: 1px solid var(--line); padding: 14px 0; }
details.faq:first-of-type { border-top: 1px solid var(--line); }
details.faq summary { cursor: pointer; font-weight: 600; list-style: none; position: relative; padding-right: 28px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; position: absolute; right: 4px; top: -2px; font-size: 22px; font-weight: 400; color: var(--muted); }
details.faq[open] summary::after { content: "−"; }
details.faq p { margin: 10px 0 0; font-size: 16px; }

/* ---------- Math ---------- */
math { font-size: 1.08em; }
math[display="block"] { margin: 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

.eq {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 16px;
    margin: 18px 0;
    padding: 18px 22px;
    border-radius: 14px;
    background: var(--bg-alt);
}
.eq .num { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.eq-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 18px 0; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
.pred { background: var(--bg-alt); }

details.more { margin-top: 12px; }
details.more summary { cursor: pointer; color: var(--link); font-size: 15px; }

/* ---------- Explorer ---------- */
.explorer {
    margin-top: 20px;
    border-radius: var(--radius);
    background: var(--bg-alt);
    padding: 22px;
}

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.presets span { font-size: 13px; color: var(--muted); align-self: center; margin-right: 4px; }

.pill {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 980px;
    background: var(--bg);
    color: var(--link);
    font: inherit;
    font-size: 13px;
    line-height: 1.5;
    cursor: pointer;
}
.pill[hidden] { display: none; }
.pill:hover { border-color: var(--link); text-decoration: none; }
.pill[aria-pressed="true"] { background: var(--link); border-color: var(--link); color: #fff; }

.ex-grid { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
@media (max-width: 860px) { .ex-grid { grid-template-columns: 1fr; } }

.controls { display: flex; flex-direction: column; gap: 14px; }
.ctrl label { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 500; }
.ctrl label output { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 400; }
.ctrl input[type="range"] { width: 100%; margin: 6px 0 0; accent-color: var(--link); }
.ctrl .hint { display: block; font-size: 12px; color: var(--muted); }

.seg { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.seg button {
    padding: 5px 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.canvas-box {
    position: relative;
    border-radius: 14px;
    background: var(--bg);
    border: 1px solid var(--line);
    overflow: hidden;
}
.canvas-box canvas { display: block; width: 100%; height: 360px; }
@media (max-width: 640px) { .canvas-box canvas { height: 300px; } }

.canvas-tools {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.legend .l-obj { border: 1.5px dashed var(--muted); }
.legend .l-now { border: 1.5px solid var(--object); background: color-mix(in srgb, var(--object) 25%, transparent); }
.legend .l-pts { background: var(--right); height: 4px; vertical-align: 2px; }
.legend .l-pts.left { background: var(--left); }
.legend .l-map { background: var(--mapper); }
.legend .l-line { height: 2px; background: currentColor; vertical-align: 3px; opacity: 0.6; }

.regime {
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--line);
}
.regime .name { font-size: 17px; font-weight: 600; }
.regime .name::before { content: "●"; margin-right: 8px; font-size: 12px; vertical-align: 2px; color: var(--accent); }
.regime p { margin: 4px 0 0; font-size: 14px; color: var(--muted); line-height: 1.45; }

.readouts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 640px) { .readouts { grid-template-columns: repeat(2, 1fr); } }
.readout { padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.readout .k { display: block; font-size: 12px; color: var(--muted); }
.readout .v { display: block; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.readout .s { display: block; font-size: 11px; color: var(--muted); }

.check { font-size: 13px; color: var(--muted); }

/* Optional 3D view */
.canvas-box.is-3d canvas { touch-action: none; cursor: grab; }
.canvas-box.is-3d canvas:active { cursor: grabbing; }
.canvas-box canvas:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }
.ex3d-notes p { margin: 0 0 4px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.ex3d-warn { color: var(--text) !important; font-weight: 600; }
.ex3d-warn::before { content: "●"; margin-right: 6px; font-size: 10px; vertical-align: 1px; color: var(--accent); }

/* Field-data panel: stacks below the canvas; beside it on wide screens,
   where the explorer box grows into the margins so the canvas keeps its width */
.canvas-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.canvas-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (min-width: 1340px) {
    #explorer .explorer { margin-left: -150px; margin-right: -150px; }
    .canvas-row { grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
}
/* Stacked layout: the panel comes after the readouts (canvas, readouts, panel) */
@media (max-width: 1339.98px) {
    .canvas-row { display: contents; }
    .stage > .canvas-row > .field { order: 1; }
}
.field {
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    min-width: 0;
}
.field h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; letter-spacing: 0; }
.field-body { font-size: 13px; line-height: 1.45; }
.field-empty { margin: 0; color: var(--muted); }
.field figure { margin: 0; }
.field-img {
    display: block;
    aspect-ratio: 960 / 600;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--bg-alt);
}
.field-img img { display: block; width: 100%; height: 100%; object-fit: contain; }
.field-img:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.field figcaption { margin-top: 8px; }
.field figcaption p { margin: 0 0 6px; }
.field .field-meta, .field .field-scale, .field .field-credit { color: var(--muted); font-size: 12px; }
.field .field-meta strong { color: var(--text); font-weight: 600; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { padding: 18px; border-radius: 14px; background: var(--bg-alt); }
.stat .v { display: block; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }

/* ---------- Resource list ---------- */
.res { list-style: none; margin: 0; padding: 0; }
.res li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.res li:last-child { border-bottom: 0; }
.res .t { font-weight: 600; }
.res .m { display: block; font-size: 14px; color: var(--muted); }
.res a.go { flex: none; align-self: center; font-size: 15px; }
.res a.go::after { content: " ›"; }

/* ---------- BibTeX ---------- */
.bib {
    position: relative;
    margin: 12px 0 0;
    padding: 18px 20px;
    background: var(--bg-alt);
    border-radius: 14px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}
.bib-copy { position: absolute; top: 12px; right: 12px; font-family: var(--font); }

/* ---------- Footer ---------- */
.footer {
    margin-top: 72px;
    padding: 24px 0 40px;
    background: var(--bg-alt);
    font-size: 12px;
    color: var(--muted);
}
.footer p { margin: 0 0 6px; }
.footer a { color: var(--text); }
.footer .sep { margin: 0 8px; opacity: 0.5; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}
