/* namcube theme: tokens for light and dark, shared by every app.
   html[data-theme] is set by theme.js before first paint. Apps map their own
   variables onto these in a namcube-skin.css loaded after their own CSS. */
@font-face {
  font-family: "Geist"; src: url(fonts/Geist-Variable.woff2) format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist Mono"; src: url(fonts/GeistMono-Variable.woff2) format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
:root, :root[data-theme="light"] {
  color-scheme: light;
  --nc-bg: #f5f6f8;
  --nc-surface: #ffffff;
  --nc-surface-2: #eef0f3;
  --nc-control: #e8ebef;
  --nc-control-hover: #dde1e6;
  --nc-control-line: #d0d5dc;
  --nc-line: #e1e4e9;
  --nc-fg: #111318;
  --nc-muted: #6b7079;
  --nc-faint: #9aa0a8;
  /* Accent is monochrome (Nam 2026-11-21: no blue buttons). */
  --nc-accent: #111318;
  --nc-accent-strong: #2b2e35;
  --nc-accent-fg: #ffffff;
  --nc-accent-soft: rgba(17, 19, 24, 0.08);
  --nc-good: #16a34a;
  --nc-bad: #dc2626;
  --nc-stage: #e4e8ee;          /* behind puzzles, so white stickers stand out */
  --nc-shadow: 0 1px 2px rgba(17, 19, 24, 0.06), 0 8px 24px -12px rgba(17, 19, 24, 0.18);
  --nc-font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --nc-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --nc-radius: 8px;
}
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --nc-bg: #0e0f11;
  --nc-surface: #16171a;
  --nc-surface-2: #1c1e21;
  --nc-control: #222428;
  --nc-control-hover: #2b2d32;
  --nc-control-line: #33363c;
  --nc-line: #25272b;
  --nc-fg: #ececee;
  --nc-muted: #8b8f97;
  --nc-faint: #63676e;
  --nc-accent: #ececee;
  --nc-accent-strong: #ffffff;
  --nc-accent-fg: #0b0c0e;
  --nc-accent-soft: rgba(236, 236, 238, 0.12);
  --nc-good: #4ade80;
  --nc-bad: #f87171;
  --nc-stage: #16171a;
  --nc-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.7);
}

/* Top bar (added by theme.js on every page). */
:root { --nc-bar-h: 44px; }
html.nc-has-bar { padding-top: var(--nc-bar-h); box-sizing: border-box; } /* height:100% pages still fit */
.nc-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1040; box-sizing: border-box; /* under Bootstrap modals/offcanvas */
  height: var(--nc-bar-h); padding: 0 12px 0 16px;
  display: flex !important; align-items: center; gap: 6px;
  background: var(--nc-bg); color: var(--nc-fg); border-bottom: 1px solid var(--nc-line);
  font: 500 13px/1 var(--nc-font); letter-spacing: 0; text-align: left;
}
.nc-bar *, .nc-bar *::before, .nc-bar *::after { box-sizing: border-box; }
.nc-bar .nc-brand { color: var(--nc-fg); text-decoration: none; font: 600 14px/1 var(--nc-mono); letter-spacing: -0.01em; padding: 6px 4px; }
.nc-bar .nc-sep { color: var(--nc-faint); font: 400 14px/1 var(--nc-mono); }
.nc-bar .nc-where { position: relative; display: flex; align-items: center; }
.nc-bar .nc-app, .nc-bar .nc-crumb, .nc-bar .nc-parent { color: var(--nc-muted); text-decoration: none; font: 500 13px/1 var(--nc-font); padding: 7px 6px; border-radius: 7px; white-space: nowrap; }
.nc-bar .nc-app:hover, .nc-bar .nc-crumb:hover, .nc-bar .nc-parent:hover { background: var(--nc-control); color: var(--nc-fg); }
.nc-bar .nc-app.is-here, .nc-bar .nc-crumb.is-here { color: var(--nc-fg); }
.nc-bar .nc-crumbs { display: flex; align-items: center; gap: 4px; flex: none; }
.nc-bar button.nc-theme {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; border-radius: 7px; color: inherit; font: 500 13px/1 var(--nc-font);
}
.nc-bar button.nc-theme:hover { background: var(--nc-control); }
.nc-bar .nc-theme svg { display: block; width: 15px; height: 15px; }
.nc-bar > .nc-brand, .nc-bar > .nc-sep, .nc-bar > .nc-parent, .nc-bar > .nc-where, .nc-bar > .nc-theme { flex: none; }
/* Right-aligned, but scrolls instead of spilling left when the page is narrow. */
.nc-bar .nc-slot { flex: 1; min-width: 0; align-self: stretch; display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.nc-bar .nc-slot::before { content: ""; margin-left: auto; }
.nc-bar .nc-slot > * { flex: none; }
.nc-bar .nc-slot > input[type="search"] { flex: 0 1 220px; }
/* Controls pages put in the bar: same compact look everywhere. */
.nc-slot button, .nc-slot a.nc-btn, .nc-slot select, .nc-slot input {
  min-height: 0;
  height: 28px; margin: 0; padding: 0 10px; border-radius: 7px;
  border: 1px solid var(--nc-control-line); background: var(--nc-surface); color: var(--nc-fg);
  font: 500 12px/1 var(--nc-font); box-shadow: none; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.nc-slot button:hover, .nc-slot a.nc-btn:hover { background: var(--nc-control); }
.nc-slot input { cursor: text; }
.nc-slot input[type="search"] { width: 220px; flex: 0 1 220px; min-width: 90px; }
.nc-bar .nc-slot .nc-chips { display: flex; gap: 2px; margin: 0; padding: 0; border: 0; background: none; overflow-x: auto; scrollbar-width: none; }
.nc-bar .nc-slot .nc-chips > a, .nc-bar .nc-slot .nc-chips > button {
  all: unset; cursor: pointer; padding: 7px 9px; border-radius: 7px; color: var(--nc-muted);
  font: 500 12px/1 var(--nc-font); white-space: nowrap;
}
.nc-bar .nc-slot .nc-chips > :hover { color: var(--nc-fg); background: var(--nc-control); }
.nc-bar .nc-slot .nc-chips > .is-on { color: var(--nc-fg); background: var(--nc-control); }
.nc-slot .nc-text { color: var(--nc-muted); font: 500 12px/1 var(--nc-font); white-space: nowrap; }
html .nc-hide, html .nc-hide.d-flex { display: none !important; }
@media (max-width: 560px) { .nc-bar:has(.nc-where) .nc-brand, .nc-bar .nc-sep, .nc-slot .nc-text { display: none; } }
@media print { .nc-bar { display: none; } html.nc-has-bar { padding-top: 0; } }

/* Touch screens (phones, tablets): taps of at least 40 px, 16 px text in inputs
   (smaller makes iPhone zoom in on focus), no double-tap zoom on controls. */
.nc-bar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
@media (pointer: coarse) {
  :root { --nc-bar-h: 48px; }
  a, button, input, select, textarea, label, summary, [role="button"] { touch-action: manipulation; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]), select, textarea { font-size: max(16px, 1em) !important; }
  button, select, input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]), [role="button"] { min-height: 40px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .nc-bar button.nc-theme { min-height: 40px; min-width: 40px; justify-content: center; }
  .nc-slot button, .nc-slot a.nc-btn, .nc-slot select, .nc-slot input { height: 36px; min-height: 36px; }
  .nc-bar .nc-slot .nc-chips > a, .nc-bar .nc-slot .nc-chips > button { padding: 12px 10px; min-height: 0; }
}

/* Turn buttons (move-pad.js): touch screens only. */
.nc-pad { display: none; }
@media (pointer: coarse) {
  .nc-pad { display: grid; gap: 6px; width: min(100%, 480px); margin: 8px auto 0; user-select: none; -webkit-user-select: none; }
  .nc-pad-row { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; }
  .nc-pad button {
    min-height: 44px; margin: 0; padding: 0; border-radius: 10px;
    border: 1px solid var(--nc-control-line); background: var(--nc-surface); color: var(--nc-fg);
    font: 600 15px/1 var(--nc-mono); touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  }
  .nc-pad button.is-down { background: var(--nc-control-hover); }
}
@media (max-width: 560px) { .nc-bar .nc-crumbs .nc-sep { display: inline; } }

/* A page control beside the path (namcubeBar.addLeft), e.g. Select in training. */
.nc-bar > .nc-left { flex: none; margin-left: 10px; padding: 5px 12px; font: 600 13px/1 var(--nc-font); border-radius: 7px; border: 1px solid var(--nc-control-line); background: var(--nc-control); color: var(--nc-fg); cursor: pointer; }
.nc-bar > .nc-left:hover { background: var(--nc-control-hover); }
body.is-setup .nc-bar > .nc-left.nc-training-only { display: none; }

/* Section level (algtrain, FTO, BLD) before the app: its separator stays on phones. */
.nc-bar > .nc-parent[hidden], .nc-bar > .nc-parent-sep[hidden] { display: none !important; }
@media (max-width: 560px) { .nc-bar > .nc-sep.nc-parent-sep:not([hidden]) { display: inline; } }
@media (max-width: 560px) { .nc-bar .nc-slot .nc-credits, .nc-bar .nc-slot .nc-github { display: none; } }
.nc-bar > .nc-parents { display: contents; }
@media (max-width: 560px) { .nc-bar .nc-parents .nc-sep { display: inline; } }

/* Slightly larger top bar (Nam, 2026-11-21): taller, bigger path text. */
:root { --nc-bar-h: 52px; }
@media (pointer: coarse) { :root { --nc-bar-h: 52px; } }
.nc-bar { font-size: 14px; }
.nc-bar .nc-brand { font-size: 16px; }
.nc-bar .nc-sep { font-size: 16px; }
.nc-bar .nc-app, .nc-bar .nc-crumb, .nc-bar .nc-parent { font-size: 15px; padding: 8px 7px; }
.nc-bar button.nc-theme { font-size: 15px; padding: 8px 10px; }
.nc-bar .nc-theme svg { width: 17px; height: 17px; }
.nc-bar > .nc-left { font-size: 14px; padding: 6px 13px; }
.nc-bar .nc-slot .nc-credits, .nc-bar .nc-slot .nc-github { font-size: 14px !important; }

/* Phones (Nam asked if the bar works on mobile): it overflowed, pushing the
   theme button off screen. Keep one level up (drop higher sections), let the
   path shrink with ellipses, and keep the right-hand buttons whole. */
@media (max-width: 560px) {
  .nc-bar { gap: 2px; overflow: hidden; }
  .nc-bar > .nc-parents > :not(:nth-last-child(-n+2)) { display: none !important; }
  .nc-bar > .nc-where, .nc-bar > .nc-crumbs { min-width: 0; flex: 0 1 auto; }
  .nc-bar .nc-crumbs > .nc-crumb { min-width: 0; }
  .nc-bar .nc-app, .nc-bar .nc-crumb, .nc-bar .nc-parent { max-width: 10em; overflow: hidden; text-overflow: ellipsis; padding-left: 5px; padding-right: 5px; }
  .nc-bar > .nc-parent { flex: 0 1 auto; min-width: 2.5em; }
  .nc-bar button.nc-theme { padding: 8px 6px; flex: none; }
  .nc-bar > .nc-left { flex: none; margin-left: 6px; padding: 6px 10px; }
  .nc-bar .nc-slot { min-width: 0; }
}
/* Touch: path links as tall as the buttons, easier to tap. */
@media (pointer: coarse) {
  .nc-bar .nc-app, .nc-bar .nc-crumb, .nc-bar .nc-parent { padding-top: 12px; padding-bottom: 12px; }
}
@media (max-width: 560px) {
  .nc-bar .nc-where > .nc-app { flex-shrink: 0; max-width: 8em; }
  .nc-bar .nc-crumbs > .nc-crumb { min-width: 2.5em; }
}
@media (max-width: 560px) { .nc-bar > .nc-where { flex: none; } }
/* Phones in training: Select stands in for the set's name (it goes back there). */
@media (max-width: 560px) { body:not(.is-setup) .nc-bar:has(> .nc-left.nc-training-only) > .nc-crumbs { display: none; } }

/* Plain text links in the bar (home: Settings, GitHub), like algtrain's Credits. */
.nc-bar .nc-slot .home-links { display: flex; align-items: center; gap: 2px; }
.nc-bar .nc-slot a.nc-link { color: var(--nc-muted); font-size: 14px; text-decoration: none; padding: 8px; border-radius: 7px; }
.nc-bar .nc-slot a.nc-link:hover { color: var(--nc-fg); background: var(--nc-control); }
.nc-bar .nc-slot .home-links .nc-text { font-size: 14px; padding: 0 8px; }
@media (max-width: 560px) { .nc-bar .nc-slot a.nc-gh { display: none; } }

/* Phones (Nam): the path always starts with "namcube" (home), as on a
   computer; the levels after it shrink with ellipses to make room. */
@media (max-width: 560px) {
  .nc-bar:has(.nc-where) .nc-brand { display: block !important; flex: none; font-size: 15px; padding: 6px 2px; }
  .nc-bar:has(.nc-where) > .nc-brand + .nc-sep { display: inline !important; flex: none; }
  .nc-bar .nc-app, .nc-bar .nc-crumb, .nc-bar .nc-parent { max-width: 7.5em; }
}

/* Section headings, one style across pages (Nam 2026-11-22): the light gray
   uppercase mono, a bit more prominent. Home and Settings h2 use it. */
.nc-heading, .nc-page h2 {
  margin: 0 0 8px; font: 600 13px/1 var(--nc-mono); color: var(--nc-muted);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.nc-heading a, .nc-page h2 a { color: inherit; text-decoration: none; }
.nc-heading a:hover, .nc-page h2 a:hover { color: var(--nc-fg); }
