/* Andy's Afternoon Amble.
   A port of the standalone kitchen-floor.html explainer, rescoped under .puzzle-app.
   Every colour the boards need is a custom property defined in both theme blocks, so
   the generator's dark/light toggle switches the SVG along with the prose. */

.puzzle-app--light {
  --paper: var(--clr-bg);
  --surface: var(--clr-surface);
  --ink: var(--clr-text);
  --body: #453d34;
  --muted: var(--clr-muted);
  --rule: #d8cec3;
  --hair: var(--clr-border);
  --tile-black: #2a241e;
  --tile-white: #fffdfa;
  --tile-edge: #d8cec3;
  --tile-ink: #2a241e;
  --sig: var(--clr-accent);
  --sig-ink: #fff6f2;
  --sig-wash: rgba(184, 92, 56, 0.10);
  --trail: #27408b;
  --ring-wash: rgba(39, 64, 139, 0.10);
}

.puzzle-app--dark {
  --paper: #111318;
  --surface: #181b21;
  --ink: #e9ebf0;
  --body: #c2c7d1;
  --muted: #8d95a3;
  --rule: #2c3039;
  --hair: #242832;
  --tile-black: #05060a;
  --tile-white: #ccd1d9;
  --tile-edge: #3b4048;
  --tile-ink: #14161b;
  --sig: #e0705c;
  --sig-ink: #1c0c08;
  --sig-wash: rgba(224, 112, 92, 0.14);
  --trail: #8ea6e8;
  --ring-wash: rgba(142, 166, 232, 0.16);
}

.puzzle-app,
.puzzle-app *,
.puzzle-app *::before,
.puzzle-app *::after {
  box-sizing: border-box;
}

.puzzle-app {
  background: var(--paper);
  color: var(--body);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.62;
  padding: clamp(1.1rem, 3vw, 2rem);
  border-radius: 16px;
  -webkit-font-smoothing: antialiased;
}

.puzzle-app .wrap {
  display: flex;
  flex-direction: column;
  gap: clamp(2.5rem, 5vw, 4rem);
}

.puzzle-app .col {
  max-width: 63ch;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.puzzle-app p { margin: 0; }
.puzzle-app a { color: var(--sig); }
.puzzle-app strong { color: var(--ink); font-weight: 500; }

.puzzle-app .eyebrow {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.puzzle-app h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 3.4vw, 2.15rem);
  line-height: 1.16;
  color: var(--ink);
  margin: .5rem 0 0;
  text-wrap: balance;
}

.puzzle-app .lede {
  font-family: var(--font-serif);
  font-size: clamp(1.18rem, 2.3vw, 1.42rem);
  font-weight: 400;
  line-height: 1.5;
  color: var(--body);
}

.puzzle-app .lede em { font-style: italic; }

.puzzle-app code,
.puzzle-app .mono {
  font-family: var(--font-mono);
  font-size: .88em;
}

.puzzle-app code {
  color: var(--ink);
  background: var(--hair);
  padding: .1em .38em;
  border-radius: 2px;
}

/* ---- panels ---------------------------------------------------- */
.puzzle-app .panel {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 3px;
  padding: clamp(1.1rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.puzzle-app .scroll { overflow-x: auto; }

.puzzle-app figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.puzzle-app figcaption {
  font-size: .9rem;
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.55;
}

.puzzle-app .pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 640px) {
  .puzzle-app .pair { grid-template-columns: 1fr; }
}

.puzzle-app .face {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  align-items: center;
  text-align: center;
}

.puzzle-app .face .name {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--ink);
}

.puzzle-app .face .count {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.puzzle-app .face .count b {
  color: var(--sig);
  font-weight: 500;
  font-size: 1rem;
}

/* ---- svg ------------------------------------------------------- */
.puzzle-app svg.mini { width: 100%; max-width: 300px; height: auto; display: block; }
.puzzle-app svg.board { width: 100%; max-width: 600px; height: auto; display: block; margin: 0 auto; }
.puzzle-app .blk { fill: var(--tile-black); stroke: var(--tile-black); stroke-width: 1; }
.puzzle-app .wht { fill: var(--tile-white); stroke: var(--tile-edge); stroke-width: 1.2; }
.puzzle-app .hcell { fill: var(--sig-wash); stroke: var(--sig); stroke-width: 2.4; }
.puzzle-app .hcell.true { fill: var(--sig); }
.puzzle-app .ring { fill: var(--ring-wash); stroke: var(--tile-edge); stroke-width: 1.2; }
.puzzle-app .ringpath { fill: none; stroke: var(--trail); stroke-width: 3.2; stroke-linejoin: round; }
.puzzle-app .door { stroke: var(--trail); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 5 4; opacity: .5; }
.puzzle-app .door.home { stroke: var(--sig); stroke-dasharray: none; stroke-width: 3.6; opacity: 1; }
.puzzle-app .gap { fill: var(--sig-wash); stroke: var(--sig); stroke-width: 1.2; stroke-dasharray: 3 3; }
.puzzle-app .walk { fill: none; stroke: var(--trail); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.puzzle-app .mini-walk { stroke-width: 3; }
.puzzle-app .node { fill: var(--trail); }
.puzzle-app .node.n0 { fill: var(--surface); stroke: var(--trail); stroke-width: 3.4; }

.puzzle-app .lbl {
  font-family: var(--font-mono);
  font-size: 20px;
  fill: var(--tile-ink);
  text-anchor: middle;
  dominant-baseline: central;
}

.puzzle-app .lbl.lh { fill: var(--sig); font-weight: 500; }

.puzzle-app .step {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  fill: var(--trail);
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
}

/* ---- legend ---------------------------------------------------- */
.puzzle-app .legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .9rem 1.6rem;
  border-top: 1px solid var(--hair);
  padding-top: 1.3rem;
}

.puzzle-app .key {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  font-size: .88rem;
  line-height: 1.45;
}

.puzzle-app .key .sw {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: .1rem;
  border-radius: 2px;
}

.puzzle-app .key b { color: var(--ink); font-weight: 500; display: block; }
.puzzle-app .sw.b { background: var(--tile-black); }
.puzzle-app .sw.w { background: var(--tile-white); border: 1px solid var(--tile-edge); }
.puzzle-app .sw.h { background: var(--sig); border: 2px solid var(--sig); }
.puzzle-app .sw.d { background: var(--sig-wash); border: 2px solid var(--sig); }
.puzzle-app .sw.t { background: var(--trail); }
.puzzle-app .sw.r { background: var(--ring-wash); border: 1px solid var(--tile-edge); }
.puzzle-app .sw.dr { background: transparent; border-top: 3px dashed var(--trail); height: 0; margin-top: .55rem; }
.puzzle-app .sw.hd { background: transparent; border-top: 4px solid var(--sig); height: 0; margin-top: .55rem; }

/* ---- steps ----------------------------------------------------- */
.puzzle-app ol.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  counter-reset: s;
}

.puzzle-app ol.steps li {
  counter-increment: s;
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: .9rem;
  align-items: baseline;
}

.puzzle-app ol.steps li::before {
  content: counter(s, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: .76rem;
  letter-spacing: .08em;
  color: var(--sig);
  padding-top: .15rem;
}

.puzzle-app ol.steps b { display: block; color: var(--ink); font-weight: 500; }

/* ---- simulator ------------------------------------------------- */
.puzzle-app .trail {
  fill: none;
  stroke: var(--trail);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .5;
}

.puzzle-app .here { fill: var(--sig); stroke: var(--surface); stroke-width: 2.5; }

.puzzle-app .sim { display: flex; flex-direction: column; gap: 1.3rem; }
.puzzle-app .sim-controls { display: flex; flex-wrap: wrap; gap: .6rem; }

.puzzle-app .sim-controls button {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: .62rem 1.05rem;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid var(--sig);
  background: var(--sig);
  color: var(--sig-ink);
  transition: opacity .15s ease;
}

.puzzle-app .sim-controls button.ghost { background: transparent; color: var(--sig); }
.puzzle-app .sim-controls button:hover:not(:disabled) { opacity: .82; }
.puzzle-app .sim-controls button:disabled { opacity: .34; cursor: default; }
.puzzle-app .sim-controls button:focus-visible { outline: 2px solid var(--sig); outline-offset: 2px; }

.puzzle-app .sim-status {
  font-family: var(--font-mono);
  font-size: .86rem;
  line-height: 1.6;
  color: var(--body);
  border-left: 2px solid var(--hair);
  padding-left: 1.05rem;
  min-height: 3.2em;
  max-width: 60ch;
}

.puzzle-app .sim-status b { color: var(--sig); font-weight: 500; }
.puzzle-app .sim-status .verdict { color: var(--ink); }

/* ---- spoiler --------------------------------------------------- */
.puzzle-app details.spoiler {
  border: 1px solid var(--sig);
  border-radius: 3px;
  background: var(--sig-wash);
  overflow: hidden;
}

.puzzle-app details.spoiler > summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem clamp(1rem, 3vw, 1.7rem);
  font-family: var(--font-mono);
  font-size: .76rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--sig);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.puzzle-app details.spoiler > summary::-webkit-details-marker { display: none; }

.puzzle-app details.spoiler > summary::before {
  content: "\25B8";
  font-size: 1.05em;
  transition: transform .18s ease;
}

.puzzle-app details.spoiler[open] > summary::before { transform: rotate(90deg); }
.puzzle-app details.spoiler > summary:focus-visible { outline: 2px solid var(--sig); outline-offset: -3px; }

.puzzle-app .spoiler-body {
  background: var(--surface);
  border-top: 1px solid var(--sig);
  padding: clamp(1.4rem, 3vw, 2rem) clamp(1rem, 3vw, 1.7rem);
  display: flex;
  flex-direction: column;
  gap: 1.9rem;
}

.puzzle-app .solve { display: flex; flex-direction: column; gap: 1.15rem; max-width: 60ch; }

.puzzle-app .solve h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.18rem;
  color: var(--ink);
  margin: .6rem 0 0;
}

.puzzle-app .solve p { font-size: .95rem; line-height: 1.6; }
.puzzle-app .solve p.note { font-size: .88rem; color: var(--muted); }
.puzzle-app .solve p.note em { color: var(--body); }
.puzzle-app .solve b { color: var(--ink); font-weight: 500; }

/* stacked fractions, no library required */
.puzzle-app .frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: -.42em;
  line-height: 1.16;
  margin: 0 .2em;
  font-size: .82em;
  font-variant-numeric: tabular-nums;
}

.puzzle-app .frac span { padding: 0 .32em; }

.puzzle-app .frac span:last-child {
  border-top: 1px solid currentColor;
  margin-top: .08em;
  padding-top: .08em;
}

.puzzle-app .eqs {
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--hair);
  padding: .35rem 0 .35rem 1.05rem;
  margin: .15rem 0;
  overflow-x: auto;
}

.puzzle-app .eq {
  display: grid;
  grid-template-columns: 2.6rem auto 1.2rem 1fr;
  align-items: center;
  gap: 0 .35rem;
  font-family: var(--font-mono);
  font-size: .94rem;
  padding: .3rem 0;
  white-space: nowrap;
}

.puzzle-app .eq .num { font-size: .72rem; color: var(--muted); }
.puzzle-app .eq .lhs { text-align: right; color: var(--ink); }
.puzzle-app .eq .rel { text-align: center; color: var(--muted); }
.puzzle-app .eq.res .lhs,
.puzzle-app .eq.res .rhs { color: var(--sig); }

.puzzle-app .answer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  padding: 1.7rem 1rem;
  border-top: 1px solid var(--sig);
  border-bottom: 1px solid var(--sig);
}

.puzzle-app .answer .big {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.1rem, 7vw, 3.1rem);
  line-height: 1;
  color: var(--sig);
}

.puzzle-app .answer .sub {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- tables ---------------------------------------------------- */
.puzzle-app table.doors,
.puzzle-app table.tally {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
  width: 100%;
  max-width: 26rem;
}

.puzzle-app table.doors td,
.puzzle-app table.tally td {
  padding: .42rem .9rem .42rem 0;
  border-bottom: 1px solid var(--hair);
}

.puzzle-app table.doors td:last-child,
.puzzle-app table.tally td:last-child {
  text-align: right;
  padding-right: 0;
  color: var(--ink);
}

.puzzle-app table.doors tr.total td,
.puzzle-app table.tally tr.exact td {
  border-bottom: none;
  border-top: 2px solid var(--rule);
  color: var(--sig);
}

/* ---- asides and footer ----------------------------------------- */
.puzzle-app .aside {
  border-left: 2px solid var(--sig);
  padding: .15rem 0 .15rem 1.1rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--ink);
  line-height: 1.5;
}

.puzzle-app footer {
  border-top: 1px solid var(--rule);
  padding-top: 1.4rem;
  font-size: .86rem;
  color: var(--muted);
  max-width: 63ch;
}

@media (prefers-reduced-motion: reduce) {
  .puzzle-app details.spoiler > summary::before,
  .puzzle-app .sim-controls button { transition: none; }
}
