/* colorbars.app — minimal selector + fullscreen viewport.
   Two distinct UI surfaces; no overlap. The selector is a clean tile grid; the
   fullscreen viewport is a single canvas with the cursor hidden. */

:root {
  --bg:    #0a0a0a;
  --bg2:   #141414;
  --ink:   #ffffff;
  --ink2:  #b8b8b8;
  --ink3:  #6a6a6a;
  --rule:  #222222;
  --rule2: #2c2c2c;
  --accent: #58a6ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'ss01';
  overflow: hidden;
  /* No selection / drag — this is a button surface */
  user-select: none;
  -webkit-user-select: none;
}

#app { width: 100vw; height: 100vh; height: 100dvh; }

/* ============ Selector grid ============ */
.selector {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}
.selector-head {
  flex: 0 0 auto;
  padding: 18px 24px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
}
/* Matches testpattern.app's brand styling: icon + "name" (heavy Manrope) +
   ".app" (dimmer monospace, slightly smaller). */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 26px;
  height: 26px;
  display: inline-block;
  line-height: 0;
  flex-shrink: 0;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand .ext {
  color: var(--ink3);
  font-weight: 400;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  margin-left: 2px;
}
.hint {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  color: var(--ink3);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  line-height: 1.2;
  text-align: right;
}
.hint .hint-shift {
  color: var(--ink2);
  font-weight: 600;
}

.grid {
  flex: 1 1 auto;
  display: grid;
  /* JS sets --cols / --tile-w to keep tiles at the target aspect ratio while
     fitting the available viewport. CSS owns the layout, JS owns the sizing. */
  grid-template-columns: repeat(var(--cols, 5), var(--tile-w, 1fr));
  grid-auto-rows: var(--tile-h, 1fr);
  gap: var(--gap, 18px);
  padding: 22px;
  overflow: hidden;
  justify-content: center;
  align-content: center;
}

.tile {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 80ms ease, border-color 80ms ease, box-shadow 80ms ease;
  display: flex;
  align-items: stretch;
  outline: none;
  /* Aspect = the actual screen aspect (set by JS at boot + on resize). Falls
     back to 16:9 if for some reason the var is not set. */
  aspect-ratio: var(--tile-aspect, 16 / 9);
}
.tile:hover, .tile:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
  transform: translateY(-1px);
}
.tile canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.tile-label {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.tile-hint {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink2);
  text-transform: uppercase;
}
.tile-kind {
  position: absolute;
  right: 10px;
  top: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  font-weight: 600;
  color: var(--ink3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Live tiles get a subtle accent tag so users can see at-a-glance which are
   interactive (vs static patterns) */
.tile.live .tile-kind { color: var(--accent); }

/* ============ Fullscreen viewport ============ */
.viewport {
  position: fixed;
  inset: 0;
  background: #000;
  cursor: none;
  z-index: 100;
}
.viewport canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Tiny hint pinned bottom-right of fullscreen — fades after a few seconds so it
   doesn't pollute the test pattern. */
.viewport-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  opacity: 1;
  transition: opacity 400ms ease;
  pointer-events: none;
}
.viewport-hint.faded { opacity: 0; }

/* ============ Bottom status bar ============ */
.selector-foot {
  flex: 0 0 auto;
  padding: 6px 24px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  color: var(--ink3);
  border-top: 1px solid var(--rule);
  background: #060606;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.04em;
  line-height: 1;
}
.selector-foot .foot-r { display: flex; align-items: center; gap: 8px; }
.selector-foot .foot-l { display: flex; align-items: center; gap: 6px; }
.selector-foot .sep { color: var(--rule2); }
.selector-foot .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink3);
}
.selector-foot .dot.ok { background: #36cf6e; box-shadow: 0 0 6px rgba(54, 207, 110, 0.5); }

/* Mobile: keep the grid usable down to ~360px wide */
@media (max-width: 760px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px;
  }
  .selector-head { padding: 12px 16px 10px; }
  .brand { font-size: 16px; }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
