/* ==========================================================================
   Kings in the Corner - "Table Compression: When Fewer Open Routes Help"
   Loaded only by /table-compression/, after styles.css, pages.css, rules.css.

   The page is a set of top-down floor plans. A position that can still take a
   card carries a thin doorway mark; an Ace carries none. Every plan also
   states in words what it can accept, so the marks are never the only signal.

   1. Dark page: the interior tokens, flipped
   2. The floor plan surface
   3. Positions, piles and doorway marks
   4. Paired plans and the optional Before/After switch
   5. Door types legend
   6. Move strips
   7. Tables and the inspection slip
   8. Responsive
   9. Print
   ========================================================================== */

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

  --t-felt:  #202A26;   /* muted green-grey table surface */
  --t-edge:  #2E3B35;
  --t-taupe: #B0A38B;   /* floor-plan lines and labels; 5.9:1 on the felt */
  --t-line:  #6F6857;
  --t-brick: #A8332B;
  --t-char:  #33302A;
  --t-mark:  #E3C07C;
  --t-paper: #EFE9D9;
  --t-note:  #D8E2DC;
}
.planpage .prose p, .planpage .prose li { color: var(--text); font-family: var(--serif); }
.planpage .prose p { font-size: 16.5px; line-height: 1.72; }
.planpage .rsec h2, .planpage .rsec h3 { color: var(--ink); }
.planpage .prose strong, .planpage .prose b { color: var(--ink); }
.planpage .layout__main a { color: var(--ilink); }
.planpage .factstrip__inner { background: var(--ipanel); border-color: var(--iline); }
.planpage .factstrip b { color: var(--ink); }
.planpage .factstrip span { color: var(--muted); }
.planpage .sources__list a { color: #7CC79B; }
.planpage .sources__list a:hover { color: #A6DDBE; }

/* --------------------- 2. The floor plan surface ------------------------ */
.floor {
  --cw: 40px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  display: grid;
  gap: 12px;
  padding: 16px 16px 14px;
  background: var(--t-felt);
  border: 1px solid var(--t-edge);
  border-radius: 10px;
}
/* brick red and warm charcoal suits, in place of the site's cool navy */
.planpage .card { color: #2E2A22; }
.planpage .card--red { color: var(--t-brick); }
.floor .card { box-shadow: 0 5px 12px rgba(0, 0, 0, .45); }
.floor__h {
  margin: 0;
  font-family: var(--sans);
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--t-mark);
}
.floor__cap {
  margin: 0;
  font-family: var(--sans);
  font-size: 12.5px; line-height: 1.5; color: var(--t-note);
}
.floor__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 10px;
  align-items: start; justify-items: center;
  padding: 6px 0 2px;
}

/* Two positions side by side, for the short before-and-after figures. */
.floor__row {
  display: flex; flex-wrap: wrap;
  gap: 14px 28px;
  justify-content: center; align-items: flex-start;
  padding: 6px 0 2px;
}
.floor__row .pos { width: auto; min-width: 118px; }

/* -------------- 3. Positions, piles and doorway marks ------------------- */
.pos {
  display: grid; justify-items: center; gap: 5px;
  min-width: 0; width: 100%;
  text-align: center;
}
.pos--nw { grid-area: 1 / 1; }
.pos--n  { grid-area: 1 / 2; }
.pos--ne { grid-area: 1 / 3; }
.pos--w  { grid-area: 2 / 1; }
.pos--mid { grid-area: 2 / 2; }
.pos--e  { grid-area: 2 / 3; }
.pos--sw { grid-area: 3 / 1; }
.pos--s  { grid-area: 3 / 2; }
.pos--se { grid-area: 3 / 3; }

.pos__name {
  margin: 0;
  font-family: var(--sans);
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--t-taupe);
}
.pos__cards { display: flex; align-items: flex-start; gap: 5px; }
.pos__takes {
  margin: 0;
  font-family: var(--sans);
  font-size: 11.5px; line-height: 1.35; color: var(--t-note);
}
.pos__takes--shut { color: var(--t-taupe); font-style: italic; }

/* A pile seen from above: base card first, exposed card last. */
.fan { display: grid; }
.fan .card + .card { margin-top: calc(var(--ch) * -.7); }

/* An original position with no pile in it. */
.hole {
  display: grid; place-items: center;
  /* the label sets the width: "No pile" and "Vacated" are wider than a card */
  width: auto; min-width: var(--cw); height: var(--ch);
  padding: 0 6px;
  border: 1.5px dashed var(--t-taupe);
  border-radius: var(--cr);
  background: rgba(0, 0, 0, .16);
  font-family: var(--sans);
  font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--t-taupe);
}
/* A corner that has been vacated: no outline to fill, only a note. */
.hole--gone { border-style: dotted; opacity: .6; }


/* The doorway mark: a leaf and its swing, drawn in floor-plan taupe. */
.door { position: relative; width: 15px; height: 17px; flex: none; margin-top: 4px; }
.door::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 2px;
  border-left: 2px solid var(--t-taupe);
}
.door::after {
  content: "";
  position: absolute; left: 1px; top: 0;
  width: 13px; height: 15px;
  border-top: 1.5px solid var(--t-taupe);
  border-right: 1.5px solid var(--t-taupe);
  border-radius: 0 100% 0 0;
  opacity: .6;
}

/* ------- 4. Paired plans and the optional Before/After switch ----------- */
.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
  margin: 18px 0 6px;
}
.planwrap { display: grid; gap: 8px; min-width: 0; }
.planwrap[hidden] { display: none; }
.planwrap__label {
  margin: 0;
  font-family: var(--sans);
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--t-taupe);
}
.cswitch {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 20px 0 0;
  padding: 0;
}
.cswitch__lab {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.cswitch button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--iline);
  border-radius: 6px;
  background: var(--ipanel);
  color: var(--text);
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.cswitch button:hover { border-color: var(--t-taupe); color: var(--ink); }
.cswitch button[aria-pressed="true"] {
  background: var(--t-mark);
  border-color: var(--t-mark);
  color: #221E17;
}
.cswitch button:focus-visible { outline: 3px solid var(--ilink); outline-offset: 2px; }

/* --------------------------- 5. Door types ------------------------------ */
.doors { list-style: none; margin: 18px 0 8px; padding: 0; display: grid; gap: 0; }
.doors li {
  --cw: 34px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  display: grid;
  grid-template-columns: 88px auto minmax(0, 1fr);
  gap: 4px 16px;
  align-items: center;
  padding: 12px 4px;
  border-top: 1px solid var(--iline);
}
.doors li:last-child { border-bottom: 1px solid var(--iline); }
.doors li > b {
  font-family: var(--sans);
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--t-mark);
}
/* direct children only: a bare `span`/`i` selector would repaint the pips and
   suit symbols inside the example card, which are spans and <i> too */
.doors li > span { font-family: var(--serif); font-size: 15px; line-height: 1.55; color: var(--text); }
.doors li > span > i { display: block; font-style: normal; font-size: 13px; color: var(--muted); }

/* --------------------------- 6. Move strips ----------------------------- */
.strips { list-style: none; margin: 18px 0 8px; padding: 0; display: grid; gap: 10px; }
.strips li {
  --cw: 34px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  display: grid;
  grid-template-columns: 30px auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--t-felt);
  border: 1px solid var(--t-edge);
  border-radius: 8px;
}
.strip__n {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border: 1px solid var(--t-taupe);
  border-radius: 50%;
  font-family: var(--sans); font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--t-mark);
}
.strip__cards { display: flex; align-items: center; gap: 4px; }
.strip__pile { display: flex; }
.strip__pile .card + .card { margin-left: calc(var(--cw) * -.62); }
.strip__arrow { font-family: var(--sans); font-size: 15px; color: var(--t-taupe); }
.strip__txt { margin: 0; font-family: var(--serif); font-size: 15px; line-height: 1.5; color: var(--t-note); }

/* ----------------- 7. Tables and the inspection slip -------------------- */
.cwrap { overflow-x: auto; margin: 18px 0 6px; }
.ctab {
  width: 100%; min-width: 420px;
  border-collapse: collapse;
  font-family: var(--sans); font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.ctab caption {
  margin-bottom: 10px;
  font-family: var(--sans);
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--t-mark); text-align: left;
}
.ctab th, .ctab td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--iline);
  text-align: left; vertical-align: middle;
  color: var(--text);
}
.ctab thead th {
  font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--t-line);
}
.ctab tbody th { color: var(--ink); font-weight: 700; }
.ctab .is-shut { color: var(--muted); font-style: italic; }
.ctab .cell {
  --cw: 30px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  display: flex; align-items: center; gap: 8px;
}

/* The Building Inspection reads as a folded card-club score slip. */
.slip {
  margin: 20px 0 8px;
  padding: 18px 18px 14px;
  background: var(--t-paper);
  border-radius: 4px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
}
.slip__h {
  margin: 0 0 12px;
  font-family: var(--sans);
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: #6A5F49;
}
.slip .cwrap { margin: 0; }
.slip table {
  width: 100%; min-width: 380px;
  border-collapse: collapse;
  font-family: var(--sans); font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.slip caption {
  margin-bottom: 10px;
  font-family: var(--serif); font-size: 15px; font-style: italic;
  color: #4A422F; text-align: left;
}
.slip th, .slip td {
  padding: 9px 12px;
  border-bottom: 1px solid #CFC5AC;
  text-align: left;
  color: #2A2519;
}
.slip thead th {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: #5C523C;
  border-bottom: 1.5px solid #9A8F73;
}
.slip tbody th { font-family: var(--serif); font-size: 15px; font-weight: 700; }
/* the fold runs between the Before and After columns */
.slip td:first-of-type { border-right: 1px solid #B7AB8D; }
.slip tbody tr:last-child th, .slip tbody tr:last-child td { border-bottom: 0; }

/* --------------------------- 8. Responsive ------------------------------ */
@media (max-width: 720px) {
  .floor { --cw: 38px; }
  .doors li { grid-template-columns: auto minmax(0, 1fr); }
  .doors li > b { grid-column: 1 / -1; }
  .strips li { grid-template-columns: 30px minmax(0, 1fr); }
  .strip__cards { grid-column: 2; }
  .strip__txt { grid-column: 2; }
}
@media (max-width: 420px) {
  .floor { --cw: 34px; padding: 12px 10px 10px; }
  .floor__grid { gap: 12px 6px; }
  .pos__takes { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .cswitch button { transition: none; }
}

/* ----------------------------- 9. Print -------------------------------- */
@media print {
  .planpage { background: #fff; }
  .planpage .prose p, .planpage .prose li,
  .planpage .rsec h2, .planpage .rsec h3 { color: #16130E; }
  .cswitch, .cswitch__lab { display: none; }
  .planwrap[hidden] { display: grid; }
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .floor { background: #fff; border-color: #999; }
  .floor__h, .planwrap__label { color: #16130E; }
  .floor__cap, .pos__takes, .strip__txt { color: #2A2519; }
  .pos__name, .hole { color: #4A422F; }
  .door::before, .door::after { border-color: #4A422F; }
  .floor .card { box-shadow: none; border: 1px solid #999; }
  .floor .card--red, .doors .card--red, .strips .card--red, .ctab .card--red { color: #A8332B; }
  .doors li > b, .ctab caption, .strip__n { color: #16130E; }
  .doors li > span, .ctab th, .ctab td, .ctab tbody th { color: #16130E; }
  .doors li > span > i, .ctab thead th, .ctab .is-shut,
  .pos__takes--shut, .strip__arrow { color: #4A422F; }
  .strip__n { border-color: #4A422F; }
  .strips li, .slip { background: #fff; box-shadow: none; border: 1px solid #999; }
  .plans, .strips li, .doors li, .slip, .floor { break-inside: avoid; page-break-inside: avoid; }
  .rsec h2, .rsec h3 { break-after: avoid; page-break-after: avoid; }
}
