/* Kelo Lead Conductor — pilot field tool.
   FONT SIZES ARE DELIBERATELY LARGE: the lead reads this off a phone on a
   stand, 1-2 metres away, mid-class. The cue text is the dominant element. */

:root {
  --text: #FFFFFF;
  --mute: rgba(255, 255, 255, 0.58);
  --mute2: rgba(255, 255, 255, 0.42);
  --gold: #f0c855;
  --line: rgba(255, 255, 255, 0.15);
  --ctrl-bg: rgba(255, 255, 255, 0.1);
  --ctrl-bg-active: rgba(255, 255, 255, 0.22);
}

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

html, body {
  width: 100%;
  height: 100%;
  background: #0a0a0a;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 1.5s ease;
  overscroll-behavior: none;
}

/* Block background colors (smooth transition between blocks) */
body.block-1 { background: #1a2440; }  /* deep midnight blue · ARRIVAL */
body.block-2 { background: #163024; }  /* deep forest · RESONANCE */
body.block-3 { background: #3a2818; }  /* deep amber sunset · INTEGRATION */
body.complete { background: #2a2a2a; }

/* ============ START OVERLAY ============ */
#start-overlay {
  position: fixed;
  inset: 0;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 32px 24px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#start-overlay.hidden { opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }
#start-overlay h1 {
  color: var(--gold);
  font-size: clamp(32px, 6vw, 52px);
  margin-bottom: 14px;
  letter-spacing: 2px;
  text-align: center;
  font-weight: 700;
}
#start-overlay .subtitle {
  color: var(--mute);
  font-size: clamp(17px, 3vw, 24px);
  margin-bottom: 56px;
  text-align: center;
}
.tap-circle {
  width: clamp(220px, 40vw, 340px);
  height: clamp(220px, 40vw, 340px);
  border-radius: 50%;
  background: var(--gold);
  color: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(48px, 10vw, 72px);
  font-weight: 800;
  letter-spacing: 4px;
  box-shadow: 0 0 100px rgba(240, 200, 85, 0.5);
  pointer-events: none;
  animation: breathe 2s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
.checklist {
  margin-top: 52px;
  color: rgba(255, 255, 255, 0.7);
  font-size: clamp(17px, 3vw, 22px);
  text-align: center;
  line-height: 2;
  pointer-events: none;
}
.checklist strong {
  color: var(--gold);
  display: block;
  margin-bottom: 10px;
  font-size: clamp(14px, 2.4vw, 17px);
  letter-spacing: 2px;
}
.tap-hint {
  position: absolute;
  bottom: 30px;
  color: var(--mute2);
  font-size: clamp(14px, 2.4vw, 17px);
  pointer-events: none;
}

/* ============ MAIN APP ============ */
#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 18px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}
#app[hidden] { display: none; }

/* Top row: block tag + X/Y progress */
.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 6px;
}
.block-tag {
  font-size: clamp(15px, 2.6vw, 20px);
  color: var(--mute);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.progress-count {
  font-size: clamp(17px, 3vw, 24px);
  color: var(--mute);
  font-family: ui-monospace, "SF Mono", monospace;
  font-weight: 600;
}

/* Middle: CUE — the dominant element. BIG. */
.cue-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 12px 2px;
  min-height: 0;
  text-align: center;
}
.star-mark {
  display: none;
  color: var(--gold);
  font-size: clamp(48px, 10vw, 80px);
  margin-bottom: 10px;
  text-shadow: 0 0 32px rgba(240, 200, 85, 0.85);
  animation: pulse 1.4s ease-in-out infinite;
}
.star-mark.show { display: block; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.92); }
}
.phase-name {
  color: var(--mute);
  font-size: clamp(22px, 4.2vw, 34px);
  letter-spacing: 1px;
  margin-bottom: 22px;
  font-weight: 400;
  line-height: 1.25;
}
/* CUE TEXT — the whole point. As large as the viewport allows. */
.cue-text {
  color: var(--text);
  font-size: clamp(46px, 11vw, 96px);
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: opacity 0.2s ease;
}
.cue-text.fade { opacity: 0.15; }

/* Climax emphasis: gold cue + gold block tag */
body.climax-active .cue-text { color: var(--gold); text-shadow: 0 0 28px rgba(240, 200, 85, 0.45); }
body.climax-active .block-tag { color: var(--gold); }

/* Next preview */
.next-section {
  text-align: center;
  padding: 10px 0 6px;
  border-top: 1px solid var(--line);
}
.next-label {
  color: var(--gold);
  font-size: clamp(14px, 2.4vw, 18px);
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.next-cue {
  color: var(--mute);
  font-size: clamp(22px, 4vw, 32px);
  line-height: 1.3;
  font-weight: 500;
}

/* Per-cue countdown (auto-advance progress) */
.countdown-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
  margin: 14px 0 12px;
}
.countdown-fill {
  height: 100%;
  background: var(--gold);
  width: 100%;
  transform-origin: left;
}
/* paused = dim the bar so it's obvious the timer stopped */
body.paused .countdown-fill { background: var(--mute2); }

/* Manual override controls — big tap targets */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}
.ctrl {
  border: none;
  border-radius: 14px;
  background: var(--ctrl-bg);
  color: var(--text);
  font-family: inherit;
  font-size: clamp(17px, 3.2vw, 24px);
  font-weight: 600;
  padding: 18px 6px;
  min-height: 64px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.12s ease;
}
.ctrl:active { background: var(--ctrl-bg-active); }
.ctrl-next {
  background: var(--gold);
  color: #0a0a0a;
  font-weight: 800;
}
.ctrl-next:active { background: #ffd866; }
.ctrl-prev:disabled { opacity: 0.3; }
/* pause button reflects state */
body.paused .ctrl-pause {
  background: var(--gold);
  color: #0a0a0a;
}

/* Tiny reference row: elapsed + this cue's remaining */
.ref-row {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: clamp(14px, 2.4vw, 18px);
  color: var(--mute2);
  letter-spacing: 1px;
}

/* ============ COMPLETE STATE ============ */
#complete-overlay {
  position: fixed;
  inset: 0;
  background: #2a2a2a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 32px;
}
#complete-overlay[hidden] { display: none; }
.complete-title {
  color: var(--gold);
  font-size: clamp(44px, 9vw, 80px);
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 18px;
  text-align: center;
}
.complete-time {
  color: var(--mute);
  font-size: clamp(20px, 3.6vw, 30px);
  margin-bottom: 52px;
  font-family: ui-monospace, "SF Mono", monospace;
}
.ctrl-restart {
  border: none;
  border-radius: 16px;
  background: var(--gold);
  color: #0a0a0a;
  font-family: inherit;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  padding: 22px 48px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* landscape: keep cue dominant, shrink chrome */
@media (orientation: landscape) and (max-height: 500px) {
  .phase-name { margin-bottom: 10px; }
  .cue-text { font-size: clamp(36px, 8vh, 72px); }
  .next-section { padding: 6px 0 4px; }
  .ctrl { min-height: 52px; padding: 12px 6px; }
}
