/* =============================================================
   Frederik Schulz — Lab Monochrome
   A Swiss/International-style system: pure black on white,
   strict 12-column grid, hairlines, big grotesque type,
   monospace metadata. Zero color by design.
   ============================================================= */

/* ===== Tokens ===== */
:root {
    --bg: #ffffff;
    --fg: #0a0a0a;
    --hair: rgba(10, 10, 10, 0.16);
    --hair-soft: rgba(10, 10, 10, 0.09);
    --guide: rgba(10, 10, 10, 0.035);
    --muted: rgba(10, 10, 10, 0.52);
    --dot: 10, 10, 10; /* canvas rgb */

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'Space Mono', 'Courier New', monospace;

    --maxw: 1280px;
    --gutter: clamp(1.25rem, 4vw, 3.5rem);

    --r1: 6rem;   /* section rhythm */
    --r2: 3rem;
    --r3: 1.5rem;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-snap: cubic-bezier(0.7, 0, 0.2, 1);
    --t: 0.55s;
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --fg: #fafafa;
    --hair: rgba(250, 250, 250, 0.18);
    --hair-soft: rgba(250, 250, 250, 0.1);
    --guide: rgba(250, 250, 250, 0.05);
    --muted: rgba(250, 250, 250, 0.52);
    --dot: 250, 250, 250;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--fg) var(--bg);
}

html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    color: var(--fg);
    background: var(--bg);
    overflow-x: hidden;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1; }
a { color: inherit; text-decoration: none; }
strong { font-weight: 500; }
sup { font-size: 0.4em; vertical-align: super; }

::selection { background: var(--fg); color: var(--bg); }

/* Hide native cursor only when custom cursor is active */
html.has-cursor, html.has-cursor a, html.has-cursor button { cursor: none; }

/* ===== Layout primitives ===== */
.container {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.section { padding: var(--r1) 0; position: relative; }

.section-grid {
    display: grid;
    grid-template-columns: 3fr 9fr;
    gap: clamp(2rem, 6vw, 6rem);
}

/* Shared mono micro-type */
.masthead-tag,
.sec-label, .sec-count, .nav-link, .margin-meta, .stat-label,
.tags li, .ix-meta, .ix-no, .role-no, .nav-clock, .theme-toggle,
.loader-label, .loader-count, .lk-no, .lk-host, .footer-colophon,
.footer-copy, .scroll-cue {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ===== Grid guides (faint 12-col background) ===== */
.grid-guides {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    display: flex;
    justify-content: center;
    opacity: 0;
    transition: opacity 1s var(--ease) 0.4s;
}
html.js .grid-guides.is-on { opacity: 1; }

.grid-guides .guide-inner {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 var(--gutter);
    display: grid;
    grid-template-columns: repeat(12, 1fr);
}
.grid-guides span { border-left: 1px solid var(--guide); }
.grid-guides span:last-child { border-right: 1px solid var(--guide); }

@media (max-width: 900px) { .grid-guides { display: none; } }

/* ===== Custom cursor ===== */
.cursor {
    position: fixed;
    top: 0; left: 0;
    width: 9px; height: 9px;
    border: 1px solid #fff;
    border-radius: 50%;
    background: transparent;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 300;
    mix-blend-mode: difference;
    display: none;
    transition: width 0.3s var(--ease), height 0.3s var(--ease),
                background 0.3s var(--ease);
}
.cursor.is-active { width: 9px; height: 9px; }
.cursor.is-hover { width: 44px; height: 44px; background: #fff; }

/* ===== Loader ===== */
.loader {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: var(--bg);
    display: none;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--gutter);
}
html.js .loader { display: flex; }

.loader-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    margin-bottom: var(--r3);
}
.loader-label { color: var(--muted); }
.loader-count { font-size: clamp(3rem, 12vw, 9rem); letter-spacing: -0.04em; }
.loader-bar { height: 1px; background: var(--hair); position: relative; }
.loader-bar-fill {
    position: absolute;
    inset: 0;
    background: var(--fg);
    transform: scaleX(0);
    transform-origin: left center;
}

/* ===== Navigation ===== */
.nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 200;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--hair);
    transition: background var(--t) var(--ease), border-color var(--t) var(--ease);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-mark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
}
.nav-mark-sub { color: var(--muted); font-weight: 400; }

.nav-links { display: flex; gap: clamp(0.5rem, 3vw, 2.25rem); }

.nav-link {
    position: relative;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--muted);
    padding: 0.5rem 0;
    display: inline-flex;
    align-items: baseline;
    gap: 0.4em;
    transition: color 0.3s var(--ease);
}
.nav-link-no { font-size: 0.5625rem; opacity: 0.6; }
.nav-link::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: right center;
    transition: transform 0.4s var(--ease-snap);
}
.nav-link:hover, .nav-link.is-active { color: var(--fg); }
.nav-link:hover::after, .nav-link.is-active::after {
    transform: scaleX(1);
    transform-origin: left center;
}

.nav-utility { display: flex; align-items: center; gap: 1.25rem; }
.nav-clock {
    font-size: 0.625rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.theme-toggle {
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--fg);
    background: none;
    border: 1px solid var(--hair);
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    transition: background 0.3s var(--ease), color 0.3s var(--ease),
                border-color 0.3s var(--ease);
}
.theme-toggle:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }

@media (max-width: 620px) {
    .nav-clock { display: none; }
    .nav-link-no { display: none; }
}

/* ===== Masthead ===== */
.masthead {
    position: relative;
    min-height: 100svh;
    display: flex;
    align-items: flex-end;
    padding: 7rem 0 var(--r2);
    overflow: hidden;
}

.dotfield {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.masthead-inner { position: relative; z-index: 1; width: 100%; }

.masthead-tag {
    display: flex;
    align-items: center;
    gap: 0.7em;
    font-size: 0.6875rem;
    color: var(--muted);
    margin-bottom: var(--r2);
}
.masthead-tag .tick {
    display: inline-block;
    font-size: 0.8em;
    color: var(--fg);
    animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.masthead-title {
    font-size: clamp(1.6rem, 7.75vw, 7rem);
    line-height: 0.86;
    letter-spacing: -0.045em;
    text-transform: uppercase;
}
.masthead-title .line { display: block; overflow: hidden; }
.masthead-title .line-in { display: block; will-change: transform; }
.masthead-rule {
    height: 1px;
    background: var(--fg);
    margin: var(--r2) 0;
    transform-origin: left center;
}

.masthead-deck {
    font-size: clamp(1.05rem, 2vw, 1.5rem);
    font-weight: 300;
    line-height: 1.45;
    max-width: 34ch;
}

.masthead-roles {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 2rem;
    margin-top: var(--r2);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.masthead-roles li { display: flex; align-items: baseline; gap: 0.6em; }
.role-no { color: var(--muted); font-size: 0.625rem; }

.masthead-foot {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-top: var(--r1);
    padding-top: var(--r3);
    border-top: 1px solid var(--hair);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.scroll-cue {
    color: var(--fg);
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    white-space: nowrap;
}

.foot-left { display: flex; flex-direction: column; gap: 0.45rem; }
.capsid-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    color: var(--muted);
    opacity: 0.9;
    transition: opacity 0.7s var(--ease);
}
.capsid-hint.is-hidden { opacity: 0; }
@media (hover: none) { .capsid-hint { display: none; } }
.scroll-cue-arrow { animation: nudge 1.8s var(--ease) infinite; }
@keyframes nudge { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* ===== Section heads / margins ===== */
.sec-no {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--muted);
    letter-spacing: 0.05em;
}
.sec-label {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3vw, 2.25rem);
    font-weight: 700;
    text-transform: none;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.col-margin { position: relative; }
.col-margin .sec-no { margin-bottom: 0.75rem; }
.col-margin .sec-label { margin-bottom: var(--r3); display: block; }

.margin-meta {
    list-style: none;
    font-size: 0.625rem;
    color: var(--muted);
    line-height: 2;
}
.margin-meta li { border-top: 1px solid var(--hair-soft); padding-top: 0.3rem; }

@media (min-width: 901px) {
    .col-margin { position: sticky; top: 90px; align-self: start; }
}

/* ===== Profile ===== */
.bio p {
    font-size: clamp(1.15rem, 2.1vw, 1.6rem);
    font-weight: 300;
    line-height: 1.5;
    margin-bottom: var(--r3);
    max-width: 40ch;
}
.bio p:last-child { margin-bottom: 0; }
.bio strong { font-weight: 500; }

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: var(--r1) 0 var(--r2);
    border-top: 1px solid var(--hair);
    padding-top: var(--r3);
}
.stat-label {
    font-size: 0.625rem;
    color: var(--muted);
    display: block;
    margin-bottom: 0.5rem;
}
.stat-value {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 0.9;
}
.stat-plus { color: var(--muted); }

.tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tags li {
    font-size: 0.625rem;
    color: var(--fg);
    border: 1px solid var(--hair);
    padding: 0.5rem 0.85rem;
    transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.tags li:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ===== Selected Work — numbered index ===== */
.section-head {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding-bottom: var(--r3);
    margin-bottom: var(--r2);
    border-bottom: 1px solid var(--fg);
}
.section-head .sec-no { font-size: 0.8rem; }
.section-head .sec-count { margin-left: auto; font-size: 0.625rem; color: var(--muted); }

.index-list { list-style: none; }

.index-link {
    display: grid;
    grid-template-columns: 3rem 1fr auto 1.5rem;
    align-items: start;
    gap: clamp(1rem, 3vw, 2.5rem);
    padding: clamp(1.1rem, 2.4vw, 1.9rem) 0;
    border-top: 1px solid var(--hair);
    position: relative;
}
.index-item:last-child .index-link { border-bottom: 1px solid var(--hair); }

/* Sliding invert fill */
.index-link::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--gutter));
    right: calc(-1 * var(--gutter));
    top: 0; bottom: 0;
    background: var(--fg);
    transform: scaleY(0);
    transform-origin: bottom center;
    transition: transform 0.45s var(--ease-snap);
    z-index: 0;
}
.index-link > * { position: relative; z-index: 1; transition: color 0.35s var(--ease); }

.ix-no {
    font-size: 0.8rem;
    color: var(--muted);
    padding-top: 0.4em;
}
.ix-body { min-width: 0; }
.ix-title {
    display: block;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.15rem, 2.6vw, 1.9rem);
    line-height: 1.12;
    letter-spacing: -0.015em;
}
.ix-desc {
    display: block;
    font-size: 0.9rem;
    font-weight: 300;
    line-height: 1.5;
    color: var(--muted);
    max-width: 52ch;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.5s var(--ease), opacity 0.4s var(--ease), margin 0.5s var(--ease);
}
.ix-meta {
    text-align: right;
    font-size: 0.625rem;
    line-height: 1.7;
    color: var(--muted);
    white-space: nowrap;
}
.ix-venue { display: block; color: var(--fg); }
.ix-year { display: block; }
.ix-type { display: block; }
.ix-arrow {
    font-size: 1rem;
    padding-top: 0.2em;
    transition: transform 0.4s var(--ease-snap), color 0.35s var(--ease);
}

/* Hover / focus invert */
.index-link:hover::before,
.index-link:focus-visible::before { transform: scaleY(1); transform-origin: top center; }
.index-link:hover > *,
.index-link:focus-visible > * { color: var(--bg); }
.index-link:hover .ix-no,
.index-link:hover .ix-meta,
.index-link:hover .ix-desc { color: rgba(255, 255, 255, 0.62); }
[data-theme="dark"] .index-link:hover .ix-no,
[data-theme="dark"] .index-link:hover .ix-meta,
[data-theme="dark"] .index-link:hover .ix-desc { color: rgba(10, 10, 10, 0.6); }
.index-link:hover .ix-venue { color: var(--bg); }
.index-link:hover .ix-desc,
.index-link:focus-visible .ix-desc { max-height: 6rem; opacity: 1; margin-top: 0.6rem; }
.index-link:hover .ix-arrow { transform: translate(4px, -4px); }

/* ===== Connect ===== */
.connect { border-top: 1px solid var(--hair); }

.big-email {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.9rem, 7vw, 5rem);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: var(--r1);
    position: relative;
    word-break: break-word;
}
.big-email-text { background-image: linear-gradient(var(--fg), var(--fg)); background-size: 0% 1px; background-position: 0 100%; background-repeat: no-repeat; transition: background-size 0.5s var(--ease-snap); padding-bottom: 0.08em; }
.big-email:hover .big-email-text { background-size: 100% 1px; }

.link-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border-top: 1px solid var(--hair);
}
.link-grid li { border-bottom: 1px solid var(--hair); }
.link-grid li:nth-child(odd) { border-right: 1px solid var(--hair); }
.link-grid a {
    display: flex;
    align-items: baseline;
    gap: 0.9rem;
    padding: 1.15rem 1.1rem;
    position: relative;
    overflow: hidden;
}
.link-grid a::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--fg);
    transform: translateY(101%);
    transition: transform 0.45s var(--ease-snap);
    z-index: 0;
}
.link-grid a:hover::before { transform: translateY(0); }
.link-grid a > * { position: relative; z-index: 1; transition: color 0.35s var(--ease); }
.link-grid a:hover > * { color: var(--bg); }
.lk-no { font-size: 0.625rem; color: var(--muted); }
.lk-name { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; letter-spacing: -0.01em; }
.lk-host { margin-left: auto; font-size: 0.625rem; color: var(--muted); }

/* ===== Footer ===== */
.footer {
    border-top: 1px solid var(--hair);
    padding: var(--r3) 0;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.footer-mark { font-family: var(--font-display); font-weight: 700; color: var(--fg); letter-spacing: -0.01em; }

/* ===== Reveal states (only when JS + motion allowed) =====
   Note: the masked headline (.line-in) is hidden by GSAP fromTo, not CSS.
   A CSS translateY(%) start poisons GSAP's px/percent transform parsing,
   which would leave the headline stuck inside its mask. px-based starts
   (rise / scaleX) round-trip fine, so those stay in CSS. */
@media (prefers-reduced-motion: no-preference) {
    html.js [data-reveal="rise"] { opacity: 0; transform: translateY(26px); }
    html.js [data-reveal="line"] { transform: scaleX(0); }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    :root { --r1: 4.5rem; }
    .section-grid { grid-template-columns: 1fr; gap: 2rem; }
    .col-margin { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
    .col-margin .sec-label { margin-bottom: 0; }
    .margin-meta { display: none; }
    .masthead-deck { max-width: none; }
}

@media (max-width: 680px) {
    .index-link {
        grid-template-columns: 2rem 1fr;
        gap: 0.4rem 1rem;
    }
    .ix-arrow { display: none; }
    .ix-meta { grid-column: 2; text-align: left; margin-top: 0.5rem; }
    .ix-venue, .ix-year, .ix-type { display: inline; }
    .ix-year::before, .ix-type::before { content: '\00b7'; margin: 0 0.4em; }
    /* On touch, always show description */
    .ix-desc { max-height: 6rem; opacity: 1; margin-top: 0.5rem; }
    .stats { grid-template-columns: 1fr; gap: 1.25rem; }
    .link-grid { grid-template-columns: 1fr; }
    .link-grid li:nth-child(odd) { border-right: none; }
    .lk-host { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .masthead-tag .tick, .scroll-cue-arrow { animation: none; }
    * { scroll-behavior: auto !important; }
}
