/*
VOICE   playful, a little uncanny, like a toy from a print ad
IDEA    a halftone newspaper cut-out of a glossy eight ball
PICTURE the 3D ball itself, rendered as printed ink dots
COLOUR  paper white and ink black, nothing else
TYPE    Archivo Black for the title, Barlow Condensed on the die
*/
:root {
  --paper: #fdfdfb;
  --ink: #121212;
  --soft: #6b6b6b;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.top, .bottom {
  position: fixed;
  left: 0; right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline: max(20px, env(safe-area-inset-left, 0px)) max(20px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.top { top: 0; padding-top: calc(var(--safe-t) + 18px); justify-content: space-between; }
.bottom {
  bottom: 0;
  padding-bottom: calc(var(--safe-b) + 22px);
  flex-direction: column;
  text-align: center;
}
.top > *, .bottom > * { pointer-events: auto; }

h1 {
  margin: 0;
  /* one line next to the header buttons, even on a 320px phone */
  font: 900 clamp(24px, calc(10vw - 8px), 46px)/1.05 Archivo, "Arial Black", sans-serif;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
#hint {
  margin: 0;
  max-width: 34ch;
  font-size: 16px;
  color: var(--soft);
  text-wrap: balance;
}

.pill {
  min-height: 44px;
  padding: 0 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: 600 15px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}
.pill.solid { background: var(--ink); color: var(--paper); }
.pill:focus-visible, #stage:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.pill[aria-pressed="false"] { color: var(--soft); border-color: var(--soft); }

#stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}
#stage:focus-visible { outline-offset: -6px; }
#gl { display: block; width: 100%; height: 100%; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 800 20px Archivo, sans-serif;
  color: var(--soft);
}
.loading[hidden] { display: none; }

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Customize sheet (panel.js). Each feature adds a .cz-section.
--------------------------------------------------------------------------- */
.top-actions { display: flex; gap: 8px; }
.sheet {
  width: min(100%, 520px);
  max-width: 100%;
  max-height: min(52vh, 560px); /* leaves the lifted ball visible above */
  margin: auto auto 0;
  padding: 0 0 calc(var(--safe-b) + 16px);
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--paper);
  color: var(--ink);
  overflow: auto;
  overscroll-behavior: contain;
}
.sheet::backdrop { background: rgb(0 0 0 / 0.06); }
.sheet[open] { animation: sheet-up 0.22s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  background: var(--paper);
}
.sheet-head h2 { margin: 0; font: 900 26px/1.1 Archivo, "Arial Black", sans-serif; letter-spacing: -0.01em; }
.cz-section { padding: 8px 20px 14px; }
.cz-section + .cz-section { border-top: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); }
.cz-section h3 { margin: 6px 0 12px; font: 600 13px/1.2 Inter, system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--soft); }
.cz-note { margin: 10px 0 0; font-size: 14px; color: var(--soft); min-height: 1.5em; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 12px; }
.swatch {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 44px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgb(255 255 255 / 0.55) 0 14%, transparent 15%), var(--sw);
  cursor: pointer;
}
.swatch[aria-checked="true"], .swatch.custom.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }
.swatch:focus-visible, .swatch.custom:focus-within { outline: 3px solid var(--ink); outline-offset: 6px; }
.swatch.custom {
  background: conic-gradient(from 0deg, #e33, #fb3, #3c6, #3bf, #63f, #e3c, #e33);
}
.swatch.custom.on { background: radial-gradient(circle at 34% 30%, rgb(255 255 255 / 0.55) 0 14%, transparent 15%), var(--sw); }
.swatch.custom span { font: 900 22px/1 Archivo, sans-serif; color: #fff; text-shadow: 0 1px 2px #000; pointer-events: none; }
.swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.pill { white-space: nowrap; }
.pill.icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; }
.top-actions, .cb-actions { flex: none; align-items: center; }

/* Halftone section (halftone-ui.js) */
.cz-section h4 { margin: 16px 0 8px; font: 600 13px/1 Inter, sans-serif; color: var(--soft); }
.ht-presets { display: flex; gap: 4px; overflow-x: auto; margin-inline: -6px; padding-bottom: 4px; scrollbar-width: none; }
.ht-presets::-webkit-scrollbar { display: none; }
.ht-preset {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 0 0 auto; width: 84px; padding: 8px 4px; min-height: 44px;
  border: 2px solid transparent; border-radius: 14px;
  background: none; color: inherit; font: 600 13px/1.2 Inter, sans-serif; cursor: pointer;
}
.ht-preset[aria-checked="true"] { border-color: var(--ink); }
.ht-swatch { width: 56px; height: 56px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.ht-styles { display: flex; flex-wrap: wrap; gap: 6px; }
.ht-chip {
  min-height: 40px; padding: 0 14px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: 600 14px/1 Inter, sans-serif; cursor: pointer;
}
.ht-chip[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.ht-row { display: grid; grid-template-columns: 84px 1fr 52px; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; }
.ht-row input { width: 100%; accent-color: var(--ink); }
.ht-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--soft); }
.ht-colours { display: flex; gap: 18px; margin-top: 14px; }
.ht-colour { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.ht-colour input { width: 44px; height: 44px; padding: 0; border: 2px solid var(--ink); border-radius: 50%; background: none; cursor: pointer; }
.ht-colour input::-webkit-color-swatch-wrapper { padding: 2px; }
.ht-colour input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.ht-reset { margin-top: 16px; padding: 10px 0; border: 0; background: none; color: var(--ink); font: 600 14px Inter, sans-serif; text-decoration: underline; cursor: pointer; }
.ht-preset:focus-visible, .ht-chip:focus-visible, .ht-reset:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
/* while the sheet is open the camera lifts the ball above it (app.js); the hint makes room */
body.customizing .bottom { visibility: hidden; }

/* short landscape phones: the hint sits beside the ball instead of across it */
@media (orientation: landscape) and (max-height: 520px) {
  .bottom { flex-direction: row; justify-content: space-between; align-items: flex-end; text-align: left; padding-bottom: calc(var(--safe-b) + 16px); }
  #hint { max-width: min(30ch, 32vw); font-size: 15px; text-wrap: pretty; }
}
