/* ============================================================
   EMBER base — reset, typography, pattern primitives
   Consumes tokens/ember.css (generated). Import that first:
     <link rel="stylesheet" href="../tokens/ember.css">
     <link rel="stylesheet" href="base.css">
   ============================================================ */

/* ---- reset --------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  /* clip, not hidden: no scroll container is created, so the sticky header
     still sticks — but the tilted band stops bleeding a scrollbar */
  overflow-x: clip;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-grot);
  font-size: var(--text-md);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-4xl);
}

h2 {
  font-size: var(--text-3xl);
}

h3 {
  font-size: var(--text-xl);
}

p {
  max-width: 68ch;
}

a {
  color: var(--azure); /* links are cold data */
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: background var(--dur-1) var(--ease-press), color var(--dur-1) var(--ease-press);
}

a:hover {
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
}

/* selection is the human hand's highlighter — pink, never ember */
::selection {
  background: var(--pink);
  color: var(--raise);
}

:focus-visible {
  outline: var(--line-heavy) solid var(--ember);
  outline-offset: 2px;
}

kbd {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--sunk);
  border: var(--line-fine) solid var(--edge-strong);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.5em;
  box-shadow: 2px 2px 0 var(--shadow-ink);
}

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

/* ---- paper grain: paper mode only ---------------------------- */

[data-mode="paper"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media print {
  [data-mode="paper"] body::after {
    display: none;
  }
}

/* ---- pattern primitives -------------------------------------- */

/* Heavy rule — the signature line. Structural use only. */
.rule {
  border: none;
  border-top: var(--line-heavy) solid var(--edge-strong);
}

.rule-fine {
  border: none;
  border-top: var(--line-fine) solid var(--edge-faint);
}

/* Annotated engineering — mono metadata for real data. */
.label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  line-height: var(--leading-mono);
  color: var(--ink-soft);
}

.mono {
  font-family: var(--font-mono);
}

/* The whisper — one serif-italic aside per composition.
   Pink: the persona color of the human hand. */
.whisper {
  font-family: var(--font-whisper);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--pink);
}

/* Layout helpers */
.container {
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: var(--sp-5);
}

.stack > * + * {
  margin-block-start: var(--sp-4);
}

.stack-lg > * + * {
  margin-block-start: var(--sp-6);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
}

.grid12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--sp-4);
}

/* Section header pattern: mono index left, rule below */
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  border-bottom: var(--line-heavy) solid var(--edge-strong);
  padding-block-end: var(--sp-3);
  margin-block-end: var(--sp-6);
}

.sec-head h2 {
  font-size: var(--text-2xl);
}

.section {
  padding-block: var(--sp-7);
}

/* ============================================================
   Composition primitives — rules make the rooms.
   Structure comes from dividing lines, not wrapping boxes.
   ============================================================ */

/* Band: full-width horizontal field, opened by a heavy rule.
   Stack bands to build the page; invert one per page at most. */
.band {
  border-top: var(--line-heavy) solid var(--edge-strong);
  padding-block: var(--sp-7);
}

.band--ink {
  background: var(--ink);
  color: var(--bg);
  border-top-color: var(--edge-strong);
}

/* labels on an ink field: --ink-soft vanishes there (≈2:1);
   edge-faint flips with the mode and stays legible in both */
.band--ink .label {
  color: var(--edge-faint);
}

.band--sunk {
  background: var(--sunk);
}

/* Ledger: ruled rows — index | content | annotation.
   Anything enumerable becomes a ledger. */
.ledger {
  border-top: var(--line-heavy) solid var(--edge-strong);
  border-bottom: var(--line-heavy) solid var(--edge-strong);
}

.ledger-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr minmax(9rem, auto);
  gap: var(--sp-5);
  align-items: start;
  padding-block: var(--sp-5);
  border-bottom: var(--line-fine) solid var(--edge-faint);
}

.ledger-row:last-child {
  border-bottom: none;
}

.ledger-index {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
  padding-top: 0.2em;
}

.ledger-annot {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  line-height: var(--leading-mono);
  color: var(--ink-soft);
  text-align: right;
  padding-top: 0.35em;
}

/* Annotation column: content beside a mono note rail. */
.annot-col {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) 1fr;
  gap: var(--sp-6);
  align-items: start;
}

.annot-col .annot {
  border-left: var(--line-heavy) solid var(--edge-strong);
  padding-left: var(--sp-4);
  display: grid;
  gap: var(--sp-3);
}

/* Scale jump: a type leap as a divider. */
.scale-jump {
  font-size: var(--text-hero);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-display);
  text-transform: uppercase;
}

@media (max-width: 860px) {
  .ledger-row {
    grid-template-columns: 2.5rem 1fr;
  }

  .ledger-annot {
    grid-column: 2;
    text-align: left;
  }

  .annot-col {
    grid-template-columns: 1fr;
  }

  .annot-col .annot {
    border-left: none;
    border-top: var(--line-heavy) solid var(--edge-strong);
    padding-left: 0;
    padding-top: var(--sp-4);
  }
}

/* ============================================================
   Postures — geometry declares intent
   ============================================================ */

.posture-give {
  border-radius: var(--shape-give);
}

.posture-speak {
  border-radius: var(--shape-speak);
}

/* ============================================================
   The philosophy of dynamics — everything wants to move
   ============================================================ */

/* The band: a belt of type that will not sit still, with a hazard rail
   running under it the other way. Rotated a hair — one grid break, taken
   deliberately — and skewed by scroll velocity so the belt answers the
   hand that throws it. Pause on hover. */
.band {
  position: relative;
  transform: rotate(-0.5deg) scaleX(1.015);
  transform-origin: center;
  margin-block: var(--sp-3);
}

.marquee {
  overflow: hidden;
  border-top: var(--line-heavy) solid var(--edge-strong);
  background: var(--conflict-gradient);
  color: var(--ember-text);
  white-space: nowrap;
  /* --belt-skew is written by JS from scroll velocity */
  transform: skewX(var(--belt-skew, 0deg));
  transition: transform 120ms linear;
}

.marquee-track {
  display: inline-flex;
  gap: var(--sp-6);
  padding-block: var(--sp-2);
  padding-inline: var(--sp-6);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  animation: ember-marquee var(--marquee-dur) linear infinite;
  will-change: transform;
}

/* the separator is the ember, and there is exactly one per phrase */
.marquee .sep {
  color: var(--ember);
  opacity: 0.9;
}

/* the hazard rail: a second band, striped, running counter to the belt */
.stripe-rail {
  height: var(--sp-3);
  border-block: var(--line-fine) solid var(--edge-strong);
  background-image: repeating-linear-gradient(
    115deg,
    var(--edge-strong) 0 6px,
    transparent 6px 14px
  );
  background-size: 200% 100%;
  animation: ember-rail var(--marquee-dur) linear infinite reverse;
}

@keyframes ember-rail {
  to {
    background-position: 200% 0;
  }
}

.marquee:hover .marquee-track {
  animation-play-state: paused;
}

.marquee:hover ~ .stripe-rail,
.band:hover .stripe-rail {
  animation-play-state: paused;
}

@keyframes ember-marquee {
  to {
    transform: translateX(-50%);
  }
}

/* Press-in entrance: elements arrive like a stamp.
   Transform-only — content stays visible even if animation never runs. */
@keyframes ember-press-in {
  from {
    transform: translate(0.35em, 0.35em);
  }

  to {
    transform: translate(0, 0);
  }
}

.press-in {
  animation: ember-press-in var(--dur-3) var(--ease-press) both;
}

.press-in-2 {
  animation: ember-press-in var(--dur-3) var(--ease-press) 120ms both;
}

.press-in-3 {
  animation: ember-press-in var(--dur-3) var(--ease-press) 240ms both;
}

.press-in-4 {
  animation: ember-press-in var(--dur-3) var(--ease-press) 360ms both;
}

/* Ember pulse: the one glow sanctioned by the language —
   and the period quivers: it is alive, never quite at rest. */
@keyframes ember-pulse {

  0%,
  100% {
    text-shadow: none;
  }

  50% {
    text-shadow: var(--glow-ember);
  }
}

@keyframes ember-quiver {

  0%,
  100% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(0.5px, -0.4px);
  }

  50% {
    transform: translate(-0.4px, 0.4px);
  }

  75% {
    transform: translate(0.3px, 0.3px);
  }
}

.ember-pulse {
  animation: ember-pulse var(--pulse-dur) ease-in-out infinite,
    ember-quiver 0.5s ease-in-out infinite;
}

/* ============================================================
   Tension — stillness as stored energy.
   Slow strain cycles, periodic clenches, hover echoes:
   the object is holding itself back, and you can tell.
   ============================================================ */

/* strain: a slow pull toward and away from rest, opposite phases */
@keyframes ember-strain-a {

  0%,
  100% {
    transform: translate(0, 0);
  }

  35% {
    transform: translate(2px, 0);
  }

  55% {
    transform: translate(-1.5px, 0);
  }

  80% {
    transform: translate(0.5px, 0);
  }
}

@keyframes ember-strain-b {

  0%,
  100% {
    transform: translate(0, 0);
  }

  35% {
    transform: translate(-2px, 0);
  }

  55% {
    transform: translate(1.5px, 0);
  }

  80% {
    transform: translate(-0.5px, 0);
  }
}

.strain-a {
  animation: ember-strain-a var(--strain-dur) ease-in-out infinite;
}

.strain-b {
  animation: ember-strain-b var(--strain-dur) ease-in-out infinite;
}

/* clench: long stillness, then a fast snap-and-settle — the fist */
@keyframes ember-clench {

  0%,
  82%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  86% {
    transform: translate(4px, 4px) scale(1.02);
  }

  90% {
    transform: translate(-2px, -1px) scale(1.004);
  }

  95% {
    transform: translate(1px, 1px) scale(1.012);
  }
}

.clench {
  animation: ember-clench var(--clench-dur) ease-in-out infinite;
}

/* headline lines: inline-block so strain can grip them;
   hovering surfaces the echo trail — potential energy made visible */
.h-line {
  display: inline-block;
  transition: text-shadow var(--dur-2) var(--ease-press);
}

.h-line:hover {
  text-shadow: 4px 4px 0 var(--edge-faint), 8px 8px 0 var(--sunk);
}

/* the scan: a plate turned in 3D toward an adjacent vacancy —
   unbalance held on purpose becomes tension. Pair with an
   annotated vacancy note. */
@keyframes ember-scan {

  0%,
  100% {
    transform: perspective(1600px) rotateY(4.5deg);
  }

  50% {
    transform: perspective(1600px) rotateY(8deg);
  }
}

.face-turn {
  transform-origin: left center;
  transform: perspective(1600px) rotateY(6deg);
  animation: ember-scan var(--scan-dur) ease-in-out infinite;
  will-change: transform;
}

/* the megaphone: type fired off an ink slab — big, stretched wide,
   sheared, mildly receding — aimed at the adjacent vacancy and
   pulsing its aim on the scan cycle. Pair with a ::before slab on
   the untransformed parent and an annotated vacancy note. */
@keyframes ember-mega {

  0%,
  100% {
    transform: perspective(1200px) rotateY(6deg) rotate(-3.2deg) skewX(-5deg) scaleX(var(--stretch, 1.2));
  }

  50% {
    transform: perspective(1200px) rotateY(10deg) rotate(-3.2deg) skewX(-5deg) scaleX(var(--stretch, 1.2));
  }
}

.megaphone {
  --stretch: 1.2;
  transform-origin: left center;
  transform: perspective(1200px) rotateY(8deg) rotate(-3.2deg) skewX(-5deg) scaleX(var(--stretch));
  animation: ember-mega var(--scan-dur) ease-in-out infinite;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {

  .marquee-track,
  .stripe-rail,
  .press-in,
  .press-in-2,
  .press-in-3,
  .press-in-4,
  .strain-a,
  .strain-b,
  .clench,
  .ember-pulse,
  .face-turn,
  .megaphone {
    animation: none;
  }

  /* the band squares up: no tilt, no skew, no counter-marching rail */
  .band {
    transform: none;
  }

  .marquee {
    transform: none;
  }

  .marquee {
    overflow-x: auto;
  }
}
