/* Standup Spinner — theme values arrive as custom properties set by app.js */

:root {
  --bg: radial-gradient(ellipse at 50% 0%, #4a0d14 0%, #1a0508 60%, #0d0305 100%);
  --accent: #ffd447;
  --rim: #f2b705;
  --text: #fff6e5;
  --scrim: 0;
  --ui-font: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* Several elements below set `display`, which would otherwise beat the
   `hidden` attribute and leave them on screen. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0d0305;
}

body {
  font-family: var(--ui-font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* The custom background image is a layer behind everything and never spins.
   It fades in when it arrives; nothing waits on it. */
.bg-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity .6s ease;
  pointer-events: none;
}
.bg-image.loaded { opacity: 1; }

/* Scrim keeps labels readable over any image the user points us at. */
.bg-scrim {
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: var(--scrim);
  pointer-events: none;
  transition: opacity .6s ease;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .72;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0 25%, transparent 0 50%, var(--accent) 0 75%, transparent 0);
  border: 1px solid var(--rim);
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 0fr;
  align-items: stretch;
  gap: 0;
  padding: 0 clamp(16px, 3vw, 40px) clamp(16px, 3vh, 32px);
  transition: grid-template-columns .55s cubic-bezier(.22, 1, .36, 1);
}

/* The wheel slides left and gives up half the stage to the speaker. */
#app.state-speaking .stage { grid-template-columns: 1fr 1.02fr; }
#app.state-complete .stage { grid-template-columns: 0fr 1fr; }

.wheel-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 0;
}

#app.state-complete .wheel-area { opacity: 0; pointer-events: none; }

/* The wrap just claims the leftover space; the canvas centres a circle in
   whatever shape that turns out to be. */
.wheel-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

#wheel {
  display: block;
  width: 100%;
  height: 100%;
}

/* The hub is the spin button: the most obvious thing on screen should be
   the thing you press. */
.hub {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  color: #1a0508;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,.95), rgba(255,255,255,0) 55%),
    linear-gradient(160deg, var(--accent), var(--rim));
  box-shadow:
    0 0 0 3px rgba(0,0,0,.35),
    0 10px 28px rgba(0,0,0,.55),
    inset 0 -4px 12px rgba(0,0,0,.28);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}

.hub:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.045); }
.hub:active:not(:disabled) { transform: translate(-50%, -50%) scale(.965); }

.hub:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.hub:disabled {
  cursor: default;
  filter: grayscale(.7) brightness(.6);
}

.hub-label {
  font-size: clamp(11px, 2.1vh, 19px);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.wheel-caption {
  margin: 0;
  flex: 0 0 auto;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .6;
  min-height: 1.2em;
  text-align: center;
}

/* ------------------------------------------------------------ speaker view */
/* Both share the stage's second column: only one is ever visible, and the
   end card must not wrap onto an implicit third track. */
.speaker, .endcard {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease .12s, visibility 0s linear .5s;
}

#app.state-speaking .speaker,
#app.state-complete .endcard {
  opacity: 1;
  visibility: visible;
  transition: opacity .4s ease .18s, visibility 0s;
}

/* While the wheel is spinning the outgoing speaker fades back, so nobody
   reads a stale name and a freshly reset clock as if they were live. */
#app.spinning .speaker-inner { opacity: .22; }

.speaker-inner, .endcard-inner {
  transition: opacity .25s ease;
  width: 100%;
  padding-left: clamp(16px, 3vw, 44px);
  max-height: 100%;
  overflow: auto;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  opacity: .55;
}

.speaker-name {
  margin: 0 0 clamp(14px, 2.4vh, 26px);
  font-size: clamp(34px, 6.4vw, 84px);
  line-height: 1.02;
  letter-spacing: -.02em;
  font-weight: 800;
  overflow-wrap: anywhere;
}

/* A memory aid, not a form. Nobody types into this app during standup. */
.prompts {
  list-style: none;
  margin: 0 0 clamp(18px, 3vh, 34px);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 34ch;
}

.prompts li {
  position: relative;
  padding-left: 22px;
  font-size: clamp(14px, 1.7vh, 19px);
  opacity: .78;
}

.prompts li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  opacity: .8;
}

/* -------------------------------------------------------------------- timer */
.clock {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: clamp(40px, 8vh, 92px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  transition: color .3s ease;
}

.timer.warning .clock { color: #ffb020; }
.timer.overtime .clock { color: #ff5a52; }

.track {
  margin: 14px 0 18px;
  height: 7px;
  border-radius: 4px;
  background: rgba(255,255,255,.14);
  overflow: hidden;
  max-width: 420px;
}

.fill {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  background: var(--accent);
  transform-origin: left center;
  transition: background-color .3s ease;
}

.timer.warning .fill { background: #ffb020; }
.timer.overtime .fill { background: #ff5a52; }

/* Auto-start: the bar fills while the clock waits to start itself, then the
   clock kicks as it goes. The kick plays on a manual start too. */
.timer.arming .fill { animation: timer-arm var(--arm, 2500ms) linear both; }
.timer.started .clock { animation: clock-go .7s cubic-bezier(.2, 1.6, .4, 1); transform-origin: 0 60%; }
.timer.started .track { animation: track-go .7s ease-out; }

@keyframes timer-arm {
  from { transform: scaleX(0); opacity: .45; }
  to   { transform: scaleX(1); opacity: 1; }
}

@keyframes clock-go {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.12); color: var(--accent); text-shadow: 0 0 28px var(--accent); }
  100% { transform: scale(1); }
}

@keyframes track-go {
  0%   { box-shadow: 0 0 0 0 var(--accent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}

.timer-controls { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.07);
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease, border-color .15s ease;
}

.btn:hover { background: rgba(255,255,255,.15); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #16100a;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }

/* ----------------------------------------------------------------- end card */
.end-title {
  margin: 0 0 8px;
  font-size: clamp(30px, 5vw, 64px);
  font-weight: 800;
  letter-spacing: -.02em;
}

.end-sub {
  margin: 0 0 clamp(16px, 2.6vh, 28px);
  font-size: clamp(14px, 1.8vh, 19px);
  opacity: .7;
}

.order {
  list-style: none;
  counter-reset: turn;
  margin: 0 0 clamp(18px, 3vh, 30px);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 440px;
}

.order li {
  counter-increment: turn;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,.06);
  font-size: clamp(14px, 1.7vh, 18px);
}

.order li::before {
  content: counter(turn);
  font-size: 12px;
  opacity: .5;
  min-width: 1.2em;
  font-variant-numeric: tabular-nums;
}

.order .who { font-weight: 600; flex: 1 1 auto; overflow-wrap: anywhere; }

.order .took {
  font-variant-numeric: tabular-nums;
  opacity: .65;
  font-size: .92em;
}

.order li.over { background: rgba(255,90,82,.16); }
.order li.over .took { color: #ff8a84; opacity: 1; }
.order li.untimed .took { font-style: italic; opacity: .45; }

.end-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .topbar { padding: 12px 16px; }

  /* A phone is a spectator, not the facilitator: stack, and let the wheel
     become a strip above the speaker. */
  .stage,
  #app.state-speaking .stage,
  #app.state-complete .stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    transition: none;
  }

  .speaker, .endcard { grid-column: 1; grid-row: 2; }
  #app.state-speaking .wheel-area { flex: 0 0 34vh; }
  /* With the wheel gone there is only the card, so it gets the whole stage
     rather than being pushed into a second row under a blank one. */
  #app.state-complete .wheel-area { display: none; }
  #app.state-complete .stage { grid-template-rows: 1fr; }
  #app.state-complete .endcard { grid-row: 1; }

  .speaker-inner, .endcard-inner { padding-left: 0; padding-top: 12px; }
  .speaker-name { font-size: clamp(30px, 9vw, 52px); }
  .clock { font-size: clamp(38px, 12vw, 64px); }
}

/* ------------------------------------------------------------ setup panel */
.topbar .btn-ghost {
  padding: 8px 16px;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.btn-ghost {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.2);
}

.setup {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 30;
  width: min(420px, 92vw);
  height: 100%;
  overflow-y: auto;
  padding: 22px 24px 32px;
  background: rgba(14, 10, 12, .93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-left: 1px solid rgba(255,255,255,.12);
  box-shadow: -24px 0 60px rgba(0,0,0,.45);
  transform: translateX(101%);
  visibility: hidden;
  transition: transform .34s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .34s;
}

#app.setup-open .setup {
  transform: translateX(0);
  visibility: visible;
  transition: transform .34s cubic-bezier(.22, 1, .36, 1), visibility 0s;
}

.scrim-click {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,.35);
}

.setup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.setup-head h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: .18em;
  text-transform: uppercase;
  opacity: .7;
  font-weight: 600;
}

.field { margin-bottom: 26px; }

.field label, .field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  opacity: .85;
}

#roster {
  width: 100%;
  resize: vertical;
  min-height: 140px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.35);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
}

#roster:focus-visible, input[type="number"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  opacity: .5;
}

.warn {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(255,90,82,.16);
  color: #ffb4af;
  font-size: 13px;
  line-height: 1.45;
}

.presence {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.presence label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  opacity: 1;
  cursor: pointer;
  transition: background-color .12s ease;
}

.presence label:hover { background: rgba(255,255,255,.07); }
.presence input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.presence label.away { opacity: .42; text-decoration: line-through; }
.presence .empty { opacity: .45; font-size: 13px; padding: 4px 0; }

.row { display: flex; align-items: center; gap: 10px; }

input[type="number"] {
  width: 96px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.35);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}

.unit { font-size: 14px; opacity: .6; }

.setup-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn-quiet {
  border-color: rgba(255, 90, 82, .45);
  color: #ffb4af;
  background: rgba(255, 90, 82, .1);
}

.btn-quiet:hover { background: rgba(255, 90, 82, .2); }

/* Away participants leave the wheel entirely and are listed under it: being
   away is a fact about today, settled before the first spin. */
.away-strip {
  margin: 0;
  flex: 0 0 auto;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .42;
  text-align: center;
}

/* ------------------------------------------------------------------ toast */
.toast {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px 11px 18px;
  border-radius: 999px;
  background: rgba(22, 18, 20, .95);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 12px 34px rgba(0,0,0,.5);
  font-size: 14px;
  animation: toast-in .22s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.toast-undo {
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.toast-undo:hover { background: rgba(255,255,255,.1); }

/* The celebration sits over the stage but under Setup, and never takes a
   click: someone can press Next while it is still falling. */
.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 15;
  pointer-events: none;
}

/* The name arrives with a bounce, in time with the confetti. */
.speaker-name.pop {
  transform-origin: 0 60%;
  animation: name-pop .75s cubic-bezier(.2, 1.6, .4, 1) .16s both;
}

@keyframes name-pop {
  0%   { transform: scale(.55) translateY(14px); opacity: 0; filter: blur(6px); }
  60%  { opacity: 1; filter: blur(0); }
  100% { transform: none; opacity: 1; filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .setup, .stage, .toast, .speaker-name.pop { transition-duration: .01ms; animation: none; }
  .timer.arming .fill, .timer.started .clock, .timer.started .track { animation: none; }
}

/* --------------------------------------------------------- theme controls */
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-family: inherit;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s ease, opacity .15s ease;
}

.icon-btn:hover { background: rgba(255,255,255,.15); }
.icon-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon-btn[aria-pressed="true"] { opacity: .5; }
.icon-btn[aria-pressed="true"] span { text-decoration: line-through; }

.themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.theme-swatch {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.05);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.theme-swatch:hover { background: rgba(255,255,255,.12); }
.theme-swatch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.theme-swatch[aria-checked="true"] {
  border-color: var(--accent);
  background: rgba(255,255,255,.14);
}

.swatch-dots {
  display: flex;
  flex: 0 0 auto;
}

.swatch-dots i {
  width: 11px;
  height: 18px;
  display: block;
  border-radius: 2px;
  margin-right: -3px;
}

input[type="url"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.35);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

input[type="url"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="url"].invalid { border-color: #ff5a52; }

/* -------------------------------------------------------- custom colours */
.colours {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.colour-chip {
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
}

.colour-chip input[type="color"] {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 10px;
  background: none;
  cursor: pointer;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}

.colour-chip input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.colour-chip input[type="color"]::-webkit-color-swatch { border: none; }
.colour-chip input[type="color"]::-moz-color-swatch { border: none; }
.colour-chip input[type="color"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.colour-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(22, 18, 20, .95);
  color: var(--text);
  cursor: pointer;
}

.colour-remove:hover { background: rgba(255, 90, 82, .5); }
.colour-remove:focus-visible, .colour-add:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.colour-remove:disabled { display: none; }

.colour-add {
  width: 44px;
  height: 44px;
  font: inherit;
  font-size: 20px;
  border-radius: 10px;
  border: 1px dashed rgba(255,255,255,.3);
  background: rgba(255,255,255,.05);
  color: var(--text);
  cursor: pointer;
}

.colour-add:hover { background: rgba(255,255,255,.12); }

.btn-small { margin-top: 10px; padding: 7px 14px; font-size: 12px; }

.field label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
}

.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
