/* ==========================================================================
   CRANSLEY SIGNAL WORKS
   Palette is the UK lever-plate standard and nothing else:
   red stop, yellow distant, black points, blue facing point lock,
   brown gate gear, white spare. Ground is signal-box diagram black.
   ========================================================================== */

:root {
  --panel:   #0B0E10;
  --panel-2: #10161A;
  --steel:   #161D22;
  --steel-2: #1D262C;
  --line:    #2A353C;
  --line-2:  #3A4A53;
  --chalk:   #E9EDEF;
  --muted:   #8E9DA6;
  --muted-2: #7C8A92;

  --paper:   #E8E2D4;
  --paper-2: #DCD3C0;
  --paper-rule: #B9AE95;
  --ink:     #15181B;

  --stop:    #C0342C;
  --dist:    #E0A81E;
  --pts:     #10161A;
  --fpl:     #2E62AE;
  --gate:    #8A5C33;
  --spare:   #D2D6D1;
  --clear:   #3E9C73;

  --sans: 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  --slab: 'Rokkitt', Georgia, serif;
  --mono: 'DM Mono', ui-monospace, 'Courier New', monospace;

  --gut: clamp(1.15rem, 4vw, 3.5rem);
  --maxw: 1280px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--panel);
  color: var(--chalk);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.02; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

.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;
}
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 90;
  background: var(--dist); color: #14181B; padding: .7rem 1.1rem;
  font-weight: 700; text-decoration: none;
}
.skip:focus { left: .5rem; top: .5rem; }

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

.eyebrow {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: .55rem;
}
.eyebrow .dot { width: 7px; height: 7px; background: var(--dist); border-radius: 50%; flex: none; }

/* ============================= HEADER ============================= */
.top {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .7rem var(--gut);
  background: rgba(11, 14, 16, .93);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.mark { text-decoration: none; display: grid; line-height: 1; }
.mark-name {
  font-family: var(--slab); font-weight: 800; font-size: 1.32rem;
  letter-spacing: .015em; text-transform: uppercase;
}
.mark-sub {
  font-family: var(--mono); font-size: .6rem; letter-spacing: .17em;
  text-transform: uppercase; color: var(--muted); margin-top: .28rem;
}
.nav { display: flex; gap: 1.6rem; }
.nav a {
  text-decoration: none; font-size: .82rem; font-weight: 500;
  letter-spacing: .02em; color: var(--chalk); padding: .35rem 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { border-bottom-color: var(--dist); }
.burger {
  display: none; background: none; border: 1px solid var(--line);
  width: 42px; height: 38px; padding: 0; cursor: pointer;
  align-items: center; justify-content: center; flex-direction: column; gap: 5px;
}
.burger span { display: block; width: 18px; height: 2px; background: var(--chalk); transition: transform .22s, opacity .22s; }
.burger[aria-expanded="true"] span:first-child { transform: translateY(3.5px) rotate(45deg); }
.burger[aria-expanded="true"] span:last-child { transform: translateY(-3.5px) rotate(-45deg); }

.drawer {
  position: fixed; inset: 61px 0 auto 0; z-index: 55;
  background: var(--panel-2); border-bottom: 1px solid var(--line);
  padding: 1.4rem var(--gut) 1.8rem;
  display: grid; gap: 1.1rem;
  transform: translateY(-115%); transition: transform .3s cubic-bezier(.2,.7,.3,1);
}
.drawer[data-open="true"] { transform: none; }
.drawer a {
  text-decoration: none; font-family: var(--slab); font-size: 1.5rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .01em;
  border-bottom: 1px solid var(--line); padding-bottom: .7rem;
}
.drawer-foot { font-family: var(--mono); font-size: .68rem; color: var(--muted); letter-spacing: .04em; }

/* ============================= HERO ============================= */
.hero { padding: clamp(3rem, 8vw, 6.5rem) var(--gut) clamp(2.2rem, 5vw, 3.4rem); max-width: var(--maxw); margin: 0 auto; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  grid-template-rows: auto auto;
  column-gap: clamp(1.5rem, 5vw, 4rem);
  row-gap: 1.6rem;
  align-items: end;
}
.hero .eyebrow { grid-column: 1 / -1; grid-row: 1; }
.hero h1 {
  grid-column: 1; grid-row: 2;
  font-family: var(--slab);
  font-size: clamp(3.1rem, 7.4vw, 6.4rem);
  font-weight: 800;
  line-height: .88;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  margin: 0;
}
.hero-side { grid-column: 2; grid-row: 2; display: grid; gap: 1.1rem; padding-bottom: .5rem; }
.stand { font-size: clamp(1.02rem, 1.6vw, 1.22rem); line-height: 1.45; max-width: 46ch; }
.stand-2 { color: var(--muted); font-size: .95rem; line-height: 1.6; max-width: 50ch; }
.cta-row { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .3rem; }

.btn {
  display: inline-block; text-decoration: none; cursor: pointer;
  font-size: .8rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  padding: .82rem 1.4rem; border: 1px solid transparent;
  transition: background .18s, color .18s, border-color .18s;
}
.btn-primary { background: var(--dist); color: #14181B; }
.btn-primary:hover { background: #F2BC2E; }
.btn-ghost { border-color: var(--line-2); color: var(--chalk); background: none; }
.btn-ghost:hover { border-color: var(--chalk); }

/* ============================= PANEL ============================= */
.panel {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, #0D1114 0%, #0A0D0F 100%);
  padding: clamp(1.6rem, 4vw, 2.6rem) var(--gut) clamp(2.6rem, 6vw, 4rem);
}
.panel-head {
  max-width: var(--maxw); margin: 0 auto clamp(1rem, 2.5vw, 1.6rem);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1.2rem;
  border-bottom: 1px solid var(--line); padding-bottom: .8rem;
}
.panel-head h2 {
  font-family: var(--slab); font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  text-transform: uppercase; letter-spacing: .01em;
}
.panel-meta { font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ------- diagram ------- */
.diagram-wrap { max-width: var(--maxw); margin: 0 auto; position: relative; }
.scroll-hint { display: none; }
.diagram-scroll {
  overflow-x: auto; overflow-y: hidden;
  background: #06090A;
  border: 1px solid var(--line);
  padding: .5rem;
  scrollbar-width: thin;
}
.diagram { width: 100%; min-width: 900px; height: auto; }

.diagram .rail { fill: none; stroke: var(--chalk); stroke-width: 2.4; }
.diagram .rail-sid { stroke: var(--muted); stroke-width: 2; }
.diagram .road { fill: rgba(138, 92, 51, .16); }
.diagram .plat { fill: rgba(233, 237, 239, .07); stroke: var(--line-2); stroke-width: 1; }
.diagram .dg-lbl { font-family: var(--mono); font-size: 7.5px; letter-spacing: .12em; fill: var(--muted-2); }
.diagram .dg-name { font-family: var(--mono); font-size: 9px; letter-spacing: .15em; fill: var(--muted); }
.diagram .dg-num { font-family: var(--mono); font-size: 10px; font-weight: 500; fill: var(--muted); letter-spacing: .04em; }
.diagram .arrowhead { fill: var(--muted); }

.diagram .leg { fill: none; stroke-width: 2.4; transition: stroke .3s, opacity .3s; }
.diagram .leg-n, .diagram .leg-r { stroke: var(--line-2); opacity: .6; }
.diagram .leg.set { stroke: var(--chalk); opacity: 1; }

.diagram .post { stroke: var(--muted); stroke-width: 2; }
.diagram .post-doll { stroke: var(--muted); stroke-width: 2; }
.diagram .blade { fill: var(--stop); stroke: none; }
.diagram .band { fill: #F3F0E8; }
.diagram .arm-dist .blade { fill: var(--dist); }
.diagram .arm-dist .chev { fill: #14181B; }
.diagram .arm { transform-origin: 0 0; transition: transform .45s cubic-bezier(.3,1.4,.5,1); }
.diagram .sig-down.off .arm { transform: rotate(45deg); }
.diagram .sig-up.off .arm { transform: rotate(-45deg); }
.diagram .lens { fill: var(--stop); transition: fill .3s; }
.diagram .sig-down.off .lens, .diagram .sig-up.off .lens { fill: var(--clear); }
.diagram .arm-dist ~ .lens, .diagram #sig-1 .lens, .diagram #sig-15 .lens { fill: var(--dist); }
.diagram #sig-1.off .lens, .diagram #sig-15.off .lens { fill: var(--clear); }

.diagram .disc-face { fill: #F3F0E8; stroke: var(--line-2); stroke-width: 1; }
.diagram .disc-bar { transform-origin: 0 0; transition: transform .4s cubic-bezier(.3,1.4,.5,1); }
.diagram .disc-bar rect { fill: var(--stop); }
.diagram .disc.off .disc-bar { transform: rotate(-45deg); }
.diagram .disc.off .disc-bar rect { fill: var(--clear); }

.diagram .gate { transform-origin: 0 0; transition: transform .5s cubic-bezier(.3,1.2,.4,1); }
.diagram .gate rect { fill: var(--gate); stroke: #C08A55; stroke-width: 1; }
.diagram #gates.across .gate { transform: rotate(90deg); }
.diagram .bolt { fill: var(--line-2); transition: fill .3s; }
.diagram #gates.bolted .bolt { fill: var(--fpl); }

/* ------- tasks ------- */
.tasks { max-width: var(--maxw); margin: 1.4rem auto 0; }
.tasks-lead { font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.task {
  display: grid; grid-template-columns: 20px 1fr; gap: .35rem .65rem;
  align-items: start;
  border: 1px solid var(--line); background: var(--steel);
  padding: .8rem .9rem; transition: border-color .25s, background .25s;
}
.task .tick {
  grid-column: 1; grid-row: 1;
  width: 18px; height: 18px; border: 1px solid var(--line-2);
  position: relative; flex: none; margin-top: .1rem;
}
.task .tick::after {
  content: ''; position: absolute; left: 5px; top: 1px;
  width: 5px; height: 10px; border: solid var(--panel);
  border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0);
  transition: transform .22s cubic-bezier(.3,1.5,.5,1);
}
.task .task-t { grid-column: 2; grid-row: 1; font-size: .87rem; line-height: 1.35; }
.task .task-s {
  grid-column: 2; grid-row: 2;
  font-family: var(--mono); font-size: .64rem; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted-2);
}
.task.done { border-color: var(--clear); background: rgba(62, 156, 115, .09); }
.task.done .tick { background: var(--clear); border-color: var(--clear); }
.task.done .tick::after { transform: rotate(45deg) scale(1); }
.task.done .task-s { color: var(--clear); }

/* ------- floor: frame + register ------- */
.floor {
  max-width: var(--maxw); margin: 1.6rem auto 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(1rem, 2.5vw, 1.8rem);
  align-items: start;
}
.frame-col { min-width: 0; }
.frame-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.frame-head h3 { font-family: var(--slab); font-size: 1.3rem; text-transform: uppercase; }
.restore {
  background: none; border: 1px solid var(--line-2); color: var(--muted);
  font-family: var(--mono); font-size: .64rem; letter-spacing: .12em;
  text-transform: uppercase; padding: .45rem .8rem; cursor: pointer;
  transition: color .2s, border-color .2s;
}
.restore:hover { color: var(--chalk); border-color: var(--chalk); }
.frame-hint { font-size: .8rem; color: var(--muted); margin: .5rem 0 1rem; max-width: 66ch; }
.frame-hint b { font-weight: 600; padding: .05rem .3rem; border-radius: 2px; }
.k-stop { background: var(--stop); color: #fff; }
.k-dist { background: var(--dist); color: #14181B; }
.k-pts  { background: #000; color: #fff; border: 1px solid var(--line-2); }
.k-fpl  { background: var(--fpl); color: #fff; }
.k-gate { background: var(--gate); color: #fff; }
.k-spare{ background: var(--spare); color: #14181B; }

.frame-scroll { overflow-x: auto; overflow-y: hidden; padding-bottom: .4rem; scrollbar-width: thin; }
.frame {
  display: flex; align-items: flex-end; gap: 3px;
  min-width: 720px;
  background:
    linear-gradient(180deg, transparent 0 62%, #0E1417 62% 100%);
  border: 1px solid var(--line);
  border-bottom: 4px solid var(--line-2);
  padding: 1.4rem .8rem 0;
}

/* ---- one lever ---- */
.lever {
  position: relative;
  flex: 1 1 0; min-width: 34px;
  background: none; border: 0; padding: 0 0 .55rem; margin: 0;
  cursor: pointer; display: grid; justify-items: center;
  -webkit-tap-highlight-color: transparent;
}
.lever-stack {
  position: relative; display: block;
  width: 100%; height: 152px;
}
.lever-arm {
  position: absolute; left: 50%; bottom: 0;
  width: 9px; height: 140px; margin-left: -4.5px;
  background: linear-gradient(90deg, #4E5C64, #8B9AA2 42%, #38444B);
  border-radius: 4px 4px 1px 1px;
  transform-origin: 50% 100%;
  transform: rotate(9deg);
  transition: transform .42s cubic-bezier(.34, 1.42, .5, 1);
}
.lever-arm .grip {
  position: absolute; left: 50%; top: -4px; margin-left: -8px;
  width: 16px; height: 34px; border-radius: 8px;
  background: linear-gradient(90deg, #2B3237, #5C6A72 45%, #232A2E);
  border: 1px solid #1A2024;
}
.lever-arm::after {
  content: ''; position: absolute; left: 50%; top: 40px; margin-left: -7px;
  width: 14px; height: 7px; border-radius: 2px;
  background: #222A2F; border: 1px solid #141A1D;
}
.lever[aria-pressed="true"] .lever-arm { transform: rotate(-36deg); }

.lever-pivot {
  position: absolute; left: 50%; bottom: -3px; margin-left: -4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #47555D; border: 1px solid #1A2024;
}

.plate {
  width: 100%; max-width: 34px;
  border: 1px solid rgba(0,0,0,.6);
  display: grid; place-items: center;
  padding: .3rem 0 .34rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
  transition: box-shadow .2s, transform .12s;
}
.pnum { font-family: var(--mono); font-weight: 500; font-size: .84rem; line-height: 1; }
.lever[data-c="stop"]  .plate { background: var(--stop);  color: #fff; }
.lever[data-c="dist"]  .plate { background: var(--dist);  color: #14181B; }
.lever[data-c="pts"]   .plate { background: #05080A;      color: #fff; border-color: #2C373D; }
.lever[data-c="fpl"]   .plate { background: var(--fpl);   color: #fff; }
.lever[data-c="gate"]  .plate { background: var(--gate);  color: #fff; }
.lever[data-c="spare"] .plate { background: var(--spare); color: #14181B; }
.lever:hover .plate, .lever:focus-visible .plate { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 0 0 2px var(--dist); }

.lever.locked .lever-arm { animation: judder .34s ease; }
.lever.locked .plate { animation: flash .6s ease; }
@keyframes judder {
  0%, 100% { transform: rotate(9deg); }
  25% { transform: rotate(4deg); }
  60% { transform: rotate(12deg); }
}
.lever[aria-pressed="true"].locked .lever-arm { animation: judder-r .34s ease; }
@keyframes judder-r {
  0%, 100% { transform: rotate(-36deg); }
  25% { transform: rotate(-31deg); }
  60% { transform: rotate(-39deg); }
}
@keyframes flash {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.22); }
  30% { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 0 0 3px var(--stop); }
}

/* ---- plate detail strip ---- */
.plate-detail {
  margin-top: 1rem; border: 1px solid var(--line); background: var(--steel);
  padding: .85rem 1rem; min-height: 84px;
}
.pd-empty { color: var(--muted-2); font-size: .85rem; }
.pd-head { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.pd-n { font-family: var(--mono); font-size: 1.05rem; font-weight: 500; }
.pd-fn { font-family: var(--slab); font-size: 1.12rem; font-weight: 700; }
.pd-state {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; padding: .15rem .45rem; border: 1px solid var(--line-2); color: var(--muted);
}
.pd-state[data-s="reverse"] { color: var(--clear); border-color: var(--clear); }
.pd-body { font-size: .86rem; color: var(--muted); margin-top: .4rem; line-height: 1.5; }
.pd-lock { font-family: var(--mono); font-size: .72rem; color: var(--muted-2); margin-top: .4rem; letter-spacing: .02em; }
.pd-lock b { color: var(--dist); font-weight: 500; }

/* ---- register book ---- */
.register {
  background: var(--paper); color: var(--ink);
  border: 1px solid #9C917A;
  box-shadow: 0 14px 30px rgba(0,0,0,.4);
  display: flex; flex-direction: column; max-height: 520px;
}
.reg-head { padding: .85rem 1rem .6rem; border-bottom: 2px solid var(--ink); }
.reg-head h3 { font-family: var(--slab); font-size: 1.12rem; text-transform: uppercase; }
.reg-head p { font-family: var(--mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: #5F5849; margin-top: .2rem; }
.reg-cols {
  display: grid; grid-template-columns: 52px 34px 1fr;
  font-family: var(--mono); font-size: .58rem; letter-spacing: .13em; text-transform: uppercase;
  color: #5F5849; padding: .4rem 1rem; border-bottom: 1px solid var(--paper-rule);
  background: var(--paper-2);
}
.reg-body { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.reg-body li {
  display: grid; grid-template-columns: 52px 34px 1fr;
  gap: 0 .3rem; padding: .42rem 1rem;
  border-bottom: 1px solid var(--paper-rule);
  font-size: .78rem; line-height: 1.35;
  animation: regin .3s ease;
}
@keyframes regin { from { opacity: 0; transform: translateY(-4px); } }
.reg-body .t, .reg-body .n { font-family: var(--mono); font-size: .72rem; }
.reg-body .n { font-weight: 500; }
.reg-body li.refused { background: rgba(192, 52, 44, .1); }
.reg-body li.refused .e { color: #8E2B25; }
.reg-body li.done-row { background: rgba(62, 156, 115, .13); }
.reg-body li.done-row .e { color: #1F6247; font-weight: 600; }

/* ============================= WORKS ============================= */
.sec-head { max-width: var(--maxw); margin: 0 auto clamp(1.4rem, 3vw, 2.4rem); display: grid; gap: .7rem; }
.sec-head h2 {
  font-family: var(--slab); font-size: clamp(1.9rem, 5vw, 3.4rem);
  text-transform: uppercase; letter-spacing: -0.02em; max-width: 18ch;
}
.works { padding: clamp(3rem, 7vw, 5.5rem) var(--gut); }
.sched { list-style: none; margin: 0 auto; padding: 0; max-width: var(--maxw); }
.sched-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 260px) minmax(0, 1fr) 140px;
  gap: 0 clamp(1rem, 3vw, 2.4rem);
  align-items: start;
  padding: 1.5rem 0 1.5rem .9rem;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  transition: border-left-color .25s, background .25s, padding-left .25s;
}
.sched-row:hover { background: rgba(233, 237, 239, .035); padding-left: 1.3rem; }
.sched-row[data-c="pts"]:hover   { border-left-color: var(--chalk); }
.sched-row[data-c="fpl"]:hover   { border-left-color: var(--fpl); }
.sched-row[data-c="stop"]:hover  { border-left-color: var(--stop); }
.sched-row[data-c="dist"]:hover  { border-left-color: var(--dist); }
.sched-row[data-c="gate"]:hover  { border-left-color: var(--gate); }
.sched-row[data-c="spare"]:hover { border-left-color: var(--spare); }
/* every child placed explicitly — see PATTERNS.md, "state both tracks" */
.sched-n { grid-column: 1; grid-row: 1; font-family: var(--mono); font-size: .8rem; color: var(--muted-2); padding-top: .32rem; }
.sched-row h3 { grid-column: 2; grid-row: 1; font-family: var(--slab); font-size: 1.32rem; text-transform: uppercase; letter-spacing: 0; }
.sched-row p { grid-column: 3; grid-row: 1; color: var(--muted); font-size: .9rem; line-height: 1.6; }
.sched-note {
  grid-column: 4; grid-row: 1;
  font-family: var(--mono); font-size: .65rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted-2); text-align: right; padding-top: .35rem;
}

/* ============================= RULE ============================= */
.rule {
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  padding: clamp(3rem, 8vw, 6rem) var(--gut);
}
/* note: `ch` here would resolve against the inherited 16px font, not the
   display size on the <p>, which collapses this to a ~190px column */
.rule blockquote { max-width: min(880px, 92%); margin: 0 auto; text-align: center; }
.rule p {
  font-family: var(--slab); font-weight: 700;
  font-size: clamp(1.8rem, 5.4vw, 3.6rem); line-height: 1.02;
  text-transform: uppercase; letter-spacing: -0.02em;
}
.rule cite {
  display: block; margin-top: 1.4rem; font-style: normal;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted-2); max-width: none;
}

/* ============================= JOB BOOK ============================= */
.book { padding: clamp(3rem, 7vw, 5.5rem) var(--gut); }
.book-scroll { max-width: var(--maxw); margin: 0 auto; overflow-x: auto; scrollbar-width: thin; }
.jobs { width: 100%; min-width: 660px; border-collapse: collapse; }
.jobs th, .jobs td { text-align: left; padding: .8rem 1rem .8rem 0; border-bottom: 1px solid var(--line); }
.jobs thead th {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted-2); font-weight: 400;
  border-bottom: 1px solid var(--line-2);
}
.jobs td { font-size: .9rem; }
.jobs tbody tr:first-child td { color: var(--chalk); }
.jobs tbody tr:first-child td:first-child { font-weight: 600; }
.jobs tbody td:nth-child(2), .jobs tbody td:nth-child(3), .jobs tbody td:nth-child(5) { color: var(--muted); }
.jobs .num { font-family: var(--mono); font-size: .82rem; text-align: right; padding-right: 1.4rem; }
.jobs tbody tr { transition: background .2s; }
.jobs tbody tr:hover { background: rgba(233, 237, 239, .04); }
.book-foot { max-width: var(--maxw); margin: 1.1rem auto 0; font-family: var(--mono); font-size: .72rem; color: var(--muted-2); letter-spacing: .03em; }

/* ============================= DOCKET ============================= */
.docket {
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  padding: clamp(3rem, 7vw, 5.5rem) var(--gut);
}
.docket-grid {
  max-width: var(--maxw); margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1.8rem, 5vw, 4rem);
  align-items: start;
}
.docket-say { display: grid; gap: 1rem; }
.docket-say h2 { font-family: var(--slab); font-size: clamp(1.8rem, 4vw, 2.7rem); text-transform: uppercase; max-width: 15ch; }
.docket-say > p { color: var(--muted); font-size: .95rem; line-height: 1.65; max-width: 48ch; }
.docket-facts { margin: .6rem 0 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.docket-facts > div {
  display: grid; grid-template-columns: 110px 1fr; gap: 1rem;
  padding: .7rem 0; border-bottom: 1px solid var(--line);
}
.docket-facts dt { font-family: var(--mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2); padding-top: .18rem; }
.docket-facts dd { margin: 0; font-size: .88rem; }

.docket-form { background: var(--steel); border: 1px solid var(--line); padding: clamp(1.2rem, 3vw, 1.9rem); }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.field { margin: 0; grid-column: 1 / -1; display: grid; gap: .35rem; }
.field-half { grid-column: span 1; }
.field label { font-family: var(--mono); font-size: .62rem; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--panel); border: 1px solid var(--line-2); color: var(--chalk);
  padding: .62rem .7rem; font-size: .9rem; width: 100%; border-radius: 0;
  transition: border-color .2s;
}
.field textarea { resize: vertical; min-height: 88px; font-family: var(--sans); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--dist); outline: none; }
.field input[aria-invalid="true"] { border-color: var(--stop); }
.docket-form .btn { margin-top: 1.1rem; }
.form-note { margin-top: .9rem; font-size: .8rem; color: var(--muted-2); }
.form-note[data-state="sent"] { color: var(--clear); }
.form-note[data-state="error"] { color: var(--stop); }

/* ============================= FOOTER ============================= */
.foot { border-top: 1px solid var(--line); padding: clamp(2.4rem, 5vw, 3.6rem) var(--gut) 1.4rem; }
.foot-grid {
  max-width: var(--maxw); margin: 0 auto;
  display: grid; grid-template-columns: 220px repeat(3, minmax(0, 1fr));
  gap: clamp(1.4rem, 4vw, 3rem);
  align-items: start;
}
.foot-plate svg { width: 100%; height: auto; }
.pl-body { fill: #1A2126; stroke: #39464D; stroke-width: 1.5; }
.pl-inner { fill: none; stroke: #4C5C64; stroke-width: 1; }
.pl-a { font-family: var(--slab); font-weight: 800; font-size: 22px; fill: #B9C6CC; letter-spacing: .08em; }
.pl-b { font-family: var(--slab); font-weight: 700; font-size: 14px; fill: #8E9DA6; letter-spacing: .13em; }
.pl-c { font-family: 'DM Mono', monospace; font-size: 8px; fill: #67757D; letter-spacing: .2em; }
.foot-col h4 { font-family: var(--mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); font-weight: 400; margin-bottom: .6rem; }
.foot-col p { font-size: .86rem; color: var(--muted); line-height: 1.75; }
.foot-col a { text-decoration: none; }
.foot-col a:hover { color: var(--dist); }
.foot-quote { font-style: italic; max-width: 26ch; }
.foot-bar {
  max-width: var(--maxw); margin: clamp(1.8rem, 4vw, 2.6rem) auto 0;
  padding-top: 1rem; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: .4rem 1.6rem;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted-2);
}

/* ============================= REVEAL =============================
   Content is visible by DEFAULT and the entrance is additive: `.in`
   plays a keyframe animation with `backwards` fill, so the element is
   only hidden while its own animation is pending. Nothing here can
   leave content stranded at opacity 0 if a callback is dropped or the
   animation clock never ticks. */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.reveal.in { animation: riseIn .7s cubic-bezier(.2, .7, .3, 1) backwards; }

/* ==========================================================================
   MOBILE — the frame is not a shrunk frame. It becomes a vertical
   lever list, the register becomes a folded sheet, the diagram a
   deliberate side-scroll with its own hint.
   ========================================================================== */
@media (max-width: 1080px) {
  .floor { grid-template-columns: 1fr; }
  .register { max-height: 380px; }
  .sched-row { grid-template-columns: 58px minmax(0, 220px) minmax(0, 1fr); }
  .sched-note { grid-column: 2 / -1; grid-row: 2; text-align: left; padding-top: .7rem; }
}

@media (max-width: 860px) {
  .nav { display: none; }
  .burger { display: flex; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero h1 { grid-column: 1; grid-row: 2; }
  .hero-side { grid-column: 1; grid-row: 3; padding-bottom: 0; }
  .hero-note { grid-column: 1; grid-row: 4; }
  .task-list { grid-template-columns: 1fr; }
  .docket-grid { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-grid > :nth-child(1) { grid-column: 1 / -1; grid-row: 1; max-width: 200px; }
  .foot-grid > :nth-child(2) { grid-column: 1; grid-row: 2; }
  .foot-grid > :nth-child(3) { grid-column: 2; grid-row: 2; }
  .foot-grid > :nth-child(4) { grid-column: 1 / -1; grid-row: 3; }
}

@media (max-width: 700px) {
  .scroll-hint {
    display: block;
    font-family: var(--mono); font-size: .6rem; letter-spacing: .13em;
    text-transform: uppercase; color: var(--muted-2); margin-bottom: .4rem;
  }
  .diagram { min-width: 760px; }

  /* --- the frame, re-composed as a vertical list of plates --- */
  .frame-scroll { overflow: visible; padding: 0; }
  .frame {
    display: grid; grid-template-columns: 1fr; gap: 0;
    min-width: 0; background: var(--steel); padding: 0;
    border-bottom-width: 1px;
  }
  .lever {
    grid-template-columns: 46px 1fr 74px;
    grid-template-areas: 'plate label state';
    align-items: center; justify-items: stretch;
    gap: .85rem; padding: .6rem .75rem;
    border-bottom: 1px solid var(--line);
    text-align: left; width: 100%;
  }
  .frame .lever:last-child { border-bottom: 0; }
  .lever-stack { display: none; }
  .plate {
    grid-area: plate; max-width: none; width: 46px; height: 40px;
    position: relative; overflow: hidden;
  }
  .plate::after {
    content: ''; position: absolute; right: 3px; top: 3px; bottom: 3px; width: 4px;
    background: rgba(0,0,0,.35); transition: background .25s;
  }
  .lever[aria-pressed="true"] .plate::after { background: var(--clear); }
  .pnum { font-size: 1rem; }
  .lever-label {
    grid-area: label; display: block; font-size: .87rem; line-height: 1.3;
    color: var(--chalk);
  }
  .lever-sub {
    display: block; font-family: var(--mono); font-size: .6rem; letter-spacing: .1em;
    text-transform: uppercase; color: var(--muted-2); margin-top: .18rem;
  }
  .lever-state {
    grid-area: state; font-family: var(--mono); font-size: .6rem; letter-spacing: .12em;
    text-transform: uppercase; color: var(--muted-2); text-align: right;
    border: 1px solid var(--line); padding: .25rem .1rem;
    transition: color .2s, border-color .2s, background .2s;
  }
  .lever[aria-pressed="true"] .lever-state { color: var(--clear); border-color: var(--clear); background: rgba(62,156,115,.1); }
  .lever.locked .plate { animation: flash .6s ease; }
  .lever.locked { animation: shakerow .3s ease; }
  @keyframes shakerow { 0%,100% { transform: none; } 30% { transform: translateX(-5px); } 65% { transform: translateX(4px); } }

  .frame-hint b { display: inline-block; margin: .1rem 0; }

  /* the plate readout becomes a pinned header for the lever list, not a
     footer plate — it is the thing you read while you work down the frame */
  .frame-col { display: flex; flex-direction: column; }
  .frame-head { order: 1; }
  .frame-hint { order: 2; }
  .plate-detail {
    order: 3; position: sticky; top: 58px; z-index: 6;
    margin: 0 0 .7rem; min-height: 0; padding: .6rem .8rem;
    background: var(--panel-2); border-color: var(--line-2);
  }
  .frame-scroll { order: 4; }
  .pd-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: .3rem; }
  .pd-fn { font-size: 1rem; }
  .jobs { min-width: 560px; }
}

@media (max-width: 560px) {
  .lever-state { display: none; }
  .lever { grid-template-columns: 46px 1fr; grid-template-areas: 'plate label'; }
  .hero h1 { font-size: clamp(3rem, 15vw, 5rem); }
  .foot-grid { grid-template-columns: 1fr; }
  .foot-grid > :nth-child(1) { grid-column: 1; grid-row: 1; }
  .foot-grid > :nth-child(2) { grid-column: 1; grid-row: 2; }
  .foot-grid > :nth-child(3) { grid-column: 1; grid-row: 3; }
  .foot-grid > :nth-child(4) { grid-column: 1; grid-row: 4; }
  .sched-row { grid-template-columns: 46px minmax(0, 1fr); }
  .sched-n { grid-column: 1; grid-row: 1; }
  .sched-row h3 { grid-column: 2; grid-row: 1; }
  .sched-row p { grid-column: 2; grid-row: 2; margin-top: .45rem; }
  .sched-note { grid-column: 2; grid-row: 3; padding-top: .55rem; }
  .docket-facts > div { grid-template-columns: 1fr; gap: .15rem; }
  .fgrid { grid-template-columns: 1fr; }
  .field-half { grid-column: 1 / -1; }
}

/* ---- lever-list labels only exist on the mobile composition ---- */
.lever-label, .lever-state { display: none; }
@media (max-width: 700px) { .lever-label { display: block; } }
@media (min-width: 561px) and (max-width: 700px) { .lever-state { display: block; } }

/* ==========================================================================
   WORKSHOP PAGE — the paperwork register. Ledger stock, a margin rail of
   bench numbers and weeks, rules instead of boxes.
   ========================================================================== */
body.doc { background: var(--paper); color: var(--ink); }
body.doc .top {
  background: rgba(232, 226, 212, .94);
  border-bottom: 2px solid var(--ink);
}
body.doc .mark-sub { color: #5F5849; }
body.doc .nav a { color: var(--ink); }
body.doc .nav a[aria-current="page"] { border-bottom-color: var(--ink); }
body.doc .burger { border-color: #9C917A; }
body.doc .burger span { background: var(--ink); }
body.doc .drawer { background: var(--paper-2); border-bottom-color: var(--ink); }
body.doc .drawer a { border-bottom-color: var(--paper-rule); }
body.doc .drawer-foot { color: #5F5849; }
body.doc .eyebrow { color: #5F5849; }

.doc-main { max-width: 1040px; margin: 0 auto; padding: 0 var(--gut); }

.doc-head { padding: clamp(2.6rem, 7vw, 5rem) 0 clamp(1.8rem, 4vw, 2.6rem); border-bottom: 2px solid var(--ink); display: grid; gap: 1.1rem; }
.doc-head h1 {
  font-family: var(--slab); font-weight: 800;
  font-size: clamp(2.8rem, 9vw, 6rem); line-height: .9;
  text-transform: uppercase; letter-spacing: -0.03em;
}
.doc-stand { font-size: clamp(1rem, 1.5vw, 1.15rem); line-height: 1.55; max-width: 62ch; color: #37342C; }

.doc-h2 {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .18em;
  text-transform: uppercase; color: #5F5849; font-weight: 400;
  padding: clamp(2.2rem, 5vw, 3.4rem) 0 1rem;
}
.doc-note { font-size: .86rem; color: #5A5446; max-width: 70ch; line-height: 1.6; margin-top: .9rem; }
.doc-note b { font-family: var(--mono); font-weight: 500; color: var(--ink); }
.doc-link { font-weight: 700; text-decoration: none; border-bottom: 2px solid var(--stop); color: var(--ink); }
.doc-link:hover { background: var(--dist); }

/* --- benches --- */
.bench-list { border-top: 1px solid var(--paper-rule); }
.bench {
  display: grid; grid-template-columns: 148px minmax(0, 1fr);
  gap: 0 clamp(1rem, 3vw, 2.4rem);
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--paper-rule);
}
.bench-rail { grid-column: 1; grid-row: 1; display: grid; gap: .2rem; align-content: start; }
.bench-body { grid-column: 2; grid-row: 1; }
.bench-n { font-family: var(--slab); font-weight: 800; font-size: 1.05rem; text-transform: uppercase; }
.bench-w { font-family: var(--mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: #5F5849; }
.bench-body h3 { font-family: var(--slab); font-size: 1.5rem; text-transform: uppercase; margin-bottom: .45rem; }
.bench-body p { font-size: .95rem; line-height: 1.65; color: #37342C; max-width: 66ch; }

/* --- locking table --- */
.doc-scroll { overflow-x: auto; scrollbar-width: thin; border-top: 2px solid var(--ink); }
.lock-table { width: 100%; min-width: 660px; border-collapse: collapse; }
.lock-table th, .lock-table td { text-align: left; padding: .6rem .9rem .6rem 0; border-bottom: 1px solid var(--paper-rule); }
.lock-table thead th {
  font-family: var(--mono); font-size: .6rem; letter-spacing: .14em;
  text-transform: uppercase; color: #5F5849; font-weight: 400;
  border-bottom: 1px solid var(--ink);
}
.lock-table td { font-size: .88rem; }
.lock-table .num { font-family: var(--mono); width: 48px; font-weight: 500; }
.lock-table .mono { font-family: var(--mono); font-size: .78rem; color: #4B463B; }
.lock-table tbody tr:hover { background: rgba(21, 24, 27, .05); }
.lock-table .spare-row td { color: #8A8271; }
.chip {
  display: inline-block; font-family: var(--mono); font-size: .6rem;
  letter-spacing: .1em; text-transform: uppercase;
  padding: .16rem .45rem; border: 1px solid rgba(0,0,0,.35);
}
.c-stop { background: var(--stop); color: #fff; }
.c-dist { background: var(--dist); color: #14181B; }
.c-pts  { background: #14181B; color: #fff; }
.c-fpl  { background: var(--fpl); color: #fff; }
.c-gate { background: var(--gate); color: #fff; }
.c-spare{ background: #F5F2E9; color: #14181B; }

/* --- refusals --- */
.refuse-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.refuse-list li {
  padding: 1.05rem 0 1.05rem 2.4rem; border-bottom: 1px solid var(--paper-rule);
  position: relative; font-size: .95rem; line-height: 1.6; color: #37342C; max-width: 72ch;
}
.refuse-list li::before {
  content: ''; position: absolute; left: 0; top: 1.35rem;
  width: 14px; height: 14px; background: var(--stop);
}
.refuse-list b { color: var(--ink); }

.doc-cta {
  margin: clamp(2.4rem, 6vw, 4rem) 0 clamp(3rem, 7vw, 5rem);
  padding: clamp(1.4rem, 4vw, 2.2rem);
  border: 2px solid var(--ink);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.2rem;
}
.doc-cta p { font-family: var(--slab); font-size: clamp(1.1rem, 2.4vw, 1.5rem); font-weight: 700; max-width: 40ch; line-height: 1.2; }
body.doc .btn-primary { background: var(--ink); color: var(--paper); }
body.doc .btn-primary:hover { background: var(--stop); }

body.doc .foot { border-top: 2px solid var(--ink); }
body.doc .pl-body { fill: #D5CBB6; stroke: #8E836C; }
body.doc .pl-inner { stroke: #A2977F; }
body.doc .pl-a { fill: #2A2721; }
body.doc .pl-b { fill: #4B463B; }
body.doc .pl-c { fill: #5F5849; }
body.doc .foot-col h4 { color: #5F5849; }
body.doc .foot-col p { color: #4B463B; }
body.doc .foot-col a:hover { color: var(--stop); }
body.doc .foot-bar { border-top-color: var(--paper-rule); color: #5F5849; }
body.doc :focus-visible { outline-color: var(--stop); }
body.doc .skip { background: var(--ink); color: var(--paper); }

@media (max-width: 700px) {
  .bench { grid-template-columns: 1fr; gap: .5rem; }
  .bench-rail { grid-column: 1; grid-row: 1; grid-auto-flow: column; justify-content: start; gap: .8rem; align-items: baseline; }
  .bench-body { grid-column: 1; grid-row: 2; }
  .lock-table { min-width: 560px; }
  .doc-cta { flex-direction: column; align-items: flex-start; }
}

/* ==========================================================================
   CRAFT LAYER
   Depth and texture come from the material the subject is actually made of:
   printed diagram halftone, routed panel edges, enamel gloss on the plates,
   and lamp glow behind the signal spectacles. No glass, no blur, no gradients
   that are not a lit surface.
   ========================================================================== */

/* ---- printed-diagram halftone + panel scanline ---- */
.panel { position: relative; }
.panel::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(rgba(233, 237, 239, .14) .5px, transparent .6px),
    repeating-linear-gradient(180deg, rgba(0, 0, 0, .10) 0 1px, transparent 1px 3px);
  background-size: 4px 4px, 100% 3px;
}
.panel > * { position: relative; z-index: 1; }

/* routed metal edge — a lit top bevel over a dark rebate */
.diagram-scroll, .frame, .plate-detail, .task, .register, .docket-form {
  box-shadow:
    inset 0 1px 0 rgba(233, 237, 239, .055),
    inset 0 -1px 0 rgba(0, 0, 0, .55),
    0 1px 0 rgba(233, 237, 239, .025);
}

/* ============================= HERO ============================= */
.hero { position: relative; overflow: hidden; }
.hero-ghost {
  position: absolute; right: 0; top: 50%; transform: translateY(-46%);
  width: 78%; max-width: none; height: auto; z-index: 0;
  pointer-events: none;
}
.hero-ghost path { fill: none; stroke: var(--chalk); stroke-width: 2; }
.hero-ghost circle { fill: none; stroke: var(--dist); stroke-width: 2; }
.hero-ghost { opacity: .07; }
.hero-grid { position: relative; z-index: 1; }

/* line-mask entrance — each headline line rises out of its own slot.
   Additive, like every other entrance here: with no `.ready` the
   headline simply sits where it belongs. */
@keyframes lineUp { from { transform: translateY(112%); } to { transform: none; } }
.hero-h1 { margin: 0; }
.hero-h1 .ln { display: block; overflow: hidden; padding-bottom: .04em; }
.hero-h1 .ln-i { display: block; }
.hero.ready .hero-h1 .ln-i {
  animation: lineUp 1s cubic-bezier(.16, 1, .3, 1) backwards;
  animation-delay: calc(var(--i) * .085s);
}
.hero.ready .eyebrow, .hero.ready .stand, .hero.ready .stand-2,
.hero.ready .cta-row, .hero.ready .hero-note {
  animation: riseIn .8s cubic-bezier(.16, 1, .3, 1) backwards;
  animation-delay: calc(var(--i) * .085s);
}
.hero.ready .hero-ghost { animation: ghostIn 1.6s ease .5s backwards; }
@keyframes ghostIn { from { opacity: 0; } to { opacity: .07; } }

/* the primary CTA carries a lever that throws on hover */
.btn-lever { position: relative; display: inline-flex; align-items: center; gap: .7rem; overflow: hidden; }
.btn-lv {
  width: 4px; height: 17px; border-radius: 2px; flex: none;
  background: linear-gradient(90deg, #3B4248, #6E7C84 45%, #2B3136);
  transform-origin: 50% 100%; transform: rotate(11deg);
  transition: transform .4s cubic-bezier(.34, 1.5, .5, 1);
}
.btn-lever:hover .btn-lv, .btn-lever:focus-visible .btn-lv { transform: rotate(-34deg); }

/* ============================= PANEL HEAD ============================= */
.panel-head { position: sticky; top: 58px; z-index: 12; background: #0C1013; }
.panel-state {
  margin-left: auto; min-width: 0;
  display: flex; align-items: center; gap: .5rem;
  font-family: var(--mono); font-size: .66rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.ps-t { min-width: 0; overflow-wrap: anywhere; }
.ps-lamp {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--line-2); transition: background .3s, box-shadow .3s;
}
.ps-lamp[data-lit="true"] { background: var(--clear); box-shadow: 0 0 7px rgba(62, 156, 115, .85); }

/* ============================= DIAGRAM ============================= */
.diagram .hit { fill: transparent; pointer-events: all; cursor: pointer; }

/* lamps: a spectacle plate is lit glass, so it gets a real bloom */
.diagram .lens { filter: drop-shadow(0 0 2.5px rgba(192, 52, 44, .85)); }
.diagram .sig-down.off .lens, .diagram .sig-up.off .lens,
.diagram .disc.off .disc-face { filter: drop-shadow(0 0 5px rgba(62, 156, 115, .9)); }
.diagram #sig-1 .lens, .diagram #sig-15 .lens { filter: drop-shadow(0 0 3px rgba(224, 168, 30, .8)); }

/* the set road is a lit road */
.diagram .leg.set { filter: drop-shadow(0 0 2px rgba(233, 237, 239, .4)); }

/* --- draw-in: the panel lights up line by line --- */
.diagram .rail, .diagram .leg { transition: stroke .3s, opacity .3s, filter .3s; }
.diagram[data-draw="pending"] .rail,
.diagram[data-draw="pending"] .leg { opacity: 0; }
.diagram[data-draw="pending"] .sig,
.diagram[data-draw="pending"] .disc,
.diagram[data-draw="pending"] #gates,
.diagram[data-draw="pending"] .plat,
.diagram[data-draw="pending"] .dg-lbl,
.diagram[data-draw="pending"] .dg-name,
.diagram[data-draw="pending"] .dg-num,
.diagram[data-draw="pending"] .arrowhead,
.diagram[data-draw="pending"] .road { opacity: 0; }
.diagram[data-draw="run"] .rail,
.diagram[data-draw="run"] .leg {
  opacity: 1;
  animation: drawline 1.05s cubic-bezier(.4, 0, .15, 1) backwards;
  animation-delay: calc(var(--d, 0) * 1ms);
}
@keyframes drawline { from { stroke-dashoffset: var(--len, 0); } to { stroke-dashoffset: 0; } }
.diagram[data-draw="run"] .sig,
.diagram[data-draw="run"] .disc,
.diagram[data-draw="run"] #gates,
.diagram[data-draw="run"] .plat,
.diagram[data-draw="run"] .dg-lbl,
.diagram[data-draw="run"] .dg-name,
.diagram[data-draw="run"] .dg-num,
.diagram[data-draw="run"] .arrowhead,
.diagram[data-draw="run"] .road {
  animation: fitup .55s ease backwards;
  animation-delay: calc(700ms + var(--d, 0) * 1ms);
}
@keyframes fitup { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* --- cross-highlight: hovering a lever lights what it works --- */
.diagram .hl .post, .diagram .hl .disc-face { stroke: var(--dist); }
.diagram .hl .blade, .diagram .hl .disc-bar rect { filter: drop-shadow(0 0 5px rgba(224, 168, 30, .95)); }
.diagram .hl .leg { stroke: var(--dist); opacity: 1; }
.diagram .hl .gate rect { fill: var(--dist); stroke: #F2C64C; }
.diagram .hl .dg-num { fill: var(--dist); }
.diagram .hl-ring {
  animation: ringpulse 1.1s ease-in-out infinite;
  transform-box: fill-box; transform-origin: center;
}
@keyframes ringpulse { 0%, 100% { opacity: .25; } 50% { opacity: .8; } }
.diagram .hitbox {
  fill: none; stroke: var(--dist); stroke-width: 1; stroke-dasharray: 3 3;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.diagram .hl .hitbox { opacity: .55; animation: ringpulse 1.2s ease-in-out infinite; }

/* ============================= THE FRAME ============================= */
/* the quadrant the levers sweep, worn where the handles pass */
.frame { position: relative; }
.frame::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 62px; height: 46px;
  background: radial-gradient(120% 100% at 50% 100%, rgba(233, 237, 239, .05), transparent 70%);
  pointer-events: none;
}

/* enamel: a fired plate has a specular sweep and a rolled edge */
.plate { position: relative; overflow: hidden; }
.plate::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 46%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, .02));
  pointer-events: none;
}
.pnum { position: relative; z-index: 1; text-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.lever:active .plate { transform: translateY(1px); }

/* the throw has weight: the catch squeezes, then the lever swings and settles */
.lever-arm { box-shadow: 2px 3px 6px rgba(0, 0, 0, .55); }
.lever.throwing .lever-arm .grip { animation: catchgrip .34s ease; }
@keyframes catchgrip { 0%, 100% { transform: scaleY(1); } 35% { transform: scaleY(.9); } }

/* --- interlocking made visible before you touch it --- */
.lever-plate-wrap { position: relative; }
.lever.is-holder .plate {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 0 0 2px var(--stop);
  animation: holderpulse 1.1s ease-in-out infinite;
}
@keyframes holderpulse {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 0 0 2px var(--stop); }
  50%      { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 0 0 2px var(--stop), 0 0 10px rgba(192, 52, 44, .7); }
}
.lever.is-affected .plate { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 2px 0 var(--dist); }
.lever.is-held::after {
  content: ''; position: absolute; left: 50%; bottom: 8px; width: 120%; height: 2px;
  margin-left: -60%; background: var(--stop); transform: rotate(-8deg);
  box-shadow: 0 0 6px rgba(192, 52, 44, .8);
}
.lever.is-src .plate { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 0 0 2px var(--dist); }

/* the readout gains a held banner */
.pd-held {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--stop);
  border: 1px solid var(--stop); padding: .15rem .45rem;
}
.pd-free { color: var(--clear); border-color: var(--clear); }

/* ---- hero technical annotation ---- */
.hero-grid { grid-template-rows: auto auto auto; }
.hero-note {
  grid-column: 1; grid-row: 3;
  display: flex; align-items: center; gap: .85rem; flex-wrap: wrap;
  font-family: var(--mono); font-size: .66rem; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted-2);
  margin-top: .3rem;
}
/* a flex item defaults to min-width:auto and will not shrink below its
   text, which pushes the whole grid column wide enough to clip the page */
.hn-t { min-width: 0; }
.hn-brk {
  width: 58px; height: 9px; flex: none;
  border: 1px solid var(--line-2); border-top: 0;
}
.hero-note b { color: var(--dist); font-weight: 400; }

/* ---- register: a real sheet stays ruled where nothing is written ---- */
.register { min-height: 300px; }
.reg-body {
  background-image: repeating-linear-gradient(180deg, transparent 0 27px, var(--paper-rule) 27px 28px);
  background-position: 0 0;
}
.reg-body li { background-color: var(--paper); }
.reg-body li.refused { background-color: #E0CFC4; }
.reg-body li.done-row { background-color: #D6E0D2; }

/* ---- block instrument ---- */
.block-inst {
  margin-top: 1rem; border: 1px solid var(--line); background: var(--steel);
  padding: .9rem 1rem 1rem;
  box-shadow:
    inset 0 1px 0 rgba(233, 237, 239, .055),
    inset 0 -1px 0 rgba(0, 0, 0, .55);
}
.bi-head h3 { font-family: var(--slab); font-size: 1.05rem; text-transform: uppercase; }
.bi-head p { font-family: var(--mono); font-size: .6rem; letter-spacing: .11em; text-transform: uppercase; color: var(--muted-2); margin-top: .2rem; }
.bi-dial { margin: .6rem 0 .2rem; }
.bi-dial svg { width: 100%; max-width: 190px; margin: 0 auto; height: auto; overflow: visible; }
.bi-arc { fill: none; stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 4; }
.bi-lbl { font-family: var(--mono); font-size: 7px; letter-spacing: .1em; fill: var(--muted-2); }
.bi-needle { transform-origin: 0 0; transform: rotate(-52deg); transition: transform .8s cubic-bezier(.3, 1.35, .45, 1); }
.bi-needle line { stroke: var(--stop); stroke-width: 2.4; stroke-linecap: round; }
.bi-needle circle { fill: var(--stop); }
.block-inst[data-block="clear"] .bi-needle { transform: rotate(0deg); }
.block-inst[data-block="clear"] .bi-needle line { stroke: var(--clear); }
.block-inst[data-block="clear"] .bi-needle circle { fill: var(--clear); }
.block-inst[data-block="train"] .bi-needle { transform: rotate(52deg); }
.block-inst[data-block="train"] .bi-needle line { stroke: var(--dist); }
.block-inst[data-block="train"] .bi-needle circle { fill: var(--dist); }
.bi-hub { fill: var(--line-2); stroke: var(--steel-2); stroke-width: 2; }
.bi-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-top: .5rem; }
.bi-b {
  background: var(--panel); border: 1px solid var(--line-2); color: var(--muted);
  font-family: var(--mono); font-size: .56rem; letter-spacing: .08em; text-transform: uppercase;
  padding: .42rem .2rem; cursor: pointer; transition: color .2s, border-color .2s, background .2s;
}
.bi-b:hover { color: var(--chalk); border-color: var(--muted); }
.bi-b[aria-pressed="true"] { background: var(--steel-2); color: var(--chalk); border-color: var(--chalk); }
.bi-code { font-size: .74rem; color: var(--muted-2); line-height: 1.45; margin-top: .6rem; }

/* ---- staggered section entrances (same additive rule as .reveal) ---- */
.reveal.in { animation-delay: calc(var(--i, 0) * 55ms); }
.sched-row.in { animation: riseIn .7s cubic-bezier(.16, 1, .3, 1) backwards; animation-delay: calc(var(--i, 0) * 70ms); }
.jobs tbody tr.in { animation: riseIn .5s ease backwards; animation-delay: calc(var(--i, 0) * 45ms); }
.task.in { animation: riseIn .55s cubic-bezier(.16, 1, .3, 1) backwards; animation-delay: calc(var(--i, 0) * 90ms); }

/* a rule that draws itself under each section heading */
@keyframes drawrule { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.sec-head::after {
  content: ''; display: block; height: 1px; background: var(--line-2);
  transform-origin: 0 50%;
}
.sec-head.in::after { animation: drawrule 1.1s cubic-bezier(.16, 1, .3, 1) .15s backwards; }

/* ---- job book becomes a counted stat strip ---- */
.book-stats {
  max-width: var(--maxw); margin: 1.6rem auto 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 2.4rem);
  border-top: 1px solid var(--line); padding-top: 1.2rem;
}
.stat { display: grid; gap: .3rem; }
.stat-n {
  font-family: var(--slab); font-weight: 800; font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: .9; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.stat-l { font-family: var(--mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2); }
.stat-s { font-size: .86rem; color: var(--muted); line-height: 1.5; max-width: 30ch; }

@media (max-width: 860px) {
  .panel-head { position: static; }
  .panel-state { margin-left: 0; }
  .book-stats { grid-template-columns: 1fr; gap: 1.4rem; }
  .hero-ghost { width: 130%; opacity: .05; }
  @keyframes ghostIn { from { opacity: 0; } to { opacity: .05; } }
  /* the single-column hero stacks headline, prose, then the annotation;
     this must sit after the base .hero-note rule to beat it */
  .hero-note { grid-column: 1; grid-row: 4; }
  .bi-b { padding: .62rem .2rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; animation-iteration-count: 1 !important; }
  .reveal.in, .sched-row.in, .task.in, .jobs tbody tr.in,
  .hero.ready .hero-h1 .ln-i, .hero.ready .eyebrow, .hero.ready .stand,
  .hero.ready .stand-2, .hero.ready .cta-row, .hero.ready .hero-note,
  .hero.ready .hero-ghost, .sec-head.in::after { animation: none !important; }
  .diagram[data-draw="pending"] * { opacity: 1 !important; }
}
