/* Trigfield: the page as a red player-piano roll. Paper, printed ink, brass,
   holes punched through to the dark backing, and light only where a signal is. */

:root {
  --paper: #dc5b3e;
  --paper-deep: #b9432c;
  --ink: #1a0f0c;
  --ink-soft: #350b07;
  --hole: #140c0a;
  --ground: #0f0908;
  --brass: #d8b25a;
  --brass-hi: #f3dc98;
  --brass-lo: #8c6622;
  --light: #fff0c2;
  --glow: rgba(255, 214, 128, 0.62);

  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --text: 'Libre Franklin', 'Franklin Gothic Medium', 'Helvetica Neue', sans-serif;
  --mono: 'JetBrains Mono', 'DejaVu Sans Mono', Menlo, Consolas, monospace;

  --gutter: clamp(18px, 6vw, 84px);
  --measure: 62ch;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.75rem;
  --space-4: 3rem;
  --space-5: clamp(4rem, 9vw, 7.5rem);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--ground);
  scrollbar-color: var(--paper-deep) var(--ground);
  scrollbar-width: thin;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 3px; }

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

code, kbd {
  font-family: var(--mono);
  font-size: 0.92em;
  font-weight: 700;
}

kbd {
  display: inline-block;
  padding: 0 0.35em;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  line-height: 1.35;
}

/* ---- the roll ----------------------------------------------------------- */

.roll {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(4.25rem, 6vw, 6rem) var(--gutter) 0;
  background-color: var(--paper);
  /* paper fibre: a faint, fixed-seed noise printed into the stock */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9 0.35' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.06 0 0 0 0 0.03 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  /* the leader tapers to the tab the take-up spool hooks into */
  clip-path: polygon(0 5.5rem, 44% 0, 56% 0, 100% 5.5rem, 100% 100%, 0 100%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.roll::before {
  /* the hook hole in the leader tab */
  content: '';
  position: absolute;
  top: 1.35rem;
  left: 50%;
  width: 1.5rem;
  height: 1.5rem;
  margin-left: -0.75rem;
  border-radius: 50%;
  background: var(--ground);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.8);
}

/* printed guide rules and markings along both edges, as on a real roll */
.margin {
  position: absolute;
  top: 7.5rem;
  display: flex;
  flex-direction: row;
  gap: 2.5rem;
  writing-mode: vertical-rl;
  font: 600 0.72rem/1 var(--text);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.margin-left { left: calc(var(--gutter) * 0.28); border-right: 1px solid var(--paper-deep); padding-right: 0.55rem; transform: rotate(180deg); transform-origin: center; }
.margin-right { right: calc(var(--gutter) * 0.28); border-left: 1px solid var(--paper-deep); padding-left: 0.55rem; }

/* ---- leader --------------------------------------------------------------- */

.leader { text-align: center; }

.title {
  margin: 0;
  font: 900 clamp(4.6rem, min(16vw, 21vh), 14.5rem)/0.8 var(--display);
  letter-spacing: 0.005em;
  text-transform: uppercase;
  color: var(--ink);
}

/* the roll label: number, what it is, and the live tempo and step, in one ruled cartouche */
.label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  max-width: 740px;
  margin: 1.1rem auto 0;
  padding: 0.55rem 0;
  border-top: 2px solid var(--ink);
}
.label-no, .label-marks {
  font: 800 0.95rem/1 var(--display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.label-marks { display: flex; gap: 1.1rem; }
.lede {
  margin: 0;
  font-size: clamp(1.02rem, 1.5vw, 1.2rem);
  line-height: 1.35;
}

/* ---- stage: the live field over the tracker bar ------------------------- */

/* the field frame's top rule also closes the roll label above it */
.stage {
  margin: 0 auto;
  max-width: 740px;
}

.stage-note {
  max-width: 44rem;
  margin: var(--space-2) auto 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-wrap: balance;
}

.field-frame {
  position: relative;
  padding: 14px 0;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

/* canvases keep their drawn size; a field wider than a phone scrolls in its frame */
.field { display: block; margin: 0 auto; }

.field-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font: 600 0.95rem var(--text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.field-status:empty { display: none; }

.tracker-bar {
  position: relative;
  margin-top: clamp(14px, 2.5vw, 22px);
  padding: 0.7rem 1.1rem 0.65rem;
  border: 1px solid var(--brass-lo);
  border-radius: 3px;
  background: var(--brass);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  color: #20140a;
}

.ports {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.port {
  --lit: 0;
  display: grid;
  justify-items: center;
  gap: 0.28rem;
  min-width: 0;
}

.port-no {
  font: 800 0.8rem/1 var(--display);
  letter-spacing: 0.06em;
}

.port-hole {
  width: min(2.2rem, 70%);
  height: 0.8rem;
  border-radius: 0.4rem;
  background: var(--hole);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.9),
    0 0 calc(var(--lit) * 16px) calc(var(--lit) * 3px) var(--glow);
  position: relative;
  overflow: hidden;
}
.port-hole::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--light);
  opacity: var(--lit);
}

.port-name {
  white-space: nowrap;
  font: 800 0.82rem/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem 1.25rem;
  margin-top: var(--space-3);
}

/* brass plate: the primary action */
.plate {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1.6rem 0.8rem;
  border: 1px solid var(--brass-lo);
  border-radius: 3px;
  background: var(--brass);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.35);
  color: #20140a;
  cursor: pointer;
  font: 800 1.35rem/1 var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 160ms cubic-bezier(0.16, 1, 0.3, 1), background-color 160ms;
}
.plate:hover { background: var(--brass-hi); transform: translateY(-1px); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35); text-decoration: none; }
.plate:active { transform: translateY(1px); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35); }
.plate:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.plate-small { font-size: 1.1rem; padding: 0.75rem 1.2rem 0.7rem; gap: 0.5rem; }
.plate-icon { width: 0.95em; height: 0.95em; }
.plate .icon-pause { display: none; }
.plate[aria-pressed='true'] .icon-play { display: none; }
.plate[aria-pressed='true'] .icon-pause { display: inline; }
.plate-arrow { width: 1.15em; height: 1.15em; }
.plate-large { font-size: clamp(1.6rem, 4vw, 2.4rem); padding: 1.1rem 2.2rem 1rem; }


/* ---- bands ------------------------------------------------------------------ */

.band {
  padding-top: var(--space-5);
}

.band h2 {
  margin: 0 0 var(--space-3);
  padding-top: var(--space-3);
  border-top: 3px solid var(--ink);
  font: 900 clamp(2.6rem, 6.5vw, 4.6rem)/0.9 var(--display);
  text-transform: uppercase;
  letter-spacing: 0.005em;
}

.band h3 {
  margin: 0 0 var(--space-1);
  font: 800 1.35rem/1.15 var(--display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.band p { max-width: var(--measure); margin: 0 0 var(--space-2); }

.band-intro { font-size: 1.12rem; }

.band-note { margin-top: var(--space-3) !important; }

/* rules: text beside a live strip, three passes down the roll */
.rule {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: var(--space-3) var(--space-4);
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--paper-deep);
}
.rule:last-child { border-bottom: 0; }
.rule h3 { font-size: clamp(1.45rem, 2.6vw, 2rem); text-transform: none; letter-spacing: 0.01em; }
.rule p { margin: 0; }

.strip-figure { margin: 0; display: grid; justify-items: center; gap: 0.6rem; }
.strip { display: block; }

/* the glyph chart: rows ruled like a roll catalogue */
.group {
  margin-top: var(--space-4) !important;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--ink);
}

.chart {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--space-4);
  margin: 0;
}

.entry {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.2rem 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--paper-deep);
}
.entry.wide { grid-column: 1 / -1; }

.entry dt {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.2;
}
.entry dt code { font-size: inherit; margin-right: 0.15em; }
.entry dd { margin: 0; }
.entry-name { font-weight: 800; margin-right: 0.3em; }
.entry .strip { margin-top: 0.75rem; }

.readout {
  display: block;
  margin-top: 0.35rem;
  font: 700 0.85rem var(--mono);
  color: var(--ink-soft);
  min-height: 1.2em;
}

/* a trig row, taken apart */
.anatomy {
  display: grid;
  grid-template-columns: repeat(4, minmax(7.5rem, 1fr)) repeat(3, minmax(6.5rem, 0.9fr));
  margin: var(--space-3) 0;
}
.anatomy code {
  grid-row: 1;
  padding: 0 0.8rem 0.6rem 0;
  border-bottom: 2px solid var(--ink);
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  white-space: nowrap;
}
.anatomy span {
  grid-row: 2;
  padding: 0.6rem 1rem 0 0;
  font-size: 0.9rem;
  line-height: 1.35;
}
.anatomy .span-fx { grid-column: 5 / span 3; }
.fx-group { display: contents; }

.fx-lists {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--space-4);
}
.fx-codes { line-height: 1.9; }
.fx-codes > span { white-space: nowrap; margin-right: 0.9em; }
.fx-codes code { margin-right: 0.2em; }

.key-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.key-list { margin: 0; padding: 0; list-style: none; }
.key-list li { padding: 0.55rem 0; border-bottom: 1px solid var(--paper-deep); }

.lineage p { font-size: 1.12rem; }

/* ---- the tail ------------------------------------------------------------------ */

.tail {
  margin-top: var(--space-5);
  padding: var(--space-4) 0 var(--space-4);
  border-top: 3px solid var(--ink);
  display: grid;
  justify-items: center;
  gap: var(--space-3);
}
.tail-mark {
  margin: 0;
  font: 900 clamp(2.4rem, 7vw, 4.4rem)/1 var(--display);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
}
.colophon { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }

/* ---- narrow ---------------------------------------------------------------------- */

@media (max-width: 860px) {
  .rule { grid-template-columns: 1fr; }
  .anatomy { grid-template-columns: 7rem 1fr; row-gap: 0; }
  .anatomy code, .anatomy span { grid-row: auto; padding: 0.55rem 0; border-bottom: 1px solid var(--paper-deep); }
  .anatomy code { grid-column: 1; }
  .anatomy span, .anatomy .span-fx { grid-column: 2; }
  .anatomy .fx-group { display: flex; flex-direction: column; gap: 0.3rem; grid-column: 1; padding: 0.55rem 0; border-bottom: 1px solid var(--paper-deep); }
  .anatomy .fx-group code { border: 0; padding: 0; }
  .chart { grid-template-columns: 1fr; }
  .fx-lists, .key-columns { grid-template-columns: 1fr; gap: var(--space-3); }
}

@media (max-width: 560px) {
  .roll { clip-path: polygon(0 3.5rem, 40% 0, 60% 0, 100% 3.5rem, 100% 100%, 0 100%); }
  .roll::before { top: 0.9rem; width: 1.1rem; height: 1.1rem; margin-left: -0.55rem; }
  .margin { display: none; }
  .label { grid-template-columns: 1fr; gap: 0.45rem; text-align: center; }
  .label-no { display: none; }
  .label-marks { justify-content: center; font-size: 0.8rem; }
  .field-frame { margin: 0 calc(8px - var(--gutter)); }
  .ports { gap: 0.1rem; }
  .port-name { font-size: 0.74rem; letter-spacing: 0.02em; }
  .entry { grid-template-columns: 1fr; }
  .plate { font-size: 1.2rem; }
  .plate-small { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  .plate { transition: none; }
}
