:root {
    --ink: #161616;
    --charcoal: #2b2b2b;   /* the sign's dark gray */
    --mute: #8c8c8c;
    --paper: #ffffff;
    --edge: 44px;          /* outer page margin */
    --nav-w: 190px;        /* width of the tab column */
    --head-h: 150px;       /* space taken by the wordmark row */
    --img-max: calc(100vh - var(--head-h) - 140px);   /* tallest a carousel photo can be */
    --font: "Lexend", "Avenir Next", "Century Gothic", system-ui, sans-serif;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: var(--font);
    font-weight: 300;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
  }
  img { display: block; }
  a { color: inherit; }
  .visually-hidden {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }

  /* ---------- Wordmark (upper left) ---------- */
  .site-head {
    height: var(--head-h);
    padding: 0 var(--edge);
    display: flex;
    align-items: center;
  }
  .wordmark {
    font-weight: 600;
    text-transform: uppercase;
    color: var(--charcoal);
    text-decoration: none;
    font-size: clamp(36px, 5.04vw, 83px);
    line-height: 1;
    letter-spacing: 0.01em;
  }

  /* ---------- Page body: tabs + content ---------- */
  .page {
    position: relative;
    z-index: 1;            /* content sits above the contours */
    display: grid;
    grid-template-columns: var(--nav-w) minmax(0, 1fr);
    min-height: calc(100vh - var(--head-h));
  }

  .site-nav { padding: 6px 0 0 var(--edge); }
  .site-nav ul { list-style: none; position: sticky; top: 40px; }
  .site-nav li + li { margin-top: 15px; }
  .site-nav a {
    position: relative;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--mute);
    transition: color 0.2s ease;
  }
  .site-nav a:hover,
  .site-nav a[aria-current="page"] { color: var(--ink); }
  .site-nav a[aria-current="page"]::after {
    content: "";
    display: inline-block;
    vertical-align: middle;
    width: 14px; height: 1px;
    margin-left: 10px;
    background: var(--ink);
  }
  /* easter egg: on the About page, the dash becomes Kai's kanji */
  .site-nav a[href="about.html"][aria-current="page"]::after {
    content: "開";
    width: auto; height: auto;
    background: none;
    vertical-align: baseline;
    font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--ink);
  }

  /* ---------- Carousel ---------- */
  .gallery {
    display: flex;
    flex-direction: column;
    padding-bottom: 40px;
  }
  .viewport {
    position: relative;
    overflow: hidden;
    cursor: grab;
    touch-action: pan-y;
    height: calc(var(--img-max) + 36px);   /* fixed, so Prev/Next never move */
  }
  .viewport.dragging { cursor: grabbing; }
  .track {
    display: flex;
    height: 100%;
    align-items: center;   /* wide photos sit in the middle, not at the top */
    gap: 48px;
    will-change: transform;
    transition: transform 0.75s cubic-bezier(0.22, 0.61, 0.36, 1);
  }
  .track.no-anim { transition: none; }

  .slide {
    flex: 0 0 auto;
    opacity: 0.14;
    transition: opacity 0.6s ease;
    cursor: pointer;
    user-select: none;
  }
  .slide.is-active { opacity: 1; cursor: default; }
  .slide img {
    max-height: var(--img-max);
    /* wide photos stay clear of the tabs now that they center on the window */
    max-width: min(calc(100vw - var(--nav-w) - 200px), calc(100vw - 2 * var(--nav-w) - 56px));
    width: auto;
    height: auto;
    -webkit-user-drag: none;
  }
  .slide figcaption {
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--mute);
    opacity: 0;
    transition: opacity 0.4s ease 0.2s;
  }
  .slide.is-active figcaption { opacity: 1; }
  .slide figcaption .title { color: var(--ink); }
  .slide figcaption a { text-decoration: none; }
  .slide figcaption a:hover { color: var(--ink); }

  .gallery-controls {
    position: relative;
    left: calc(var(--nav-w) / -2);   /* line up with the window's center, under the photo */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 36px;
    margin-top: 22px;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--mute);
  }
  .gallery-controls button {
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: var(--mute);
    background: none;
    border: 0;
    padding: 8px 0;
    cursor: pointer;
    transition: color 0.2s ease;
  }
  .gallery-controls button:hover { color: var(--ink); }
  .counter { color: var(--ink); font-variant-numeric: tabular-nums; min-width: 64px; text-align: center; }

  /* ---------- Footer with topographic lines ---------- */
  .site-foot {
    position: relative;
    z-index: 0;
    height: 380px;
    margin-top: -150px;    /* top of the footer peeks into the first screen */
    overflow: hidden;
  }
  #topo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.9s ease;
    /* lines emerge from the page rather than starting at a hard edge */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.6) 28%, #000 70%);
            mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.6) 28%, #000 70%);
  }
  .foot-text {
    position: absolute;
    z-index: 1;
    left: var(--edge);
    right: var(--edge);
    bottom: 32px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;   /* copyright centered, icon in the corner */
    align-items: center;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--mute);
  }
  .foot-text .copyright { grid-column: 2; grid-row: 1; }
  .foot-social, .foot-full {
    display: block;
    width: 16px; height: 16px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--mute);
    cursor: pointer;
    transition: color 0.2s ease;
  }
  .foot-links { grid-column: 1; grid-row: 1; justify-self: start; display: flex; gap: 14px; }   /* bottom-left */
  .foot-full   { grid-column: 3; grid-row: 1; justify-self: end; }     /* bottom-right */
  .foot-social:hover, .foot-full:hover { color: var(--ink); }
  .foot-social svg, .foot-full svg { display: block; width: 100%; height: 100%; }
  .foot-lb { width: 24px; display: flex; align-items: center; }
  .foot-lb svg { height: auto; }
  .foot-full .icon-exit { display: none; }
  .is-fullscreen .foot-full .icon-enter { display: none; }
  .is-fullscreen .foot-full .icon-exit { display: block; }
  .foot-full[hidden] { display: none; }

  /* ---------- Small screens ---------- */
  @media (max-width: 760px) {
    :root { --edge: 20px; --head-h: 96px; --nav-w: 0px; --img-max: 64vh; }
    .wordmark { font-size: 9.54vw; }
    .page { display: block; }
    .site-nav { padding: 0 var(--edge) 28px; }
    .site-nav ul { position: static; display: flex; flex-wrap: wrap; gap: 18px; }
    .site-nav li + li { margin-top: 0; }
    .site-nav a { font-size: 10px; letter-spacing: 0.16em; }
    .site-nav a[aria-current="page"]::after { display: none; }
    .site-nav a[aria-current="page"] { border-bottom: 1px solid var(--ink); padding-bottom: 4px; }
    .track { gap: 20px; }
    .slide img { max-width: calc(100vw - 56px); }
    .site-foot { height: 300px; margin-top: -110px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .track, .slide, .slide figcaption, #topo { transition: none; }
  }

/* ---------- About page ---------- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 46ch) auto;   /* text left, photo right */
  gap: 64px;
  align-items: center;
  justify-content: center;
  padding: 0 56px 40px 0;
}
.about figure img {
  max-height: calc((100vh - var(--head-h) - 140px) * 0.82);
  max-width: 100%;
  width: auto;
  height: auto;
}
.about figcaption {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mute);
}
.about h2 {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 22px;
}
.about p {
  font-size: 14px;
  line-height: 1.8;
  color: var(--charcoal);
}
.about p + p { margin-top: 1.2em; }

@media (max-width: 1000px) {
  .about { grid-template-columns: minmax(0, 1fr); gap: 36px; padding-right: var(--edge); }
  .about figure img { max-height: 57vh; }
}
@media (max-width: 760px) {
  .about { padding: 0 var(--edge) 40px; }
  .about figure img { max-height: 51vh; }
  .about p { font-size: 13px; }
}

/* ---------- Full-screen mode: just the photos ---------- */
.is-fullscreen {
  --head-h: 0px;
  --nav-w: 0px;
  --img-max: calc(100vh - 150px);
}
.is-fullscreen .site-head,
.is-fullscreen .site-nav { display: none; }
.is-fullscreen .page {
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
  padding-top: 40px;
}
.is-fullscreen .about { padding-left: var(--edge); }
.is-fullscreen .copyright,
.is-fullscreen .foot-links { visibility: hidden; }
.is-fullscreen .site-foot { z-index: auto; }   /* lets the exit button sit above the photos */
/* keep the exit button in view without scrolling */
.is-fullscreen .foot-full {
  position: fixed;
  right: var(--edge);
  bottom: 28px;
  z-index: 30;
}

/* ---------- Steady sizes on phones ----------
   Phone browsers shrink their address bar as you scroll, which changes "vh"
   and made photos grow mid-scroll. "svh" stays fixed, so use it where supported. */
@supports (height: 1svh) {
  :root { --img-max: calc(100svh - var(--head-h) - 140px); }
  .page { min-height: calc(100svh - var(--head-h)); }
  .about figure img { max-height: calc((100svh - var(--head-h) - 140px) * 0.82); }
  @media (max-width: 1000px) { .about figure img { max-height: 57svh; } }
  @media (max-width: 760px)  { :root { --img-max: 64svh; } }
  .is-fullscreen { --img-max: calc(100svh - 150px); }
  .is-fullscreen .page { min-height: 100svh; }
}

/* About on narrow screens: photo centered under the bio, sized by width (not screen height) */
@media (max-width: 1000px) {
  .about figure { justify-self: center; }
}
@media (max-width: 760px) {
  .about figure { width: 100%; text-align: center; }
  .about figure img { width: min(100%, 320px); max-height: none; margin: 0 auto; }
}

/* ---------- 404 page ---------- */
.notfound {
  display: flex;
  flex-direction: column;
  padding: 0 var(--edge) 40px 0;   /* top-aligned with the tabs, like the photos */
}
.notfound-code {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--mute);
  margin-bottom: 18px;
}
.notfound h1 {
  font-weight: 600;
  text-transform: uppercase;
  color: var(--charcoal);
  font-size: clamp(28px, 3.2vw, 46px);
  line-height: 1.1;
  letter-spacing: 0.01em;
}
.notfound p:not(.notfound-code) {
  margin-top: 18px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--charcoal);
}
.notfound-link {
  margin-top: 28px;
  align-self: flex-start;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 4px;
}
.notfound-link:hover { color: var(--mute); border-color: var(--mute); }
@media (max-width: 760px) {
  .notfound { padding: 0 var(--edge) 40px; }
}
