/* ==========================================================================
   Kings in the Corner - "Turn Order: One Trip Around the Table"
   Loaded only by /turn-order/, after styles.css, pages.css and rules.css.

   A four-seat clock seen from above, with the reader at twelve. The orbit is
   four ordinary states in the document; orbit.js adds the stepping. Distance
   is carried by arc length, a number and a word - never by colour alone.

   1. Dark page: the interior tokens, flipped
   2. The clock
   3. Seats
   4. Orbit controls and the progress ring
   5. Distance arcs
   6. Stock slips
   7. Tables and the orbit slip
   8. Responsive
   9. Print
   ========================================================================== */

/* ------------------- 1. Dark page: tokens, flipped ---------------------- */
.turnpage {
  --ipage:  #14120E;
  --ipanel: #1D1A14;
  --iline:  #343026;
  --ilink:  #E8C784;
  --ink:    #F3ECDC;
  --text:   #DAD2C2;
  --muted:  #ADA491;

  --t-felt:  #202A26;   /* a quiet card-club table, not a bright felt */
  --t-edge:  #2E3B35;
  --t-taupe: #9C8F79;
  --t-blue:  #6E88A6;   /* dusty blue seat markers */
  --t-brick: #A8332B;
  --t-char:  #33302A;
  --t-mark:  #E3C07C;
  --t-paper: #EFE9D9;
}
.turnpage .prose p, .turnpage .prose li { color: var(--text); }
.turnpage .rsec h2, .turnpage .rsec h3 { color: var(--ink); }
.turnpage .prose strong, .turnpage .prose b { color: var(--ink); }
.turnpage .layout__main a { color: var(--ilink); }
.turnpage .factstrip__inner { background: var(--ipanel); border-color: var(--iline); }
.turnpage .factstrip b { color: var(--ink); }
.turnpage .factstrip span { color: var(--muted); }
.turnpage .sources__list a { color: #7CC79B; }
.turnpage .sources__list a:hover { color: #A6DDBE; }
.turnpage .table-top .card { border-color: var(--t-char); }
.turnpage .table-top .card--red { color: var(--t-brick); }

/* ------------------------------ 2. The clock ---------------------------- */
.table-top {
  --cw: 40px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  margin: 20px 0 24px;
  padding: 18px 20px 16px;
  background: var(--t-felt);
  border: 1px solid var(--t-edge);
  border-radius: 10px;
}
.table-top__h {
  margin: 0 0 14px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--t-mark);
}
.table-top__cap { margin: 14px 0 0; font-size: 13px; line-height: 1.5; color: #D8E2DC; }
.table-top .card { box-shadow: 0 5px 12px rgba(0, 0, 0, .45); }

.clock {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  gap: 10px;
  justify-items: center; align-items: center;
  max-width: 560px; margin-inline: auto;
}
.clock__ring { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.clock__ring ellipse { fill: none; stroke: var(--t-taupe); stroke-width: 1; opacity: .55; }
.ring__mark {
  position: absolute; width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 10px solid var(--t-taupe);
  opacity: .8; pointer-events: none;
}
.ring__mark--ne { left: 80.4%; top: 21.7%; transform: translate(-50%, -50%) rotate(135deg); }
.ring__mark--se { left: 80.4%; top: 78.3%; transform: translate(-50%, -50%) rotate(225deg); }
.ring__mark--sw { left: 19.6%; top: 78.3%; transform: translate(-50%, -50%) rotate(315deg); }
.ring__mark--nw { left: 19.6%; top: 21.7%; transform: translate(-50%, -50%) rotate(45deg); }
.clock__mid { grid-column: 2; grid-row: 2; display: grid; justify-items: center; gap: 6px; min-width: 0; }
.clock__slot {
  display: grid; place-items: center;
  min-width: var(--cw); height: var(--ch);
  padding: 4px 8px;
  border: 1.5px dashed var(--t-taupe);
  border-radius: var(--cr);
  color: #D3DED8; font-size: 10.5px; line-height: 1.2; text-align: center;
}
.clock__pile { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-width: 0; }

/* -------------------------------- 3. Seats ------------------------------ */
.seat {
  display: grid; justify-items: center; gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--t-blue);
  border-radius: 6px;
  /* opaque: the clockwise ring runs behind the seats, and a translucent
     panel let the line cut straight through the names */
  background: #232E29;
  min-width: 104px;
  position: relative; z-index: 1;
}
.seat--n { grid-column: 2; grid-row: 1; }
.seat--e { grid-column: 3; grid-row: 2; }
.seat--s { grid-column: 2; grid-row: 3; }
.seat--w { grid-column: 1; grid-row: 2; }
.seat__name { font-family: var(--serif); font-size: 16px; font-weight: 700; color: #F1F6F3; }
/* styles.css dresses .seat__meta as a dark pill for the game board. On the
   clock the seat is already the box, and the pill kept a dark translucent
   ground that printed dark-on-dark, so it is reset to plain text here. */
.seat__meta {
  padding: 0; border: 0; border-radius: 0; background: none;
  font-size: 12px; line-height: 1.3; text-align: center;
  color: #C4D2CB; font-variant-numeric: tabular-nums lining-nums;
}
.seat__count { font-family: var(--serif); font-size: 19px; color: #FFF6E2;
               font-variant-numeric: tabular-nums lining-nums; }
/* the active seat in an orbit state; the rest simply sit at lower contrast */
.seat.is-active { border-color: var(--t-mark); box-shadow: inset 0 0 0 1px var(--t-mark); }
/* .5 dropped the pill text to 3.4:1 against the felt; .72 keeps the seats
   visibly secondary while every glyph clears 4.5:1 */
.seat.is-quiet { opacity: .72; }
.seat__turn {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--t-mark);
}

/* ------------- 4. Orbit controls and the progress ring ------------------ */
.orbitbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; margin-top: 14px; }
.orbitbar button {
  min-height: 40px; min-width: 92px; padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--t-taupe); border-radius: 4px;
  font-family: var(--sans); font-size: 14px; font-weight: 600; color: #EDF3EF;
  cursor: pointer;
}
.orbitbar button:hover:not(:disabled) { border-color: var(--t-mark); }
.orbitbar button:disabled { opacity: .45; cursor: default; }
.orbitbar button:focus-visible { outline: 2px solid #FFF6E2; outline-offset: 2px; }
.orbitbar__count { font-size: 14px; color: #C4D2CB; font-variant-numeric: tabular-nums; }

/* four positions, one per seat, filled as the orbit advances */
.ring { display: flex; gap: 6px; }
.ring i {
  display: block; width: 12px; height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--t-taupe);
}
.ring i.is-on { background: var(--t-mark); border-color: var(--t-mark); }

/* --------------------------- 5. Distance arcs --------------------------- */
.dist { position: relative; }
.dist__arcs { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.dist__arcs path { fill: none; stroke: var(--t-taupe); stroke-width: 1.4; }
.dist__arcs polygon { fill: var(--t-taupe); }
.distkey { display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.distkey li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; align-items: start; }
.distkey b {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--t-taupe);
  font-size: 12.5px; color: #F1F6F3;
}
.distkey span { font-size: 14px; line-height: 1.45; color: #D8E2DC; }
.distkey em { font-style: normal; display: block; color: #FFF6E2; font-weight: 600; }

/* ---------------------------- 6. Stock slips ---------------------------- */
.slips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 20px 0 22px; }
.slip2 {
  display: grid; gap: 10px; justify-items: center; align-content: start;
  padding: 16px 14px;
  background: var(--t-paper);
  border: 1px solid #C6BCA4;
}
.slip2__h {
  margin: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #6B5A2E;
}
.slip2__stock { position: relative; width: 46px; height: 66px; }
.slip2__stock i {
  position: absolute; inset: 0; border-radius: 4px;
  background: #24407F; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .45);
}
.slip2__stock i:first-child { transform: translate(-3px, -3px); }
.slip2__empty {
  display: grid; place-items: center;
  width: 46px; height: 66px;
  border: 1.5px dashed #8C846E; border-radius: 4px;
  color: #4E4838; font-size: 10.5px;
}
.slip2__note { margin: 0; font-size: 12.5px; line-height: 1.45; color: #26251E; text-align: center; }

/* --------------------- 7. Tables and the orbit slip --------------------- */
.twrap { overflow-x: auto; margin: 18px 0 22px; }
.ttab {
  width: 100%; min-width: 400px;
  border-collapse: collapse;
  font-size: 14.5px; color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
}
.ttab caption { padding: 0 0 8px; text-align: left; font-size: 13px; color: var(--muted); }
.ttab th, .ttab td {
  padding: 10px 15px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--iline);
}
.ttab thead th {
  border-bottom: 1.5px solid var(--t-taupe);
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.ttab tbody th { color: var(--ink); font-weight: 700; white-space: nowrap; }
.ttab tr:last-child th, .ttab tr:last-child td { border-bottom: 0; }
.ttab .num { text-align: right; }

/* a seat note, ruled rather than panelled */
.orbitslip { margin: 20px 0 24px; }
.orbitslip h3 {
  margin: 0 0 4px;
  font-family: var(--serif); font-size: 18px; color: var(--ink);
}
.orbitslip p { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }
.orbitslip .ttab { border-top: 1px solid var(--t-taupe); }
.orbitslip .ttab thead th { border-bottom-color: var(--iline); }

/* ----------------------------- 8. Responsive ---------------------------- */
@media (max-width: 900px) {
  .table-top { --cw: 34px; --ch: calc(var(--cw) * 1.44); --cr: calc(var(--cw) * .1); padding: 14px 12px 12px; }
  .clock { gap: 8px; }
  .seat { min-width: 0; padding: 7px 9px; }
  .seat__name { font-size: 14px; }
  .slips { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 480px) {
  .table-top { --cw: 30px; --ch: calc(var(--cw) * 1.44); --cr: calc(var(--cw) * .1); }
  .clock { column-gap: 6px; }
  .clock__pile { gap: 3px; }
  .seat__meta { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .turnpage * { transition: none !important; animation: none !important; }
}

/* ------------------------------- 9. Print ------------------------------- */
@media print {
  .turnpage { --ipage: #FFF; --ipanel: #FFF; --iline: #999; --ink: #14120E; --text: #23201A; --muted: #4E4838; }
  .turnpage .factstrip__inner { background: #FFF; }
  .orbitbar, .ring { display: none !important; }
  /* all four states print as a vertical strip */
  .orbitstate[hidden] { display: block !important; }
  .table-top { background: #FFF; border-color: #777; break-inside: avoid; page-break-inside: avoid; }
  .table-top__h { color: #6B5A2E; }
  .table-top__cap, .seat__meta, .clock__slot, .distkey span { color: #1A1A1A; }
  .seat__name, .seat__count, .distkey em { color: #14120E; }
  .seat { background: #FFF; border-color: #666; }
  .seat.is-quiet { opacity: 1 !important; }
  .seat.is-active { box-shadow: none; outline: 2px solid #6B5A2E; }
  .clock__ring ellipse, .dist__arcs path { stroke: #666; opacity: 1; }
  .dist__arcs polygon { fill: #666; }
  .ring__mark { border-bottom-color: #666; opacity: 1; }
  .slips, .orbitslip, .twrap { break-inside: avoid; page-break-inside: avoid; }
  .rsec h2, .rsec h3 { break-after: avoid; page-break-after: avoid; }
  .turnpage .table-top .card--red { color: #A8332B; }
}
