/* Princeps — one sheet, no scroll. Layout and type after contourholdings.ai. */

:root {
  --bg: #f8f6f1; /* near-white, faintly warm (tried #f4efe4, #efe7d6 cream; original #faf9f7) */
  --ink: #1c2a27;
  --dim: rgba(28, 42, 39, 0.55);
  --statement: rgba(28, 42, 39, 0.88);
  --hover: rgba(28, 42, 39, 0.8);
  --pad: 24px;
  --a4: 1.4142; /* landscape A4: 297 / 210 */
}

/* Alternative sheet: the chip painting is the page, the type sits on it in warm paper ink. */
:root[data-theme='chip'] {
  --bg: #0b0806;
  --ink: #f4ece0;
  --dim: rgba(244, 236, 224, 0.62);
  --statement: rgba(244, 236, 224, 0.92);
  --hover: rgba(244, 236, 224, 0.85);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100vh;
  height: 100dvh;
  position: relative;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter Tight', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Plate (landing) ---------- */

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  /* the plate sits in the space between the header and the statement */
  padding: 84px var(--pad) 128px;
  pointer-events: none;
}

.plate {
  --w: min(100vw - 2 * var(--pad), (100dvh - 212px) * var(--a4), 1680px);
  width: var(--w);
  height: calc(var(--w) / var(--a4));
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.8s ease-out;
}

.plate img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  transform: scale(1.04);
  transition: transform 6s cubic-bezier(0.2, 0.7, 0.2, 1);
  -webkit-user-drag: none;
}

html.ready .plate {
  opacity: 1;
}
html.ready .plate img {
  transform: scale(1);
}

/* ---------- Full-bleed (chip) ---------- */

.bleed {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.8s ease-out;
}
.bleed img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 53%; /* keeps the die on the page's centre */
  transform: scale(1.09);
  transition: transform 8s cubic-bezier(0.2, 0.7, 0.2, 1);
  -webkit-user-drag: none;
}
/* a soft shade at top and bottom so the type reads on the painting */
.bleed::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0) 18%),
    linear-gradient(rgba(0, 0, 0, 0) 72%, rgba(0, 0, 0, 0.55) 100%);
}
html.ready .bleed {
  opacity: 1;
}
html.ready .bleed img {
  transform: scale(1.04); /* stays slightly over-scaled to hide the canvas edge */
}

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

.top,
.bottom {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: var(--pad);
  user-select: text;
  -webkit-user-select: text;
}
.top {
  top: 0;
  align-items: flex-start;
}
.bottom {
  bottom: 0;
  align-items: flex-end;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.group.right {
  align-items: flex-end;
  text-align: right;
}

.logo {
  display: block;
  line-height: 0;
}
.logo img {
  height: 26px;
  width: auto;
  display: block;
  -webkit-user-drag: none;
}

.label {
  font: 400 12px/1.2 'Inter Tight', system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}
.dim {
  color: var(--dim);
}
a.label {
  transition: color 0.2s ease;
}
a.label:hover {
  color: var(--hover);
}
.at {
  position: relative;
  top: -0.11em;
}

.statement {
  font: 400 24px/1.35 'Inter Tight', system-ui, sans-serif;
  letter-spacing: -0.005em;
  color: var(--statement);
  max-width: 38ch;
}

.backed {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.yc {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  background: #f26625;
  color: #fff;
  font: 700 13px/1 'Inter Tight', system-ui, sans-serif;
  letter-spacing: 0;
  text-decoration: none;
  transition: opacity 0.2s ease;
}
.yc:hover {
  opacity: 0.8;
}

/* ---------- Menu ---------- */

.menu-button {
  position: relative;
  width: 18px;
  height: 18px;
  margin-top: 4px;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.menu-button span {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: currentColor;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}
.menu-button span:nth-child(1) {
  top: 4px;
}
.menu-button span:nth-child(2) {
  top: 9px;
}
.menu-button span:nth-child(3) {
  top: 14px;
}
html.menu-open .menu-button span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}
html.menu-open .menu-button span:nth-child(2) {
  opacity: 0;
}
html.menu-open .menu-button span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

.right-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}
.menu {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}
html.menu-open .menu {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  :root {
    --pad: 18px;
  }
  .logo img {
    height: 20px;
  }
  .statement {
    font-size: 19px;
  }
  .bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .bottom .group.right {
    align-items: flex-start;
  }
  .stage {
    padding-bottom: 150px;
  }
  .plate {
    --w: min(100vw - 2 * var(--pad), (100dvh - 234px) * var(--a4));
  }
}

@media (prefers-reduced-motion: reduce) {
  .plate,
  .bleed,
  .plate img,
  .bleed img {
    transition: none;
    transform: none;
  }
}

/* ---------- Fill variant (fill.html): the plate takes the whole sheet bar a paper margin ---------- */

html[data-layout='fill'] .stage {
  padding: 74px 3cm 112px var(--pad); /* 3cm of paper on the right (CSS cm ≈ 113px) */
  place-items: stretch;
}
html[data-layout='fill'] .plate {
  width: 100%;
  height: 100%;
}
html[data-layout='fill'] .plate img {
  object-position: 50% 42%;
}
@media (max-width: 640px) {
  html[data-layout='fill'] .stage {
    padding: 60px var(--pad) 138px;
  }
}

/* ---------- Mission (mission.html): a short column on the chip painting ---------- */

/* pages cross-fade into one another (Chrome, Safari 18.2+; others just navigate) */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.6s;
}

/* shade the left of the painting so the column reads; the die stays bright */
html[data-page='mission'] .bleed::after {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.5) 38%, rgba(0, 0, 0, 0) 68%),
    linear-gradient(rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0) 18%),
    linear-gradient(rgba(0, 0, 0, 0) 72%, rgba(0, 0, 0, 0.55) 100%);
}
/* header in the PRINCEPS wordmark's face (Archivo Expanded 500, matched by overlay):
   two lines max, sized so line one (~20em) spans the width, set at the vertical centre */
/* header + copy stack in one flow so the header always clears the copy, whatever the height */
.mission-sheet {
  position: absolute;
  z-index: 5;
  inset: clamp(56px, 10vh, 120px) var(--pad) 72px;
  display: flex;
  flex-direction: column;
  justify-content: center; /* copy sits at the vertical centre */
  pointer-events: none;
}
.mission-sheet > * {
  pointer-events: auto;
}
/* header back at its original spot: centred, then lifted 8cm */
.mission-title {
  position: fixed; /* measured from the window, exactly as before */
  left: var(--pad);
  top: 50%;
  transform: translateY(calc(-50% - 8cm));
  font-family: 'Archivo', system-ui, sans-serif;
  font-stretch: 125%;
  font-weight: 500;
  font-size: calc((100vw - 2 * var(--pad)) / 22);
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ink);
  user-select: text;
  -webkit-user-select: text;
}
.mission-title span {
  display: block;
  white-space: nowrap;
}
html[data-page='mission'] .top > a.label,
html[data-page='contact'] .top > a.label {
  margin-top: 6px;
}

.mission {
  max-width: min(560px, 100vw - 2 * var(--pad));
  color: var(--ink);
  user-select: text;
  -webkit-user-select: text;
  opacity: 0;
  transition: opacity 1.4s ease-out 0.4s;
}
html.ready .mission {
  opacity: 1;
}
.mission-lead {
  font: 400 28px/1.3 'Inter Tight', system-ui, sans-serif;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.mission-body {
  margin-top: 24px;
  font: 400 19px/1.45 'Inter Tight', system-ui, sans-serif;
  color: var(--statement);
}
.mission-close {
  margin-top: 28px;
  font: 400 19px/1.45 'Inter Tight', system-ui, sans-serif;
  color: var(--statement);
  text-wrap: pretty;
}

@media (max-width: 640px) {
  html[data-page='mission'] .bleed::after {
    background: rgba(0, 0, 0, 0.55);
  }
  .mission {
    max-width: none;
  }
  .mission-title span {
    white-space: normal;
  }
  .mission-lead {
    font-size: 22px;
  }
  .mission-body,
  .mission-close {
    font-size: 16px;
  }
}

/* the one-line statement set in capitals, in STIX Two Math (self-hosted, OFL) */
@font-face {
  font-family: 'STIX Two Math';
  src: url('assets/fonts/STIXTwoMath.otf') format('opentype');
  font-weight: 400;
  font-display: block;
}
.statement.caps {
  font-family: 'STIX Two Math', 'STIX Two Text', Georgia, serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 26px;
  max-width: none;
}
@media (max-width: 640px) {
  .statement.caps {
    font-size: 19px;
  }
}

/* ---------- PRINCEPS across the foot of the plate (fill.html), as in Figma frame 2147239880 ----------
   Subtract.svg: white letters at 20% fill, added onto the painting (plus-lighter). In the 1413 × 1024 frame
   it sits 46px in from the left and 36px up from the bottom, 1327px wide. */
.plate {
  position: relative;
}
.plate img.wordmark {
  position: absolute;
  left: 3.25%;
  bottom: 3.5%;
  width: 93.9%;
  height: auto;
  object-fit: initial;
  transform: none;
  transition: none;
  mix-blend-mode: plus-lighter;
}

/* ---------- Circuit board on the paper (fill.html, drawn by board.js) ----------
   Union.svg chips and trace bundles in the margins, in the ink at low strength, running under the plate. */
.board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  color: var(--ink);
}
html[data-layout='fill'] .stage {
  z-index: 1;
}
.board-g {
  opacity: 0.34;
}
.board .chip {
  fill: currentColor;
  opacity: 0;
  animation: board-fade 1.2s ease-out var(--d) forwards;
}
.board .trace {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: board-draw 1.4s cubic-bezier(0.4, 0, 0.2, 1) calc(var(--d) + 0.8s) forwards;
}
.board .pad {
  fill: currentColor;
  opacity: 0;
  animation: board-fade 0.6s ease-out calc(var(--d) + 0.8s) forwards;
}
.board.drawn :is(.chip, .trace, .pad) {
  animation: none !important;
  opacity: 1;
  stroke-dashoffset: 0;
}
@keyframes board-draw {
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes board-fade {
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .board :is(.chip, .trace, .pad) {
    animation: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
  }
}

/* ---------- Variant preview label (fill.html?board=…): ← / → or click to cycle ---------- */
.preview-label {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 28px;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: rgba(250, 249, 247, 0.9);
  border: 1px solid rgba(28, 42, 39, 0.12);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

/* ---------- Credits row (fill.html): "As featured in Forbes" beside "Backed by Y", one line ---------- */
.credits {
  display: flex;
  align-items: center;
  gap: 28px;
}
.forbes {
  display: block;
  height: 21px;
  aspect-ratio: 200 / 54;
  background: var(--ink);
  -webkit-mask: url('assets/forbes.svg') center / contain no-repeat;
  mask: url('assets/forbes.svg') center / contain no-repeat;
  transition: opacity 0.2s ease;
}
.forbes:hover {
  opacity: 0.8;
}
@media (max-width: 640px) {
  .credits {
    gap: 20px;
  }
}

/* ---------- Footer row (fill.html): tagline and credits centred in the paper band below the board ---------- */
@media (min-width: 641px) {
  html[data-layout='fill'] .bottom {
    height: 96px; /* the 112px band under the plate, less the ring */
    padding-top: 0;
    padding-bottom: 0;
    align-items: center;
  }
}
.credits .label {
  font: 400 15px/1 'STIX Two Math', 'STIX Two Text', Georgia, serif;
  letter-spacing: 0.06em;
  gap: 10px;
}
.credits .yc {
  width: 25px;
  height: 25px;
  font-size: 16px;
}
.credits {
  gap: 34px;
}

/* footer row on one bottom line: text baselines sit level with the bottoms of the Forbes and Y logos */
@media (min-width: 641px) {
  html[data-layout='fill'] .bottom,
  html[data-layout='fill'] .credits,
  html[data-layout='fill'] .credits .backed {
    align-items: baseline;
  }
  html[data-layout='fill'] .bottom {
    flex-wrap: wrap; /* a wrapping container lets align-content centre the single baseline-aligned line */
    align-content: center;
  }
}
/* the Y is drawn out of flow so the badge's bottom edge, not the letter, sits on the shared baseline */
html[data-layout='fill'] .credits .yc {
  position: relative;
}
html[data-layout='fill'] .credits .yc::after {
  content: 'Y';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

/* Wide screens: the footer becomes a three-column grid laid over the board's geometry
   (plate w = page width − 24px − 3cm; in the footer's content box that is 100% + 24px − 3cm).
   Col 1: tagline. Col 2: between the two bottom buses (0.47w → 0.75w), where the bottom chip was — Forbes centred.
   Col 3: from the right bus to the page edge, where the credits sat — Y Combinator centred. */
@media (min-width: 1200px) {
  html[data-layout='fill'] .bottom {
    --pw: calc(100% + 24px - 3cm);
    display: grid;
    grid-template-columns: calc(0.47 * var(--pw)) calc(0.28 * var(--pw)) 1fr;
    align-items: baseline;
    align-content: center;
    gap: 0;
  }
  html[data-layout='fill'] .credits {
    display: contents;
  }
  html[data-layout='fill'] .credits .backed {
    justify-self: center;
  }
}

/* each label sits on the vertical centre of its logo */
html[data-layout='fill'] .credits .backed {
  align-items: center;
}

/* trim the label's line box to cap-height → baseline, so centring uses the letters, not STIX Two Math's tall
   ascent/descent (which Safari and Chrome read differently) */
html[data-layout='fill'] .credits .lbl {
  display: block;
  line-height: 1;
  text-box: trim-both cap alphabetic;
}

/* Y Combinator: the official logo SVG from ycombinator.com (assets/yc.svg) replaces the CSS-drawn badge */
html[data-layout='fill'] .credits .yc {
  display: block;
  background: url('assets/yc.svg') center / contain no-repeat;
  border-radius: 0;
}
html[data-layout='fill'] .credits .yc::after {
  content: none;
}

/* No-features version (data-board="off"): no buses to centre between, so the footer spans the painting's width —
   tagline left, Forbes centred under the painting, Y Combinator flush with the painting's right edge */
@media (min-width: 1200px) {
  html[data-layout='fill'][data-board='off'] .bottom {
    padding-right: 3cm;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); /* equal side columns: Forbes truly centred */
  }
  html[data-layout='fill'][data-board='off'] .credits .backed:last-child {
    justify-self: end;
  }
}
@media (min-width: 1200px) and (max-width: 1699px) {
  /* too narrow for the tagline to fit half the width: let the side columns size to content, Forbes in the gap */
  html[data-layout='fill'][data-board='off'] .bottom {
    grid-template-columns: auto 1fr auto;
  }
}

/* Trial (landing-bleed-top-left.html): the painting runs off the top and left edges; paper stays below and to the right */
html[data-plate='bleed'] .stage {
  padding: 0 3cm 112px 0;
}


/* tagline letter-spacing opened up (was 0.04em); a touch bigger (was 26px) and lifted slightly off the credits' line */
.statement.caps {
  letter-spacing: 0.12em;
  font-size: 29px;
}
/* the whole footer row lifted 5px together, so tagline, Forbes and Y stay on one line */
@media (min-width: 641px) {
  html[data-layout='fill'] .bottom {
    transform: translateY(-5px);
  }
}
@media (max-width: 640px) {
  .statement.caps {
    font-size: 20px;
  }
}

/* Landing menu: the dropdown starts level with the top edge of the painting (the stage's 74px top padding);
   labels trimmed to cap height so the top of "MISSION" sits exactly on that line */
@media (min-width: 641px) {
  html[data-layout='fill'] .menu {
    position: absolute;
    top: 74px;
    right: var(--pad);
    gap: 10px;
  }
  html[data-layout='fill'] .menu .label {
    display: block;
    text-box: trim-both cap alphabetic;
  }
}

/* ---------- Contact (contact.html): details placed by the chip's die ----------
   chip.jpg is 2400 × 2016; the die is the dark square at x 1037–1369, y 900–1227 (centre 50.1%, 52.75%; side 16.4% of the
   image height). The image is object-fit: cover at object-position 50% 53%, then scale(1.04) about the page centre, so: */
html[data-page='contact'] {
  --hr: max(100vw * 0.84, 100vh); /* rendered image height (cover) */
  --wr: calc(var(--hr) * 1.1905); /* rendered image width */
  --die: calc(1.04 * 0.1637 * var(--hr));
  --die-x: calc(50vw + 1.04 * ((100vw - var(--wr)) * 0.5 + 0.50125 * var(--wr) - 50vw));
  --die-y: calc(50vh + 1.04 * ((100vh - var(--hr)) * 0.53 + 0.5275 * var(--hr) - 50vh));
}
.contact {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease-out 0.4s;
}
html.ready .contact {
  opacity: 1;
}
.contact-row {
  position: absolute;
  left: var(--die-x);
  top: calc(var(--die-y) + 1.45 * var(--die)); /* below the chip's bottom pins */
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}
.contact a {
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}
.contact a:hover {
  opacity: 0.7;
}
.contact-email {
  display: block;
  font: 400 26px/1 'STIX Two Math', 'STIX Two Text', Georgia, serif;
  letter-spacing: 0.04em;
  text-box: trim-both cap alphabetic;
}
/* LinkedIn "in" mark (Simple Icons, CC0), one colour in the page ink */
.contact-li {
  display: block;
  line-height: 0;
}
.contact-li svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
/* placed in the copper strip between the die's bottom edge and the bottom pins (die bottom → pins ≈ 0.13 × die),
   scaled with the die, in the die's own black so it reads as printed on the package */
.contact-row {
  top: calc(var(--die-y) + 0.565 * var(--die));
  transform: translate(-50%, -50%);
  gap: calc(var(--die) * 0.035);
}
.contact a {
  color: #0b0806;
}
.contact-email {
  font-size: calc(var(--die) * 0.068);
  letter-spacing: 0.06em;
}
.contact-li svg {
  width: calc(var(--die) * 0.05);
  height: calc(var(--die) * 0.05);
}
/* email set like a package marking: IBM Plex Mono, a touch bigger (was 0.068 × die) */
.contact-email {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-weight: 500;
  font-size: calc(var(--die) * 0.078);
  letter-spacing: 0.02em;
}
.contact-li svg {
  width: calc(var(--die) * 0.058);
  height: calc(var(--die) * 0.058);
}
