/* ═══════════════════════════════════════════════
   M.S. TAVELLA — Swiss-editorial personal site
   Fraunces (display, serif) · JetBrains Mono (UI)
   Palette: paper / ink / oxblood accent
   Dark is the default; [data-theme="light"] opts in to paper.
   ═══════════════════════════════════════════════ */

/* Self-hosted Google Fonts, latin subset only (SIL OFL 1.1). */
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 300 600;
  font-display: swap;
  src: url(fonts/Fraunces-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url(fonts/Fraunces-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/JetBrainsMono-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/JetBrainsMono-numero.woff2) format('woff2');
  unicode-range: U+2116; /* № only */
}

:root {
    /* dark — "ink stock": warm near-black paper, bone-white ink */
    --paper:       #0E0E0D;
    --paper-2:     #181816;
    --ink:         #EDEBE4;
    --ink-80:      #CFCDC5;
    --ink-60:      #A9A79F;   /* secondary text   — 7.9:1 */
    --ink-30:      #85837C;   /* tertiary labels  — 5.1:1 (AA) */
    --ink-10:      #2A2A27;   /* hairlines (decorative only, never text) */
    --ink-05:      #1F1F1D;
    --accent:      #E0574E;   /* oxblood, lifted for dark ground */
    --accent-50:   rgba(224, 87, 78, 0.5);
    --grain-blend: screen;
    --grain-alpha: 0.05;
    --grid-line:   rgba(237, 235, 228, 0.045);
    color-scheme: dark;

    --grid-gap:    clamp(16px, 4vw, 48px);
    --maxw:        1180px;
    --masthead-h:  68px;

    /* type scale — mono labels sit on the three small steps, serif on the rest */
    --fs-micro:    0.625rem;                       /* 10px  mono caps labels   */
    --fs-xs:       0.6875rem;                      /* 11px  mono metadata      */
    --fs-sm:       0.75rem;                        /* 12px  mono UI / buttons  */
    --fs-small:    0.9375rem;                      /* 15px  serif secondary    */
    --fs-body:     1rem;                           /* 16px  serif body         */
    --fs-lead:     clamp(1.05rem, 1.5vw, 1.15rem); /* bio / ledes              */
    --fs-h3:       clamp(1.2rem, 2vw, 1.5rem);     /* paper titles             */
    --fs-h2:       clamp(2rem, 4vw, 3rem);         /* project titles           */
    --fs-display:  clamp(2.4rem, 5.5vw, 4.4rem);   /* name                     */
    --fs-hero:     clamp(4.5rem, 16vw, 11rem);     /* "Write."                 */

    /* spacing scale (4px base) */
    --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
    --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;
    --section-gap: clamp(var(--s-6), 6vh, var(--s-8));

    --ease:        cubic-bezier(.2,.7,.3,1);

    --serif:       'Fraunces', 'EB Garamond', Georgia, serif;
    --mono:        'JetBrains Mono', 'SF Mono', Menlo, monospace;
    --sans:        'Inter Tight', -apple-system, BlinkMacSystemFont, sans-serif;
}

:root[data-theme="light"] {
    --paper:       #FAFAF7;   /* warm off-white stock */
    --paper-2:     #F3F2EC;   /* slightly darker, for hairlines */
    --ink:         #111110;   /* near-black, slightly warm */
    --ink-80:      #2A2A26;
    --ink-60:      #55554F;   /* secondary text   — 7.4:1 */
    --ink-30:      #6F6F69;   /* tertiary labels  — 4.8:1 (AA) */
    --ink-10:      #E4E3DC;   /* hairlines */
    --ink-05:      #EFEDE6;
    --accent:      #B4302A;   /* oxblood */
    --accent-50:   rgba(180, 48, 42, 0.5);
    --grain-blend: multiply;
    --grain-alpha: 0.045;
    --grid-line:   rgba(17, 17, 16, 0.05);
    color-scheme: light;
}

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

html { scroll-behavior: smooth; }

html, body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

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

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

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

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* skip link: hidden until focused */
.skip-link {
    position: fixed;
    top: var(--s-2);
    left: var(--s-2);
    z-index: 10000;
    padding: var(--s-2) var(--s-4);
    font-family: var(--mono);
    font-size: var(--fs-sm);
    background: var(--ink);
    color: var(--paper);
    transform: translateY(-200%);
    transition: transform 0.2s var(--ease);
}
.skip-link:focus { transform: none; color: var(--paper); }
.stage:focus { outline: none; }

/* theme switch: cross-fade colours only while toggling */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, fill 0.4s ease !important;
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ═════════════════ Paper grain overlay ═════════════════ */
.grain {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: var(--grain-alpha);
    mix-blend-mode: var(--grain-blend);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 220px 220px;
}

/* ═════════════════ Hairline grid guide ═════════════════ */
.grid-guide {
    position: fixed;
    inset: 0 var(--grid-gap);
    z-index: 0;
    pointer-events: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
}
.grid-guide span {
    border-right: 1px solid var(--grid-line);
    height: 100vh;
}
/* text blocks carry the page colour so the guides stop around them */
.section-label > span:not(.sl-rule), .display-name, .typed, .role-line, .cv-group, .rail-block, .entry-r,
.feature-lede, .feature-meta, .feature-title, .ar-desc, .write-block {
    background-color: var(--paper);
}
.grid-guide span:last-child { border-right: none; }

/* ═════════════════ MASTHEAD ═════════════════ */
.masthead {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--paper);
    height: var(--masthead-h);
    transition: transform 0.4s ease, background-color 0.35s ease;
}

.masthead-row {
    max-width: var(--maxw);
    margin: 0 auto;
    height: 100%;
    padding: 0 var(--grid-gap);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--grid-gap);
}

.wordmark {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-family: var(--serif);
}

.wm-name {
    font-size: 1.05rem;
    font-style: italic;
    font-weight: 500;
    letter-spacing: -0.01em;
}

/* nav */
.nav {
    position: relative;
    display: flex;
    align-items: stretch;
    justify-self: center;
    padding: 6px 0;
}

.nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 14px 8px;
    color: var(--ink-60);
    transition: color 0.25s ease;
    position: relative;
    z-index: 2;
}
.nav-link:hover { color: var(--ink); }
.nav-link::after {
    content: '';
    position: absolute;
    left: 50%; bottom: 2px;
    width: 24px; height: 1px;
    background: var(--ink-30);
    transform: translateX(-50%) scaleX(0);
    transition: transform 0.3s var(--ease);
}
.nav-link:not(.is-active):hover::after { transform: translateX(-50%) scaleX(1); }
.nav-link.is-active { color: var(--ink); }

/* active-tab dot (replaces the old 01–04 indices; keeps the two-line rhythm) */
.nav-idx {
    font-size: 6px;
    line-height: 10px;
    color: var(--accent);
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.25s ease, transform 0.3s var(--ease);
}
.nav-link.is-active .nav-idx { opacity: 1; transform: none; }
.nav-label {
    font-family: var(--mono);
    font-size: var(--fs-sm);
    font-weight: 500;
    letter-spacing: 0.02em;
    margin-top: 1px;
}

/* sliding marker */
.nav-marker {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    transition: transform 0.42s cubic-bezier(.5,.05,.2,1), width 0.42s cubic-bezier(.5,.05,.2,1);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.nav-marker .nav-marker-tab {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--accent);
    margin-bottom: 2px;
    animation: tabIn 0.45s var(--ease) both;
}
@keyframes tabIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* theme toggle */
.theme-toggle {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 7px;
    font-family: var(--mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.06em;
    color: var(--ink-60);
    border: 1px solid var(--ink-10);
    transition: color 0.25s ease, border-color 0.25s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.tt-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid currentColor;
    /* half-filled disc: shows the *other* mode */
    background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}


.masthead-rule {
    height: 1px;
    background: var(--ink);
    width: 100%;
    transform: scaleY(0.5);
    transform-origin: center;
    opacity: 0.85;
}

/* ═════════════════ STAGE / VIEWS ═════════════════ */
.stage {
    margin-top: var(--masthead-h);
    margin-bottom: 34px;
    min-height: calc(100vh - var(--masthead-h) - 34px);
    position: relative;
    z-index: 1;
}

.view {
    display: none;
    min-height: calc(100vh - var(--masthead-h));
    padding-bottom: 4rem;
}
.view.is-active { display: block; }

.view-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: clamp(48px, 7vh, 96px) var(--grid-gap) 0;
    animation: viewIn 0.5s cubic-bezier(.2,.7,.3,1) both;
}

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

/* section label */
.section-label {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: clamp(36px, 6vh, 80px);
    font-family: var(--mono);
    font-size: var(--fs-sm);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: var(--ink-60);
    font-weight: 400;
    animation: viewIn 0.55s 0.05s var(--ease) both;
}
.sl-num { color: var(--accent); font-size: 8px; line-height: 1; }
.sl-rule { width: 64px; height: 1px; background: var(--ink); }
.sl-name { color: var(--ink); font-weight: 600; }
.sl-tail { color: var(--ink-30); margin-left: 4px; }

/* ═════════════════ 01 — ABOUT ═════════════════ */
.view[data-view="home"] {
    min-height: calc(100vh - var(--masthead-h) - 34px) !important;
    display: none !important;
    padding-bottom: 3rem !important;
}
.view[data-view="home"].is-active {
    display: grid !important;
    place-items: center;
}
.view[data-view="home"] > .view-inner {
    width: 100%;
    padding-top: clamp(32px, 5vh, 64px) !important;
    padding-bottom: 0 !important;
}

.view[data-view="home"] .section-label {
    margin-bottom: clamp(20px, 3vh, 32px);
    animation: viewIn 0.55s 0.05s cubic-bezier(.2,.7,.3,1) both;
}

.view[data-view="home"] .about-grid {
    align-items: center;
    gap: clamp(28px, 4vw, 64px);
}

.view[data-view="home"] .display-name {
    font-size: var(--fs-display);
    line-height: 0.92;
    margin-bottom: 1rem;
}

.view[data-view="home"] .role-line {
    margin-bottom: 1.4rem;
}

.view[data-view="home"] .typed {
    font-size: var(--fs-lead);
    line-height: 1.5;
    margin-bottom: 1.4rem;
    min-height: 5em;
    max-width: 52ch;
}

.view[data-view="home"] .social-row {
    padding-top: 1rem;
}

.about-grid {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: clamp(36px, 6vw, 96px);
    align-items: center;
}

.portrait {
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
}
.portrait-frame {
    position: relative;
    background: var(--paper-2);
    aspect-ratio: 4 / 5;
    overflow: hidden;
}
.portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%) contrast(1.04);
    image-rendering: pixelated;   /* keep the pixel-art edges crisp when scaled */
    transition: transform 0.8s ease, filter 0.6s ease;
}
.portrait-frame:hover .portrait-img {
    filter: grayscale(85%) contrast(1.06);
    transform: scale(1.012);
}

/* crop marks */
.crop {
    position: absolute;
    width: 14px;
    height: 14px;
    pointer-events: none;
}
.crop::before, .crop::after {
    content: '';
    position: absolute;
    background: var(--ink);
}
.crop::before { width: 14px; height: 1px; }
.crop::after  { width: 1px; height: 14px; }
.crop.tl { top: -1px; left: -1px; }
.crop.tl::before { top: 0; left: 0; }
.crop.tl::after  { top: 0; left: 0; }
.crop.tr { top: -1px; right: -1px; }
.crop.tr::before { top: 0; right: 0; }
.crop.tr::after  { top: 0; right: 0; }
.crop.bl { bottom: -1px; left: -1px; }
.crop.bl::before { bottom: 0; left: 0; }
.crop.bl::after  { bottom: 0; left: 0; }
.crop.br { bottom: -1px; right: -1px; }
.crop.br::before { bottom: 0; right: 0; }
.crop.br::after  { bottom: 0; right: 0; }

.portrait-caption {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 10px;
    font-family: var(--mono);
    font-size: var(--fs-micro);
    letter-spacing: 0.08em;
    color: var(--ink-30);
    text-transform: uppercase;
}
.pc-ref { color: var(--ink); font-weight: 600; }
.pc-name { color: var(--ink-60); }
.pc-meta { margin-left: auto; }

/* bio */
.bio-col { padding-top: 4px; }

.display-name {
    font-family: var(--serif);
    font-weight: 300;
    font-size: clamp(3.2rem, 8vw, 6rem);
    line-height: 0.94;
    letter-spacing: -0.025em;
    color: var(--ink);
    font-variation-settings: "opsz" 144;
    margin-bottom: 1.4rem;
    animation: viewIn 0.7s 0.15s cubic-bezier(.2,.7,.3,1) both;
}
.display-name em {
    font-style: italic;
    font-weight: 400;
    color: var(--ink);
}

.role-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    font-family: var(--mono);
    font-size: var(--fs-sm);
    letter-spacing: 0.04em;
    color: var(--ink);
    margin-bottom: 2.4rem;
    animation: viewIn 0.7s 0.25s cubic-bezier(.2,.7,.3,1) both;
}
.rl-tag {
    color: var(--paper);
    background: var(--ink);
    padding: 3px 8px 4px;
    letter-spacing: 0.08em;
    font-weight: 600;
    font-size: var(--fs-xs);
}
.rl-sep { color: var(--ink-30); }

/* typed bio */
.typed {
    font-family: var(--serif);
    font-size: clamp(1.15rem, 2vw, 1.45rem);
    line-height: 1.55;
    color: var(--ink-80);
    font-weight: 400;
    max-width: 56ch;
    margin-bottom: 2.4rem;
    min-height: 6em;
    font-variation-settings: "opsz" 36;
}
.tline {
    margin-bottom: 0.5rem;
    text-wrap: pretty;
}
.hello {
    font-style: italic;
    color: var(--accent);
    font-weight: 500;
}

.typed a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--accent-50);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.25s ease;
}
.typed a:hover { color: var(--ink); text-decoration-color: var(--accent); }


/* social row — icon links */
.social-row {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding-top: 1.2rem;
    border-top: 1px solid var(--ink-10);
}
.social-row li a {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: var(--ink-60);
    transition: color 0.25s ease, transform 0.25s ease;
}
.social-row li a svg { width: 22px; height: 22px; }
.social-row:not(.contact-icons) li:first-child a { margin-left: -9px; }
.social-row li a:hover { color: var(--accent); transform: translateY(-2px); }


/* CV — now / before / education */
.cv {
    margin-top: clamp(40px, 6vh, 72px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(24px, 3vw, 48px);
}
.cv-head {
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--ink);
    font-family: var(--mono);
    font-size: var(--fs-micro);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
}
.cv-list { list-style: none; }
.cv-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: baseline;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--ink-10);
}
.cv-what {
    font-family: var(--serif);
    font-size: var(--fs-small);
    line-height: 1.35;
    color: var(--ink);
    font-variation-settings: "opsz" 24;
}
.cv-dot { color: var(--ink-30); }
.cv-org { color: var(--ink-60); }
a.cv-org {
    text-decoration: underline;
    text-decoration-color: var(--ink-10);
    text-underline-offset: 3px;
    transition: color 0.25s ease, text-decoration-color 0.25s ease;
}
a.cv-org:hover { color: var(--accent); text-decoration-color: var(--accent-50); }
.cv-when {
    font-family: var(--mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.04em;
    color: var(--ink-60);
    white-space: nowrap;
}

/* about, wide screens: portrait | name + bio | CV in one viewport, no scrolling */
@media (min-width: 981px) {
    .view[data-view="home"] { padding-bottom: var(--s-4) !important; }
    .view[data-view="home"] > .view-inner { padding-top: var(--s-4) !important; }
    .view[data-view="home"] .section-label { margin-bottom: var(--s-4); }

    .about-layout {
        display: grid;
        grid-template-columns: minmax(130px, 1.5fr) 4.6fr 4.4fr;
        column-gap: clamp(28px, 3vw, 56px);
        align-items: start;
    }
    .about-layout .about-grid { display: contents; }
    .view[data-view="home"] .portrait { max-width: 220px; margin: 0; }
    .view[data-view="home"] .display-name {
        font-size: clamp(2.2rem, 3.8vw, 3.4rem);
        margin-bottom: var(--s-3);
    }
    .view[data-view="home"] .role-line {
        gap: 6px;
        letter-spacing: 0.02em;
        margin-bottom: var(--s-4);
    }
    .view[data-view="home"] .typed {
        font-size: clamp(0.94rem, 1.1vw, 1.05rem);
        line-height: 1.5;
        min-height: 0;
        margin-bottom: var(--s-3);
    }
    .view[data-view="home"] .tline { margin-bottom: var(--s-2); }
    .view[data-view="home"] .social-row { padding-top: var(--s-2); }

    .about-layout .cv {
        margin-top: 0;
        grid-template-columns: 1fr;
        gap: var(--s-4);
        padding-top: 4px;
    }
    .about-layout .cv-head { padding-bottom: var(--s-2); }
    .about-layout .cv-row { padding: 7px 0; gap: var(--s-3); }
    .about-layout .cv-what { font-size: 0.875rem; line-height: 1.3; }
    .about-layout .cv-when { font-size: var(--fs-micro); }
}

/* ── shared desktop rhythm: every view fits one screen, three columns ── */
@media (min-width: 981px) {
    .view > .view-inner { padding-top: var(--s-4); }
    .view .section-label { margin-bottom: var(--s-4); }
    .view:not([data-view="home"]) { padding-bottom: var(--s-4); }
}

/* ═════════════════ 02 — RESEARCH ═════════════════ */
.research-grid {
    display: grid;
    grid-template-columns: 3fr 9fr;
    gap: clamp(36px, 5vw, 80px);
    align-items: start;
}

.research-rail {
    position: sticky;
    top: calc(var(--masthead-h) + 32px);
    font-family: var(--mono);
    padding-right: 1rem;
    border-right: 1px solid var(--ink-10);
}
.rail-block {
    margin-bottom: 2rem;
}
.rail-key {
    font-size: var(--fs-micro);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-30);
    display: block;
    margin-bottom: 8px;
}
.rail-val {
    font-family: var(--serif);
    font-size: var(--fs-small);
    line-height: 1.45;
    color: var(--ink-80);
    font-style: italic;
}
.rail-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-xs);
    color: var(--ink);
    letter-spacing: 0.04em;
    border-top: 1px solid var(--ink-10);
    padding-top: 1.2rem;
    transition: color 0.25s ease;
}
.rail-link:hover { color: var(--accent); }
.rl-icon { color: var(--accent); }

.research-body { min-width: 0; }

.entry-group { margin-bottom: 3rem; }
.group-title {
    font-family: var(--mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-30);
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--ink);
}

.entry {
    display: grid;
    grid-template-columns: 130px 1fr auto;
    gap: 24px;
    padding: 1.4rem 0;
    border-bottom: 1px solid var(--ink-10);
    cursor: pointer;
    transition: background 0.25s ease;
    align-items: start;
}
.entry:hover { color: inherit; }
.entry:hover, .entry:focus-visible {
    background: linear-gradient(to right, var(--paper-2) 0%, transparent 80%);
}
.entry:hover .entry-title, .entry:focus-visible .entry-title { color: var(--accent); }
.entry:hover .entry-goto, .entry:focus-visible .entry-goto {
    color: var(--accent);
    transform: translate(3px, -3px);
}

.entry-l {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--mono);
    font-size: var(--fs-xs);
    color: var(--ink-30);
    letter-spacing: 0.04em;
}
.entry-year { color: var(--ink); font-weight: 600; font-size: var(--fs-sm); }
.entry-cite { color: var(--ink-30); }
.entry-cite.status {
    color: var(--accent);
    border: 1px solid var(--accent-50);
    padding: 1px 6px 2px;
    width: fit-content;
    margin-top: 2px;
    letter-spacing: 0.08em;
    font-size: var(--fs-micro);
}

.entry-r { min-width: 0; }
.entry-title {
    font-family: var(--serif);
    font-size: var(--fs-h3);
    font-weight: 500;
    line-height: 1.2;
    color: var(--ink);
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
    font-variation-settings: "opsz" 48;
    transition: color 0.3s ease;
}
.entry-title::after {
    content: '';
    display: block;
    height: 1px;
    width: 0;
    background: var(--accent);
    margin-top: 0.4rem;
    transition: width 0.32s cubic-bezier(.4,.05,.2,1);
}
.entry:hover .entry-title::after, .entry:focus-visible .entry-title::after { width: 80px; }

.entry-authors {
    font-family: var(--serif);
    font-size: var(--fs-small);
    color: var(--ink-60);
    margin-bottom: 0.25rem;
}
.entry-authors em { color: var(--ink); font-style: italic; font-weight: 500; }
.entry-venue {
    font-family: var(--mono);
    font-size: var(--fs-xs);
    color: var(--ink-30);
    letter-spacing: 0.04em;
    font-style: normal;
}

.entry-goto {
    font-family: var(--mono);
    font-size: 1.1rem;
    color: var(--ink-30);
    align-self: center;
    transition: transform 0.32s ease, color 0.25s ease;
}

/* research, wide screens: domains | papers | patents */
@media (min-width: 981px) {
    .research-grid {
        grid-template-columns: minmax(130px, 1.5fr) 4.6fr 4.4fr;
        column-gap: clamp(28px, 3vw, 56px);
    }
    .research-body { display: contents; }
    .research-rail { position: static; padding-right: var(--s-4); }
    .rail-val { font-size: var(--fs-small); }
    .rail-link { display: block; line-height: 1.5; }
    .rl-icon { margin-right: 6px; }
    .entry-group { margin-bottom: 0; }
    .group-title {
        color: var(--ink);
        font-weight: 600;
        font-size: var(--fs-micro);
        margin-bottom: 0;
        padding-bottom: var(--s-2);
    }
    .entry {
        grid-template-columns: 1fr auto;
        grid-template-areas: "meta goto" "body body";
        column-gap: var(--s-3);
        row-gap: var(--s-1);
        padding: var(--s-3) 0;
    }
    .entry-l { grid-area: meta; flex-direction: row; align-items: baseline; gap: var(--s-3); }
    .entry-r { grid-area: body; }
    .entry-goto { grid-area: goto; align-self: start; font-size: var(--fs-sm); }
    .entry-cite.status { margin-top: 0; }
    .entry-title {
        font-size: clamp(0.98rem, 1.25vw, 1.15rem);
        line-height: 1.25;
        margin-bottom: var(--s-1);
    }
    .entry-title::after { display: none; }
    .entry-authors { font-size: 0.8125rem; margin-bottom: 2px; }
}

/* ═════════════════ 03 — PROJECTS ═════════════════ */
.featured {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: clamp(28px, 4vw, 56px);
    margin-bottom: var(--s-8);
}

/* both cards share the parent's row tracks (subgrid), so tag / title / lede /
   meta / CTAs line up across columns regardless of copy length */
.feature {
    border-top: 1px solid var(--ink);
    padding-top: var(--s-5);
    display: grid;
    grid-row: span 5;
    grid-template-rows: subgrid;
    row-gap: var(--s-4);
    align-content: start;
}
.feature-meta { align-self: start; }
.feature-links { align-self: end; }
.feature-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-30);
}
.ft-no { color: var(--ink); font-weight: 600; }
.ft-pill {
    color: var(--paper);
    background: var(--accent);
    padding: 3px 10px 4px;
    letter-spacing: 0.1em;
    font-weight: 600;
    font-size: var(--fs-micro);
}
.ft-pill.ghost {
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--ink-10);
}

.feature-title {
    font-family: var(--serif);
    font-weight: 400;
    font-size: var(--fs-h2);
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-variation-settings: "opsz" 96;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
}
.feature-title em {
    font-style: italic;
    font-weight: 500;
    color: var(--ink);
}
.feature-sub {
    font-family: var(--mono);
    font-size: var(--fs-sm);
    font-style: normal;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--ink-60);
}
.feature-lede {
    font-family: var(--serif);
    font-size: var(--fs-lead);
    line-height: 1.5;
    color: var(--ink-80);
    font-variation-settings: "opsz" 24;
    max-width: 46ch;
}
.feature-lede a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--accent-50);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.25s ease;
}
.feature-lede a:hover { text-decoration-color: var(--accent); color: var(--ink); }

.feature-meta {
    border-top: 1px solid var(--ink-10);
    padding-top: 1rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.fm-row {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 12px;
    align-items: baseline;
    font-family: var(--mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.02em;
}
.fm-row dt {
    color: var(--ink-30);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: var(--fs-micro);
    font-weight: 500;
}
.fm-row dd { color: var(--ink-80); }

.feature-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: var(--s-2);
}
.flink {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: var(--fs-sm);
    letter-spacing: 0.04em;
    color: var(--ink);
    padding: 8px 14px 9px;
    border: 1px solid var(--ink-10);
    background: var(--paper);
    transition: all 0.28s ease;
}
.flink:hover {
    border-color: var(--ink);
    color: var(--ink);
}
.flink.primary {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}
.flink.primary:hover { background: var(--accent); border-color: var(--accent); }
.flink .arrow { color: inherit; transition: transform 0.28s ease; }
.flink:hover .arrow { transform: translateX(4px); }
.flink.star {
    background: transparent;
    color: var(--ink-60);
}
.flink.star:hover { color: var(--ink); }

/* reveal animation */
[data-reveal] {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.7s cubic-bezier(.2,.7,.3,1), transform 0.7s cubic-bezier(.2,.7,.3,1);
}
[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* archive */
.archive {
    border-top: 1px solid var(--ink);
    padding-top: 1.2rem;
}
.archive-head {
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-30);
    margin-bottom: 0.8rem;
}
.ah-label { color: var(--ink); font-weight: 600; }

.arch-row {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 24px;
    align-items: baseline;
    padding: 1rem 0;
    border-bottom: 1px solid var(--ink-10);
    font-family: var(--mono);
    color: var(--ink-80);
    transition: background 0.25s ease, color 0.25s ease;
}
.arch-row:hover, .arch-row:focus-visible {
    background: var(--paper-2);
    color: var(--ink);
}
.arch-row:hover .ar-name, .arch-row:focus-visible .ar-name { color: var(--accent); }
.arch-row:hover .ar-goto, .arch-row:focus-visible .ar-goto { color: var(--accent); transform: translate(3px, -3px); }
.arch-row { grid-template-areas: "name desc goto"; }
.ar-name { grid-area: name; } .ar-desc { grid-area: desc; } .ar-goto { grid-area: goto; }

.ar-name {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--ink);
    transition: color 0.3s ease;
}
.ar-desc {
    font-size: var(--fs-sm);
    color: var(--ink-60);
    line-height: 1.4;
    font-family: var(--serif);
    letter-spacing: 0;
}
.ar-goto {
    font-size: 1rem;
    color: var(--ink-30);
    transition: transform 0.32s ease, color 0.25s ease;
}

/* projects, wide screens: aevum | cocotagger | also open-sourced */
@media (min-width: 981px) {
    .projects-layout {
        display: grid;
        grid-template-columns: 1fr 1fr 0.9fr;
        grid-template-rows: repeat(5, auto);
        column-gap: clamp(28px, 3vw, 56px);
        align-items: start;
    }
    .projects-layout .featured { display: contents; }
    .projects-layout .feature { grid-row: 1 / span 5; padding-top: var(--s-3); row-gap: var(--s-3); }
    .projects-layout .archive { grid-column: 3; grid-row: 1 / span 5; padding-top: var(--s-3); }

    .feature-title { font-size: clamp(1.6rem, 2.6vw, 2.2rem); flex-direction: column; align-items: flex-start; gap: var(--s-1); }
    .feature-lede { font-size: clamp(0.9rem, 1.05vw, 1rem); line-height: 1.45; }
    .feature-meta { padding-top: var(--s-3); gap: 6px; }
    .fm-row { grid-template-columns: 64px 1fr; font-size: var(--fs-micro); }
    .flink { padding: 6px 10px 7px; font-size: var(--fs-xs); }

    .archive-head { margin-bottom: 0; padding-bottom: var(--s-2); border-bottom: 1px solid var(--ink-10); }
    .arch-row {
        grid-template-columns: 1fr auto;
        grid-template-areas: "name goto" "desc desc";
        row-gap: 2px;
        padding: var(--s-3) 0;
    }
    .ar-name { font-size: 1rem; }
    .ar-desc { font-size: 0.8125rem; }
}

/* ═════════════════ 04 — CONTACT ═════════════════ */
/* fill the viewport and centre the composition between masthead and colophon */
.view[data-view="contact"].is-active {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--masthead-h) - 34px);
    padding-bottom: var(--s-7);
}
.contact-inner {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
}
.write-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: var(--s-6) 0;
}

.write {
    display: block;
    color: var(--ink);
    text-align: center;
}
.write-word {
    display: block;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 300;
    font-size: var(--fs-hero);
    line-height: 0.85;
    letter-spacing: -0.04em;
    color: var(--ink);
    font-variation-settings: "opsz" 144;
    transition: color 0.3s ease;
    padding-bottom: 0.08em; /* room for descender-less italic overhang */
}
.write-word em {
    color: var(--accent);
    font-style: italic;
    font-weight: 400;
    transition: color 0.3s ease;
}
.write:hover .write-word { color: var(--accent); }
.write:hover .write-word em { color: var(--ink); }

/* rule + email / icons row, set to the width of the hero word */
.write-foot {
    width: 100%;
    margin-top: var(--s-6);
    padding-top: var(--s-4);
    border-top: 1px solid var(--ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--s-4);
}
.email-copy {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}
.write-addr {
    font-family: var(--mono);
    font-size: var(--fs-sm);
    letter-spacing: 0.04em;
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--ink-10);
    text-underline-offset: 4px;
    transition: color 0.25s ease, text-decoration-color 0.25s ease;
}
.write-addr:hover { color: var(--accent); text-decoration-color: var(--accent-50); }
.copy-btn {
    font-family: var(--mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.06em;
    color: var(--ink-60);
    border: 1px solid var(--ink-10);
    padding: 4px 10px 5px;
    min-width: 8ch;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.copy-btn:hover { color: var(--ink); border-color: var(--ink); }
.copy-btn.is-done { color: var(--paper); background: var(--accent); border-color: var(--accent); }

.social-row.contact-icons { border-top: none; padding-top: 0; gap: var(--s-2); }
.social-row.contact-icons li:last-child a { margin-right: -9px; }

/* ═════════════════ COLOPHON ═════════════════ */
.colophon {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--paper);
    border-top: 1px solid var(--ink-10);
}
.colophon-row {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0.6rem var(--grid-gap);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-family: var(--mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.05em;
    color: var(--ink-30);
}
.c-left, .c-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.c-mark { color: var(--accent); font-weight: 600; }
.c-mid { color: var(--ink-30); }
.c-sep { color: var(--ink-30); }

/* ═════════════════ PAGE-LOAD ORCHESTRATION ═════════════════ */
.masthead { animation: mastIn 0.5s cubic-bezier(.2,.7,.3,1) both; }
@keyframes mastIn {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.colophon { animation: colIn 0.6s 0.3s cubic-bezier(.2,.7,.3,1) both; }
@keyframes colIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ═════════════════ RESPONSIVE ═════════════════ */
@media (max-width: 980px) {
    :root { --grid-gap: clamp(20px, 5vw, 32px); }

    .about-grid { grid-template-columns: 1fr; gap: 40px; }
    .research-grid { grid-template-columns: 1fr; }
    .research-rail { position: relative; top: 0; border-right: none; padding-right: 0; padding-bottom: 1.5rem; border-bottom: 1px solid var(--ink-10); margin-bottom: 1.5rem; }
    .featured { grid-template-columns: 1fr; row-gap: var(--s-7); }
    .feature { grid-row: auto; grid-template-rows: none; }
    .cv { grid-template-columns: 1fr 1fr; }
    .arch-row {
        grid-template-columns: 1fr auto;
        grid-template-areas: "name goto" "desc desc";
        column-gap: var(--s-4);
        row-gap: var(--s-1);
    }
}

@media (max-width: 720px) {
    .masthead-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 8px;
        padding-top: 12px;
        padding-bottom: 10px;
    }
    :root { --masthead-h: 112px; }

    .wordmark { justify-self: start; }
    .theme-toggle { grid-column: 2; grid-row: 1; padding: 4px 8px 5px; font-size: var(--fs-xs); }
    .nav {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
        justify-content: space-between;
        overflow-x: auto;
        scrollbar-width: none;
        padding: 6px 0 4px;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav-link { padding: 4px 8px 6px; }
    .nav-idx { font-size: var(--fs-micro); }
    .nav-label { font-size: var(--fs-xs); }

    .grid-guide { display: none; }

    .sl-num { white-space: nowrap; }
    .sl-rule { width: 32px; flex-shrink: 0; }
    .sl-tail { display: none; }

    .cv { grid-template-columns: 1fr; gap: 32px; }

    /* about: let content set the height so a long bio never slides under the masthead */
    .view[data-view="home"] {
        height: auto !important;
    }
    .view[data-view="home"].is-active {
        place-items: start stretch;
        padding-bottom: 3rem !important;
    }
    .view[data-view="home"] > .view-inner { padding-top: 32px !important; }

    /* mobile about: small portrait LEFT column, text RIGHT column */
    .view[data-view="home"] .about-grid {
        grid-template-columns: 96px 1fr;
        gap: 18px;
        align-items: start;
    }
    .view[data-view="home"] .portrait {
        max-width: 96px;
        width: 96px;
        margin: 0;
        float: none;
    }
    .view[data-view="home"] .portrait-frame { aspect-ratio: 4 / 5; }
    .view[data-view="home"] .portrait-caption { display: none; }
    .view[data-view="home"] .display-name {
        font-size: clamp(1.6rem, 8vw, 2.4rem);
        line-height: 0.92;
        margin-bottom: 0.6rem;
        overflow: hidden;
    }
    .view[data-view="home"] .role-line { margin-bottom: 0.8rem; font-size: var(--fs-xs); gap: 6px; }
    .view[data-view="home"] .typed {
        min-height: 0;
        font-size: 0.88rem;
        line-height: 1.45;
        margin-bottom: 0.8rem;
    }
    .view[data-view="home"] .social-row {
        padding-top: 0.6rem;
        clear: none;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .display-name { font-size: clamp(2.6rem, 16vw, 4rem); }

    .entry {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .entry-l { flex-direction: row; gap: 12px; }
    .entry-goto { display: none; }


    .colophon-row { justify-content: center; text-align: center; }
    .c-mid { display: none; }
}

@media (max-width: 480px) {
    .view-inner { padding-top: 36px; }
    .display-name em { display: inline; }
    .write-word { font-size: clamp(4rem, 26vw, 7rem); }
    .write-foot { flex-direction: column; align-items: center; }
}


/* ═════════════════ REDUCED MOTION ═════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
    [data-reveal] { opacity: 1; transform: none; }
}
