/* void family: the canvas fills the viewport, one floating translucent card,
   ui fades on idle. density tight, radius 14, elevated glass. */

#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  background: var(--bg);
}

#stage:focus-visible {
  outline-offset: -4px;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  background: var(--surface);
  color: var(--ink);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

/* identity: wordmark top-left in the type pair's display face, one line */
.wordmark {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 5;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.18em;
  color: var(--ink);
  pointer-events: none;
}

.hud {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 6;
  display: flex;
  gap: var(--gap);
}

.icon-btn {
  width: var(--target);
  height: var(--target);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.panel {
  position: fixed;
  top: 68px;
  right: 12px;
  z-index: 6;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 68px - 52px);
  max-height: calc(100dvh - 68px - 52px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: var(--pad);
}

.panel[hidden] {
  display: none;
}

.panel:focus {
  outline: none;
}

.panel h2 {
  margin: 0 0 var(--gap);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.group {
  padding-bottom: var(--pad);
  margin-bottom: var(--pad);
  border-bottom: 1px solid var(--border);
}

.group:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.btn {
  min-height: var(--target);
  min-width: var(--target);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.field {
  display: block;
  margin-bottom: var(--gap);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gap);
  font-size: 13px;
  margin-bottom: 2px;
}

.label-row .value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  display: block;
  width: 100%;
  min-height: var(--target);
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
}

.hint {
  display: block;
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.status {
  margin: var(--gap) 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.status:empty {
  display: none;
}

/* a switch row: label and one line of explanation left, the switch right (Sora) */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pad);
  margin-top: var(--gap);
}

.switch-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.switch-label {
  font-size: 13px;
  font-weight: 600;
}

.switch {
  position: relative;
  flex: none;
  width: 56px;
  min-height: var(--target);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

/* the track and thumb are drawn inside a full 44px target */
.switch::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 26px;
  transform: translateY(-50%);
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--field);
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--muted);
  transition: left 0.2s ease;
}

.switch[aria-checked="true"]::before {
  background: var(--accent);
  border-color: var(--accent);
}

.switch[aria-checked="true"]::after {
  left: 28px;
  background: var(--accent-ink);
}

/* the four modes as tabs, one segmented row at the top of the card */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  margin-bottom: var(--pad);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--field);
}

.tab,
.seg {
  min-width: 0;
  min-height: var(--target);
  padding: 0 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

/* the chosen tab or option changes surface and weight, not opacity */
.tab[aria-selected="true"],
.seg[aria-checked="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--border);
}

.tabpanel[hidden] {
  display: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--field);
}

.select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--target);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--ink);
  font-size: 14px;
}

/* the chosen algorithm's texture as a tag line, its explanation under it (Relevance AI) */
.tag {
  margin: 2px 0 6px;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.explain {
  margin: 0 0 var(--pad);
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

/* one transport row, the primary action larger in the middle (Disney+) */
.transport-group {
  margin-top: var(--pad);
  padding-top: var(--pad);
  border-top: 1px solid var(--border);
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
}

.icon-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.icon-btn.big {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

/* keep it: the svg export under the build settings */
.keep {
  margin-top: var(--pad);
  padding-top: var(--pad);
  border-top: 1px solid var(--border);
}

.keep .switch-row {
  margin: 0 0 var(--gap);
}

/* race: two identical pickers side by side, each keyed to its colour on the stage (Mixpanel) */
.race-pick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.key {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: baseline;
}

.key-a {
  background: var(--accent);
}

.key-b {
  background: var(--second);
}

.race-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  margin: var(--gap) 0;
}

.race-counts div {
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--field);
}

.race-counts dt {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.race-counts dd {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.race-result {
  margin: var(--gap) 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.race-result:empty {
  display: none;
}

/* play: the clock and moves in a bar above the maze, never faded while playing (The Atlantic) */
.play-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  align-items: center;
  gap: var(--pad);
  max-width: calc(100vw - 24px);
  padding: 0 6px 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.play-bar[hidden] {
  display: none;
}

.play-stat {
  margin: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#playTime {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.result {
  width: min(360px, calc(100vw - 24px));
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.result::backdrop {
  background: var(--scrim);
}

.result h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 20px;
}

.result p {
  margin: 0 0 var(--pad);
  font-size: 14px;
  line-height: 1.5;
}

/* the gallery: six finished mazes side by side, each with its name, texture
   and measured dead ends (Mintlify rows: a bold name and one line) */
.gallery {
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: var(--pad);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.gallery::backdrop {
  background: var(--scrim);
}

.gallery-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--pad);
  margin-bottom: var(--pad);
}

.gallery-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: var(--pad);
}

.gallery-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--field);
}

.gallery-item canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  background: var(--bg);
}

.gallery-item h3 {
  margin: 10px 0 2px;
  font-size: 14px;
}

.gallery-item p {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.4;
}

.gallery-item .measure {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.gallery-item .btn {
  margin-top: auto;
  align-self: flex-start;
}

.play-best:empty {
  display: none;
}

/* the a4 print: hidden on screen, the only thing on paper */
.print-sheet {
  display: none;
}

@page {
  size: A4;
  margin: 12mm;
}

@media print {
  html,
  body {
    height: auto;
    overflow: visible;
    background: #ffffff;
  }

  #stage,
  .panel,
  .hud,
  .wordmark,
  .skip-link,
  .play-bar,
  footer.site-footer,
  dialog {
    display: none !important;
  }

  .print-sheet {
    display: block;
  }

  .print-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 270mm;
    break-after: page;
    page-break-after: always;
  }

  .print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-page svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 250mm;
  }

  .print-caption {
    margin: 6mm 0 0;
    font: 10pt var(--font);
    color: #0d0d12;
  }
}

.notice {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
  text-align: center;
}

.notice[hidden] {
  display: none;
}

.notice-card {
  max-width: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 24px;
}

.notice-card h1 {
  font-size: 18px;
  margin: 0 0 10px;
}

.notice-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.notice-inline {
  margin: 0 0 var(--pad);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--field);
  font-size: 13px;
  line-height: 1.45;
}

.notice-inline[hidden] {
  display: none;
}

/* house footer: one link, muted, no hover styling */
footer.site-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  font-size: 12px;
  white-space: nowrap;
}

footer.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  padding: 0 8px;
  color: var(--muted);
  text-decoration: none;
}

/* idle mode: after 3 seconds without input the ui fades so the maze has the
   screen; any input, or focus inside the ui, brings it back (src/idle.js) */
.hud,
.panel,
.wordmark,
footer.site-footer {
  transition: opacity 0.6s ease;
}

body[data-idle="true"] .hud,
body[data-idle="true"] .panel,
body[data-idle="true"] .wordmark,
body[data-idle="true"] footer.site-footer {
  opacity: 0;
  pointer-events: none;
}

body[data-idle="true"] .hud:focus-within,
body[data-idle="true"] .panel:focus-within,
body[data-idle="true"] footer.site-footer:focus-within {
  opacity: 1;
  pointer-events: auto;
}

body[data-idle="true"] #stage {
  cursor: none;
}

/* mobile first: on a phone the card is a bottom sheet so the maze stays visible */
@media (max-width: 759px) {
  /* at 320px: time 50 + moves 62 + best 72 + stop 58 + gaps 24 + padding 16
     is about 282px, inside the 296px the bar may use */
  .play-bar {
    top: 64px;
    gap: 8px;
    padding: 0 4px 0 12px;
  }

  .play-stat {
    font-size: 13px;
  }

  #playTime {
    font-size: 16px;
  }

  .panel {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 48px;
    width: auto;
    max-height: 46vh;
    max-height: 46dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
