/* Fence Challenge · printable kit. Dark on screen like the hub, white sheets on paper. */
:root {
  --bg0: #07060a;
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.7);
  --muted2: rgba(255, 255, 255, 0.52);
  --line: rgba(255, 255, 255, 0.12);
  --pink: #ff3bd4;
  --cyan: #2ff3ff;
  --lime: #70ff7a;
  --amber: #ffd24a;
  --purple: #b278ff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sheet-w: 190mm;
  --sheet-h: 276mm;
  --page-ratio: 210 / 297;
  --margin-pct: 4.7619%;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}

a:focus-visible,
button:focus-visible,
input:focus-visible + .track {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

.app,
.sheets {
  max-width: 1120px;
  margin: 0 auto;
  padding-inline: 20px;
}

/* ---------- top bar ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 14px 4px;
}

.home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}

.home:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.07);
}

.langSel {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(7, 6, 10, 0.8);
  border: 1px solid var(--line);
}

.langSel button {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted2);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
}

.langSel button:hover {
  color: var(--text);
}

.langSel button[aria-pressed="true"] {
  color: var(--bg0);
  background: var(--amber);
}

/* ---------- intro and steps ---------- */

.intro {
  text-align: center;
  padding-block: 18px 8px;
}

.kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

h1 {
  margin: 6px 0 8px;
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 900;
  letter-spacing: -0.4px;
  line-height: 1.08;
}

.lede {
  margin: 0 auto;
  max-width: 40em;
  color: var(--muted);
  font-size: 16px;
}

.steps {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.steps li {
  position: relative;
  padding: 16px 16px 16px 60px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.steps .num {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 15px;
  color: var(--bg0);
  background: var(--amber);
}

.steps h2 {
  margin: 4px 0 4px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.steps p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.camLink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(47, 243, 255, 0.5);
  background: rgba(47, 243, 255, 0.1);
  color: var(--cyan);
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
}

.camLink:hover {
  background: rgba(47, 243, 255, 0.18);
}

/* ---------- board picker ---------- */

.picker,
.options,
.previewHead {
  margin-top: 28px;
}

.picker > h2,
.previewHead h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 800;
}

.group + .group {
  margin-top: 14px;
}

.group h3 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted2);
}

.boards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.boardBtn {
  --accent: var(--pink);
  display: grid;
  grid-template-columns: 76px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  min-height: 96px;
  padding: 10px 14px 10px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.boardBtn.hexagonal {
  --accent: var(--lime);
}

.boardBtn.triangular {
  --accent: var(--cyan);
}

.boardBtn:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.boardBtn[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.boardBtn .thumb {
  grid-row: 1 / span 2;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
}

.boardBtn .thumb svg {
  max-width: 76px;
  max-height: 76px;
  width: auto;
  height: 76px;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.boardBtn .bName {
  align-self: end;
  font-weight: 800;
  font-size: 15px;
  line-height: 1.25;
  color: var(--accent);
}

.boardBtn .bPieces {
  align-self: start;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- options ---------- */

.options {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.optRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
}

.seg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
}

.segLabel {
  padding: 0 10px 0 12px;
  font-size: 14px;
  color: var(--muted);
}

.seg button {
  min-width: 56px;
  min-height: 44px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: var(--amber);
  color: var(--bg0);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-size: 14px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 44px;
  height: 26px;
  margin: 0;
  cursor: pointer;
}

.switch .track {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.15s ease;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch input:checked + .track {
  background: var(--purple);
}

.switch input:checked + .track::after {
  transform: translateX(18px);
}

.printWrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.printBtn {
  min-height: 48px;
  padding: 0 26px;
  border: none;
  border-radius: 999px;
  background: var(--amber);
  color: var(--bg0);
  font: inherit;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255, 210, 74, 0.18);
}

.printBtn:hover {
  filter: brightness(1.06);
}

.keys {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted2);
}

.paperNote {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 210, 74, 0.35);
  background: rgba(255, 210, 74, 0.07);
  font-size: 14px;
  color: var(--text);
}

.paperNote span {
  flex: 1 1 22em;
}

.linkBtn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 210, 74, 0.6);
  background: transparent;
  color: var(--amber);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.linkBtn:hover {
  background: rgba(255, 210, 74, 0.12);
}

.tip {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.previewHead .note {
  margin: 0;
  font-size: 14px;
  color: var(--muted2);
}

/* ---------- sheet preview ---------- */

.sheets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  padding-block: 14px 60px;
}

.sheetBox {
  margin: 0;
}

.paper {
  aspect-ratio: var(--page-ratio);
  padding: var(--margin-pct);
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.paper svg {
  display: block;
  width: 100%;
  height: auto;
}

.sheetBox.blank .paper {
  background: repeating-linear-gradient(45deg, #fff 0 10px, #f2f2f2 10px 20px);
}

.sheetBox figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.sheetBox figcaption b {
  color: var(--text);
}

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  .steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .boards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app,
  .sheets {
    padding-inline: 14px;
  }
  .steps,
  .boards {
    grid-template-columns: 1fr;
  }
  .printWrap {
    margin-left: 0;
    width: 100%;
  }
  .printBtn {
    flex: 1 1 auto;
  }
  .sheets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

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

/* ---------- print: only the sheets, at actual size ---------- */

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  html,
  body {
    background: #fff !important;
    color: #000;
    min-height: 0;
  }
  .app {
    display: none !important;
  }
  .sheets {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  .sheetBox {
    margin: 0;
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
  }
  .sheetBox:last-child {
    break-after: auto;
    page-break-after: auto;
  }
  .sheetBox figcaption {
    display: none;
  }
  .paper,
  .sheetBox.blank .paper {
    aspect-ratio: auto;
    width: var(--sheet-w);
    height: var(--sheet-h);
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    /* the box is rounded to whole pixels: a piece laid on the sheet's edge must not lose a sliver */
    overflow: visible;
  }
  .paper svg {
    overflow: visible;
    width: var(--sheet-w);
    height: var(--sheet-h);
  }
}

@media (pointer: coarse) {
  .keys {
    display: none;
  }
}
