/* Finn Schonfelder - personal site v4
   Instrument Serif everywhere, ASCII center of gravity, one red accent.
   No em dashes, no purple, no mono. */

@font-face {
  font-family: "Instrument Serif";
  src: url("assets/fonts/instrument-serif.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("assets/fonts/instrument-serif-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #0b0b0d;
  --bg-raised: #131316;
  --bg-raised-2: #17171b;
  --text: #ececea;
  --text-dim: #a3a39b;
  --accent: #a31621;
  --accent-ink: #ffe7e7;
  --hairline: rgba(255, 255, 255, 0.09);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  background: var(--bg);
  color-scheme: dark;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 24px;
}

::selection { background: var(--accent); color: var(--accent-ink); }

a { color: inherit; }

.dot { color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Hero: centered shrine ---------- */

.hero {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 40px 0 56px;
  overflow: hidden;
}

.masthead {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(42px, 6vw, 72px);
  letter-spacing: -0.01em;
  line-height: 1.05;
  text-align: center;
  padding-inline: 24px;
}

.hero-face {
  position: relative;
  line-height: 0;
  max-width: 100vw;
}

#ascii {
  opacity: 0;
  transition: opacity 0.9s var(--ease);
  touch-action: pan-y;
  max-width: 100%;
}
#ascii.ready { opacity: 1; }

/* Floating link particles */
.orb {
  position: absolute;
  top: 0; left: 0;
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  background: rgba(19, 19, 22, 0.78);
  border: 1px solid var(--hairline);
  will-change: transform;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.orb:hover { color: var(--accent); border-color: var(--accent); }

/* Typed questions: same finish as the masthead */
.questions {
  min-height: 84px;
  max-width: 780px;
  text-align: center;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(22px, 2.8vw, 32px);
  line-height: 1.25;
  color: var(--text);
  padding-inline: 16px;
}
.type-caret {
  display: inline-block;
  width: 0.45em;
  height: 0.95em;
  margin-left: 5px;
  background: var(--accent);
  vertical-align: baseline;
  transform: translateY(0.12em);
}
@media (prefers-reduced-motion: no-preference) {
  .type-caret { animation: blink 1.3s steps(2, start) infinite; }
  @keyframes blink { to { visibility: hidden; } }
}

/* The pull: a soft glow at the bottom edge of the hero */
.scroll-glow {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(70vw, 760px);
  height: 130px;
  background: radial-gradient(55% 100% at 50% 100%, rgba(163, 22, 33, 0.28), transparent 72%);
  pointer-events: auto;
}
@media (prefers-reduced-motion: no-preference) {
  .scroll-glow { animation: breathe 4.5s ease-in-out infinite; }
  @keyframes breathe {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
  }
}

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

.section {
  padding-block: 112px;
  border-top: 1px solid var(--hairline);
  scroll-margin-top: 24px;
}

.section h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 4.2vw, 56px);
  letter-spacing: -0.01em;
  margin-bottom: 48px;
}

@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(18px); }
  .js .reveal.in {
    opacity: 1;
    transform: none;
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  }
}

/* ---------- Now: bento 1 + 2, every cell a door ---------- */

.bento {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  grid-template-rows: auto auto;
  gap: 14px;
}

.cell {
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  padding: 32px;
  text-decoration: none;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.cell:hover { border-color: var(--accent); transform: translateY(-2px); }
.cell:active { transform: translateY(0); }

.cell h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 27px;
  letter-spacing: 0;
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cell-go {
  font-size: 18px;
  color: var(--text-dim);
  transition: color 0.2s var(--ease), transform 0.25s var(--ease);
}
.cell:hover .cell-go { color: var(--accent); transform: translate(2px, -2px); }

.cell p {
  color: var(--text-dim);
  font-size: 15.5px;
  line-height: 1.6;
  max-width: 52ch;
}

.cell-main {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 340px;
  background:
    radial-gradient(120% 90% at 85% 0%, rgba(163, 22, 33, 0.18), transparent 55%),
    var(--bg-raised);
}

.cell-grid-bg {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(var(--hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--hairline) 1px, transparent 1px),
    var(--bg-raised-2);
  background-size: 28px 28px, 28px 28px, auto;
}

/* One grid square flashes and wanders (JS moves it) */
.grid-spark {
  position: absolute;
  width: 27px;
  height: 27px;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s var(--ease);
}

/* ---------- ASCII footer ---------- */

footer {
  position: relative;
  border-top: 1px solid var(--hairline);
  overflow: hidden;
}

#footer-ascii {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.footer-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-block: 72px 60px;
  text-align: center;
}

.footer-name {
  font-family: var(--serif);
  font-size: clamp(30px, 3.4vw, 44px);
  line-height: 1.1;
}

.footer-links {
  display: flex;
  gap: 30px;
}
.footer-links a {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.footer-links a:hover { color: var(--accent); border-color: var(--accent); }

.footer-note {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text-dim);
  opacity: 0.8;
}

/* ---------- Speech modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 6, 0.96);
}

.modal-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

#speech-canvas { max-width: min(88vw, 560px); touch-action: none; }

.modal-quote {
  max-width: 30ch;
  text-align: center;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.3;
  color: var(--text);
}
.modal-quote cite {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 16px;
  color: var(--text-dim);
}

.modal-close {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--hairline);
  padding: 9px 22px;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.modal-close:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Mobile ---------- */

@media (max-width: 860px) {
  .hero { padding-top: 56px; gap: 10px; }
  .masthead { font-size: clamp(36px, 9.5vw, 48px); }
  .questions { font-size: 20px; min-height: 100px; }

  .orb { width: 42px; height: 42px; }

  .section { padding-block: 72px; }

  .bento { grid-template-columns: 1fr; grid-template-rows: none; }
  .cell-main { grid-row: auto; min-height: 260px; }

  .footer-links { gap: 20px; flex-wrap: wrap; justify-content: center; }
}
