/* ============================================================================
   LAYOUT — app bar, the snapping scroller, sections, peek rails, responsive.

   The vertical maths, in one place:
     scroller height   = 100dvh - app bar
     section height    = scroller height - 2 rails
     section snap edge = one rail down from the top of the scroller
   Keep those three in step and a snapped section always sits exactly between
   the two rails.
   ========================================================================= */

body {
  height: 100vh; /* fallback for browsers without dvh */
  height: 100dvh;
}

/* ---- App bar ------------------------------------------------------------ */

.appbar {
  flex: none;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 var(--gutter);
  background: var(--bg);
}

.appbar__brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.appbar__actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.appbar__link {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 8px 4px;
}

/* ---- Scroller ----------------------------------------------------------- */

.scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

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

/* Every section spans the screen and starts at --gutter, the same left edge
   as the app bar's name. That shared edge is the anchor every piece of text
   on the page hangs off. */
.section {
  min-height: calc(100dvh - var(--appbar-h) - (2 * var(--rail-h)));
  padding: clamp(28px, 5vw, 48px) var(--gutter);
  display: flex;
  flex-direction: column;
  justify-content: center;
  scroll-snap-align: start;
  scroll-margin-top: var(--rail-h);
  transition: opacity 0.4s ease;
}

/* Sections other than the one you are reading fade back. Applied by
   js/nav.js, so with JavaScript off everything stays fully legible. */
.section.is-inactive {
  opacity: 0.32;
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

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

.hero {
  display: flex;
  flex-wrap: wrap-reverse; /* photo moves above the text when it wraps */
  align-items: center;
  gap: 48px;
  /* The text starts at the anchor; this keeps the photo a readable distance
     from it instead of drifting to the far side of a wide screen. */
  max-width: var(--content-max);
}

.hero__text {
  flex: 1 1 380px;
  min-width: 260px;
}

.hero__photo {
  flex: 0 0 auto;
}

.hero__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 14px 0 18px;
}

.hero__role {
  font-size: 17px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 22px;
}

.hero__blurb {
  font-size: 16px;
  line-height: 1.65;
  color: var(--fg-body);
  max-width: 520px;
  margin-bottom: 28px;
}

/* ---- Peek rails ---------------------------------------------------------
   Sticky children of the scroller: they float over the sections without ever
   becoming snap targets. The top one is also the "back one section" button.
   ------------------------------------------------------------------------ */

.peek {
  position: sticky;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: var(--rail-h);
  padding: 0 var(--gutter);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--fg-faint);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(8px);
  transition: color 0.2s ease;
}

.peek--up {
  top: 0;
}

.peek--down {
  bottom: 0;
}

.peek:hover {
  color: var(--fg-muted);
}

/* At the first / last section there is nothing to preview. Hide the rail but
   keep its space, so the sections never shift under the reader. */
.peek.is-off {
  visibility: hidden;
}

.peek[hidden] {
  display: none; /* no JavaScript: no rails, and the anchors still work */
}

.peek__label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 720px) {
  :root {
    --appbar-h: 58px;
    --rail-h: 38px;
  }

  .section {
    padding: 24px var(--gutter);
  }

  /* Keep the whole hero inside one screen so nothing hides under a rail. */
  .hero {
    gap: 22px;
  }

  .hero__name {
    font-size: 34px;
    margin: 10px 0 12px;
  }

  .hero__role {
    font-size: 16px;
    margin-bottom: 16px;
  }

  .hero__blurb {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 22px;
  }

  .peek {
    font-size: 12px;
  }
}

@media (max-width: 400px) {
  .appbar__actions {
    gap: 12px;
  }
}
