/* ============================================================
   THE GILDED ORRERY — the index: filter rail, circuits, module
   plates, sigils, keeper's plate and the station feed.

   A wing is one engraved sheet subdivided by hairlines, not a
   row of floating cards: the grid's 1px gaps show the rule
   colour through, so the cuts between plates are the engraving.
   ============================================================ */

/* ── FILTER RAIL ────────────────────────────────────────────
   Four worlds live on this station. The counts are real. */

.index-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 24px;
}

.index-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-2);
  letter-spacing: 0.01em;
  color: var(--ivory);
}
.index-title em { font-style: italic; color: var(--brass-pale); }

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--rule-faint);
  border-radius: var(--r-chip);
  background: transparent;
  color: var(--ash);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.filter .n {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--ash-dim);
}
.filter:hover { color: var(--ivory-soft); border-color: var(--rule); }
.filter[aria-pressed="true"] {
  color: var(--ink);
  background: var(--brass);
  border-color: var(--brass);
}
.filter[aria-pressed="true"] .n { color: rgba(10, 11, 12, 0.65); }

/* ── CIRCUITS ───────────────────────────────────────────────
   The circuit code is the real identifier — it is what the
   orrery rings are keyed to — so it leads, and the name is set
   as the plate's engraved title. */

.wings { margin-top: clamp(26px, 4vw, 44px); }

.wing { margin-bottom: clamp(30px, 5vw, 52px); }
.wing[hidden] { display: none; }

.wing-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
}
.wing-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-3);
  line-height: 1;
  letter-spacing: 0.005em;
  color: var(--ivory);
  white-space: nowrap;
}
.wing-head .rule-h { flex: 1; transform: translateY(-6px); }
.wing-head .wing-code { white-space: nowrap; }
.wing-head .wing-count { white-space: nowrap; color: var(--ash-dim); }

/* ── THE SHEET ──────────────────────────────────────────────
   Container background shows through the 1px gaps as engraved
   cuts between plates. */

.plates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 1px;
  background: var(--rule-faint);
  border: 1px solid var(--rule);
  border-radius: var(--r-plate);
}

.plate {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 14px;
  text-decoration: none;
  color: inherit;
  background: var(--plate-fill);
  background-color: var(--ink-plate);
  transition:
    background 0.32s var(--ease),
    box-shadow 0.32s var(--ease),
    transform 0.32s var(--ease);
}
.plate[hidden] { display: none; }

/* Unengraved plate. A sheet is cut to a whole number of plates, so a
   short row is filled rather than left as a hole — the blanks carry
   only a registration cross, the way a plate does before it is worked.
   Count is computed against the live column count in hub/js/ui.js. */
.plate--blank {
  pointer-events: none;
  /* recessive: flatter and a shade deeper than a worked plate, so the
     eye reads unengraved stock rather than a missing card */
  background: linear-gradient(168deg, rgba(13, 13, 14, 0.9), rgba(8, 9, 10, 0.94));
  background-color: var(--ink-inset);
  min-height: 96px;
}
.plate--blank::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 11px;
  transform: translate(-50%, -50%);
  opacity: 0.18;
  background:
    linear-gradient(var(--brass), var(--brass)) center / 11px 1px no-repeat,
    linear-gradient(var(--brass), var(--brass)) center / 1px 11px no-repeat;
}

/* corner ticks, drawn as four hairline pairs; they extend on approach */
.plate::before {
  content: "";
  position: absolute;
  inset: 7px;
  pointer-events: none;
  background-image:
    linear-gradient(var(--brass), var(--brass)), linear-gradient(var(--brass), var(--brass)),
    linear-gradient(var(--brass), var(--brass)), linear-gradient(var(--brass), var(--brass));
  background-size: 1px 6px, 1px 6px, 1px 6px, 1px 6px;
  background-position: left top, right top, left bottom, right bottom;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.32s var(--ease), background-size 0.32s var(--ease);
}

.plate:hover,
.plate:focus-visible,
.plate.is-lit {
  z-index: 2;
  background: var(--plate-fill-lit);
  box-shadow: var(--lift-lit);
  transform: translateY(-2px);
}
.plate:hover::before,
.plate:focus-visible::before,
.plate.is-lit::before {
  opacity: 0.7;
  background-size: 1px 13px, 1px 13px, 1px 13px, 1px 13px;
}
.plate:focus-visible { outline: 1px solid var(--brass); outline-offset: -1px; }

.plate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.plate-id {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.2em;
  color: var(--brass);
}
.plate-systems { display: flex; gap: 4px; }

.plate-body {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.plate-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-1);
  line-height: 1.12;
  letter-spacing: 0.015em;
  color: var(--ivory);
  text-wrap: balance;
}
.plate-desc {
  margin-top: 5px;
  font-size: var(--step--1);
  line-height: 1.48;
  color: var(--ash);
  text-wrap: pretty;
}

.plate-foot {
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.plate-ckt { font-size: 10px; letter-spacing: 0.18em; color: var(--ash-dim); }
.plate-go {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--brass-pale);
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
}
.plate:hover .plate-go,
.plate:focus-visible .plate-go,
.plate.is-lit .plate-go { opacity: 1; transform: none; }

/* ── SIGILS ─────────────────────────────────────────────────
   Generated per module in hub/js/sigil.js. The figure is
   always there; hovering redraws it stroke by stroke. */

.sigil {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  overflow: visible;
}
.sig-field {
  fill: none;
  stroke: var(--rule-faint);
  stroke-width: 0.5;
}
.sig-tick { stroke: var(--brass-deep); stroke-width: 0.7; }
.sig-web {
  fill: none;
  stroke: var(--brass);
  stroke-width: 0.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.5;
  stroke-dasharray: 100;
  transition: opacity 0.32s var(--ease);
}
.sig-chord { opacity: 0.24; stroke-dasharray: 100; }
.sig-star {
  fill: var(--brass-pale);
  opacity: 0.65;
  transition: opacity 0.32s var(--ease), fill 0.32s var(--ease);
}
.sig-star--primary { fill: var(--brass-lit); opacity: 1; }
.sig-halo {
  fill: none;
  stroke: var(--brass);
  stroke-width: 0.5;
  opacity: 0.3;
  transition: opacity 0.32s var(--ease);
}

.plate:hover .sig-web,
.plate:focus-visible .sig-web,
.plate.is-lit .sig-web {
  opacity: 0.95;
  animation: sig-draw 0.85s var(--ease) both;
}
.plate:hover .sig-chord,
.plate:focus-visible .sig-chord,
.plate.is-lit .sig-chord {
  opacity: 0.5;
  animation: sig-draw 0.85s var(--ease) 0.12s both;
}
.plate:hover .sig-star,
.plate:focus-visible .sig-star,
.plate.is-lit .sig-star { opacity: 1; fill: var(--brass-lit); }
.plate:hover .sig-halo,
.plate:focus-visible .sig-halo,
.plate.is-lit .sig-halo { opacity: 0.8; }

@keyframes sig-draw {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0; }
}

/* ── EMPTY STATE ────────────────────────────────────────────*/

.index-empty {
  margin-top: 26px;
  padding: 34px 20px;
  border: 1px dashed var(--rule);
  border-radius: var(--r-plate);
  text-align: center;
  color: var(--ash);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.1em;
}
.index-empty[hidden] { display: none; }

/* ── KEEPER'S PLATE ─────────────────────────────────────────*/

.keeper {
  margin-top: clamp(34px, 6vw, 66px);
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.keeper-plate { display: flex; flex-direction: column; gap: 4px; }
.keeper-k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ash-dim);
}
.keeper-v {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: var(--step-2);
  line-height: 1.1;
  color: var(--brass-pale);
}
.keeper-v span {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.5em;
  letter-spacing: 0.16em;
  color: var(--ash);
}

.stamp {
  padding: 6px 13px;
  border: 1px solid var(--crit);
  border-radius: var(--r-chip);
  color: var(--crit);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  transform: rotate(-2.5deg);
  opacity: 0.72;
}

/* ── STATION FEED ───────────────────────────────────────────*/

:root { --feed-h: 34px; }

.news-ticker-container {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 7;
  display: flex;
  align-items: stretch;
  height: var(--feed-h);
  border-top: 1px solid var(--rule);
  background: rgba(6, 6, 7, 0.94);
}
.news-label {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-right: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--brass);
}
.ticker-wrap { flex: 1; overflow: hidden; position: relative; }
.ticker-wrap::before,
.ticker-wrap::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 34px;
  z-index: 2;
  pointer-events: none;
}
.ticker-wrap::before { left: 0; background: linear-gradient(90deg, rgba(6, 6, 7, 0.96), transparent); }
.ticker-wrap::after { right: 0; background: linear-gradient(-90deg, rgba(6, 6, 7, 0.96), transparent); }
.ticker {
  position: absolute;
  top: 50%;
  white-space: nowrap;
  padding-right: 100%;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--verdigris);
  animation: ticker 800s linear infinite;
}
/* left animates in container widths so the text enters straight away —
   the element is ~150k px wide, so a translateX(100%) start would keep
   it off-screen for twenty minutes. */
@keyframes ticker {
  0%   { left: 100%; transform: translate(0, -50%); }
  100% { left: -100%; transform: translate(-100%, -50%); }
}

/* ── RESPONSIVE ─────────────────────────────────────────────*/

@media (max-width: 620px) {
  .plates { grid-template-columns: 1fr 1fr; }
  .plate { padding: 12px 11px 10px; gap: 9px; }
  .plate--blank { min-height: 0; }
  .plate-body { flex-direction: column; gap: 9px; }
  .sigil { width: 34px; height: 34px; }
  .plate-title { font-size: var(--step-0); }
  .plate-desc { font-size: 11.5px; line-height: 1.4; }
  .plate-go { display: none; }
  .wing { margin-bottom: 28px; }
  .wing-name { font-size: var(--step-2); }
  .index-head { align-items: flex-start; }
  .keeper { flex-direction: column; align-items: flex-start; }
}

/* One column below 440px, and the sigil goes back beside the text so a
   plate stays one compact band rather than a tall stack. */
@media (max-width: 440px) {
  .plates { grid-template-columns: 1fr; }
  .plate { gap: 7px; }
  .plate-body { flex-direction: row; gap: 11px; }
  .plate-desc { margin-top: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .plate, .plate::before, .plate-go, .sig-web, .sig-star, .sig-halo { transition: none; }
  .plate:hover, .plate.is-lit { transform: none; }
  .plate:hover .sig-web, .plate.is-lit .sig-web,
  .plate:hover .sig-chord, .plate.is-lit .sig-chord { animation: none; }
  .ticker { animation-play-state: paused; }
}
