/* Scroll-choreographed home layout.
   site.css supplies the palette, Courier Prime and the existing card design.
   This file places the settled one-screen layout and the 450dvh sticky
   scroller. The only motion is transform + opacity, driven by scroll.js. */

:root {
  --gutter: 24px;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  /* "clip" prevents sideways scrolling without turning body into a scroll
     container (which would break the sticky stage). */
  overflow-x: clip;
}

/* Without JS this is simply the settled one-screen layout. */

[data-scroller] {
  position: relative;
}

[data-stage] {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

/* The script adds .js only after it has measured the settled layout. */

.js [data-scroller] {
  height: 450dvh;
}

.js [data-stage] {
  position: sticky;
  top: 0;
}

/* One centred column; every child shares these left and right edges. */

.page {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(24px + env(safe-area-inset-top, 0px)) var(--gutter)
    calc(20px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

.item {
  transform-origin: 50% 50%;
}

/* The name keeps its own box so scaling happens around the visible letters.
   No compositor layer here: will-change on scaled text makes it blurry. */

.hero-name {
  flex: none;
  width: fit-content;
  max-width: 100%;
  font-size: 32px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.tagline {
  --rest-opacity: 0.7;
  flex: none;
  margin-top: 6px;
  font-size: 14px;
  font-style: italic;
  line-height: 1.35;
  opacity: var(--rest-opacity);
}

.details {
  flex: none;
  width: fit-content;
  max-width: 100%;
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail {
  font-size: 13px;
  line-height: 1.35;
}

.detail-dob {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.detail-email a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

/* One animated row of four equal tiles. */

.social-row {
  flex: none;
  margin-top: 20px;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.social-cell {
  display: flex;
  min-width: 0;
}

.tile {
  width: 100%;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(0, 0, 0, 0.04);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-align: center;
}

/* The grid absorbs the remaining height so the last row always ends at least
   the 20px bottom gutter (and therefore 16px) above the viewport bottom. */

.project-grid {
  flex: 1 1 0;
  min-height: 0;
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px;
}

.card-cell {
  display: flex;
  min-width: 0;
  min-height: 0;
}

/* Keep every typographic treatment from site.css; only fit the card frame
   into its grid cell (reduced padding, clipped overflow, full size). */

.project-grid .item:nth-child(n) > .card {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 10px 8px;
  display: grid;
  align-content: center;
  justify-items: stretch;
  overflow: hidden;
  opacity: 1;
  transform: none;
  animation: none;
}

/* Only animated surfaces get a compositor layer - never the scaled name. */

[data-socials],
.card-cell {
  will-change: transform, opacity;
}

@media (max-width: 359px) {
  .tile {
    font-size: 9px;
  }
}

/* Reduced motion / JS failure: the settled page, with no extra scroll.
   .force-motion is added by the engine when ?p= is used for inspection. */

@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) [data-scroller] {
    height: auto;
  }

  html:not(.force-motion) [data-stage] {
    position: relative;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  html:not(.force-motion) .page {
    height: auto;
    min-height: 100dvh;
  }

  html:not(.force-motion) .item {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
  }
}
