/* ==========================================================
   Binaya Ghimire — mandala.html
   Day: ink & vermilion on lokta paper. Night: gold on lapis.
   ========================================================== */

:root,
:root[data-theme="light"] {
    --paper: #f3e9d6;
    --paper-2: #eadcc2;
    --ink: #2b1d14;
    --muted: #6d5848;
    --verm: #c23b22;
    --lapis: #23418f;
    --jade: #2f7d5b;
    --gold: #b8862b;
    --band: rgba(184, 134, 43, 0.09);
    --panel: rgba(250, 244, 232, 0.88);
    --panel-border: rgba(120, 80, 40, 0.18);
    --shadow: 0 24px 60px -28px rgba(90, 50, 20, 0.45);
    --on-accent: #fff8ee;
    --grain: 0.09;

    --serif: 'Cormorant Garamond', Georgia, serif;
    --sans: 'Inter', system-ui, -apple-system, sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --gutter: clamp(16px, 4vw, 56px);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --paper: #0b1438;
    --paper-2: #111d4d;
    --ink: #f4e9cf;
    --muted: #b9b0c9;
    --verm: #e2553a;
    --lapis: #3d63c9;
    --jade: #3fae80;
    --gold: #e0b452;
    --band: rgba(224, 180, 82, 0.08);
    --panel: rgba(13, 22, 60, 0.86);
    --panel-border: rgba(224, 180, 82, 0.2);
    --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.7);
    --on-accent: #fff8ee;
    --grain: 0.05;
    color-scheme: dark;
}

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

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

body {
    font-family: var(--sans);
    color: var(--ink);
    background-color: var(--paper);
    background-image: radial-gradient(120% 90% at 70% 40%, var(--paper) 30%, var(--paper-2));
    background-attachment: fixed;
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.8s, color 0.6s;
}

/* handmade-paper grain */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: var(--grain);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.2 0 0 0 0 0.1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

ul,
ol {
    list-style: none;
}

::selection {
    background: var(--verm);
    color: var(--on-accent);
}

:focus-visible {
    outline: 2px solid var(--verm);
    outline-offset: 3px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 3000;
    padding: 10px 16px;
    background: var(--verm);
    color: var(--on-accent);
    border-radius: 8px;
    font-weight: 600;
}

.skip-link:focus {
    top: 16px;
}

/* ---------- Stage + mandala ---------- */
.stage {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 60vw;
    z-index: 1;
    display: grid;
    place-items: center;
    pointer-events: none;
}

#mandala {
    width: min(56vw, 92vh);
    height: min(56vw, 92vh);
    overflow: visible;
    pointer-events: auto;
}

.ring-label {
    position: absolute;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 8px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    font-family: var(--serif);
    font-size: 1.1rem;
    white-space: nowrap;
}

.ring-label span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--verm);
    color: var(--on-accent);
    font-weight: 700;
    font-size: 0.95rem;
}

/* SVG parts */
.m-line { fill: none; stroke: var(--gold); stroke-width: 1.4; }
.m-line-strong { fill: none; stroke: var(--gold); stroke-width: 3; }
.m-ink { fill: none; stroke: var(--ink); stroke-width: 1; opacity: 0.35; }
.m-dot { fill: var(--gold); }
.m-paper { fill: var(--paper); stroke: var(--gold); stroke-width: 3; }
.m-band { fill: none; stroke: var(--band); }
.m-verm { fill: var(--verm); stroke: var(--gold); stroke-width: 1.2; }
.m-lapis { fill: var(--lapis); stroke: var(--gold); stroke-width: 1.2; }
.m-jade { fill: var(--jade); stroke: var(--gold); stroke-width: 1.2; }
.m-soft { fill-opacity: 0.16; }
.m-text { fill: var(--ink); font-family: var(--serif); font-weight: 600; }
.m-caps { fill: var(--ink); font-family: var(--sans); font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; }
.m-gold-text { fill: var(--gold); }
[data-theme="dark"] #mandala .inv { filter: invert(1); }

.ring {
    opacity: 0.14;
    transition: opacity 1s var(--ease);
}

.ring.on {
    opacity: 1;
}

.ring.far {
    opacity: 0;
}

.draw {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 1.8s var(--ease);
}

.ring.on .draw {
    stroke-dashoffset: 0;
}

/* journey nodes */
.node circle {
    fill: var(--paper);
    stroke: var(--gold);
    stroke-width: 2.5;
    transition: fill 0.6s, r 0.6s;
}

.node text {
    transition: fill 0.6s;
}

.node.lit circle {
    fill: var(--verm);
}

.node.lit .num {
    fill: var(--on-accent);
}

/* skills */
.skill {
    cursor: help;
}

.skill .petal {
    transition: fill-opacity 0.3s;
}

.skill:hover .petal {
    fill-opacity: 0.55;
}

/* project gates */
.gate-link {
    cursor: pointer;
}

.gate-link .shade {
    fill: #000;
    fill-opacity: 0.18;
    stroke: var(--gold);
    stroke-width: 2.5;
    transition: fill-opacity 0.35s;
}

.gate-link:hover .shade,
.gate-link.hot .shade {
    fill-opacity: 0.02;
}

.gate-link .label {
    fill: #fff8ee;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.04em;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 3px;
}

/* contact gates */
.door {
    cursor: pointer;
}

.door rect {
    fill: var(--paper);
    stroke: var(--gold);
    stroke-width: 2.5;
    transition: fill 0.3s;
}

.door text {
    transition: fill 0.3s;
}

.door:hover rect {
    fill: var(--verm);
}

.door:hover text {
    fill: var(--on-accent);
}

.tip {
    position: fixed;
    z-index: 1500;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--verm);
    color: var(--on-accent);
    font-size: 0.82rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -140%);
    transition: opacity 0.2s;
    white-space: nowrap;
}

.tip.show {
    opacity: 1;
}

/* ---------- Nav ---------- */
.nav {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px var(--gutter);
    transition: background 0.4s, padding 0.4s var(--ease), box-shadow 0.4s;
}

.nav.scrolled {
    padding-top: 12px;
    padding-bottom: 12px;
    background: var(--panel);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 1px 0 var(--panel-border);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--serif);
    font-size: 1.45rem;
    font-weight: 700;
}

.nav-logo i {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    background: radial-gradient(circle, var(--gold) 0 3px, var(--verm) 4px 6px, transparent 7px);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-links a {
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 500;
    transition: color 0.3s, background 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--verm);
}

.nav-links .nav-cv {
    margin-left: 6px;
    background: var(--verm);
    color: var(--on-accent);
}

.nav-links .nav-cv:hover {
    color: var(--on-accent);
    filter: brightness(1.08);
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    position: relative;
    overflow: hidden;
}

.theme-toggle i {
    position: absolute;
    transition: transform 0.6s var(--ease), opacity 0.4s;
}

.theme-toggle .fa-sun { color: var(--gold); }
.theme-toggle .fa-moon { color: var(--lapis); }
[data-theme="light"] .theme-toggle .fa-sun { transform: translateY(150%) rotate(90deg); opacity: 0; }
[data-theme="dark"] .theme-toggle .fa-moon { transform: translateY(-150%) rotate(-90deg); opacity: 0; }

.nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    position: relative;
    z-index: 2;
}

.nav-toggle span {
    position: absolute;
    left: 10px;
    right: 10px;
    height: 2px;
    border-radius: 2px;
    background: var(--ink);
    transition: transform 0.4s var(--ease);
}

.nav-toggle span:first-child { top: 15px; }
.nav-toggle span:last-child { top: 23px; }
.nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }

/* ---------- Chapters ---------- */
main {
    position: relative;
    z-index: 2;
    width: 40vw;
    min-width: 380px;
    pointer-events: none; /* let the mandala receive hover/clicks beside the panels */
}

.chapter {
    position: relative;
    min-height: 150vh;
    padding: 0 0 0 var(--gutter);
}

.panel {
    position: sticky;
    top: 16vh;
    width: min(500px, 100%);
    padding: clamp(24px, 2.6vw, 34px);
    border-radius: 22px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: auto;
    transition: background 0.6s, border-color 0.6s;
}

[data-reveal] {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1s var(--ease), transform 1s var(--ease);
}

[data-reveal].in {
    opacity: 1;
    transform: none;
}

.kicker {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--verm);
    margin-bottom: 10px;
}

h1,
h2 {
    font-family: var(--serif);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.01em;
}

h2 {
    font-size: clamp(2rem, 3.2vw, 2.8rem);
    margin-bottom: 16px;
}

.lead {
    font-family: var(--serif);
    font-size: clamp(1.15rem, 1.6vw, 1.35rem);
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 14px;
}

.panel > p:not(.kicker):not(.lead) {
    color: var(--muted);
}

/* hero */
.hero {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
}

.hero .panel {
    position: relative;
    top: auto;
    background: none;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 90px 0 0;
}

.hero h1 {
    font-size: clamp(3.6rem, 7vw, 6.4rem);
    margin-bottom: 18px;
}

.hero h1 em {
    font-style: italic;
    font-weight: 600;
    color: var(--verm);
}

.btns {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 24px 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 22px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: transform 0.4s var(--ease), box-shadow 0.4s, background 0.3s;
}

.btn:hover {
    transform: translateY(-3px);
}

.btn-primary {
    background: var(--verm);
    color: var(--on-accent);
    box-shadow: 0 12px 28px -12px var(--verm);
}

.btn-ghost {
    background: var(--panel);
    border: 1px solid var(--panel-border);
}

.socials {
    display: flex;
    gap: 10px;
}

.socials a {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--gold);
    transition: background 0.3s, color 0.3s, transform 0.4s var(--ease);
}

.socials a:hover {
    background: var(--gold);
    color: var(--paper);
    transform: translateY(-3px);
}

.hint {
    margin-top: 40px;
    font-size: 0.85rem;
    color: var(--muted);
}

.hint i {
    margin-right: 8px;
    animation: bob 1.8s ease-in-out infinite;
}

@keyframes bob {
    50% { transform: translateY(4px); }
}

/* about */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.stats > div {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    background: var(--band);
}

.stats dt {
    font-size: 0.72rem;
    color: var(--muted);
}

.stats dd {
    font-family: var(--serif);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--verm);
}

/* journey */
.timeline {
    counter-reset: step;
}

.timeline li {
    position: relative;
    padding: 0 0 12px 46px;
    counter-increment: step;
}

.timeline li:last-child {
    padding-bottom: 0;
}

.timeline li::before {
    content: counter(step, upper-roman);
    position: absolute;
    left: 0;
    top: 2px;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px solid var(--gold);
    font-family: var(--serif);
    font-weight: 700;
    font-size: 0.85rem;
    transition: background 0.5s, color 0.5s;
}

.timeline li.lit::before {
    background: var(--verm);
    border-color: var(--verm);
    color: var(--on-accent);
}

.timeline b {
    display: block;
    font-family: var(--serif);
    font-size: 1.25rem;
}

.timeline small {
    display: block;
    margin: 1px 0 3px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--verm);
}

.timeline span {
    display: block;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
}

/* skills */
.group + .group {
    margin-top: 16px;
}

.group h3 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 4px;
}

.group p {
    font-family: var(--serif);
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.35;
}

.note {
    margin-top: 18px;
    font-size: 0.85rem;
}

/* projects */
.projects {
    display: grid;
    gap: 4px;
    counter-reset: proj;
}

/* the projects panel is long: scroll inside it rather than overflow the screen */
#projects .panel {
    max-height: 78vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gold) transparent;
}

#projects {
    min-height: 190vh;
}

/* fallback for short screens: scroll inside the card instead of cutting it off */
#journey .panel {
    top: 11vh;
    max-height: 84vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gold) transparent;
}

.projects li {
    counter-increment: proj;
}

.projects a {
    position: relative;
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 12px;
    align-items: center;
    padding: 6px 10px 6px 6px;
    border-radius: 12px;
    transition: background 0.3s;
}

.projects a > div {
    display: grid;
    min-width: 0;
}

.projects img {
    width: 92px;
    height: 58px;
    object-fit: cover;
    object-position: top;
    border-radius: 8px;
    border: 1.5px solid var(--gold);
    transition: transform 0.4s var(--ease);
}

.projects a:hover img,
.projects a.hot img {
    transform: scale(1.06);
}

/* roman numeral badge on the thumbnail */
.projects a::before {
    content: counter(proj, upper-roman);
    position: absolute;
    left: 2px;
    top: 2px;
    z-index: 1;
    min-width: 24px;
    padding: 0 5px;
    border-radius: 6px;
    background: var(--verm);
    color: var(--on-accent);
    text-align: center;
    font-family: var(--serif);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.5;
}

.projects a:hover,
.projects a.hot {
    background: var(--band);
}

.projects b {
    font-family: var(--serif);
    font-size: 1.15rem;
}

.projects b::after {
    content: ' ↗';
    color: var(--verm);
    font-family: var(--sans);
    font-size: 0.8rem;
}

.projects span {
    font-size: 0.82rem;
    color: var(--muted);
}

.projects em {
    font-style: normal;
    font-size: 0.72rem;
    color: var(--gold);
    letter-spacing: 0.04em;
}

/* contact */
.chapter-last {
    min-height: 130vh;
}

.email {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    max-width: 100%;
    padding: 12px 18px;
    border-radius: 14px;
    border: 1px dashed var(--verm);
    background: var(--band);
    font-family: var(--serif);
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    font-weight: 700;
    text-align: left;
    transition: transform 0.35s var(--ease);
}

.email:hover {
    transform: translateY(-2px);
}

.email span:not(.addr) {
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
}

.mail-link {
    display: block;
    margin: 8px 0 20px;
    width: fit-content;
    font-size: 0.85rem;
    color: var(--muted);
}

.mail-link:hover {
    color: var(--verm);
}

.pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 15px;
    border-radius: 999px;
    border: 1px solid var(--panel-border);
    font-size: 0.88rem;
    font-weight: 500;
    transition: border-color 0.3s, transform 0.35s var(--ease);
}

.pill:hover {
    border-color: var(--verm);
    transform: translateY(-2px);
}

.pill-accent {
    background: #25d366;
    border-color: #25d366;
    color: #06240f;
    font-weight: 600;
}

.meta {
    font-size: 0.88rem;
}

.meta a:hover {
    color: var(--verm);
}

.footer {
    position: absolute;
    left: var(--gutter);
    bottom: 24px;
    font-size: 0.82rem;
    color: var(--muted);
    pointer-events: auto;
}

.footer a {
    color: var(--verm);
}

/* ---------- Centre preview (SVG) ---------- */
#preview {
    opacity: 0;
    transition: opacity 0.35s var(--ease);
    pointer-events: none;
}

#preview.show {
    opacity: 1;
}

#preview .pv-frame {
    fill: var(--paper);
    stroke: var(--gold);
    stroke-width: 3;
}

#preview .pv-title {
    fill: var(--ink);
    font-family: var(--serif);
    font-weight: 700;
    font-size: 19px;
}

#preview .pv-tags {
    fill: var(--verm);
    font-family: var(--sans);
    font-weight: 600;
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* ---------- Lightbox ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: grid;
    place-items: center;
    padding: 24px;
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    clip-path: circle(0 at var(--ox, 50%) var(--oy, 50%));
    transition: clip-path 0.7s var(--ease);
}

.lightbox[hidden] {
    display: none;
}

.lightbox.open {
    clip-path: circle(150% at var(--ox, 50%) var(--oy, 50%));
}

.lb-inner {
    position: relative;
    width: min(1100px, 100%);
    max-height: 100%;
    display: grid;
    grid-template-columns: 1.7fr 1fr;
    gap: 28px;
    align-items: center;
    padding: 24px;
    border-radius: 24px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
}

.lb-figure {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid var(--gold);
    background: var(--paper-2);
    aspect-ratio: 16 / 10;
}

.lb-figure img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s;
}

.lb-figure img.swap {
    opacity: 0;
}

.lb-info h3 {
    font-family: var(--serif);
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    line-height: 1.05;
    margin-bottom: 10px;
}

.lb-info p {
    color: var(--muted);
    margin-bottom: 12px;
}

.lb-info .kicker {
    color: var(--verm);
}

.lb-tags {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold) !important;
    font-weight: 600;
}

.lb-close,
.lb-nav {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--paper);
    border: 1.5px solid var(--gold);
    transition: background 0.3s, color 0.3s;
}

.lb-close:hover,
.lb-nav:hover {
    background: var(--verm);
    color: var(--on-accent);
    border-color: var(--verm);
}

.lb-close {
    top: -16px;
    right: -16px;
}

.lb-prev {
    left: -22px;
    top: 50%;
    transform: translateY(-50%);
}

.lb-next {
    right: -22px;
    top: 50%;
    transform: translateY(-50%);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 2000;
    padding: 12px 20px;
    border-radius: 999px;
    background: var(--verm);
    color: var(--on-accent);
    font-weight: 600;
    transform: translate(-50%, 160%);
    opacity: 0;
    transition: transform 0.5s var(--ease), opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .nav-toggle {
        display: block;
    }

    .nav-links {
        position: fixed;
        inset: 0;
        flex-direction: column;
        justify-content: center;
        gap: 6px;
        background: var(--paper);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.4s, visibility 0.4s;
    }

    .nav-links.open {
        opacity: 1;
        visibility: visible;
    }

    .nav-links a {
        font-family: var(--serif);
        font-size: 2rem;
        font-weight: 700;
    }

    .nav-links .nav-cv {
        margin: 14px 0 0;
        font-family: var(--sans);
        font-size: 1rem;
    }

    /* mandala sits in the top of the screen, panels scroll up over it */
    .stage {
        width: 100vw;
        bottom: auto;
        height: 66vh;
        top: 56px;
    }

    #mandala {
        width: min(94vw, 62vh);
        height: min(94vw, 62vh);
    }

    .ring-label {
        bottom: 0;
        font-size: 0.95rem;
    }

    main {
        width: 100%;
        min-width: 0;
    }

    .chapter {
        min-height: 0;
        padding: calc(56px + 66vh + 24px) var(--gutter) 10vh;
    }

    .panel {
        position: relative;
        top: auto;
        width: 100%;
    }

    .hero {
        padding-top: 0;
        align-items: flex-end;
    }

    .hero .panel {
        padding: calc(56px + 66vh + 24px) 0 40px; /* below the mandala and its label */
    }

    .hero h1 {
        font-size: clamp(3rem, 14vw, 4.4rem);
    }

    .hint {
        margin-top: 24px;
    }

    .chapter-last {
        min-height: 0;
        padding-bottom: 90px;
    }

    #projects {
        min-height: 0;
    }

    #projects .panel,
    #journey .panel {
        max-height: none;
        overflow: visible;
    }

    .lightbox {
        padding: 16px;
    }

    .lb-inner {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 14px;
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }

    .lb-close {
        top: 8px;
        right: 8px;
        z-index: 2;
    }

    .lb-prev,
    .lb-next {
        top: auto;
        bottom: 14px;
        transform: none;
    }

    .lb-prev { left: auto; right: 66px; }
    .lb-next { right: 14px; }

    .lb-info .btn {
        margin-bottom: 4px;
    }
}

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

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    [data-reveal] {
        opacity: 1;
        transform: none;
    }
}
