/* It's a Metric, Too.
   A port of the standalone its-a-metric-too.html solver and guide, rescoped under .puzzle-app.
   Every color the page needs is a custom property defined in both theme blocks, so the
   generator's dark/light toggle switches the board, the figures and the state fills together. */

.puzzle-app--light {
  --paper: var(--clr-bg);
  --surface: var(--clr-surface);
  --ink: var(--clr-text);
  --body: #333844;
  --muted: var(--clr-muted);
  --rule: #ccd1da;
  --hair: var(--clr-border);
  --cell: #fbfbfd;
  --cell-edge: #c4cad4;
  --frame: #15171d;
  --sig: var(--clr-accent);
  --cap: #15171d;
  --fixed: rgba(184, 92, 56, 0.22);
  --st-purple: #c9a7ef;
  --st-blue: #b9d8f5;
  --st-green: #b4ecb4;
  --st-red: #f3a6a2;
  --st-ink: #1f3fd1;
  --ok: #23824a;
  --danger: #c0392b;
  --guard: #b45f06;
  --state-s: 58%;
  --state-l: 80%;
  --inner: rgba(21, 23, 29, 0.08);
}

.puzzle-app--dark {
  --paper: #111318;
  --surface: #181b21;
  --ink: #e9ebf0;
  --body: #c2c7d1;
  --muted: #8d95a3;
  --rule: #2c3039;
  --hair: #242832;
  --cell: #1d2028;
  --cell-edge: #3b4048;
  --frame: #c2c7d1;
  --sig: #e0705c;
  --cap: #e9ebf0;
  --fixed: rgba(224, 112, 92, 0.3);
  --st-purple: #4f3a6e;
  --st-blue: #2d4a66;
  --st-green: #2f5a35;
  --st-red: #6b3532;
  --st-ink: #9fb4ff;
  --ok: #34d27b;
  --danger: #ff6b6b;
  --guard: #ffa94d;
  --state-s: 42%;
  --state-l: 30%;
  --inner: rgba(255, 255, 255, 0.07);
}

.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;
  -webkit-font-smoothing: antialiased;
  padding: clamp(1.1rem, 3vw, 2rem);
  border-radius: 16px;
}

.puzzle-app .wrap {
  display: flex;
  flex-direction: column;
  gap: clamp(3rem, 6vw, 4.75rem);
}

.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 .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 h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.3rem;
  color: var(--ink);
  margin: .4rem 0 0;
}

.puzzle-app strong {
  color: var(--ink);
  font-weight: 500;
}

.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;
}

.puzzle-app blockquote {
  margin: 0;
  padding: 0 0 0 1.2rem;
  border-left: 2px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: .9rem;
  font-size: .95rem;
  color: var(--body);
}

.puzzle-app ul,
.puzzle-app ol {
  margin: 0;
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.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 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 .scroll {
  overflow-x: auto;
}

.puzzle-app .trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

@media (max-width:720px) {
  .puzzle-app .trio {
    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-mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.puzzle-app .shapes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.6rem 1.2rem;
}

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

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

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

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

.puzzle-app .shape .why {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.45;
}

.puzzle-app svg {
  display: block;
  height: auto;
}

.puzzle-app svg.board {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.puzzle-app svg.small {
  width: 100%;
  max-width: 240px;
}

.puzzle-app svg.mini {
  width: 100%;
  max-width: 110px;
}

.puzzle-app .c {
  fill: var(--cell);
  stroke: var(--cell-edge);
  stroke-width: 1;
}

.puzzle-app .frame {
  fill: none;
  stroke: var(--frame);
  stroke-width: 3;
}

.puzzle-app .wall {
  stroke: var(--frame);
  stroke-width: 2.5;
  stroke-linecap: square;
}

.puzzle-app .num {
  font-family: var(--font-sans);
  font-size: 22px;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: central;
}

.puzzle-app .num.sz {
  fill: var(--st-ink);
  font-weight: 500;
}

.puzzle-app .capdot {
  fill: var(--cap);
}

.puzzle-app .fx {
  fill: var(--fixed);
}

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

.puzzle-app .note {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  fill: var(--sig);
}

.puzzle-app ol {
  list-style: decimal;
}

.puzzle-app .purple {
  fill: var(--st-purple);
}

.puzzle-app .blue {
  fill: var(--st-blue);
}

.puzzle-app .green {
  fill: var(--st-green);
}

.puzzle-app .red {
  fill: var(--st-red);
}

.puzzle-app table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: .92rem;
  width: 100%;
  max-width: 520px;
}

.puzzle-app th,
.puzzle-app td {
  padding: .4rem .7rem;
  text-align: right;
  border-bottom: 1px solid var(--hair);
}

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

.puzzle-app td:first-child,
.puzzle-app th:first-child {
  text-align: left;
}

.puzzle-app td.cells {
  text-align: left;
  color: var(--muted);
}

.puzzle-app tr.total td {
  border-bottom: 0;
  color: var(--ink);
  font-weight: 500;
}

.puzzle-app tr.total td:last-child {
  color: var(--sig);
}

.puzzle-app table.plain {
  max-width: none;
}

.puzzle-app table.plain th,
.puzzle-app table.plain td {
  text-align: left;
  vertical-align: top;
}

.puzzle-app .solver {
  container-type: inline-size;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 14px;
  line-height: 1.45;
}

.puzzle-app .solver .panel {
  gap: .8rem;
  padding: 1rem 1.1rem;
}

.puzzle-app .solver .controls {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: .7rem 1rem;
}

.puzzle-app .solver-main {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.puzzle-app .board-panel {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

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

.puzzle-app .sidecol {
  flex: 1 1 250px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.puzzle-app .seg {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
}

.puzzle-app .seg button {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: .5rem .9rem;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}

.puzzle-app .seg button.active {
  background: var(--ink);
  color: var(--surface);
}

.puzzle-app button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .5rem .9rem;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}

.puzzle-app button.ghost:hover {
  color: var(--ink);
  border-color: var(--sig);
}

.puzzle-app .hint {
  color: var(--muted);
  font-size: 12px;
}

.puzzle-app .divider {
  width: 1px;
  height: 24px;
  background: var(--rule);
}

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

.puzzle-app select {
  background: var(--cell);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .4rem .5rem;
  font: inherit;
  margin-left: .4rem;
  min-width: 180px;
}

.puzzle-app #board {
  --size: clamp(30px, calc((100cqw - 500px) / 11), 50px);
  display: grid;
  grid-template-columns: 26px repeat(11, var(--size)) 14px 50px 66px;
  grid-template-rows: 24px;
  grid-auto-rows: var(--size);
  user-select: none;
  touch-action: none;
}

@media (max-width:640px) {
  .puzzle-app #board {
    --size: 36px;
  }

}

.puzzle-app .cell {
  position: relative;
  background: var(--cell);
  border: 1px solid var(--cell-edge);
  cursor: pointer;
}

.puzzle-app .cell:hover {
  outline: 2px solid var(--sig);
  outline-offset: -3px;
  z-index: 2;
}

.puzzle-app .cell.sel {
  outline: 2px solid var(--sig);
  outline-offset: -3px;
  box-shadow: inset 0 0 0 4px var(--fixed);
  z-index: 2;
}

.puzzle-app .cell .cost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  pointer-events: none;
}

@media (max-width:640px) {
  .puzzle-app .cell .cost {
    font-size: 14px;
  }

}

.puzzle-app .cell .cost.bad {
  color: var(--danger);
}

.puzzle-app .cell .cost.good {
  color: var(--ok);
}

.puzzle-app .cell .size {
  position: absolute;
  left: 4px;
  bottom: 1px;
  font-size: 11px;
  font-weight: 600;
  color: var(--st-ink);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.puzzle-app .cell .min {
  position: absolute;
  left: 4px;
  top: 1px;
  font-size: 10px;
  font-weight: 600;
  color: var(--guard);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.puzzle-app .cell.violate {
  box-shadow: inset 0 0 0 3px var(--danger);
}

.puzzle-app .cell .cap {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cap);
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

.puzzle-app .coord {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.puzzle-app .coord.row {
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px 0 0;
}

.puzzle-app .sumhead,
.puzzle-app .sum {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-variant-numeric: tabular-nums;
}

.puzzle-app .sumhead {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  align-items: flex-end;
  padding-bottom: 4px;
}

.puzzle-app .sum {
  color: var(--ink);
  font-weight: 500;
}

.puzzle-app .sum.sq {
  color: var(--muted);
}

.puzzle-app .switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}

.puzzle-app .switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.puzzle-app .switch .track {
  width: 34px;
  height: 18px;
  border-radius: 9px;
  background: var(--rule);
  position: relative;
  transition: background .2s;
}

.puzzle-app .switch .track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  transition: left .2s;
}

.puzzle-app .switch input:checked + .track {
  background: var(--guard);
}

.puzzle-app .switch input:checked + .track::after {
  left: 18px;
}

.puzzle-app .switch input:focus-visible + .track {
  outline: 2px solid var(--sig);
  outline-offset: 2px;
}

.puzzle-app .staterow {
  display: grid;
  grid-template-columns: 18px 16px 1fr auto 22px;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px dashed var(--hair);
}

.puzzle-app .staterow.active {
  background: var(--hair);
  border-radius: 3px;
}

.puzzle-app .staterow input {
  margin: 0;
  accent-color: var(--sig);
  cursor: pointer;
}

.puzzle-app .staterow label {
  cursor: pointer;
  color: var(--ink);
}

.puzzle-app .staterow small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.puzzle-app .staterow small.warn {
  color: var(--danger);
}

.puzzle-app .staterow small.good {
  color: var(--ok);
}

.puzzle-app .staterow b {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--ink);
}

.puzzle-app .staterow .del {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 0;
}

.puzzle-app .staterow .del:hover {
  color: var(--danger);
}

.puzzle-app .sw {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--cell-edge);
}

.puzzle-app #stateList {
  max-height: 420px;
  overflow: auto;
}

.puzzle-app .total {
  font-size: 13px;
  color: var(--muted);
}

.puzzle-app .total b {
  display: block;
  font-size: 30px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.puzzle-app #message {
  min-height: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
  transition: opacity .4s;
}

.puzzle-app #checks {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.puzzle-app #checks .bad {
  color: var(--danger);
}

.puzzle-app #checks .good {
  color: var(--ok);
  font-weight: 500;
}

.puzzle-app .legend-line {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.puzzle-app .legend-line span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.puzzle-app .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cap);
  display: inline-block;
}
