/* =============================================================
   PALETTE: change these three colours to re-theme the whole site.
   Dark mode swaps --paper and --ink automatically.
   ============================================================= */
:root {
  --paper: #F3EFE6;   /* off-white */
  --ink: #151412;     /* near-black */
  --accent: #E8461E;  /* vermilion */
}


/* ---------- Fonts (self-hosted, so every phone, tablet and in-app browser gets the
   same files; Google Fonts sends some browsers older versions that render wider) ---------- */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("../assets/fonts/bricolage-grotesque-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("../assets/fonts/bricolage-grotesque-latin.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: "Geist Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/geist-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/geist-mono-latin.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: "Geist Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../assets/fonts/geist-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../assets/fonts/geist-mono-latin.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;
}


/* ---------- Tokens (derived from the palette) ---------- */

:root {
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --gutter: clamp(1rem, 5vw, 5rem);
  --max: 90rem;
  --space-section: clamp(4.5rem, 11vw, 9rem);
  --header-h: 4rem;
  --thumb-h: clamp(13rem, 34vw, 26rem);

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.7, 0, .2, 1);

  /* light theme (default) */
  color-scheme: light;
  --bg: var(--paper);
  --fg: var(--ink);
  --accent-text: color-mix(in oklab, var(--accent) 78%, var(--ink)); /* accent dark enough for small text */

  --muted: color-mix(in oklab, var(--fg) 62%, var(--bg));
  --line: color-mix(in oklab, var(--fg) 16%, var(--bg));
  --on-accent: var(--ink);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--ink);
  --fg: var(--paper);
  --accent-text: var(--accent);
}

/* No-JS fallback: follow the system setting. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: var(--ink);
    --fg: var(--paper);
    --accent-text: var(--accent);
  }
}


/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-display);
  font-size: clamp(1rem, .95rem + .25vw, 1.125rem);
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

a {
  color: inherit;
  text-decoration-thickness: .08em;
  text-underline-offset: .18em;
}

em { font-style: normal; color: var(--accent); }

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

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

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

.skip-link {
  position: fixed;
  top: .75rem; left: .75rem;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: .8rem;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Small mono labels used across the page */
.section__label,
.nav,
.job__dates,
.tags,
.project__links,
.gallery-hint,
.copy-btn,
.contact__links,
.footer__label,
.footer__meta,
.footer__bottom,
.lightbox__count,
.lightbox__caption {
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
}


/* ---------- Word-reveal masks (added by main.js) ---------- */

.w {
  --mask-top: .06em;
  --mask-bottom: .14em;
  display: inline-block;
  vertical-align: top;
  overflow: clip;
  padding: var(--mask-top) .08em var(--mask-bottom);
  margin: calc(var(--mask-top) * -1) -.08em calc(var(--mask-bottom) * -1);
}
.w__i { display: inline-block; }


/* ---------- Header ---------- */

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  background: var(--bg);
  transition: transform .6s var(--ease-in-out), box-shadow .3s;
}
.site-header.is-scrolled { box-shadow: 0 1px 0 var(--line); }
.site-header.is-hidden:not(:focus-within) { transform: translateY(calc(-100% - 2px)); }

.site-header__inner {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.5vw, 2rem);
  height: var(--header-h);
}

.nav { display: flex; gap: clamp(1rem, 2.5vw, 2rem); margin-right: auto; }
.nav a {
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
  padding-bottom: 2px;
  transition: background-size .45s var(--ease-out);
}
@media (hover: hover) {
  .nav a:hover { background-size: 100% 1px; }
}

.theme-toggle {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transition: border-color .3s;
}
@media (hover: hover) {
  .theme-toggle:hover { border-color: var(--fg); }
}
.theme-toggle svg {
  width: 1.2rem;
  transition: transform .7s var(--ease-in-out);
}
[data-theme="dark"] .theme-toggle svg { transform: rotate(180deg); }

/* Phones: all links stay in the bar. Slightly smaller, tighter text, spread evenly up to the
   theme button, so all five fit even on a 320px-wide screen. */
@media (max-width: 40em) {
  .site-header__inner { gap: .75rem; }
  .nav {
    flex: 1;
    justify-content: space-between;
    gap: .375rem;
    margin-right: 0;
    font-size: clamp(.625rem, 3.2vw, .75rem);
    letter-spacing: .02em;
  }
}

/* Theme switch: circular reveal (View Transitions API, where supported) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}


/* ---------- Hero ---------- */

.hero {
  --name-size: clamp(3.5rem, min(20vw, 25svh), 18.5rem); /* phones/tablets: leaves room even if a fallback font is used */
  --sticker-size: clamp(7rem, 34vw, 13rem);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100vh;
  min-height: 100svh;
  padding-top: calc(var(--header-h) + 1.5rem);
  padding-bottom: clamp(2rem, 5vw, 4rem);
}

/* Phones: don't leave half a screen empty above the name */
@media (max-width: 40em) {
  .hero {
    min-height: 0;
    padding-top: calc(var(--header-h) + 2rem + var(--sticker-size));
  }
}

/* Desktop: the name shrinks a little so the photo fits in the space to its right.
   The photo grows to fill whatever space is left (4.1em is roughly the width of "Makandar"). */
@media (min-width: 64em) {
  .hero {
    --name-size: clamp(3.5rem, min(17vw, 25svh), 15rem);
    --sticker-size: max(9rem, min(calc(min(100vw, var(--max)) - 2 * var(--gutter) - 4.1 * var(--name-size) - 3rem), 40svh, 26rem));
  }
}

.hero__name {
  margin-left: -.045em; /* optical alignment of the Z */
  font-variation-settings: "opsz" 96; /* tight poster cut on every screen (laptops already get it) */
  font-size: var(--name-size);
  font-weight: 800;
  line-height: .84;
  letter-spacing: -.055em;
}
.hero__word { display: block; }
/* index.html carries plain fallback text for crawlers without JavaScript; hide it until main.js
   has rendered the real (animated) version, so visitors never see it flash. */
html.js:not(.is-rendered) .hero__name,
html.js:not(.is-rendered) .hero__tagline { visibility: hidden; }
.hero__name .w { --mask-top: .12em; --mask-bottom: .22em; }

.hero__tagline {
  max-width: 17em;
  margin-top: clamp(1.25rem, 2.5vw, 2rem);
  font-size: clamp(1.4rem, 2.6vw, 2.25rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.028em;
  text-wrap: pretty;
}

/* Round photo sticker. Phones and tablets: top-right corner of the hero.
   Desktop: the empty space right of the name, centred on it.
   The outer box is what the slap animation moves; the face inside holds the tilt and hover. */
.sticker {
  position: absolute;
  z-index: 1;
  top: calc(var(--header-h) + 1rem);
  right: var(--gutter);
  width: var(--sticker-size);
  aspect-ratio: 1;
}
@media (min-width: 64em) {
  .hero__title { position: relative; }
  .sticker {
    top: calc(50% - var(--sticker-size) / 2);
    right: 0;
  }
}
.sticker__face {
  --lift: 0;
  position: relative; /* 0 = flat on the page, 1 = held up by the hand (bigger, softer shadow) */
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: calc(var(--sticker-size) * .035) solid var(--paper);
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 calc(2px + var(--lift) * var(--sticker-size) * .1) calc(4px + var(--lift) * var(--sticker-size) * .2) rgb(0 0 0 / .18),
    0 calc(var(--sticker-size) * (.06 + var(--lift) * .16)) calc(var(--sticker-size) * (.15 + var(--lift) * .25)) rgb(0 0 0 / .18);
  transform: rotate(0deg); /* resting tilt: try -4deg for a slapped-on angle */
  transition: transform .6s var(--ease-out);
}
/* "#OPENTOWORK" frame over the bottom of the photo */
.sticker__badge {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.sticker__badge-stop { stop-color: var(--ink); }
.sticker__badge-band {
  fill: none;
  stroke-width: 14;
}
.sticker__badge-text {
  fill: var(--paper);
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .08em;
}

.sticker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.08);
  filter: grayscale(1) contrast(1.2) brightness(1.05);
  mix-blend-mode: multiply; /* duotone: the photo picks up the accent colour */
}
@media (hover: hover) {
  .sticker:hover .sticker__face { transform: rotate(0deg) scale(1.04); }
  .sticker:hover img { filter: none; mix-blend-mode: normal; }
}

/* The cartoon glove and impact lines; hidden until the animation shows them. */
.hand,
.burst {
  position: absolute;
  display: none; /* main.js shows them only while the slap plays */
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}
.hand {
  z-index: 2;
  top: -5%;
  left: 20%;
  width: 80%;
}
.burst {
  top: -30%;
  left: -30%;
  width: 160%;
}
.hand svg,
.burst svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.hand__outline {
  fill: var(--ink);
  stroke: var(--ink);
  stroke-width: 12;
  stroke-linejoin: round;
}
.hand__fill { fill: var(--paper); }
.hand__lines,
.burst path {
  fill: none;
  stroke-linecap: round;
}
.hand__lines {
  stroke: var(--ink);
  stroke-width: 5;
}
.burst path {
  stroke: var(--accent);
  stroke-width: 6;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: clamp(1.5rem, 2.5vw, 2rem);
}
.btn {
  display: inline-flex;
  align-items: center;
  padding: .8em 1.35em;
  border: 1px solid var(--fg);
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1;
  text-decoration: none;
  transition: background-color .3s, border-color .3s, color .3s;
}
@media (hover: hover) {
  .btn:hover {
    background: var(--fg);
    color: var(--bg);
  }
}
.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
@media (hover: hover) {
  .btn--primary:hover {
    border-color: var(--fg);
    background: var(--fg);
    color: var(--bg);
  }
}



/* ---------- Sections ---------- */

.section {
  display: grid;
  gap: 1.5rem 2rem;
  padding-block: calc(var(--space-section) / 2);
}

@media (min-width: 56em) {
  .section { grid-template-columns: minmax(10rem, 1fr) minmax(0, 4fr); }
}

.section__label {
  padding-top: .5em;
  color: var(--muted);
}
.section__label h2 { font: inherit; }


/* ---------- About ---------- */

.about p {
  max-width: 30ch;
  font-size: clamp(1.5rem, 3.1vw, 2.6rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -.028em;
}
.about p + p { margin-top: .55em; }


/* ---------- Work ---------- */

.job {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .4rem 2rem;
  padding-block: 1.35rem;
  border-block: 1px solid var(--line);
}
.job + .job { border-top: 0; }
.job__title {
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.job__at { color: var(--muted); font-weight: 400; }
.job__dates { color: var(--muted); white-space: nowrap; }


/* ---------- Roles marquee ---------- */

.marquee {
  margin-block: calc(var(--space-section) / 2);
  overflow: hidden;
}
.marquee__row--roles {
  padding-block: clamp(.9rem, 2vw, 1.5rem);
  background: var(--accent);
  color: var(--on-accent);
}
/* Thin strips above and below the roles. Black in light mode, off-white in dark mode. */
.marquee__row--caption {
  padding-block: .7rem;
  background: var(--fg);
  color: var(--bg);
}
.marquee__caption {
  padding-inline: 1.1em;
  font-family: var(--font-mono);
  font-size: clamp(.75rem, 1vw, .875rem);
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.marquee__row--caption .marquee__sep {
  width: .85rem;
  margin-inline: 0;
  color: var(--accent);
}
.marquee__track {
  display: flex;
  width: max-content;
  will-change: transform;
}
.marquee__group {
  display: flex;
  flex-shrink: 0;
  align-items: center;
}
.marquee__item {
  padding-inline: .32em;
  font-size: clamp(2rem, 5.5vw, 4.75rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.marquee__sep {
  flex-shrink: 0;
  width: clamp(1.1rem, 2.6vw, 2.4rem);
  margin-inline: .25em;
}

/* Reduced motion: a still, wrapped list instead of a moving strip */
.marquee.is-static .marquee__track {
  width: auto;
  padding-inline: var(--gutter);
}
.marquee.is-static .marquee__group {
  flex-wrap: wrap;
  justify-content: center;
  flex-shrink: 1;
  margin-inline: auto;
}
.marquee.is-static .marquee__item { font-size: clamp(1.75rem, 4.5vw, 3.5rem); }
.marquee.is-static .marquee__sep:last-child { display: none; }
.marquee.is-static .marquee__row--roles { padding-block: clamp(1.25rem, 3vw, 2rem); }
.marquee.is-static .marquee__row--caption:last-child { display: none; }


/* ---------- Skills ---------- */

.skills { border-top: 1px solid var(--line); }
.skill-group {
  display: grid;
  gap: .9rem 2rem;
  padding-block: 1.35rem;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 48em) {
  .skill-group { grid-template-columns: minmax(11rem, 1fr) minmax(0, 3fr); align-items: baseline; }
}
.skill-group__title {
  font-size: clamp(1.15rem, 1.8vw, 1.4rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.skill-group__items {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.skill-group__items li {
  padding: .4em .9em;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .95rem;
  line-height: 1.2;
  transition: background-color .3s, border-color .3s, color .3s;
}
@media (hover: hover) {
  .skill-group__items li:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
  }
}


/* ---------- Projects ---------- */

.projects { border-top: 1px solid var(--line); }
.project { border-bottom: 1px solid var(--line); }
.project h3 { font: inherit; }

.project__toggle {
  --fill-pad: min(1.25rem, var(--gutter));
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .45rem 1.5rem;
  width: 100%;
  padding: clamp(1.25rem, 2.6vw, 2rem) 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: color .35s;
}

/* Hover: accent fill wipes in from below and out through the top */
.project__toggle::before {
  content: "";
  position: absolute;
  inset: 0 calc(var(--fill-pad) * -1);
  z-index: -1;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform .6s var(--ease-in-out);
}

.project__title {
  font-size: clamp(1.75rem, 4.4vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.04em;
  transition: transform .6s var(--ease-out);
}
.project__line {
  grid-column: 1;
  max-width: 60ch;
  color: var(--muted);
  font-size: clamp(1rem, 1.3vw, 1.125rem);
  line-height: 1.4;
  transition: color .35s;
}
.project__icon {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 2;
  width: clamp(2.25rem, 3.5vw, 2.9rem);
  aspect-ratio: 1;
  border: 1px solid currentColor;
  border-radius: 50%;
  transition: transform .6s var(--ease-in-out);
}
.project__icon::before,
.project__icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38%;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}
.project__icon::after { transform: translate(-50%, -50%) rotate(90deg); }

.project.is-open .project__icon { transform: rotate(135deg); }

@media (hover: hover) {
  .project__toggle:hover { color: var(--on-accent); }
  .project__toggle:hover::before {
    transform: scaleY(1);
    transform-origin: 50% 100%;
  }
  .project__toggle:hover .project__title { transform: translateX(.3em); }
  .project__toggle:hover .project__line { color: color-mix(in oklab, var(--on-accent) 78%, var(--accent)); }
}

/* Expanding panel: animates grid rows from 0fr to 1fr */
.project__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .7s var(--ease-in-out);
}
.project.is-open .project__panel { grid-template-rows: 1fr; }
.project__panel-inner { min-height: 0; overflow: hidden; }

.project__content {
  display: grid;
  gap: 1.5rem 3rem;
  padding: .5rem 0 clamp(1.75rem, 3vw, 2.5rem);
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity .35s, transform .7s var(--ease-out);
}
.project.is-open .project__content {
  opacity: 1;
  transform: none;
  transition-delay: .18s;
}

@media (min-width: 64em) {
  .project__content {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: start;
  }
}

.project__desc { max-width: 44ch; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: 1.25rem;
  font-size: .7rem;
}
.tags li {
  padding: .35em .8em;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.project__links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  margin-top: 1.25rem;
}
.project__links a {
  color: var(--accent-text);
  text-decoration: none;
}
@media (hover: hover) {
  .project__links a:hover { text-decoration: underline; }
}

.project__media img {
  width: 100%;
  height: auto;
  border-radius: 4px;
}


/* ---------- Gallery ---------- */

.gallery-section { padding-block: calc(var(--space-section) / 2); }
.section--head { padding-block: 0 1.5rem; }
.gallery-hint { padding-top: .5em; color: var(--muted); }

.gallery {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 1rem;
  cursor: grab;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  -webkit-user-select: none;
  user-select: none;
}
.gallery:focus-visible { outline-offset: -2px; }
.gallery.is-dragging { cursor: grabbing; }

.gallery__track {
  display: flex;
  gap: clamp(.6rem, 1.2vw, 1rem);
  width: max-content;
  /* line the first photo up with the page content, bleed off the right edge */
  padding-inline: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
}

.gallery__btn {
  display: block;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background: var(--line);
  cursor: inherit;
}
.gallery__btn img {
  width: auto;
  height: var(--thumb-h);
  transition: transform .9s var(--ease-out);
  -webkit-user-drag: none;
}
@media (hover: hover) {
  .gallery__btn:hover img { transform: scale(1.05); }
}

.gallery-empty {
  padding: 2rem;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .8rem;
}


/* ---------- Lightbox ---------- */

.lightbox {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: var(--ink);
  color: var(--paper);
}
.lightbox { touch-action: pinch-zoom; overscroll-behavior: contain; }
.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.lightbox::backdrop { background: transparent; }

.lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--gutter);
}
.lightbox__count { opacity: .7; font-variant-numeric: tabular-nums; }

.lightbox__stage {
  display: grid;
  place-items: center;
  min-height: 0;
  padding-inline: var(--gutter);
  touch-action: pinch-zoom;
}
.lightbox__img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  -webkit-user-select: none;
  user-select: none;
}

.lightbox__caption {
  flex: 1;
  text-align: center;
  text-transform: none;
  letter-spacing: .02em;
  font-size: .85rem;
  line-height: 1.4;
}

.lightbox__btn {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid color-mix(in oklab, var(--paper) 30%, transparent);
  border-radius: 50%;
  background: none;
  color: var(--paper);
  cursor: pointer;
  transition: background-color .3s, border-color .3s, color .3s;
}
.lightbox__btn svg {
  width: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (hover: hover) {
  .lightbox__btn:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--ink);
  }
}
.lightbox__btn[hidden] { visibility: hidden; display: grid; }


/* ---------- Contact ---------- */

.contact__heading {
  max-width: 20ch;
  font-size: clamp(1.75rem, 4.2vw, 3.5rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -.035em;
}

.contact__email-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.25rem;
  margin-top: clamp(1.75rem, 3.5vw, 2.75rem);
}
.contact__email {
  font-size: clamp(1.3rem, 4.4vw, 3.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
  text-decoration-color: var(--accent);
  text-decoration-thickness: .07em;
  text-underline-offset: .14em;
  transition: color .3s;
}
@media (hover: hover) {
  .contact__email:hover { color: var(--accent); }
}

.copy-btn {
  padding: .5em 1em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  cursor: pointer;
  transition: border-color .3s, background-color .3s, color .3s;
}
@media (hover: hover) {
  .copy-btn:hover { border-color: var(--fg); }
}
.copy-btn.is-done {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.contact__links {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 2rem;
  margin-top: clamp(2rem, 4vw, 3rem);
  font-size: .8rem;
}
.contact__links a {
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
  padding-bottom: 3px;
  transition: background-size .45s var(--ease-out);
}
@media (hover: hover) {
  .contact__links a:hover { background-size: 100% 1px; }
}


/* ---------- Footer ---------- */

/* The page is a sheet with rounded bottom corners. On screens tall enough, the footer is
   pinned underneath it, so scrolling to the end lifts the page off and reveals it. */
main {
  position: relative;
  z-index: 1;
  overflow-x: clip; /* nothing (like the flying photo sticker) may widen the page */
  padding-bottom: calc(var(--space-section) / 2);
  border-radius: 0 0 var(--sheet-radius) var(--sheet-radius);
  background: var(--bg);
  box-shadow: 0 1.5rem 3rem -1.5rem rgb(0 0 0 / .45);
}
:root { --sheet-radius: clamp(1.5rem, 4vw, 3rem); }

.site-footer {
  /* Gradient built from the palette: near-black, through ember, into vermilion,
     with a soft glow at the bottom. Always dark, in both themes. */
  --footer-base: var(--ink);
  --ember: color-mix(in oklab, var(--accent) 38%, var(--footer-base));
  --glow: color-mix(in oklab, var(--accent) 72%, var(--paper));
  position: relative;
  overflow: hidden;
  margin-top: calc(var(--sheet-radius) * -1); /* tuck under the page's rounded corners */
  padding-top: var(--sheet-radius);
  color: var(--paper);
  background:
    radial-gradient(60% 50% at 50% 100%, color-mix(in oklab, var(--glow) 70%, transparent) 0%, transparent 100%),
    linear-gradient(180deg, var(--footer-base) 0%, var(--footer-base) 32%, var(--ember) 62%, var(--accent) 100%);
}
/* In dark mode the page is near-black too, so the footer starts a touch warmer to show the edge. */
:root[data-theme="dark"] .site-footer { --footer-base: color-mix(in oklab, var(--ink) 88%, var(--accent)); }

/* Fine grain over the gradient: looks printed and hides colour banding. */
.site-footer::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Pinned only on mouse/trackpad devices, and only when it fits on screen (main.js adds
   .is-tall when it doesn't). On touch screens the browser bars resize the viewport while
   scrolling, so there the footer simply scrolls into view. */
@media (hover: hover) and (pointer: fine) {
  .site-footer:not(.is-tall) {
    position: sticky;
    bottom: 0;
  }
}

.footer__inner {
  position: relative;
  z-index: 1;
  padding-top: clamp(3rem, 7vw, 5.5rem);
}

.footer__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); /* phones: link columns side by side */
  gap: 2.5rem 2rem;
}
.footer__intro { grid-column: 1 / -1; }
@media (min-width: 48em) {
  .footer__top { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
  .footer__intro { grid-column: auto; }
}

.footer__status {
  display: flex;
  align-items: center;
  gap: .7rem;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.1;
}
.footer__star {
  flex-shrink: 0;
  width: .8em;
  color: var(--accent);
}
.footer__meta {
  margin-top: 1rem;
  line-height: 1.8;
  color: color-mix(in oklab, var(--paper) 62%, transparent);
}
.footer__clock {
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

.footer__label {
  margin-bottom: 1rem;
  color: color-mix(in oklab, var(--paper) 55%, transparent);
}
.footer__list {
  display: grid;
  gap: .45rem;
}
.footer__list a {
  font-size: 1.1rem;
  font-weight: 500;
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
  padding-bottom: 2px;
  transition: background-size .45s var(--ease-out), color .3s;
}
.footer__handle {
  display: block;
  margin-top: .1rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: .02em;
  color: color-mix(in oklab, var(--paper) 55%, transparent);
}
@media (hover: hover) {
  .footer__list a:hover {
    color: var(--accent);
    background-size: 100% 1px;
  }
}

.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: clamp(3rem, 6vw, 5rem);
  padding-top: 1.25rem;
  border-top: 1px solid color-mix(in oklab, var(--paper) 18%, transparent);
  color: color-mix(in oklab, var(--paper) 62%, transparent);
}
.footer__bottom a { text-decoration: none; }
@media (hover: hover) {
  .footer__bottom a:hover { color: var(--paper); }
}

/* The giant name: sized by main.js to fill the width, cropped by the bottom edge. */
.footer__wordmark {
  position: relative;
  z-index: 1;
  margin-top: clamp(1.5rem, 4vw, 3rem);
  margin-bottom: -.06em;
  padding-inline: var(--gutter);
  line-height: 0;
  white-space: nowrap;
}
.footer__wordmark-inner {
  display: inline-block;
  font-size: calc((100vw - 2 * var(--gutter)) / 6.9); /* first guess; main.js refines it */
  font-weight: 800;
  line-height: .78;
  letter-spacing: -.055em;
  margin-left: -.04em;
  color: var(--paper);
}
/* Each word is its own mask, so rising letters only appear inside their own line. */
.footer__word {
  display: inline-block;
  vertical-align: top;
  overflow: clip;
  padding: .14em .06em .22em;
  margin: -.14em -.06em -.22em;
}
.footer__letter { display: inline-block; }

@media (max-width: 40em) {
  .footer__word { display: block; } /* two lines on phones, so it can be bigger */
}

.load-error {
  max-width: 40rem;
  margin: 30vh auto 0;
  padding: 0 var(--gutter);
  font-family: var(--font-mono);
  font-size: .9rem;
}


/* ---------- Custom cursor (mouse and trackpad only; see initCursor in main.js) ---------- */

html.has-cursor,
html.has-cursor * { cursor: none !important; }

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  pointer-events: none;
}
html:not(.has-cursor) .cursor { display: none; }

.cursor__dot,
.cursor__ring {
  position: fixed;
  top: 0;
  left: 0;
  transition: opacity .25s;
}
.cursor.is-hidden .cursor__dot,
.cursor.is-hidden .cursor__ring { opacity: 0; }

/* Dot: exact position. The halo keeps it visible on vermilion too. */
.cursor__dot {
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
  transition: opacity .25s, scale .35s var(--ease-out);
}

/* Ring: trails the pointer; main.js rotates and stretches it with speed. */
.cursor__shape {
  position: absolute;
  top: -20px;
  left: -20px;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--fg);
  border-radius: 50%;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--bg) 55%, transparent);
  transition:
    width .45s var(--ease-out), height .45s var(--ease-out),
    top .45s var(--ease-out), left .45s var(--ease-out),
    background-color .3s, border-color .3s, scale .3s var(--ease-out);
}

.cursor__label {
  position: absolute;
  top: 0;
  left: 0;
  translate: -50% -50%;
  scale: .5;
  opacity: 0;
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity .25s, scale .45s var(--ease-out);
}

.cursor__glove {
  position: absolute;
  top: -30px;
  left: -24px;
  width: 52px;
  max-width: none; /* the cursor's container has no width, so the global max-width: 100% would squash it */
  overflow: visible;
  rotate: -20deg;
  scale: .4;
  opacity: 0;
  transition: opacity .25s, scale .4s var(--ease-out);
}

/* Over links and buttons: a bigger, softly filled ring. */
.cursor[data-mode="hover"] .cursor__shape {
  top: -32px;
  left: -32px;
  width: 64px;
  height: 64px;
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 14%, transparent);
}

/* Projects, gallery, lightbox: a solid bubble with a label ("Open", "View", "Drag"...). */
.cursor[data-mode="label"] .cursor__shape {
  top: -44px;
  left: -44px;
  width: 88px;
  height: 88px;
  border-color: var(--fg);
  background: var(--fg);
}
.cursor[data-mode="label"] .cursor__label {
  opacity: 1;
  scale: 1;
}

/* Over the photo sticker: the cartoon glove. */
.cursor[data-mode="glove"] .cursor__shape {
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-width: 0;
}
.cursor[data-mode="glove"] .cursor__glove {
  opacity: 1;
  scale: 1;
}
.cursor.is-busy .cursor__glove { opacity: 0; }

.cursor[data-mode="hover"] .cursor__dot,
.cursor[data-mode="label"] .cursor__dot,
.cursor[data-mode="glove"] .cursor__dot { scale: 0; }

/* Pressed */
.cursor.is-down .cursor__shape { scale: .85; }
.cursor.is-down .cursor__glove { scale: .85; }

/* Over the always-dark footer and lightbox: light colours. Over the vermilion strip: dark dot. */
.cursor[data-tone="dark"] {
  --fg: var(--paper);
  --bg: var(--ink);
}
.cursor[data-tone="accent"] .cursor__dot { background: var(--fg); }

/* High-contrast mode: back to the system cursor. */
@media (forced-colors: active) {
  html.has-cursor,
  html.has-cursor * { cursor: auto !important; }
  .cursor { display: none; }
}


/* ---------- Phones and tablets ---------- */

/* No grey flash when tapping links and buttons. */
a, button, summary { -webkit-tap-highlight-color: transparent; }

/* Bigger tap targets on touch screens (invisible padding, same look). */
@media (pointer: coarse) {
  .nav a { padding-block: .9rem; }
  .contact__links a,
  .footer__bottom a { display: inline-block; padding-block: .45rem; }
  .footer__list { gap: 0; }
  .footer__list a { display: inline-block; padding-block: .3rem; }
}

/* Phones: the email must fit on one line instead of breaking mid-word. */
@media (max-width: 40em) {
  .contact__email { font-size: clamp(1rem, 5.4vw, 1.5rem); }
}

/* Tablets held upright: keep the photo, name and buttons together instead of leaving a
   half-empty screen between the photo (top corner) and the name (bottom). */
@media (min-width: 40em) and (max-width: 63.99em) and (orientation: portrait) {
  .hero {
    min-height: 0;
    padding-top: calc(var(--header-h) + 3rem + var(--sticker-size));
  }
}

/* Fallbacks for older phone browsers (iOS 15 and earlier). Modern browsers skip these. */
@supports not (overflow: clip) {
  body, main { overflow-x: hidden; }
}
@supports not (height: 1svh) {
  .hero { --name-size: clamp(3.5rem, min(20vw, 25vh), 18.5rem); }
}
@supports not (color: color-mix(in oklab, red, blue)) {
  :root { --muted: #6E6A63; --line: #D6D1C7; --accent-text: #B8380F; }
  :root[data-theme="dark"] { --muted: #A39E95; --line: #3A3835; --accent-text: var(--accent); }
  .site-footer { background: linear-gradient(180deg, var(--ink) 30%, #6B2A17 62%, var(--accent) 100%); }
}


/* ---------- Lenis (smooth scroll) ---------- */

html.lenis, html.lenis body { height: auto; }
.lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
.lenis [data-lenis-prevent],
.lenis [data-lenis-prevent-horizontal] { overscroll-behavior: contain; }
.lenis.lenis-smooth iframe { pointer-events: none; }

html.is-locked { overflow: hidden; }


/* ---------- Reduced motion ---------- */

/* No transitions or animations at all. (A tiny duration like .01ms would turn every
   property change into a transition, which breaks size measurements in main.js.) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
