/* ---------- Tokens ---------- */
:root {
  --paper: #ffffff;
  --ink: #000000;
  --muted: #6b6b6b;
  --line: #e7e7e7;
  --red: #f64241;       /* sampled from the name graphic */
  --pad: clamp(20px, 4vw, 64px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth;  }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--red); color: #fff; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0 0 12px; }

a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { text-decoration-color: var(--red); }
a:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; border-radius: 2px; }

.wrap {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: var(--pad);
}

/* ---------- Reading progress ---------- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: 3px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---------- Hero ---------- */
.hero { position: relative; height: 340vh; }

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.stage canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.hero-grid {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 32px;
}

.hero-text {
  align-self: center;
  max-width: 640px;
}

.name {
  margin: 0 0 0 -0.04em;
  font-size: clamp(3.2rem, 7.4vw, 8.5rem);
  font-weight: 800;
  font-stretch: 112%;
  line-height: 0.88;
  letter-spacing: -0.035em;
}
.name .line { display: block; overflow: hidden; padding-bottom: 0.06em; }
.name .line > span {
  display: inline-block;
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.1, 1) both;
}
.name .line:nth-child(2) > span { animation-delay: 0.12s; }
.name .dot { font-style: normal; color: var(--red); }

@keyframes rise {
  from { transform: translateY(105%); }
  to   { transform: none; }
}

.lede {
  margin: clamp(24px, 4vh, 40px) 0 16px;
  font-size: clamp(1.15rem, 1.6vw, 1.4rem);
  line-height: 1.45;
  max-width: 36ch;
}

.meta {
  color: var(--muted);
  font-size: 0.95rem;
  padding-left: 14px;
  border-left: 2px solid var(--red);
}

.portrait-slot {
  align-self: end;
  height: min(78vh, 760px);
  margin-bottom: 4vh;
}

.hint {
  position: absolute;
  left: var(--pad);
  bottom: 4vh;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  opacity: calc(1 - var(--p, 0) * 8);
}
.hint span {
  width: 32px;
  height: 1px;
  background: var(--red);
}

.fallback {
  position: absolute;
  right: var(--pad);
  bottom: 4vh;
  height: 78vh;
}

/* ---------- Content blocks ---------- */
main { padding-top: 8vh; }

.block {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 32px;
  padding: 56px 0 72px;
  border-top: 1px solid var(--line);
}

.block > h2 {
  grid-column: 1 / span 3;
  align-self: start;
  position: sticky;
  top: 32px;
  font-size: 1.05rem;
  font-weight: 600;
  font-stretch: 115%;
  display: flex;
  align-items: center;
  gap: 10px;
}
.block > h2::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--red);
  flex: none;
}

.block > .body { grid-column: 4 / span 9; }

.statement {
  font-size: clamp(1.4rem, 2.6vw, 2.2rem);
  line-height: 1.3;
  font-weight: 400;
  letter-spacing: -0.01em;
  max-width: 30ch;
  margin: 0;
}

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px 40px;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.entry:first-child { padding-top: 0; }
.entry:last-child { border-bottom: 0; }
.entry > div:first-child { max-width: 64ch; }

.entry h3, .entry h4 {
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
  font-weight: 600;
  font-stretch: 108%;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.sub { color: var(--muted); font-size: 0.95rem; }

.when {
  margin: 4px 0 0;
  text-align: right;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat { color: var(--muted); font-size: 0.95rem; margin: 0; }
.stat strong { color: var(--ink); font-weight: 600; }

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 14px 0 0;
}
.tags li {
  font-size: 0.8rem;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #333;
}

/* ---------- Galleries (filled by gallery.js) ---------- */
.gallery {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.gallery[hidden] { display: none; }
.gallery[data-count="1"] { grid-template-columns: minmax(0, 720px); }
.gallery[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gallery[data-count="1"] .shot img { aspect-ratio: 16 / 9; }

.mini .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mini .gallery[data-count="1"] { grid-template-columns: 1fr; }

.shot {
  display: block;
  padding: 0;
  border: 0;
  background: var(--line);
  cursor: zoom-in;
  overflow: hidden;
}
.shot:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.shot img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  transition: filter 0.4s ease, transform 0.6s ease;
}
.shot:hover img, .shot:focus-visible img { filter: none; transform: scale(1.02); }

.lightbox {
  max-width: 94vw;
  max-height: 94vh;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}
.lightbox::backdrop { background: rgba(0, 0, 0, 0.88); }
.lightbox img {
  display: block;
  max-width: 94vw;
  max-height: 88vh;
  width: auto;
  height: auto;
}
.lightbox .close {
  position: absolute;
  top: -36px;
  right: 0;
  background: none;
  border: 0;
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--red);
  padding: 0 0 2px;
}

.group {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  margin: 48px 0 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
}

.body > .group:first-child { margin-top: 0; }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 40px;
  border-bottom: 1px solid var(--line);
}
.mini { padding: 24px 0; min-width: 0; }
.mini h4 { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.mini p { color: #333; margin: 0; }

.skills { margin: 0; }
.skills > div {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.skills > div:first-child { padding-top: 0; }
.skills dt { color: var(--muted); }
.skills dd { margin: 0; font-size: 1.15rem; }

/* ---------- Contact ---------- */
.contact {
  background: var(--ink);
  color: #fff;
  padding: 96px 0 40px;
}
.contact h2 {
  font-size: 1.05rem;
  font-weight: 600;
  font-stretch: 115%;
  color: #9a9a9a;
  margin-bottom: 20px;
}
.email {
  display: inline-block;
  font-size: clamp(2rem, 7vw, 6rem);
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.03em;
  line-height: 1;
  text-decoration: none;
  word-break: break-word;
  transition: color 0.2s;
}
.email:hover { color: var(--red); }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 96px;
  padding-top: 20px;
  border-top: 1px solid #2a2a2a;
  font-size: 0.9rem;
  color: #9a9a9a;
}
.foot a:hover { color: #fff; }

/* ---------- Tablet ---------- */
@media (max-width: 1000px) {
  .block > h2 { grid-column: 1 / -1; position: static; }
  .block > .body { grid-column: 1 / -1; }
  .block { gap: 24px; padding: 44px 0 56px; }
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .hero-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    gap: 0;
  }
  .portrait-slot {
    grid-row: 1;
    height: auto;
    margin: 8px 0 0;
    align-self: stretch;
  }
  .hero-text {
    grid-row: 2;
    align-self: end;
    padding-bottom: 9vh;
  }
  .name { font-size: clamp(2.8rem, 15vw, 4.6rem); }
  .lede { margin-top: 16px; font-size: 1.05rem; }
  .meta { display: none; }
  .hint { bottom: 3vh; }

  .entry { grid-template-columns: 1fr; }
  .when { text-align: left; order: -1; margin: 0; }
  .pair { grid-template-columns: 1fr; }
  .gallery, .gallery[data-count] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery[data-count="1"] { grid-template-columns: 1fr; }
  .skills > div { grid-template-columns: 1fr; gap: 2px; }
  .lede { max-width: 26ch; }
  .foot { flex-direction: column; margin-top: 64px; }
}
