/* ─── the field · base styles ─────────────────────────────────────────────
   Resets, typography, and the substrate on which all surfaces are built.
   Imports tokens.css.
   ──────────────────────────────────────────────────────────────────────── */

@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap");
@import url("./tokens.css");

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-base);
  font-family: var(--font-mono);
  font-size: var(--text-body);
  line-height: var(--line-height);
  font-weight: var(--weight-regular);
  font-feature-settings: "calt" 1, "ss01" 1;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

p { margin: 0 0 calc(var(--text-body) * var(--line-height)) 0; }
p:last-child { margin-bottom: 0; }

a {
  color: inherit;
  text-decoration-color: var(--color-faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: text-decoration-color var(--dur-quick) var(--ease-considered);
}
a:hover { text-decoration-color: var(--color-base); }

h1, h2, h3 {
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  margin: 0;
}

h1 { font-size: var(--text-h1); line-height: 1.25; }
h2 {
  font-size: var(--text-h2);
  line-height: 1.35;
  margin: calc(var(--line-height) * var(--text-body) * 2) 0 calc(var(--line-height) * var(--text-body) * 1) 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-rule);
  margin: var(--space-12) 0;
}

::selection { background: rgba(10,10,10,0.12); }

/* Reading column — anchors the prose width across surfaces */
.column {
  max-width: var(--measure-prose);
  margin-left: auto;
  margin-right: auto;
}

/* Layer chrome — the em-dash convention, used everywhere a layer announces
   itself. Restrained, typographic, no boxes. */
.layer-marker {
  font-size: var(--text-small);
  color: var(--color-muted);
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-3);
  user-select: none;
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
}
.layer-marker::before,
.layer-marker::after {
  content: "—";
  color: var(--color-faint);
}

.layer-marker .layer-dismiss {
  margin-left: var(--space-3);
  color: var(--color-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-quick) var(--ease-considered),
              color var(--dur-quick) var(--ease-considered);
  border: 0;
  background: transparent;
  font: inherit;
  padding: 0;
}
.layer:hover .layer-dismiss,
.layer:focus-within .layer-dismiss { opacity: 1; }
.layer-dismiss:hover { color: var(--color-base); }

/* A layer is just type at varying opacity. No background, no border, no
   shadow. Vertical offset when stacked. */
.layer {
  transition: opacity var(--dur-slow) var(--ease-considered);
}
.layer + .layer { margin-top: var(--space-3); }

.layer[data-state="active"]  { opacity: var(--layer-active); }
.layer[data-state="recent"]  { opacity: var(--layer-recent); }
.layer[data-state="fading"]  { opacity: var(--layer-fading); }
.layer[data-state="floor"]   { opacity: var(--layer-floor); }

/* Typing primitive — used in motion demos and in mechanic intros.
   Letter-by-letter typing happens via JS (see motion.js); this is the
   per-character entry CSS. */
.typed {
  white-space: pre-wrap;
}
.ch {
  opacity: 0;
  display: inline-block;
  transform: translateY(2px);
  filter: blur(1.5px);
  animation: ch-in 320ms var(--ease-considered) forwards;
}
@keyframes ch-in {
  from { opacity: 0; transform: translateY(2px); filter: blur(1.5px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}

/* Word-level entrance for companion offerings, mechanic intros */
.word-in {
  display: inline-block;
  opacity: 0;
  transform: translateY(3px);
  filter: blur(2px);
  animation: word-in 460ms var(--ease-considered) forwards;
}
@keyframes word-in {
  from { opacity: 0; transform: translateY(3px); filter: blur(2px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}

/* Cursor — thin underline cursor matched to the typeface. */
.cursor {
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  border-bottom: 1.5px solid var(--color-base);
  margin-left: 1px;
  vertical-align: -2px;
  animation: cursor-breathe 1100ms var(--ease-considered) infinite alternate;
}
@keyframes cursor-breathe {
  from { opacity: 0.15; }
  to   { opacity: 0.95; }
}

/* Strikethrough animation — the perspective-shift overstrike. The line is
   drawn left-to-right over an existing word, then the word fades and the
   replacement types in at the same position. */
.strike {
  position: relative;
  display: inline-block;
}
.strike::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  top: 56%;
  border-top: 1px solid currentColor;
  animation: strike-draw 360ms var(--ease-considered) forwards;
}
@keyframes strike-draw {
  from { right: 100%; }
  to   { right: -2px; }
}
.strike.fading {
  transition: opacity 520ms var(--ease-considered),
              filter 520ms var(--ease-considered),
              transform 520ms var(--ease-considered);
  opacity: 0;
  filter: blur(2px);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .ch, .word-in,
  .strike::after,
  .cursor,
  .layer { animation: none !important; transition: opacity 200ms linear !important; }
  .ch, .word-in { opacity: 1 !important; transform: none !important; filter: none !important; }
}

/* Inline kbd / control glyphs */
kbd {
  font-family: inherit;
  font-size: 0.85em;
  padding: 1px 5px;
  border: 1px solid var(--color-rule-strong);
  border-radius: 2px;
  color: var(--color-muted);
  background: transparent;
}
