/* ==========================================================================
   Bhagesh Hunakunti · portfolio
   Layout: mobile-first single column. From 720px the nav moves into the header;
   from 860px the hero splits copy | portrait.
   Motif: the R hex sticker that all four project logos share, on a paper ground.
   ========================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-opsz.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens --------------------------------------------------------
   Colour comes from the assets: the sticker orange, engraving ink and sticker
   white of the logos; the navy T-shirt and golden-hour light of the photo. */
:root {
  --paper: #F2F4F7;
  --surface: #FFFFFF;
  --ink: #12151B;
  --muted: #566072;
  --line: #DCE0E7;
  --orange: #EE6F0F;        /* logo hexagon */
  --orange-text: #B04A00;   /* orange that passes AA for small text on paper */
  --navy: #2D3A55;          /* T-shirt */
  --gold: #F2C27A;          /* evening sun on the alpaca */
  --on-orange: #12151B;
  --sticker-rim: #FBF3F0;   /* the pale border on the logo stickers */
  --hex-a: #F48A2C;
  --hex-b: #E2600A;
  --shadow: 18 21 27;

  /* Nucleotide fills for the hex field: A orange, T navy, G gold, C ink.
     Gold is taken one shade deeper so its white letter stays legible. */
  --nt-a: #EE6F0F;
  --nt-t: #2D3A55;
  --nt-g: #C8893B;
  --nt-c: #12151B;
  --nt-opacity: 0.55;   /* the field stays in the background */

  /* Paper: an even, fine grain over the flat paper colour (generated, no request). */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .07 0 0 0 0 .08 0 0 0 0 .11 .42 0 0 0 -.17'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");

  /* Cinematic film grain over the whole page, photo included. */
  --film-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1.8 0 0 0 -.4 1.8 0 0 0 -.4 1.8 0 0 0 -.4 0 0 0 0 .1'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23f)'/%3E%3C/svg%3E");
  --film-opacity: 0.6;

  --font-sans: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Fluid type: rem floor + small vw slope keeps 200% zoom working (WCAG 1.4.4). */
  --step--1: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-0: clamp(1rem, 0.96rem + 0.18vw, 1.125rem);
  --step-1: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --step-2: clamp(1.375rem, 1.2rem + 0.9vw, 1.875rem);
  --step-3: clamp(1.75rem, 1.4rem + 1.8vw, 3rem);
  --step-4: clamp(2.875rem, 1.7rem + 5.6vw, 6rem);

  --gutter: clamp(16px, 4vw, 40px);
  --header-h: 3.75rem;
  --radius: 18px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1014;
    --surface: #161A21;
    --ink: #ECEEF2;
    --muted: #9AA3B3;
    --line: #272C36;
    --orange: #F07A1E;
    --orange-text: #FF9A52;
    --navy: #93A9D1;
    --gold: #EFCC90;
    --on-orange: #12151B;
    --hex-a: #F58A2E;
    --hex-b: #DE5E08;
    --shadow: 0 0 0;
    --nt-a: #F07A1E;
    --nt-t: #34466B;
    --nt-g: #B9802F;
    --nt-c: #3A404C;
  --nt-opacity: 0.6;
    --nt-opacity: 0.6;
  --film-opacity: 0.85;
    --film-opacity: 0.85;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 .3 0 0 0 -.125'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E1014;
  --surface: #161A21;
  --ink: #ECEEF2;
  --muted: #9AA3B3;
  --line: #272C36;
  --orange: #F07A1E;
  --orange-text: #FF9A52;
  --navy: #93A9D1;
  --gold: #EFCC90;
  --on-orange: #12151B;
  --hex-a: #F58A2E;
  --hex-b: #DE5E08;
  --shadow: 0 0 0;
  --nt-a: #F07A1E;
  --nt-t: #34466B;
  --nt-g: #B9802F;
  --nt-c: #3A404C;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 .3 0 0 0 -.125'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
  color-scheme: dark;
}

/* ---------- Base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background-color: var(--paper);
  background-image: var(--grain);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  font-optical-sizing: auto;
  line-height: 1.6;
  position: relative;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

img, svg, canvas, picture { display: block; max-width: 100%; }
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
:where(ul[role="list"], ol[role="list"]) { list-style: none; padding: 0; }
a { color: inherit; text-underline-offset: 0.2em; }
button { font: inherit; color: inherit; }
strong { font-weight: 650; }

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

:focus-visible {
  outline: 2px solid var(--orange-text);
  outline-offset: 3px;
  border-radius: 6px;
}

.icon { width: 1em; height: 1em; flex: none; }

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

.skip-link {
  position: absolute;
  left: max(16px, env(safe-area-inset-left, 0px));
  top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus { transform: none; }

.wrap {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

/* ---------- Header -------------------------------------------------------- */
.site-header {
  position: relative;
  z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
}
@media (min-width: 720px) {
  .site-header { position: sticky; top: 0; }
}
/* The blur lives on a pseudo-element: a backdrop-filter on the header itself
   would become the containing block for the fixed mobile nav inside it. */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--paper);
  background-color: color-mix(in srgb, var(--paper) 86%, transparent);
  background-image: var(--grain);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid transparent;
  opacity: 0;
  transition: border-color 0.3s ease, opacity 0.3s ease;
}
.site-header.is-scrolled::before { border-bottom-color: var(--line); opacity: 1; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  height: var(--header-h);
}


.theme-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.theme-toggle .icon { grid-area: 1 / 1; width: 20px; height: 20px; transition: transform 0.3s var(--ease-out), opacity 0.25s ease; }
.theme-toggle .icon-sun { opacity: 0; transform: scale(0.6); }
@media (hover: hover) and (pointer: fine) {
  .theme-toggle:hover { border-color: var(--muted); }
}
.theme-toggle:active { transform: scale(0.94); }

:root[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: scale(0.6); }
:root[data-theme="dark"] .theme-toggle .icon-sun { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { opacity: 0; transform: scale(0.6); }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { opacity: 1; transform: none; }
}

/* ---------- Nav: floating pill in the thumb zone on phones ---------------- */
.nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
}
.nav ul {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: var(--surface);
  background-color: color-mix(in srgb, var(--surface) 84%, transparent);
  background-image: var(--grain);
  -webkit-backdrop-filter: saturate(1.5) blur(16px);
  backdrop-filter: saturate(1.5) blur(16px);
  box-shadow: 0 12px 32px -14px rgb(var(--shadow) / 0.45);
}
.nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 clamp(10px, 3.6vw, 16px);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 560;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.nav a[aria-current="location"] { background: var(--ink); color: var(--paper); }
.nav a:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .nav a:not([aria-current="location"]):hover { color: var(--ink); }
}

body { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }

@media (min-width: 720px) {
  body { padding-bottom: 0; }
  .nav { position: static; transform: none; max-width: none; }
  .nav ul {
    padding: 0;
    border: 0;
    background: none;
    background-image: none;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .nav a { padding: 0 14px; }
}

/* ---------- Hero ---------------------------------------------------------- */
.hero {
  display: grid;
  gap: clamp(1.75rem, 5vw, 3rem);
  align-items: center;
  padding-block: clamp(1rem, 3vw, 3rem) clamp(1.5rem, 4vw, 3rem);
  overflow-x: clip;
}
.hero-copy { position: relative; z-index: 1; min-width: 0; display: grid; gap: 1.1rem; }


.hero-name {
  font-size: var(--step-4);
  font-weight: 760;
  line-height: 0.92;
  letter-spacing: -0.035em;
}
.hero-name span { display: block; }

.hero-role {
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--navy);
}
.hero-lede { max-width: 34rem; color: var(--muted); }


.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 0.4rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out), background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.25s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--orange); color: var(--on-orange); }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { box-shadow: 0 10px 24px -10px var(--orange); transform: translateY(-1px); }
  .btn-primary:hover .icon { transform: translateY(2px); }
}
.btn .icon { transition: transform 0.3s var(--ease-out); }

/* Portrait: a hex sticker with the head breaking out of the top edge. */
.portrait {
  position: relative;
  order: -1;
  justify-self: center;
  width: min(64vw, 18rem);
  max-width: 100%;
  aspect-ratio: 10 / 13;
  margin-top: 0.5rem;
}
.portrait-hex {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.portrait-hex .stop-a { stop-color: var(--hex-a); }
.portrait-hex .stop-b { stop-color: var(--hex-b); }
.hex-fill { fill: url(#hex-grad); transform-box: fill-box; transform-origin: 50% 60%; }
.hex-echo {
  fill: none;
  stroke: var(--navy);
  stroke-width: 1.25px;
  vector-effect: non-scaling-stroke;
  transform: translate(-2.5px, 2.2px);
}
.portrait picture { position: absolute; inset: 0; pointer-events: none; }
/* Keep the photo from being saved casually: no drag, no long-press menu, and a
   transparent shield on top so right-click never targets the image. */
.portrait { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.portrait-img { -webkit-user-drag: none; }
.portrait-shield { position: absolute; inset: 0; z-index: 2; }
.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Square above the upper hex corners, hexagon below: the subject sits inside the sticker. */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 130' preserveAspectRatio='none'%3E%3Cpath d='M0,0 L100,0 L100,96.13 Q100,101.13 95.67,103.63 L54.33,127.5 Q50,130 45.67,127.5 L4.33,103.63 Q0,101.13 0,96.13 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 130' preserveAspectRatio='none'%3E%3Cpath d='M0,0 L100,0 L100,96.13 Q100,101.13 95.67,103.63 L54.33,127.5 Q50,130 45.67,127.5 L4.33,103.63 Q0,101.13 0,96.13 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

@media (min-width: 480px) {
  .portrait { width: 18rem; }
}
@media (min-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); column-gap: clamp(3rem, 7vw, 6rem); }
  .portrait { order: 0; width: min(100%, 26rem); justify-self: end; margin-top: 2.5rem; }
}

/* ---------- Sections ------------------------------------------------------ */
.section { padding-block: clamp(2.25rem, 5vw, 4rem); }
.section + .section { border-top: 1px solid var(--line); }

.section-head {
  display: grid;
  gap: 0.6rem;
  max-width: 44rem;
  margin-bottom: clamp(1.5rem, 3.5vw, 2.25rem);
}
.section-head h2 {
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.section-lede { color: var(--muted); max-width: 38rem; }


.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
  background: linear-gradient(var(--orange), var(--orange)) 0 calc(50% + 0.75em) / 0 2px no-repeat;
  transition: background-size 0.35s var(--ease-out);
}
.text-link .icon { transition: transform 0.3s var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .text-link:hover { background-size: 100% 2px; }
  .text-link:hover .icon { transform: translate(2px, -2px); }
}
/* "Find more projects here" with the GitHub tile beside it. */
.more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 1.25rem;
}
.more-text { font-size: var(--step-1); font-weight: 600; letter-spacing: -0.01em; }
.more .elsewhere li { flex: 0 0 auto; }
/* Phones: keep the GitHub tile on the same line as the text. */
@media (max-width: 480px) {
  .more { gap: 10px; }
  .more-text { font-size: 0.9375rem; }
  .more .elsewhere a { min-height: 48px; padding: 8px 10px; column-gap: 8px; }
  .more .elsewhere .brand { width: 26px; height: 26px; }
  .more .ew-handle { font-size: 0.75rem; }
}

/* ---------- Work ----------------------------------------------------------
   Only the hex logos. Opening one (hover, tap or keyboard) extends its orange
   background into a label with a one-liner and links, and the other logos
   shrink aside. Sizes are in container units so the open
   row always fits: open logo + label + three small logos <= 100cqi. */
.tools {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));   /* 2 per row, or 1 + 3 while one is open */
  gap: 14px;
  --hexw: 38cqi;                 /* logo size while open on phones */
  --pad: 0px;
}
.tool {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  grid-column: span 3;
  scroll-margin-block: 24px 96px;   /* clear of the floating menu when scrolled to */
}
.tool-hex {
  position: relative;
  z-index: 2;
  flex: none;
  width: min(100%, 200px);
  aspect-ratio: 0.866;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  cursor: pointer;
  transition: width 0.55s var(--ease-out), opacity 0.4s ease;
}
.tool-hex:focus-visible { outline-offset: 6px; border-radius: 12px; }
.tool-hex img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgb(var(--shadow) / 0.2));
}

/* The extended background: starts behind the middle of the sticker and runs
   out under the label, in the same orange as the logo. */
.tool-bg {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: calc(var(--pad) + var(--hexw) / 2);
  right: var(--pad);
  height: calc(var(--hexw) * 1.155 * 0.72);
  transform: translateY(-50%);
  border-radius: 0 999px 999px 0;
  background: linear-gradient(135deg, var(--hex-a), var(--hex-b));
  box-shadow: 0 10px 22px -12px rgb(var(--shadow) / 0.35);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.tool-panel {
  position: relative;
  z-index: 1;
  flex: none;
  width: 0;
  overflow: hidden;
  transition: width 0.55s var(--ease-out);
}
.tool-panel-inner {
  width: var(--panel-w, 60cqi);
  padding: 0 18px 0 16px;
  color: var(--on-orange);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.tool-line { font-size: 0.875rem; font-weight: 500; line-height: 1.38; text-wrap: balance; }
.tool-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tool-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  min-height: 36px;
  min-width: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--on-orange);
  color: var(--sticker-rim);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.tool-links .icon { width: 0.9em; height: 0.9em; }
.tool-links .glyph { display: none; width: 1.05rem; height: 1.05rem; fill: currentColor; }
.tool-links a:active { transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) {
  .tool-links a:hover { transform: translateY(-1px); }
}

/* Open state, shared by every layout. */
.tool.is-open .tool-bg,
.tool:has(:focus-visible) .tool-bg { opacity: 1; }
.tool.is-open .tool-panel-inner,
.tool:has(:focus-visible) .tool-panel-inner { opacity: 1; transition-delay: 0.2s; }

/* Phones: a 2 x 2 grid. The open logo moves to the top and takes the whole
   row with its label; the other three shrink into one row of three beneath it
   (animated with a view transition where supported). */
@media (max-width: 759px) {
  .tools:has(.tool.is-open) .tool { grid-column: span 2; }
  .tool.is-open { order: -1; }
  .tool:nth-child(1) { view-transition-name: tool-1; }
  .tool:nth-child(2) { view-transition-name: tool-2; }
  .tool:nth-child(3) { view-transition-name: tool-3; }
  .tool:nth-child(4) { view-transition-name: tool-4; }
  .tools:has(.tool.is-open) .tool.is-open { grid-column: 1 / -1; justify-content: flex-start; }
  .tool.is-open .tool-hex { width: var(--hexw); }
  .tool.is-open .tool-panel { width: calc(100cqi - var(--hexw)); }
  .tools { --panel-w: calc(100cqi - var(--hexw)); }
  .tool-panel-inner { padding: 0 12px 0 14px; }
  .tool-line { font-size: 0.8125rem; }
  /* icon buttons keep the label short on small screens */
  .tool-links a { padding: 0; width: 38px; min-height: 38px; }
  .tool-links .label, .tool-links .icon { display: none; }
  .tool-links .glyph { display: block; }
}

/* Wide screens: one row. Each logo carries half the gap as padding so the
   pointer never falls between two logos while moving across the row. */
@media (min-width: 760px) {
  .tools {
    display: flex;
    gap: 0;
    --hexw: min(21cqi, 232px);   /* logo, open or at rest */
    --hex-sm: min(12.5cqi, 140px); /* the others while one is open */
    --panel-w: min(30cqi, 330px);
    --pad: 1.2cqi;
  }
  .tool { flex: none; padding-inline: var(--pad); }
  .tool-hex { width: var(--hexw); }
  .tool.is-open .tool-panel,
  .tool:has(:focus-visible) .tool-panel { width: var(--panel-w); }
  .tools:has(.tool.is-open, .tool :focus-visible) .tool:not(.is-open):not(:has(:focus-visible)) .tool-hex {
    width: var(--hex-sm);
    opacity: 0.8;
  }
}
@media (min-width: 760px) and (hover: hover) and (pointer: fine) {
  .tool:hover .tool-bg { opacity: 1; }
  .tool:hover .tool-panel { width: var(--panel-w); }
  .tool:hover .tool-panel-inner { opacity: 1; transition-delay: 0.2s; }
  .tools:has(.tool:hover) .tool:not(:hover) .tool-hex { width: var(--hex-sm); opacity: 0.8; }
}

/* ---------- Contact ------------------------------------------------------- */
.elsewhere {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.elsewhere li { flex: 1 1 auto; }
.elsewhere a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 14px;
  min-height: 64px;
  height: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background-color: var(--surface);
  background-image: var(--grain);
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.elsewhere a:active { transform: scale(0.98); }
/* Official marks, all the same size and all in the logo orange. */
.elsewhere .brand {
  width: 30px;
  height: 30px;
  fill: var(--orange);
}
.ew-handle {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
}
.elsewhere .icon { color: var(--muted); transition: transform 0.3s var(--ease-out), color 0.2s ease; }
@media (hover: hover) and (pointer: fine) {
  .elsewhere a:hover { border-color: var(--orange); }
  .elsewhere a:hover .icon { color: var(--orange-text); transform: translate(2px, -2px); }
}

/* ---------- Footer -------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--line); }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding-block: 20px calc(20px + env(safe-area-inset-bottom, 0px));
  font-size: var(--step--1);
  color: var(--muted);
}

/* ---------- Nucleotide layer -----------------------------------------------
   Behind all content, spanning the page. js/main.js lights single hexagons in
   free space with a white A, T, G or C; fills encode the base. */
.dna-layer {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.dna-halo { position: absolute; left: 0; top: 0; }
.nt {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--nt-w, 22px);
  height: var(--nt-h, 25px);
  margin: calc(var(--nt-h, 25px) / -2) 0 0 calc(var(--nt-w, 22px) / -2);
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--nt-fs, 13px);
  line-height: 1;
  color: #FFFFFF;
  opacity: 0;
  transition: opacity 0.7s ease;
}
.nt.on { opacity: var(--nt-opacity); transition-duration: 0.22s; }
/* The letter arrives just after the fill and leaves just before it. */
.nt > span { opacity: 0; transition: opacity 0.3s ease; }
.nt.on > span { opacity: 1; transition-delay: 0.12s; }
.nt-A { background: var(--nt-a); }
.nt-T { background: var(--nt-t); }
.nt-G { background: var(--nt-g); }
.nt-C { background: var(--nt-c); }
@media print {
  .dna-layer { display: none; }
}

/* ---------- Film grain ----------------------------------------------------
   One fixed layer above everything (portrait included). It jitters ten times
   a second by moving, never repainting, and holds still with reduced motion. */
body::after {
  content: "";
  position: fixed;
  inset: -80px;
  z-index: 200;
  pointer-events: none;
  background-image: var(--film-grain);
  background-size: 220px 220px;
  opacity: var(--film-opacity);
}
@media print {
  body::after { display: none; }
}

/* ==========================================================================
   Motion. Everything above is the resting state, fully visible.
   Only transform and opacity animate; nothing runs with reduced motion.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  /* Page-load sequence: sticker settles, outline slides out, photo rises, copy follows. */
  .hex-fill { animation: hex-in 0.9s var(--ease-out) both; }
  .hex-echo { animation: echo-in 1.1s 0.35s var(--ease-out) both; }
  .portrait-img { animation: rise 0.9s 0.2s var(--ease-out) both; }
  .dna-halo { animation: fade-in 1.2s 0.4s ease both; }
  .hero-copy > * { animation: fade-up 0.7s var(--ease-out) both; }
  .hero-copy > :nth-child(1) { animation-delay: 0.05s; }
  .hero-copy > :nth-child(2) { animation-delay: 0.12s; }
  .hero-copy > :nth-child(3) { animation-delay: 0.2s; }
  .hero-copy > :nth-child(4) { animation-delay: 0.28s; }

  body::after { animation: film-grain 0.8s steps(1) infinite; }
}

/* Hero content animates movement only, never opacity: text and photo are
   readable on the very first frame, and the photo counts for LCP immediately. */
@keyframes hex-in {
  from { transform: scale(0.9); }
  to { transform: none; }
}
@keyframes echo-in {
  from { transform: translate(0, 0); opacity: 0; }
  to { transform: translate(-2.5px, 2.2px); opacity: 1; }
}
@keyframes rise {
  from { transform: translateY(18px); }
  to { transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes film-grain {
  0% { transform: translate(0, 0); }
  12.5% { transform: translate(-38px, 22px); }
  25% { transform: translate(27px, -41px); }
  37.5% { transform: translate(-19px, -63px); }
  50% { transform: translate(52px, 14px); }
  62.5% { transform: translate(-61px, 47px); }
  75% { transform: translate(33px, 58px); }
  87.5% { transform: translate(-8px, -29px); }
  100% { transform: translate(0, 0); }
}
@keyframes fade-up {
  from { transform: translateY(12px); }
  to { transform: none; }
}

/* Reduced motion: still the same page, just still. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
