/* After the Prompt — homepage corkboard
 *
 * Loaded by index.html only. Builds on the tokens in styles.css.
 *
 * Two states:
 *   - No JS: the board is one screen tall and the six polaroids sit in a
 *     plain grid on the cork. Every link works.
 *   - html.board-js (set by an inline script in <head>, removed again by a
 *     failsafe if assets/board.js never starts): the board becomes a pinned
 *     stage inside a tall scroll runway, and board.js positions the polaroids
 *     and pins as you scroll. Polaroids stay hidden only until board.js adds
 *     .live, so they are never stranded invisible.
 */

@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url(/fonts/caveat-latin-v1.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font-hand: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
  --cork: #c29a6b;
  --frame: #6b4a32;
  --sticky: #efd679;
  --card: #fbf8f2;
  --w: 240px; /* polaroid width; board.js sets the real value */
}

/* ---- Stage and board ----------------------------------------------------- */

.runway {
  position: relative;
}

.stage {
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  padding: clamp(8px, 1.4vw, 16px);
  background: var(--frame);
  background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.08), transparent 30%, rgba(255, 255, 255, 0.05) 60%, rgba(0, 0, 0, 0.1));
}

.board-js .runway { height: 300vh; }
.board-js .stage { position: sticky; top: 0; }

.board {
  position: relative;
  height: 100%;
  border-radius: 2px;
  background: var(--cork);
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

/* Cork grain: coarse flecks + fine speckle, both SVG noise. */
.board::before,
.board::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.board::before {
  opacity: 0.55;
  mix-blend-mode: multiply;
  background-size: 220px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='c'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .22 0 0 0 0 .12 0 0 0 2.2 -1.1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23c)'/%3E%3C/svg%3E");
}

.board::after {
  opacity: 0.4;
  mix-blend-mode: screen;
  background-size: 160px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='1' seed='9'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .9 0 0 0 0 .75 0 0 0 3 -2.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
}

/* A warm desk lamp off to the upper right, falling off into darker edges. */
.lamp {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 64% 28%, rgba(255, 226, 170, 0.3), transparent 70%),
    radial-gradient(ellipse 120% 95% at 55% 40%, transparent 55%, rgba(40, 20, 5, 0.38) 100%);
}

.board-about {
  position: absolute;
  z-index: 6;
  top: 14px;
  right: 18px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--card);
  text-decoration: none;
  background: rgba(40, 24, 12, 0.35);
  border-radius: 2px;
}

.board-about:hover,
.board-about:focus-visible {
  background: rgba(40, 24, 12, 0.6);
}

.board :focus-visible {
  outline-color: var(--card);
}

/* ---- Sticky note: the site name, handwritten, with the raised mark ------- */

.sticky {
  position: absolute;
  z-index: 4;
  left: clamp(14px, 4vw, 48px);
  top: clamp(26px, 4vh, 40px);
  width: clamp(250px, 15rem + 6vw, 350px);
  aspect-ratio: 1 / 0.78;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 22px 22px 24px;
  color: #2a211b;
  text-decoration: none;
  background: var(--sticky);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 30%), linear-gradient(0deg, rgba(150, 110, 20, 0.1), transparent 40%);
  border-bottom-right-radius: 22px 7px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 4px 14px 18px -10px rgba(50, 30, 5, 0.6);
  transform: rotate(-2.5deg);
}

.sticky .name {
  align-self: flex-end;
  font: 700 clamp(3rem, 2rem + 2.8vw, 4.3rem) / 0.86 var(--font-hand);
  letter-spacing: 0.005em;
  white-space: nowrap;
  transform: rotate(-1.5deg);
}

.mark3d {
  flex: none;
  width: clamp(52px, 2.6rem + 2vw, 80px);
  height: auto;
  overflow: visible;
  transform: rotate(8deg) translateY(-4px);
}

/* Raised clay asterisks in polaroid and reader titles. */
.ast {
  display: inline-block;
  margin: 0 0.08em 0 0.04em;
  font-family: var(--font-serif);
  font-weight: 700;
  color: #b8714f;
  transform: translateY(-0.05em) scale(1.15);
  text-shadow: 0.5px 0.6px 0 #8a4f34, 1px 1.2px 0 #6e3e2a, 1.5px 1.8px 0 #5c3322, 2px 3px 3px rgba(30, 15, 5, 0.35);
}

/* ---- Index card: the intro, taped (pins are for the photos) -------------- */

.note {
  position: absolute;
  z-index: 3;
  left: clamp(14px, 4vw, 48px);
  top: clamp(290px, 40vh, 330px);
  width: min(380px, 74vw);
  padding: 22px 22px 18px;
  background: var(--card);
  background-image: repeating-linear-gradient(transparent 0 27px, rgba(80, 120, 170, 0.18) 27px 28px);
  background-position: 0 46px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15), 0 10px 20px -8px rgba(40, 25, 10, 0.45);
  transform: rotate(-2deg);
}

.note::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 92px;
  height: 26px;
  margin-left: -46px;
  background: rgba(232, 214, 180, 0.82);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transform: rotate(3deg);
}

.note .k {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--clay-text);
}

.note h1 {
  margin: 0;
  font: 700 clamp(1.6rem, 1.1rem + 1.8vw, 2.4rem) / 1 var(--font-serif);
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.note h1 em {
  font-weight: 400;
  color: var(--ink-muted);
}

.note p {
  margin: 12px 0 0;
  font-size: 0.98rem;
  line-height: 1.75;
}

.note .hint {
  display: block;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* ---- Polaroids ----------------------------------------------------------- */

.pols {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* No-JS layout: a plain grid on the right of the board. */
.pols {
  position: absolute;
  z-index: 5;
  left: 36%;
  right: 4%;
  top: 9%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px 30px;
}

.pols li:nth-child(odd) .pol { transform: rotate(-2deg); }
.pols li:nth-child(even) .pol { transform: rotate(2.4deg); }

.pol {
  display: block;
  color: inherit;
  text-decoration: none;
}

.pol .face {
  position: relative;
  padding: 7px 7px 0;
  background: var(--card);
  transform-origin: 50% 0;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.18), var(--shx, 2px) var(--sh, 6px) calc(var(--sh, 6px) * 1.8) calc(var(--sh, 6px) * -0.2) rgba(35, 20, 8, 0.42);
  transition: transform 450ms var(--ease-out), box-shadow 450ms var(--ease-out);
}

.pol img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #ece4d6;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.pol .cap {
  min-height: 56px;
  padding: 6px 6px 10px;
}

.pol h2 {
  margin: 0;
  font: 700 clamp(1.25rem, 1.05rem + 0.5vw, 1.5rem) / 1 var(--font-hand);
  color: #231c17;
  transform: rotate(-1.2deg);
  transform-origin: 0 50%;
}

.pol h2 .why {
  display: block;
  margin-top: 2px;
  font: 600 clamp(1rem, 0.9rem + 0.3vw, 1.15rem) / 1.05 var(--font-hand);
  color: #5a4a3e;
  transform: rotate(0.8deg);
}

/* Hover: the polaroid lifts off the cork, tilts toward the pointer and catches the light. */
.pol .face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 30%), rgba(255, 250, 235, 0.38), transparent 55%);
  transition: opacity 300ms;
}

.pol.lift .face {
  --sh: 24px;
  transform: perspective(700px) rotateX(var(--rx, 8deg)) rotateY(var(--ry, 0deg)) translateY(-5px) scale(1.04);
  transition: transform 180ms ease-out, box-shadow 300ms var(--ease-out);
}

.pol.lift .face::after {
  opacity: 1;
}

/* JS layout: board.js places every polaroid absolutely. */
.board-js .pols {
  display: block;
  inset: 0;
  left: 0;
  right: 0;
  top: 0;
  z-index: auto;
}

.board-js .pols li {
  display: contents;
}

.board-js .pol {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--w);
  z-index: 5;
  will-change: transform;
  visibility: hidden;
}

.board-js .board.live .pol {
  visibility: visible;
}

/* ---- Pins: long steel shaft, round metal head ----------------------------
   The element sits where the pin enters the cork; the SVG is drawn with that
   point at its origin. Height off the board is faked: the pin rises, grows a
   touch, and its shadow moves away and softens. */

.tack {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 30;
  pointer-events: none;
  will-change: transform;
}

.tack svg {
  position: absolute;
  left: -10.5px;
  top: -47px;
  width: 47px;
  height: 52px;
  overflow: visible;
  filter: drop-shadow(var(--dx, 2px) var(--dy, 3px) var(--blur, 1.2px) rgba(30, 15, 5, 0.5));
}

/* ---- Reader: the unpinned polaroid, up close ----------------------------- */

.dim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(30, 20, 12, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 350ms;
}

.dim.on {
  opacity: 1;
  pointer-events: auto;
}

.reader {
  position: fixed;
  z-index: 80;
  left: 50%;
  top: 50%;
  width: min(960px, 92vw);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  padding: 14px;
  background: var(--card);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.reader.on {
  pointer-events: auto;
  visibility: visible;
}

.reader img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  align-self: start;
}

.reader .txt {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 8px 10px 26px;
}

.reader time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.reader h2 {
  margin: 8px 0 0;
  font: 700 clamp(1.6rem, 1.1rem + 1.6vw, 2.3rem) / 1.02 var(--font-serif);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.reader h2 .why {
  display: block;
  margin-top: 6px;
  font-size: 0.7em;
  font-weight: 400;
  font-style: italic;
  color: var(--ink-muted);
}

.reader p {
  margin: 16px 0 0;
  font-size: 1rem;
  line-height: 1.65;
}

.reader .go {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
}

.reader .go a {
  color: var(--clay-text);
  border-bottom: 1px solid currentColor;
  text-decoration: none;
}

.reader .go button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink-muted);
  cursor: pointer;
}

/* ---- Below the board ------------------------------------------------------ */

.home .site-main {
  padding-top: var(--sp-5);
}

.home .site-main > .section-label:first-child {
  margin-top: var(--sp-5);
}

/* ---- Phones --------------------------------------------------------------- */

@media (max-width: 720px) {
  .sticky {
    top: 18px;
    width: auto;
    aspect-ratio: auto;
    align-items: center;
    gap: 12px;
    padding: 12px 14px 14px 16px;
  }

  .sticky .name { font-size: 2.5rem; }
  .sticky .name br { display: none; }
  .mark3d { width: 44px; }

  .board-about { top: auto; bottom: 12px; right: 12px; }

  .note {
    top: 112px;
    width: min(300px, 78vw);
    padding: 16px 16px 12px;
  }

  .note h1 { font-size: 1.45rem; }
  .note p { display: none; }

  /* The board is small, so a polaroid keeps only its title; the catch is in the reader. */
  .pol h2 .why { display: none; }
  .board-js .pol h2 { font-size: clamp(0.95rem, calc(var(--w) * 0.12), 1.4rem); white-space: nowrap; }
  .pol .cap { min-height: 0; padding: 6px 2px 8px; }

  .pols {
    left: 14px;
    right: 14px;
    top: 230px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .reader {
    grid-template-columns: 1fr;
    max-height: 88vh;
    overflow: auto;
  }

  .reader .txt { padding: 16px 6px 6px; }
}

/* Without motion the board opens already pinned up, one screen tall. */
@media (prefers-reduced-motion: reduce) {
  .board-js .runway { height: auto; }
  .board-js .stage { position: relative; }
  .pol .face,
  .pol.lift .face { transition: none; }
}
