/* ==========================================================================
   Kings in the Corner - "Move Order: One Turn, Three Ways"
   Loaded only by /move-order/, after styles.css, pages.css and rules.css.

   A replay desk around one frozen layout. The three replays are ordinary
   sections in the document; replay.js promotes them to a tab set and adds
   the step controls, so the whole article is still there with scripting off
   and in print.

   1. Tokens and the table surface
   2. The hand
   3. The table cross
   4. Replay desk: tabs, stage, controls
   5. Move list
   6. Dependency chain
   7. End-state slips
   8. Five-second scan card
   9. Responsive
  10. Print
   ========================================================================== */

/* --------------------- 1. Tokens and table surface ---------------------- */
.movepage {
  --t-felt:   #10281C;   /* flat, deep - not a bright casino green */
  --t-felt-2: #17362A;
  --t-edge:   #3B3630;   /* warm charcoal card border */
  --t-brick:  #A8332B;   /* muted brick red */
  --t-label:  #D7E7DE;
  --t-dim:    #A9C1B4;
  --t-mark:   #E3C07C;
}
/* the cards on this page take a warm charcoal edge and a brick red suit */
.movepage .table-surface .card { border-color: var(--t-edge); }
.movepage .table-surface .card--red { color: var(--t-brick); }

.table-surface {
  --cw: 46px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  padding: 16px 18px 14px;
  background: var(--t-felt);
  border: 1px solid var(--t-felt-2);
  border-radius: 10px;
}
.table-surface__h {
  margin: 0 0 12px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--t-mark);
}
.table-surface__cap { margin: 12px 0 0; font-size: 13px; line-height: 1.45; color: var(--t-label); }

/* ------------------------------ 2. The hand ----------------------------- */
.hand { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.hand .card { box-shadow: 0 6px 14px rgba(0, 0, 0, .45); }
.hand--spent .card { opacity: .28; }
.hand__empty {
  display: inline-grid; place-items: center;
  min-height: calc(var(--ch));
  padding: 0 14px;
  font-size: 13px; color: var(--t-dim);
}

/* --------------------------- 3. The table cross ------------------------- */
.cross {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 10px;
  justify-content: center; justify-items: center; align-items: center;
}
.pos { display: grid; justify-items: center; gap: 5px; }
.pos__name {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--t-dim);
}
.pos__cards { position: relative; display: flex; align-items: center; gap: 4px; }
.pos__empty {
  display: grid; place-items: center;
  min-width: var(--cw); height: var(--ch);
  padding: 4px 7px;
  border: 1.5px dashed rgba(214, 236, 224, .55);
  border-radius: var(--cr);
  color: #C3DCCF; font-size: 10.5px; line-height: 1.2; text-align: center;
}
.pos__more {
  align-self: center;
  padding: 0 2px;
  color: var(--t-dim); font-size: 15px; letter-spacing: .08em;
}
.cross__stock { position: relative; width: var(--cw); height: var(--ch); }
.cross__stock i {
  position: absolute; inset: 0; border-radius: var(--cr);
  background: #24407F; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .4);
}
.cross__stock i:first-child { transform: translate(-3px, -3px); }
.cross__gap { width: var(--cw); height: 1px; }

/* the numbered marker for the move being shown */
.marker {
  position: absolute; top: -10px; right: -10px; z-index: 2;
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--t-felt);
  box-shadow: 0 0 0 2px var(--t-mark);
  color: #FFF3DC; font-size: 13px; font-weight: 700;
}
.pos.is-target .pos__cards::after {
  content: ""; position: absolute; inset: -7px;
  border: 1.5px solid var(--t-mark); border-radius: 10px;
}
/* thin directional line drawn between the two positions of the current move */
.lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lines path { fill: none; stroke: var(--t-mark); stroke-width: 1.6; }
.lines polygon { fill: var(--t-mark); }

/* ---------------------- 4. Replay desk: tabs, stage --------------------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.tab {
  min-height: 40px; padding: 8px 16px;
  background: var(--ipanel);
  border: 1px solid var(--iline); border-radius: 6px;
  font-family: var(--sans); font-size: 14.5px; font-weight: 600; color: var(--ink);
  cursor: pointer;
}
.tab:hover { border-color: var(--gold-b-dk); }
.tab[aria-selected="true"] {
  background: var(--nav); border-color: var(--nav); color: #fff;
}
.tab:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 18px; align-items: start; }

.controls { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.controls button {
  min-height: 40px; min-width: 92px; padding: 8px 16px;
  background: var(--ipanel);
  border: 1px solid var(--iline); border-radius: 6px;
  font-family: var(--sans); font-size: 14.5px; font-weight: 600; color: var(--ink);
  cursor: pointer;
}
.controls button:hover:not(:disabled) { border-color: var(--gold-b-dk); }
.controls button:disabled { opacity: .45; cursor: default; }
.controls button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.controls__count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ----------------------------- 5. Move list ----------------------------- */
.movelist { margin: 0; padding: 0 0 0 26px; display: grid; gap: 7px; }
.movelist li { font-size: 14.5px; line-height: 1.45; color: var(--text); }
.movelist li[data-state="done"] { color: var(--muted); }
.movelist li[data-state="current"] { color: var(--ink); font-weight: 700; }
.movelist li[data-state="todo"] { color: var(--muted); opacity: .7; }

/* the zero-card slip that closes replay three */
/* `display` on the base rule beats the hidden attribute's UA style, so the
   attribute has to be honoured explicitly */
.zeroslip[hidden] { display: none; }
.zeroslip {
  display: inline-grid; gap: 2px;
  margin-top: 14px; padding: 10px 16px;
  background: var(--ipanel);
  border: 1px solid var(--iline); border-left: 3px solid #2F6B44;
  border-radius: 4px;
}
.zeroslip b { font-family: var(--serif); font-size: 21px; color: var(--ink);
              font-variant-numeric: tabular-nums lining-nums; }
.zeroslip span { font-size: 12.5px; color: var(--muted); }

/* ------------------------- 6. Dependency chain -------------------------- */
.chain { margin: 20px 0 24px; padding: 0; list-style: none; display: grid; gap: 0; max-width: 460px; }
.chain li {
  position: relative;
  padding: 12px 16px 12px 18px;
  background: var(--ipanel);
  border: 1px solid var(--iline);
  border-radius: 6px;
  font-size: 14.5px; line-height: 1.45; color: var(--text);
}
.chain li b { color: var(--ink); }
/* the rule that joins one link to the next */
.chain li + li { margin-top: 26px; }
.chain li + li::before {
  content: ""; position: absolute; left: 28px; top: -26px;
  width: 1.5px; height: 26px; background: var(--iline);
}
.chain li + li::after {
  content: ""; position: absolute; left: 24px; top: -9px;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 7px solid var(--iline);
}

/* -------------------------- 7. End-state slips -------------------------- */
.slipwrap { overflow-x: auto; margin: 16px 0 22px; }
.slip {
  border-collapse: collapse;
  min-width: 340px;
  background: var(--ipanel);
  border: 1px solid var(--iline);
  font-size: 14.5px;
}
.slip caption {
  padding: 0 0 7px; text-align: left;
  font-size: 13px; color: var(--muted);
}
.slip th, .slip td {
  padding: 9px 14px; text-align: left;
  border-bottom: 1px solid var(--iline);
  font-variant-numeric: tabular-nums lining-nums;
}
.slip thead th {
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
}
.slip tbody td { color: var(--text); }
.slip tr:last-child th, .slip tr:last-child td { border-bottom: 0; }
.slip .num { text-align: right; color: var(--ink); font-weight: 700; }
/* the winning replay, and only that one */
.slip .won { border-bottom: 2px solid #2F6B44; padding-bottom: 2px; color: var(--ink); font-weight: 700; }

/* ---------------------- 8. Five-second scan card ------------------------ */
.scancard {
  margin: 20px 0 24px;
  padding: 14px 18px 12px;
  background: var(--tips-bg);
  border: 1px solid var(--tips-line);
  border-radius: 6px;
}
.scancard h3 { margin: 0 0 8px; font-size: 16px; }
.scancard dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0 18px; }
.scancard dt, .scancard dd {
  margin: 0; padding: 8px 0;
  border-top: 1px solid var(--tips-line);
  font-size: 14px; line-height: 1.45;
}
.scancard dt { color: var(--ink); font-weight: 600; }
.scancard dd { color: var(--text); }

/* --------------------------- 9. Responsive ------------------------------ */
@media (max-width: 900px) {
  /* hand, layout, then the move list */
  .stage { grid-template-columns: minmax(0, 1fr); }
  .table-surface { --cw: 38px; --ch: calc(var(--cw) * 1.44); --cr: calc(var(--cw) * .1); padding: 14px 12px 12px; }
  .cross { gap: 7px; }
  .scancard dl { grid-template-columns: minmax(0, 1fr); }
  .scancard dd { padding-top: 0; border-top: 0; }
  .tab { flex: 1 1 auto; }
}

@media (max-width: 420px) {
  /* still large enough to read a rank and a suit */
  .table-surface { --cw: 34px; --ch: calc(var(--cw) * 1.44); --cr: calc(var(--cw) * .1); }
}

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

/* ------------------------------ 10. Print ------------------------------- */
@media print {
  /* every replay prints in sequence, with its controls removed */
  .tabs, .controls, .lines, .marker { display: none !important; }
  .replay[hidden] { display: block !important; }
  .stage { grid-template-columns: minmax(0, 1fr); }
  .table-surface { background: #FFF; border-color: #666; break-inside: avoid; page-break-inside: avoid; }
  .table-surface__h { color: #6B5A2E; }
  .table-surface__cap, .pos__name, .pos__empty, .pos__more, .hand__empty { color: #1A1A1A; }
  .pos__empty { border-color: #777; }
  .cross__stock i { background: #FFF; box-shadow: inset 0 0 0 1.5px #555; }
  .movepage .table-surface .card--red { color: #A8332B; }
  /* a replay heading never leaves its diagram behind */
  .replay { break-inside: avoid; page-break-inside: avoid; }
  .replay h2, .replay h3 { break-after: avoid; page-break-after: avoid; }
  .slipwrap, .chain, .scancard { break-inside: avoid; page-break-inside: avoid; }
}
