/* Nathan Ribeiro — portfolio
   Type scale and rhythm follow the reference: bold names, grey meta, a very large serif year range
   with tight tracking. On desktop everything scales with the viewport, as on the reference
   (measured there at 1440px: 32px gutter, 16px text, 409px sidebar, year range spanning the column);
   phones keep their own fixed sizes at the bottom of this file. */

:root {
  --ground: #FBFBFA;
  --ink: #111110;
  --grey: #6B6B68;
  --rule: #D9D8D4;
  --tone: #E9E4DC;
  --dark: #1C1C1A;
  --dark-rule: #3A3A37;
  --dark-grey: #B7B6B1;
  --sans: 'Schibsted Grotesk', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --gutter: clamp(16px, 2.2vw, 48px);
}

* { box-sizing: border-box; }
html { background: var(--ground); }
body {
  margin: 0;
  background: transparent; /* html paints the page colour, so the figure canvas can sit behind the content */
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(13px, 1.11vw, 21px);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--grey); }
p { margin: 0; text-wrap: pretty; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
.muted { color: var(--grey); }
.strong { font-weight: 600; }
.icon { width: 1.15em; height: 1.15em; flex: 0 0 auto; }
.icon-sm { width: .85em; height: .85em; }

/* Page frame: left column + main */
.page {
  min-height: 100vh;
  padding: var(--gutter) var(--gutter) 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 32px clamp(24px, 1.95vw, 44px);
  align-items: stretch;
}
.aside {
  flex: 0 0 clamp(280px, 28.4vw, 620px);
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.main {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.spacer { flex: 1 1 auto; }

/* Nav + bio */
.nav { display: flex; justify-content: space-between; align-items: center; gap: clamp(12px, 1.6vw, 24px); font-weight: 700; }
.nav a { white-space: nowrap; }
.nav a, .footer a, .link { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.nav .mark { width: 1.5em; height: 1.5em; }
.nav a[aria-current="page"], .nav a[aria-current="true"] { color: var(--grey); }
.bio { display: flex; flex-direction: column; gap: 12px; }
.rule { height: 1px; background: var(--rule); }
.plus { font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; gap: 2px; }
.plus svg { width: 1em; height: 1em; }

/* Portrait slot (home) */
.portrait {
  position: relative; width: 100%; aspect-ratio: 4 / 5;
  background: var(--tone); overflow: hidden;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
.portrait .hint { font-family: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace; font-size: .9em;
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: var(--ground); background: rgba(17,17,16,.62); padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.tile {
  position: absolute; inset: 0; background: var(--dark); color: var(--ground);
  padding: 28px; display: flex; flex-direction: column; justify-content: space-between;
  opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.tile.is-on { opacity: 1; }
.tile .name { font-family: var(--serif); font-size: clamp(40px, 3.9vw, 84px); line-height: .95; letter-spacing: -.01em; text-wrap: balance; }
.tile .meta { display: flex; flex-direction: column; gap: 6px; }
.tile .meta .cat { color: var(--dark-grey); }

/* Headline year range */
.years {
  margin: 0 0 8px; font-family: var(--serif); font-weight: 400;
  font-size: clamp(72px, 13.7vw, 300px); line-height: .86; letter-spacing: -.045em;
  display: flex; align-items: center; gap: .18em;
}
.years .dash { flex: 1 1 auto; min-width: .3em; height: .045em; background: var(--ink); }
.label { color: var(--grey); }
.years + .label { margin-bottom: clamp(32px, 4.5vw, 96px); }

/* Work index */
.index { position: relative; display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 4em;
  gap: 8px 16px; align-items: baseline; padding: max(6px, .49vw) 0; line-height: 1.2; border-top: 1px solid var(--rule); min-height: 24px;
}
.row .name { font-weight: 600; }
.row .cat, .row .yr { color: var(--grey); }
.row .yr { text-align: right; }
.row:hover { color: var(--ink); }
.row:hover .name { color: var(--grey); }
.row:hover .cat, .row:hover .yr { color: var(--ink); }
.row.wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 8em; }
.row.repo { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 8em 4em; }
.row.single { grid-template-columns: minmax(0, 1fr); }
.row.last, .index > :last-child { border-bottom: 1px solid var(--rule); }
.figs { position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: 0; transition: opacity .4s ease; }
.figs.is-on { opacity: 1; }

/* Footer */
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px 40px; font-weight: 700; margin-top: 48px; }
.footer .links { display: flex; flex-wrap: wrap; gap: 32px; }
.footer .copy { color: var(--grey); }
.footer a { gap: 8px; }

/* Popup (+) */
.popup { position: fixed; inset: 0; background: rgba(251,251,250,.6); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.popup.is-open { display: flex; }
.card {
  position: relative; width: 100%; max-width: 32em; background: var(--ground); border: 1px solid var(--ink);
  padding: 28px; display: flex; flex-direction: column; gap: 20px;
}
.card .close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.card .lead { display: flex; gap: 20px; align-items: flex-start; }
.card .lead p { font-size: 1.45em; line-height: 1.2; }
.card .list { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.card .list a { display: flex; justify-content: space-between; align-items: center; min-height: 44px; border-bottom: 1px solid var(--rule); font-weight: 600; }

/* Info page */
.headline { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(64px, min(9vw, 18vh), 200px); line-height: .82; letter-spacing: -.03em; padding-bottom: .3em; }
.main.stack { gap: 40px; }
.hero { width: 100%; height: clamp(320px, 44.4vw, 960px); object-fit: cover; object-position: 55% 45%; background: var(--tone); }
.prose { display: flex; flex-direction: column; gap: .9em; max-width: 62ch; }
.section { display: flex; flex-direction: column; }
.section > .label { margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid.drawings { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.grid figure { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.grid figure img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--tone); }
figcaption { color: var(--grey); }
.facts { display: flex; flex-wrap: wrap; gap: 40px 64px; }
.facts > div { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }

/* GitHub */
.gh-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; }
.gh-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.gh-total .big { font-family: var(--serif); font-size: clamp(48px, 4.4vw, 96px); line-height: .9; letter-spacing: -.03em; }
.gh-scroll { overflow-x: auto; }
.gh-cal { display: flex; flex-direction: column; gap: 4px; width: max(100%, 680px); }
.gh-months { display: grid; grid-template-columns: repeat(53, minmax(0, 1fr)); gap: 3px; color: var(--grey); line-height: 1.4; }
.gh-months span { white-space: nowrap; overflow: visible; }
.gh-weeks { display: grid; grid-template-columns: repeat(53, minmax(0, 1fr)); gap: 3px; }
.gh-week { display: grid; gap: 3px; }
.gh-day { aspect-ratio: 1; background: #ECEBE7; }
.gh-day[data-level="1"] { background: #C9C7C0; }
.gh-day[data-level="2"] { background: #9B9992; }
.gh-day[data-level="3"] { background: #5E5D58; }
.gh-day[data-level="4"] { background: #111110; }
.gh-key { display: flex; align-items: center; gap: 6px; color: var(--grey); }
.gh-key .gh-day { display: inline-block; width: 12px; height: 12px; }

/* Project pages */
.project-meta { display: flex; flex-direction: column; gap: 20px; }
.project-year { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(64px, 6.7vw, 140px); line-height: .9; letter-spacing: -.02em; }
.project-year.range { font-size: clamp(56px, 5vw, 108px); display: flex; align-items: center; gap: .12em; flex-wrap: wrap; }
.project-meta .block { display: flex; flex-direction: column; gap: 6px; }
.main.media { gap: 16px; }
.media figure { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.media figure img { width: 100%; object-fit: cover; background: var(--tone); }
.media .three { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.media .three img { aspect-ratio: 4 / 3; }
.panel {
  margin: 0; width: 100%; min-height: 460px; padding: 40px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.panel.dark { background: var(--dark); color: var(--ground); }
.panel.tone { background: var(--tone); color: var(--ink); }
.panel .title { font-family: var(--serif); font-size: clamp(56px, 7vw, 160px); line-height: .9; letter-spacing: -.02em; max-width: 12ch; text-wrap: balance; }
.panel .facts3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 24px; padding-top: 20px; border-top: 1px solid var(--dark-rule); }
.panel.tone .facts3 { border-top-color: #C9C4BA; }
.panel .facts3 > div { display: flex; flex-direction: column; gap: 4px; }
.panel.dark .facts3 .label { color: var(--dark-grey); }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px 40px; font-weight: 600; margin-top: 24px; }
.pager a { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }

/* Video player facade */
.player { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; background: var(--ink); color: var(--ground); overflow: hidden; }
.player:hover { color: var(--ground); }
.player > img { width: 100%; height: 100%; object-fit: cover; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player .bar-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; font-weight: 600; }
.player .bar-top .mark { width: 20px; height: 20px; background: var(--ground); }
.player .bar-top .by { color: var(--dark-grey); font-weight: 400; }
.player .playbtn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 88px; height: 88px; border-radius: 50%; background: var(--ground); color: var(--ink);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(0,0,0,.35);
  transition: transform .2s ease;
}
.player:hover .playbtn { transform: translate(-50%, -50%) scale(1.06); }
.player .playbtn svg { width: 30px; height: 30px; margin-left: 4px; }
.player .bar-bottom { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(17,17,16,.72); padding: 12px 20px 14px; display: flex; flex-direction: column; gap: 10px; }
.player .track { position: relative; height: 2px; background: rgba(251,251,250,.3); }
.player .knob { position: absolute; left: 0; top: 50%; width: 10px; height: 10px; border-radius: 50%; background: var(--ground); transform: translate(-50%, -50%); }
.player .controls { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.player .controls > div { display: flex; align-items: center; gap: 16px; }
.player .time { font-variant-numeric: tabular-nums; }
.player.is-playing > img, .player.is-playing .bar-top, .player.is-playing .playbtn, .player.is-playing .bar-bottom { display: none; }
.player:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

.demos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; }
.demo { display: flex; flex-direction: column; gap: 8px; min-width: 0; color: var(--ink); }
.demo .player { aspect-ratio: 16 / 9; }
.demo .playbtn { left: 12px; bottom: 12px; top: auto; transform: none; width: 44px; height: 44px; box-shadow: none; }
.demo:hover .playbtn { transform: scale(1.06); }
.demo .playbtn svg { width: 16px; height: 16px; margin-left: 2px; }
.demo .dur { position: absolute; right: 12px; bottom: 12px; padding: 4px 8px; background: rgba(17,17,16,.8); color: var(--ground); font-variant-numeric: tabular-nums; }
.demo .title { font-weight: 600; }
.demo .player.is-playing .dur { display: none; }


/* Desktop: the left column stays put while the right column scrolls (as on the reference) */
@media (min-width: 900px) {
  .aside { position: sticky; top: var(--gutter); align-self: flex-start; height: calc(100vh - var(--gutter) - 24px);
    overflow: hidden; }
  /* a sidebar taller than the window (long case studies) stops being sticky and scrolls with the page:
     nothing gets cut off and no inner scrollbar is needed (site.js sets the class) */
  .aside.is-tall { position: static; height: auto; overflow: visible; }
}

/* Phone */
@media (max-width: 640px) {
  body { font-size: 14px; }
  /* four menu items on one line: tighter gaps on phones */
  .nav { gap: 12px; }
  .page { padding: 16px 16px 24px; }
  .aside { flex-basis: 100%; }
  .row,   .row { grid-template-columns: minmax(0, 1fr) auto !important; }
  .row .cat { grid-column: 1 / -1; }
  .row .yr { grid-column: 2; grid-row: 1; white-space: nowrap; }
  .row.repo .lang { display: none; }
  .years { font-size: 84px; }
  .headline { font-size: 96px; }
  .hero, .hero-figure .hero { height: 220px; }
  .grid.drawings { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .panel { padding: 24px; min-height: 0; }
  .player .bar-top .by, .player .controls .label { display: none; }
}

/* ---------- Review additions ---------- */
/* text only for screen readers and search engines (the visual H1s are years) */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* labels and titles are real headings now; they keep their look */
h2.label, h3.label { margin: 0; font-size: inherit; font-weight: inherit; line-height: inherit; }
h2.title { margin: 0; font-weight: 400; }
.section > h2.label { margin-bottom: 12px; }
/* sidebar portrait in black and white (the file stays in colour) */
/* punchy black and white, tuned to match the LinkedIn profile photo: bright highlights, deep blacks */
.portrait img { filter: grayscale(1) contrast(1.6) brightness(1.15); }
/* grey on the beige panels needs to be darker to stay above 4.5:1 */
.panel.tone .label, .panel.tone .meta, .panel.tone .muted { color: #5E5E5B; }
/* 44px tap height for the GitHub profile link */
.gh-head a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
/* phone screenshots keep their tall shape */
.media .three.phones img { aspect-ratio: 720 / 1558; object-position: top; }
.media figure img { height: auto; }

/* Portfolio index */
.main.portfolio { gap: 24px; }
.pf-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.pf-filter button { min-height: 36px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 999px; font-weight: 600; }
.pf-filter button:hover { border-color: var(--ink); }
.pf-filter button[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 40px 16px; }
.pf-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pf-card[hidden] { display: none; }
.pf-card img, .pf-card .pf-panel { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; border: 1px solid var(--rule); }
.pf-card img { background: var(--tone); }
.pf-card .pf-panel { min-height: 0; padding: 24px; justify-content: flex-start; }
.pf-card .pf-panel .title { font-size: clamp(36px, 3.2vw, 64px); }
.pf-card:hover img { opacity: .88; }
.pf-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--grey); margin-top: 4px; }
.pf-title { margin: 0; font-size: 1.25em; font-weight: 600; line-height: 1.2; display: inline-flex; align-items: center; gap: 6px; }
.pf-desc { color: var(--grey); }

/* loading screen: covers the home page while three.js, the minifigure model and its materials preload */
.loader { position: fixed; inset: 0; z-index: 20; background: var(--ground); display: grid; place-items: center; transition: opacity .5s ease; }
.loader.is-done { opacity: 0; pointer-events: none; }
.loader path { fill: var(--dark); transform-origin: 50% 100%; animation: climb 2.6s cubic-bezier(.4, 0, .2, 1) infinite both; }
.loader path:nth-child(2) { animation-delay: .3s; }
.loader path:nth-child(3) { animation-delay: .6s; }
@keyframes climb {
  0% { transform: translateY(14px); opacity: 0; }
  30%, 60% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-10px); opacity: 0; }
}

/* keyboard: one consistent focus ring, and a skip link that only appears when focused */
a:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.skip { position: absolute; left: 16px; top: -100px; z-index: 30; padding: 8px 14px; background: var(--dark); color: var(--ground); font-weight: 700; }
.skip:focus { top: 16px; }

/* reveal motion on every page: blocks rise in as they enter the viewport (the class comes from site.js) */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Info: Doré hero with caption, and a fluid "who am I" — a serif lead that scales, then columns that flow */
.hero-figure { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.hero-figure .hero { height: clamp(220px, min(26vw, 42vh), 520px); object-position: 50% 42%; background: var(--ground); }
.about { columns: 2 30ch; column-gap: clamp(24px, 3vw, 72px); }
.about p { margin: 0 0 .9em; break-inside: avoid; }
.about .lead { column-span: all; margin-bottom: clamp(20px, 2vw, 40px); font-size: clamp(19px, 1.55vw, 32px); line-height: 1.32; letter-spacing: -.005em; text-wrap: pretty; }

/* projects under NDA: a card without imagery or a case page */
.pf-card.nda .pf-panel { display: flex; flex-direction: column; justify-content: space-between; }
.pf-nda { color: var(--dark-grey); }
.pf-card.nda .pf-meta span:first-child { color: var(--ink); }

/* (+) and the EN / PT switch share a row */
.bio-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.lang-switch { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.lang-switch a { min-height: 44px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center; }
.lang-switch a[aria-current="true"] { color: var(--grey); }
.lang-switch span { color: var(--rule); }

/* ---------- Services ---------- */
.main.services { gap: clamp(32px, 3vw, 56px); }
.svc-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.svc { display: grid; grid-template-columns: 4em minmax(0, 1fr); gap: 6px 16px; padding: clamp(18px, 1.6vw, 32px) 0; border-bottom: 1px solid var(--rule); }
.svc > :not(.svc-num) { grid-column: 2; }
.svc-num { color: var(--grey); font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: .9em; padding-top: .5em; }
.svc h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(32px, 3vw, 60px); line-height: 1; letter-spacing: -.02em; }
.svc p { max-width: 62ch; }
.svc-tags { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.svc-tags li { padding: 2px 10px; border: 1px solid var(--rule); border-radius: 999px; color: var(--grey); }
.svc-examples a { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.steps4 { grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)) !important; }
.svc-cta { display: flex; flex-direction: column; gap: 12px; padding: clamp(24px, 3vw, 56px) 0; }
.svc-cta h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 5vw, 104px); line-height: .95; letter-spacing: -.02em; }
.svc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px; background: var(--ink); color: var(--ground); font-weight: 600; }
.btn:hover { background: var(--dark); color: var(--ground); opacity: .88; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn.ghost:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- Phone menu: a full-screen sheet (built by site.js; without JS the links simply stay in the bar) ---------- */
.menu-btn { display: none; }
.menu-sheet { display: none; }
/* phones and tablets: the sidebar is too narrow for every link, so the menu sheet takes over */
@media (max-width: 1023px) {
  /* the top bar stays pinned while the page scrolls; the page makes room for it */
  .nav.has-menu { position: fixed; top: 0; left: 0; right: 0; z-index: 25; padding: 8px var(--gutter);
    background: var(--ground); border-bottom: 1px solid transparent; transition: border-color .2s ease-out; }
  .nav.has-menu.is-scrolled { border-bottom-color: var(--rule); }
  .page:has(.nav.has-menu) { padding-top: calc(60px + var(--gutter)); }
  html { scroll-padding-top: 76px; }
  .nav.has-menu > a:not(:first-child) { display: none; }
  .nav.has-menu .menu-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; }
  .menu-btn svg { width: 1.1em; height: 1.1em; }
  .menu-sheet { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--ground);
    padding: 16px 16px max(24px, env(safe-area-inset-bottom)); opacity: 0; transform: translateY(-8px); visibility: hidden;
    transition: opacity .2s ease-out, transform .2s ease-out, visibility 0s .2s; }
  .menu-sheet.is-open { opacity: 1; transform: none; visibility: visible; transition: opacity .2s ease-out, transform .2s ease-out; }
  .menu-sheet .sheet-top { display: flex; justify-content: space-between; align-items: center; }
  .menu-sheet .sheet-top a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; }
  .menu-sheet .sheet-top .mark { width: 1.5em; height: 1.5em; }
  .menu-sheet .sheet-links { list-style: none; margin: 32px 0 0; padding: 0; border-top: 1px solid var(--rule); }
  .menu-sheet .sheet-links a { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--rule);
    font-family: var(--serif); font-size: clamp(44px, 13vw, 64px); line-height: 1; letter-spacing: -.02em; }
  .menu-sheet .sheet-links a span { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 13px; letter-spacing: 0; color: var(--grey); }
  .menu-sheet .sheet-links a[aria-current] { color: var(--grey); }
  .menu-sheet .sheet-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
  .menu-sheet .sheet-foot .links { display: flex; flex-wrap: wrap; gap: 4px 24px; font-weight: 600; }
  .menu-sheet .sheet-foot a { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
  .menu-sheet .sheet-foot .row2 { display: flex; justify-content: space-between; align-items: center; color: var(--grey); }
  html.menu-open { overflow: hidden; }
  /* motion: links rise in one after another when the sheet opens (transform + opacity only, so it stays smooth) */
  .menu-sheet .sheet-links li, .menu-sheet .sheet-foot { opacity: 0; transform: translateY(18px); transition: opacity .15s ease-out, transform .15s ease-out; }
  .menu-sheet.is-open .sheet-links li, .menu-sheet.is-open .sheet-foot { opacity: 1; transform: none; transition: opacity .32s ease-out, transform .32s ease-out; }
  .menu-sheet.is-open .sheet-links li:nth-child(1) { transition-delay: .06s; }
  .menu-sheet.is-open .sheet-links li:nth-child(2) { transition-delay: .11s; }
  .menu-sheet.is-open .sheet-links li:nth-child(3) { transition-delay: .16s; }
  .menu-sheet.is-open .sheet-links li:nth-child(4) { transition-delay: .21s; }
  .menu-sheet.is-open .sheet-links li:nth-child(5) { transition-delay: .26s; }
  .menu-sheet.is-open .sheet-foot { transition-delay: .3s; }
  .menu-sheet .sheet-links a span { opacity: 0; transition: opacity .2s ease-out; }
  .menu-sheet.is-open .sheet-links a span { opacity: 1; transition-delay: .32s; }
  /* tap feedback: the label nudges right */
  .menu-sheet .sheet-links a { transition: transform .15s ease-out; }
  .menu-sheet .sheet-links a:active, .menu-sheet .sheet-links a:hover { transform: translateX(6px); }
  /* the Menu button's lines open up slightly on press */
  .nav .menu-btn svg path { transition: transform .15s ease-out; transform-origin: center; }
  .nav .menu-btn:active svg path { transform: scaleX(.8); }
  .menu-btn, .menu-sheet a { -webkit-tap-highlight-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .menu-sheet *, .menu-sheet { transition-delay: 0s !important; }
}
