/* pomodots — black & white only, depth through gradients */

:root {
  --bg-0: #000;
  --bg-1: #0b0b0b;
  --ink: #f5f5f5;
  --ink-dim: #8c8c8c;
  --ink-faint: #3a3a3a;

  --pill-h: 44px;                                /* the dock never changes size */
  --item-h: 20px;                                /* reel row pitch */
  --ease-slot: cubic-bezier(.22, 1.25, .36, 1);  /* slight overshoot, like a reel settling */
  --ease-out: cubic-bezier(.2, .8, .2, 1);

  --dock-bottom: max(28px, env(safe-area-inset-bottom));

  --mono: ui-monospace, "SF Mono", "Menlo", "Roboto Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: radial-gradient(120% 80% at 50% 40%, var(--bg-1) 0%, var(--bg-0) 70%);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.defs { position: absolute; width: 0; height: 0; }

.brand {
  position: fixed;
  top: 24px; left: 28px;
  font-size: 13px;
  letter-spacing: .18em;
  color: var(--ink-dim);
  z-index: 2;
}

/* ---------- stage: fixed box, grid scales inside ---------- */

.stage {
  position: fixed;
  top: 72px;
  left: 20px; right: 20px;
  bottom: calc(var(--dock-bottom) + var(--pill-h) + 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.grid {
  --w: min(100cqw, 640px);
  --h: 100cqh;
  /* dot size fits both width and height; gap is 60% of a dot */
  --dot: min(
    calc(var(--w) / (var(--cols) * 1.6 - .6)),
    calc(var(--h) / (var(--rows) * 1.6 - .6)),
    40px
  );
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--dot));
  gap: calc(var(--dot) * .6);
}

.dot {
  --p: 0;
  position: relative;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  /* empty dot: the dark side of the moon */
  background: radial-gradient(circle at 35% 30%, #262626 0%, #141414 55%, #0d0d0d 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .03);
  transition: box-shadow .4s ease;
}

/* full dot */
.dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #ececec 50%, #cfcfcf 100%);
  opacity: 0;
}
.dot.full::after { opacity: 1; }

/* active dot: moon phase drawn as svg */
.moon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.moon path { fill: url(#lit); }

.dot.current {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .06),
    0 0 calc(var(--dot) * .9) rgba(255, 255, 255, calc(var(--p) * .28));
}

/* paused: the active moon breathes so you know it is waiting */
.app[data-status="paused"] .dot.current .moon { animation: breathe 2.4s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: .4; }
}

/* done: a slow wave of light passes through the grid */
.app[data-status="done"] .dot { animation: wave 2.8s ease-in-out calc(var(--i) * 18ms) 2; }

@keyframes wave {
  0%, 100% { filter: brightness(1); transform: scale(1); }
  40%      { filter: brightness(.35); transform: scale(.82); }
}

/* ---------- dock: the bottom pill ---------- */

.dock {
  position: fixed;
  left: 50%;
  bottom: var(--dock-bottom);
  transform: translateX(-50%);
  height: var(--pill-h);
  display: flex;
  align-items: center;
  padding: 0 6px 0 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #101010 0%, #080808 100%);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .8);
  white-space: nowrap;
  overflow: hidden;          /* the pill clips the drums: numbers roll over its edge */
}

/* outline drawn above the drums so they sit inside the pill, not on it */
.dock::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .05),
    inset 0 0 0 1px #1c1c1c;
  pointer-events: none;
}

/* reels stay in place in every state, only dim while a session runs */
.setup {
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity .3s ease;
}
.app:not([data-status="idle"]) .setup {
  opacity: .32;
  pointer-events: none;
}

.sep {
  width: 1px;
  height: 18px;
  margin: 0 14px;
  background: linear-gradient(180deg, transparent, #2a2a2a, transparent);
}

.readout {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  letter-spacing: .1em;
  color: var(--ink-dim);
  width: 8ch;            /* fixed: fits 25 min, 17:54 and 2:24:00 alike */
  text-align: center;
  transition: color .3s ease;
}
.app:not([data-status="idle"]) .readout { color: #d0d0d0; }

/* ---------- slot reels: a drum wrapped around the pill ---------- */

.reel {
  position: relative;
  width: 28px;
  height: var(--pill-h);        /* full pill height: numbers roll over its edge */
  overflow: hidden;
  cursor: ns-resize;
  touch-action: none;
  outline: none;
  /* the drum: lit at the middle, falling into shadow where it turns away */
  background: linear-gradient(180deg, #050505 0%, #151515 50%, #050505 100%);
}

/* curvature shading over the numbers */
.reel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.85) 0%, rgba(0,0,0,0) 32%, rgba(0,0,0,0) 68%, rgba(0,0,0,.85) 100%);
  pointer-events: none;
}

.reel:focus-visible { background: linear-gradient(180deg, #050505 0%, #232323 50%, #050505 100%); }

.reel-list {
  will-change: transform;
  transition: transform .42s var(--ease-slot);
}

.reel-item {
  height: var(--item-h);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: #6a6a6a;
  /* neighbours are foreshortened, as if turning away on the drum */
  transform: scaleY(.62);
  transition: color .2s ease, transform .25s ease;
}

.reel-item.active {
  color: var(--ink);
  transform: none;
}

.times {
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------- buttons: quiet icons ---------- */

.btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font: inherit;
  color: #bdbdbd;
  background: transparent;
  border: 1px solid #1f1f1f;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease, opacity .3s ease;
}
.btn + .btn { margin-left: 4px; }
.btn:hover { color: var(--ink); border-color: #333; background: #141414; }
.btn:focus-visible { outline: 1px solid #555; outline-offset: 2px; }
.btn svg { display: block; }

#primary { margin-left: 10px; }

/* show the icon that matches the state */
#primary .i-pause { display: none; }
.app[data-status="running"] #primary .i-play { display: none; }
.app[data-status="running"] #primary .i-pause { display: block; }

/* reset keeps its place when idle, just goes quiet */
.app[data-status="idle"] #reset { opacity: .25; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .reel-list, .reel-item, .setup, .btn { transition: none; }
  .app[data-status="done"] .dot,
  .app[data-status="paused"] .dot.current .moon { animation: none; }
}
