/* site.css — Taari Chandaria
 * White paper, ink, and one highlighter. Figures are drawn from words by
 * js/field.js; everything here stays quiet so the fields can speak.
 */

/* Computer Modern — the LaTeX book face, self-hosted, roman only */
@font-face {
  font-family: 'CMU Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/cmu-serif-roman.woff2') format('woff2');
}

:root {
  --paper: #ffffff;
  --panel: #f6f6f6;
  --ink: #161616;
  --ink-2: #6d6d6d;
  --line: #eaeaea;
  --mark: #f4ff3d;

  --serif: 'CMU Serif', 'Latin Modern Roman', 'Computer Modern', Georgia,
    serif;
  --mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;

  --measure: 1180px;
  --gutter: clamp(20px, 4vw, 48px);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  font-size: 17.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ── header / footer ─────────────────────────────────────────────── */

.site-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding-block: 30px 26px;
}

.brand {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 21px;
  text-decoration: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
}

.site-nav a {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--ink-2);
  padding: 1px 2px;
}

.site-nav a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-nav a[aria-current='page'] {
  color: var(--ink);
  background: var(--mark);
}

.site-foot {
  margin-top: clamp(64px, 10vh, 120px);
  border-top: 1px solid var(--line);
  padding-block: 26px 44px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.site-foot a {
  color: inherit;
  text-underline-offset: 3px;
}

.site-foot a:hover {
  color: var(--ink);
}

/* ── shared type ─────────────────────────────────────────────────── */

.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 18px;
}

.page-head {
  padding: clamp(28px, 6vh, 64px) 0 0;
  max-width: 760px;
}

.page-head h1 {
  font-size: clamp(38px, 5.4vw, 58px);
  font-weight: 400;
  line-height: 1.08;
  margin: 0 0 20px;
}

.page-head .deck {
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
  max-width: 56ch;
}

/* ── the fields ──────────────────────────────────────────────────── */

.field {
  position: relative;
  overflow: hidden;
  --mx: -999px;
  --my: -999px;
}

.field pre {
  margin: 0;
  font-family: var(--mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0;
  user-select: none;
  /* repaints replace the pre's children every frame; if a click's target
     node is destroyed mid-press the click never fires, so route all
     pointer events to the stable .field container instead */
  pointer-events: none;
  color: var(--ink);
}

.field .t1 {
  opacity: 0.15;
}

.field .t2 {
  opacity: 0.42;
}

.field .t3 {
  opacity: 0.95;
}

.field mark {
  background: var(--mark);
  color: var(--ink);
}

/* quiet variant: ornamental minis that must never compete with copy */
.field-quiet .t1 {
  opacity: 0.1;
}

.field-quiet .t2 {
  opacity: 0.2;
}

.field-quiet .t3 {
  opacity: 0.38;
}

.field-lens {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.35s ease;
  -webkit-mask-image: radial-gradient(
    circle 150px at var(--mx) var(--my),
    #000 25%,
    transparent 72%
  );
  mask-image: radial-gradient(
    circle 150px at var(--mx) var(--my),
    #000 25%,
    transparent 72%
  );
}

.field-lens .t1,
.field-lens .t2,
.field-lens .t3 {
  opacity: 1;
}

.field-lit .field-lens {
  opacity: 1;
}

.field-reveal .field-base {
  -webkit-mask-image: linear-gradient(104deg, #000 46%, transparent 54%);
  mask-image: linear-gradient(104deg, #000 46%, transparent 54%);
  -webkit-mask-size: 260% 100%;
  mask-size: 260% 100%;
  animation: field-sweep 1.15s cubic-bezier(0.6, 0, 0.25, 1) both;
}

@keyframes field-sweep {
  from {
    -webkit-mask-position: 100% 0;
    mask-position: 100% 0;
  }
  to {
    -webkit-mask-position: 0% 0;
    mask-position: 0% 0;
  }
}

/* ── plates (the diptych panels) ─────────────────────────────────── */

.plate {
  display: grid;
  grid-template-columns: 11fr 10fr;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.plate-info {
  background: var(--panel);
  padding: clamp(32px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.plate-figure {
  position: relative;
  min-height: 300px;
}

.plate-figure .field {
  position: absolute;
  inset: 0;
}

/* ── landing ─────────────────────────────────────────────────────── */

.hero {
  margin-top: clamp(16px, 4vh, 44px);
}

.hero h1 {
  font-size: clamp(34px, 4.6vw, 52px);
  font-weight: 400;
  line-height: 1.12;
  margin: 0 0 22px;
}

.hero .lede {
  color: var(--ink-2);
  font-size: 17.5px;
  margin: 0 0 16px;
  max-width: 46ch;
}

.hero .lede:last-of-type {
  margin-bottom: 34px;
}

.hero-links {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12.5px;
}

.social-links {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.hero-links .social {
  display: inline-flex;
  line-height: 0;
}

.hero-links .social svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.hero-links a {
  text-underline-offset: 4px;
}

.hero-links a:hover {
  background: var(--mark);
}

.hero .plate-figure {
  min-height: clamp(380px, 56vh, 560px);
}

.toc {
  margin-top: clamp(56px, 9vh, 96px);
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-top: 26px;
}

.toc-card {
  display: block;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 22px 18px;
  background: #fff;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.toc-card:hover {
  border-color: var(--ink-2);
  transform: translateY(-2px);
}

.toc-card .field {
  height: 118px;
  margin-bottom: 18px;
}

.toc-card h3 {
  font-size: 22px;
  font-weight: 400;
  margin: 0;
}

.toc-card .go {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.toc-card:hover .go {
  color: var(--ink);
  background: var(--mark);
}

/* ── experience ──────────────────────────────────────────────────── */

.xp-switch {
  display: inline-flex;
  gap: 3px;
  margin-top: 28px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.xp-switch button {
  border: 0;
  border-radius: 6px;
  padding: 7px 13px;
  background: transparent;
  color: var(--ink-2);
  font: 12px/1.2 var(--mono);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.xp-switch button:hover {
  color: var(--ink);
}

.xp-switch button[aria-pressed='true'] {
  color: var(--ink);
  background: var(--mark);
}

.xp-panel[hidden] {
  display: none;
}

.xp-layout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(260px, 4fr);
  gap: clamp(36px, 6vw, 88px);
  margin-top: clamp(40px, 7vh, 72px);
  align-items: start;
}

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

.xp-item {
  border-top: 1px solid var(--line);
  padding: 30px 0 34px;
}

.xp-item:last-child {
  border-bottom: 1px solid var(--line);
}

.xp-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

.xp-item h2 {
  font-size: 30px;
  font-weight: 400;
  margin: 10px 0 4px;
}

.xp-role {
  font-size: 17px;
  color: var(--ink-2);
  margin: 0 0 14px;
}

.xp-note {
  margin: 0;
  max-width: 52ch;
}

.xp-more {
  margin-top: 16px;
}

.xp-more summary {
  display: inline-block;
  list-style: none;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  cursor: pointer;
  padding: 1px 2px;
}

.xp-more summary::-webkit-details-marker {
  display: none;
}

.xp-more summary .open,
.xp-more[open] summary .closed {
  display: none;
}

.xp-more[open] summary .open {
  display: inline;
}

.xp-more summary:hover {
  color: var(--ink);
  background: var(--mark);
}

.xp-more ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-width: 56ch;
}

.xp-more li {
  border-top: 1px solid var(--line);
  padding: 12px 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-2);
}

.xp-core {
  position: sticky;
  top: 32px;
}

.xp-core .field {
  height: min(62vh, 520px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  cursor: crosshair;
}

.xp-core figcaption {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  letter-spacing: 0.06em;
  margin-top: 12px;
  text-align: center;
}

.education-panel {
  width: 100%;
}

.education-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 28px;
  padding-bottom: 28px;
}

.education-head h2 {
  margin: 0 0 3px;
  font-size: 30px;
  font-weight: 400;
}

.education-head p {
  margin: 0;
  color: var(--ink-2);
}

.education-meta {
  display: flex;
  flex-direction: column;
  align-items: end;
  flex: none;
  font: 12px/1.7 var(--mono);
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

.course-groups,
.course-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.course-group {
  border-top: 1px solid var(--line);
  padding: 26px 0 30px;
}

.course-group:last-child {
  border-bottom: 1px solid var(--line);
}

.course-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 13px;
}

.course-group-head h3 {
  margin: 0;
  font-size: 23px;
  font-weight: 400;
}

.course-list li {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 84px;
  gap: 14px;
  padding: 7px 0;
  line-height: 1.45;
}

.course-title {
  min-width: 0;
}

.course-code {
  padding-top: 3px;
  font: 11.5px/1.4 var(--mono);
  color: var(--ink-2);
  letter-spacing: 0.025em;
}

.course-term {
  padding-top: 3px;
  font: 10.5px/1.4 var(--mono);
  color: var(--ink-2);
  text-align: right;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ── projects ────────────────────────────────────────────────────── */

.proj-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: clamp(40px, 7vh, 72px);
}

.proj-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.25s ease;
}

.proj-card:hover {
  border-color: var(--ink-2);
}

.proj-body {
  padding: 26px 28px;
}

.proj-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.proj-card h2 {
  font-size: 26px;
  font-weight: 400;
  margin: 8px 0 10px;
}

.proj-card p {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
}

.proj-figure {
  position: relative;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.proj-figure .field {
  position: absolute;
  inset: 0;
}

/* ── writing ─────────────────────────────────────────────────────── */

.writing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: clamp(36px, 6vw, 80px);
  margin-top: clamp(40px, 7vh, 72px);
  align-items: stretch;
}

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

.essay {
  border-top: 1px solid var(--line);
}

.essay:last-child {
  border-bottom: 1px solid var(--line);
}

.essay a {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 26px;
  padding: 30px 0;
  text-decoration: none;
}

.essay-when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
  line-height: 2;
}

.essay h2 {
  font-size: 27px;
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 8px;
  transition: background 0.2s ease;
}

.essay a:hover h2 {
  background: var(--mark);
  width: fit-content;
}

.essay p {
  margin: 0;
  color: var(--ink-2);
  font-size: 15.5px;
  max-width: 58ch;
}

.writing-river .field {
  height: 100%;
  min-height: 480px;
}

/* ── reading ─────────────────────────────────────────────────────── */

/* ── life (the easter egg) ───────────────────────────────────────── */

.foot-ps {
  flex-basis: 100%;
  text-align: center;
  margin-top: 14px;
  padding: 4px;
  background: none;
  border: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  cursor: pointer;
}

.foot-ps .key,
.life-hint .key {
  background: var(--panel);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.foot-ps:hover {
  color: var(--ink);
}

.foot-ps:hover .key {
  background: var(--mark);
  border-color: var(--mark);
}

/* The p.s. is a keyboard invitation, and the game itself only closes from
 * the keyboard — on touch screens there is no G to press, so the footer
 * keeps just its two lines. */
@media (hover: none) {
  .foot-ps {
    display: none;
  }
}

.life {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--paper);
  display: none;
  flex-direction: column;
}

.life.is-open {
  display: flex;
}

.life-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 30px);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.life-name .nm {
  color: var(--ink);
}

.life-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.life-grid {
  position: relative;
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 15px;
  color: var(--ink);
  user-select: none;
}

.life-grid .d {
  opacity: 0.08;
}

.life-grid .a1 {
  opacity: 0.35;
}

.life-grid .a2 {
  opacity: 0.6;
}

.life-grid .a3 {
  opacity: 0.95;
}

.life-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 7.8px;
  height: 15px;
  background: var(--mark);
  opacity: 0;
  pointer-events: none;
}

.life-hint {
  margin: 0;
  padding: 12px 16px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  border-top: 1px solid var(--line);
}

.life-rules-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.life-rules-btn:hover {
  color: var(--ink);
  background: var(--mark);
}

.life-rules {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 420px;
  width: calc(100% - 48px);
  padding: 22px 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink);
}

.life-rules-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: 0;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1;
  color: var(--ink-2);
  cursor: pointer;
}

.life-rules-close:hover {
  color: var(--ink);
  background: var(--mark);
}

.life-rules p {
  margin: 0;
}

.life-rules p + p {
  margin-top: 12px;
}

/* ── responsive ──────────────────────────────────────────────────── */

@media (max-width: 940px) {
  .plate,
  .proj-grid {
    grid-template-columns: 1fr;
  }

  .hero .plate-figure {
    min-height: 340px;
  }

  .toc-grid {
    grid-template-columns: 1fr 1fr;
  }

  .xp-layout {
    grid-template-columns: 1fr;
  }

  .xp-core {
    position: static;
  }

  .xp-core .field {
    height: 420px;
  }

  .writing-layout {
    grid-template-columns: 1fr;
  }

  .writing-river {
    display: none;
  }

  .proj-card {
    grid-template-columns: minmax(0, 1fr) 128px;
  }
}

@media (max-width: 560px) {
  .site-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-block: 22px 10px;
  }

  .site-nav {
    gap: 18px;
  }

  .toc-grid {
    grid-template-columns: 1fr;
  }

  .essay a {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .proj-card {
    grid-template-columns: 1fr;
  }

  .proj-figure {
    border-left: none;
    border-top: 1px solid var(--line);
    height: 130px;
  }

  .education-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .education-meta {
    align-items: flex-start;
  }

  .course-list li {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 9px 0;
  }

  .course-term {
    padding-top: 0;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── balanced direction ────────────────────────────────────────────
 * Keep the site as a quiet reading surface, then use a small number of
 * high-contrast field panels and decisive interaction states as punctuation.
 * That borrows the redesign's confidence without turning every surface into
 * a card, a shadow, or a colour block.
 */

:root {
  --panel: #f5f5f2;
  --ink: #151412;
  --ink-2: #66645f;
  --line: #e6e5e0;
  --mark: #f4ff3d;
  --night: #151412;
  --measure: 1200px;
}

body {
  font-size: 18px;
}

.site-head {
  align-items: center;
  padding: 26px 0 22px;
}

.brand {
  font-size: 21px;
  letter-spacing: -0.01em;
}

.site-nav {
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.site-nav a {
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 11.5px;
  letter-spacing: 0.07em;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.site-nav a:hover {
  background: var(--mark);
  text-decoration: none;
  transform: translateY(-1px);
}

.site-nav a[aria-current='page'] {
  color: var(--ink);
  background: var(--mark);
}

.page-head {
  max-width: 840px;
  padding-top: clamp(42px, 7vh, 78px);
}

.page-head h1 {
  max-width: 15ch;
  margin-bottom: 22px;
  font-size: clamp(42px, 5.8vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.page-head .deck {
  font-size: 19px;
  line-height: 1.5;
}

.field pre {
  color: var(--field-ink, var(--ink));
}

/* One strong moment: the opening panel still reads as a calm diptych, but
 * the living field now has enough contrast to feel like an instrument. */
.hero {
  margin-top: clamp(28px, 5vh, 58px);
}

.plate {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 520px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(21, 20, 18, 0.06);
}

.plate-info {
  padding: clamp(38px, 5vw, 64px);
  background: var(--panel);
}

.hero h1 {
  max-width: 11ch;
  margin-bottom: 24px;
  font-size: clamp(40px, 5.5vw, 64px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.hero .lede {
  max-width: 42ch;
  font-size: 17.5px;
  line-height: 1.58;
}

.hero-links {
  gap: 16px 24px;
}

.hero-links a {
  text-decoration: none;
  padding: 2px 3px;
}

.hero-links a:hover {
  background: var(--mark);
}

.plate-figure,
.xp-core .field,
.writing-river .field,
.proj-figure {
  background: var(--night);
}

.plate-figure .field,
.xp-core .field,
.writing-river .field,
.proj-figure .field {
  --field-ink: #ffffff;
}

.plate-figure .field mark,
.xp-core .field mark,
.writing-river .field mark,
.proj-figure .field mark {
  background: var(--mark);
  color: var(--ink);
}

.toc {
  margin-top: clamp(68px, 10vh, 112px);
}

.toc-grid {
  gap: 16px;
}

.toc-card {
  min-height: 224px;
  padding: 20px 20px 18px;
  border-radius: 16px;
  background: #fbfbfa;
  transition: background 0.22s ease, border-color 0.22s ease, color 0.22s ease,
    transform 0.22s ease;
}

.toc-card .field {
  height: 136px;
  margin-bottom: 16px;
}

.toc-card h3 {
  font-size: 25px;
  letter-spacing: -0.025em;
}

.toc-card:hover,
.toc-card:focus-visible {
  border-color: var(--ink);
  background: #fbfbfa;
  color: var(--ink);
  transform: translateY(-4px);
}

.toc-card:hover .field,
.toc-card:focus-visible .field {
  --field-ink: var(--ink);
}

.toc-card:hover .field .t1,
.toc-card:focus-visible .field .t1 {
  opacity: 0.1;
}

.toc-card:hover .field .t2,
.toc-card:focus-visible .field .t2 {
  opacity: 0.2;
}

.toc-card:hover .field .t3,
.toc-card:focus-visible .field .t3 {
  opacity: 0.38;
}

.toc-card:hover h3,
.toc-card:focus-visible h3 {
  width: fit-content;
  background: var(--mark);
}

.toc-card:hover .go,
.toc-card:focus-visible .go {
  color: var(--ink);
  background: var(--mark);
}

/* Interior pages remain mostly paper and rules. The dark fields repeat the
 * hero's visual language without asking ordinary reading content to compete. */
.xp-layout,
.proj-grid,
.writing-layout {
  margin-top: clamp(50px, 8vh, 84px);
}

.xp-item {
  padding: 32px 0 36px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.xp-item:hover {
  padding-left: 0;
  box-shadow: none;
  transform: translateX(5px);
}

.xp-item h2 {
  font-size: clamp(30px, 3.1vw, 38px);
  letter-spacing: -0.025em;
}

.xp-item h2,
.xp-item .xp-role {
  width: fit-content;
  transition: background 0.2s ease, color 0.2s ease;
}

.xp-item:hover h2 {
  background: var(--mark);
}

.xp-item:hover .xp-role {
  background: #e8e7e1;
  color: var(--ink);
}

.xp-core .field,
.writing-river .field {
  border: 1px solid var(--night);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(21, 20, 18, 0.08);
}

.proj-grid {
  gap: 18px;
}

.proj-card {
  display: flex;
  min-height: 440px;
  flex-direction: column;
  border-radius: 16px;
  background: #fbfbfa;
  box-shadow: 0 8px 20px rgba(21, 20, 18, 0.035);
  transition: border-color 0.22s ease, transform 0.22s ease;
}

.proj-card:hover {
  border-color: var(--ink);
  transform: translateY(-6px);
}

.proj-body {
  min-height: 210px;
  padding: 30px 30px 24px;
}

.proj-card h2 {
  margin: 12px 0;
  font-size: clamp(30px, 3vw, 40px);
  line-height: 1;
  letter-spacing: -0.05em;
}

.proj-figure {
  min-height: 230px;
  flex: 1;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  border-left: 0;
}

.proj-card:nth-child(even) .proj-figure {
  background: var(--mark);
}

.proj-card:nth-child(even) .proj-figure .field {
  --field-ink: var(--ink);
}

.proj-card:nth-child(even) .proj-figure .field mark {
  background: var(--night);
  color: var(--mark);
}

.essay a {
  transition: transform 0.2s ease;
}

.essay a:hover {
  padding-left: 0;
  box-shadow: none;
  transform: translateX(5px);
}

.essay h2 {
  font-size: clamp(27px, 3vw, 34px);
  letter-spacing: -0.025em;
}

.essay a:hover h2 {
  width: fit-content;
  background: var(--mark);
  text-decoration: none;
}

.site-foot a:hover {
  background: var(--mark);
}

@media (max-width: 940px) {
  .plate {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .hero .plate-figure {
    min-height: 360px;
  }

}

@media (max-width: 560px) {
  .site-head {
    padding-block: 22px 16px;
  }

  .site-nav {
    flex-wrap: wrap;
  }

  .site-foot {
    flex-direction: column;
    gap: 12px;
    padding-block: 22px 36px;
  }

  .hero h1,
  .page-head h1 {
    letter-spacing: -0.03em;
  }

  .toc-card {
    min-height: 0;
  }

  .proj-figure {
    border-left: none;
    border-top-color: rgba(255, 255, 255, 0.18);
    min-height: 130px;
  }

}

/* ── reading page, simplified ────────────────────────────────────── */

.reading-section {
  margin-top: clamp(46px, 7vh, 72px);
}

.reading-section > h2,
.reading-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: clamp(29px, 3.1vw, 40px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.04em;
}

.reading-section-title h2 {
  margin: 0;
  font: inherit;
}

.reading-section-title p {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}

.current-book {
  display: grid;
  grid-template-columns: clamp(144px, 19vw, 210px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 5vw, 72px);
  max-width: 820px;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafaf7;
}

.book-cover {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background: var(--panel);
  box-shadow: 4px 6px 0 rgba(21, 20, 18, 0.12);
}

.book-cover-fallback {
  max-width: 12ch;
  padding: 12px;
  font-family: var(--mono);
  font-size: clamp(8px, 1.1vw, 11px);
  line-height: 1.35;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink-2);
}

.book-cover img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.current-book .book-cover {
  width: 100%;
}

.book-status,
.favorite-label,
.book-year {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.read-more-note {
  margin: 24px 0 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
}

.book-status {
  width: fit-content;
  margin: 0 0 18px;
  padding: 3px 5px;
  background: var(--mark);
  color: var(--ink);
}

.current-book h3 {
  max-width: 15ch;
  margin: 0;
  font-size: clamp(31px, 4vw, 50px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.book-author {
  margin: 11px 0 0;
  font-size: 17px;
}

.book-note {
  max-width: 44ch;
  margin: 22px 0 0;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.45;
}

.shelf-frame {
  position: relative;
  max-width: 1080px;
  padding: 25px 22px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px 10px 3px 3px;
  background: linear-gradient(145deg, #fafaf7, #e8e7e1);
}

.shelf {
  display: flex;
  align-items: flex-end;
  min-height: 272px;
  gap: 9px;
  padding: 0 2px;
  border-bottom: 7px solid var(--ink);
  overflow-x: auto;
  scrollbar-color: var(--ink-2) transparent;
  scrollbar-width: thin;
}

/* Each favorite is a button whose body is a typographic field — the
 * characters are the book. A hairline, open at the bottom where the book
 * meets the shelf, keeps the silhouette crisp. */
.spine-book {
  flex: 0 0 auto;
  position: relative;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(22, 22, 22, 0.35);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: none;
  appearance: none;
  cursor: pointer;
}

.spine-book:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.spine-field {
  position: absolute;
  inset: 0;
  display: block;
}

/* taking a book down: it lifts off the shelf, develops to full ink, and
 * the rest of the shelf recedes */
.spine-book {
  transition: opacity 0.25s ease, transform 0.22s ease;
}

.spine-book:hover,
.spine-book:focus-visible,
.spine-book.is-active {
  transform: translateY(-7px);
}

.shelf:has(.spine-book:hover) .spine-book:not(:hover),
.shelf:has(.spine-book:focus-visible) .spine-book:not(:focus-visible),
.shelf:has(.spine-book.is-active) .spine-book:not(.is-active) {
  opacity: 0.45;
}

@media (prefers-reduced-motion: reduce) {
  .spine-book:hover,
  .spine-book:focus-visible,
  .spine-book.is-active {
    transform: none;
  }
}

.spine-book:hover .t1,
.spine-book:focus-visible .t1,
.spine-book.is-active .t1 {
  opacity: 0.5;
}

.spine-book:hover .t2,
.spine-book:focus-visible .t2,
.spine-book.is-active .t2 {
  opacity: 0.8;
}

.spine-book:hover .t3,
.spine-book:focus-visible .t3,
.spine-book.is-active .t3 {
  opacity: 1;
}

/* the detail card: title, author, and cover of whichever book is in hand */
.shelf-detail {
  position: absolute;
  top: 24px;
  right: 20px;
  z-index: 1;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  width: min(330px, 46%);
  padding: 14px;
  border: 1px solid var(--line);
  background: #fffefa;
  box-shadow: 5px 7px 0 rgba(21, 20, 18, 0.1);
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

.shelf-frame.has-detail .shelf-detail {
  opacity: 1;
  transform: none;
}

.shelf-detail .book-cover {
  width: 88px;
  flex: 0 0 88px;
  box-shadow: 3px 4px 0 rgba(21, 20, 18, 0.1);
}

.shelf-detail-copy {
  min-width: 0;
  padding-top: 2px;
}

.shelf-detail .book-year {
  margin: 0;
}

.shelf-detail h3 {
  margin: 8px 0 0;
  font-size: 23px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.shelf-detail .book-author {
  margin-top: 7px;
  font-size: 14px;
  color: var(--ink-2);
}

.finished-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 34px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.finished-book {
  display: flex;
  min-height: 134px;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.finished-book .book-cover {
  width: 72px;
  flex: 0 0 72px;
  box-shadow: 3px 4px 0 rgba(21, 20, 18, 0.1);
}

.finished-book-copy {
  min-width: 0;
  padding-top: 2px;
}

.finished-book h3 {
  margin: 0;
  font-size: 21px;
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.finished-book .book-author {
  margin-top: 7px;
  font-size: 14px;
  color: var(--ink-2);
}

.book-year {
  margin: 12px 0 0;
}

.favorite-label {
  width: fit-content;
  margin: 0 0 8px;
  padding: 2px 4px;
  background: var(--mark);
  color: var(--ink);
}


@media (max-width: 700px) {
  .reading-section > h2,
  .reading-section-title {
    font-size: 30px;
  }

  .current-book {
    grid-template-columns: 118px minmax(0, 1fr);
    gap: 22px;
    padding: 18px;
  }

  .current-book h3 {
    font-size: 31px;
  }

  .book-note {
    margin-top: 16px;
    font-size: 15px;
  }

  .shelf-frame {
    padding: 20px 14px 0;
  }

  .shelf {
    min-height: 236px;
  }

  .shelf-detail {
    width: min(280px, 62%);
    gap: 12px;
  }

  .shelf-detail .book-cover {
    width: 64px;
    flex-basis: 64px;
  }

  .shelf-detail h3 {
    font-size: 19px;
  }

  .finished-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .reading-section-title {
    display: block;
  }

  .reading-section-title p {
    margin-top: 8px;
  }

  .current-book {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 16px;
  }

  .current-book h3 {
    font-size: 27px;
  }

  .book-status {
    margin-bottom: 12px;
    font-size: 10px;
  }

  .book-note {
    grid-column: 1 / -1;
  }

}
