/* Design tokens for the app shell, taken from the Claude Design prototype
   (.claude/project design.html). A theme overrides these on :root at load time.
   Themes change the accent, glow, background and panel colors, and the fonts. */
:root {
  --color-bg: #0d0a1f;
  --color-bg-gradient: radial-gradient(ellipse at 50% 100%, #2c1f5c 0%, #150f33 55%, #0a0719 100%);
  --color-glow: rgba(110, 80, 200, 0.55);
  --color-accent: #cbb8ff;
  --color-text: #efe9ff;
  --color-text-muted: rgba(239, 233, 255, 0.8);
  --color-panel: rgba(18, 12, 40, 0.62);
  --color-border: rgba(255, 255, 255, 0.14);
  --color-divider: rgba(255, 255, 255, 0.12);
  --color-control: rgba(255, 255, 255, 0.3);
  --color-hover: rgba(255, 255, 255, 0.16);
  --color-warning: #f2b84b;
  --color-star: #ffffff;
  --color-knob: #ffffff;
  --color-dock: rgba(18, 12, 40, 0.6);
  --color-input: rgba(0, 0, 0, 0.3);
  --color-input-border: rgba(255, 255, 255, 0.2);
  --color-orb: rgba(0, 0, 0, 0.55);
  --color-orb-fill: rgba(255, 255, 255, 0.55);
  --color-subtle: rgba(255, 255, 255, 0.06);
  --color-mist: rgba(255, 255, 255, 0.07);
  --color-active: rgba(255, 255, 255, 0.12);
  --color-separator: rgba(255, 255, 255, 0.18);
  --color-track: rgba(255, 255, 255, 0.22);
  --color-shadow: rgba(0, 0, 0, 0.35);
  --color-accent-glow: rgba(203, 184, 255, 0.35);

  --font-display: 'Cinzel', serif;
  --font-body: 'Cormorant Garamond', serif;
  --font-family: var(--font-body);

  --radius: 16px;
  --gutter: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Background: gradient, mist and stars. A theme with video covers this layer later. */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--color-bg-gradient);
  transition: background 1.2s ease;
  overflow: hidden;
}

.mist {
  position: absolute;
  left: -10%;
  right: -10%;
  height: 55%;
  opacity: 0.7;
  background: radial-gradient(ellipse at 50% 100%, var(--color-glow), transparent 70%);
}

.mist-a {
  bottom: -8%;
  animation: mist 40s ease-in-out infinite alternate;
}

.mist-b {
  top: 10%;
  height: 40%;
  opacity: 1;
  background: radial-gradient(ellipse at 30% 50%, var(--color-mist), transparent 65%);
  animation: mist 55s ease-in-out infinite alternate-reverse;
}

.stars {
  position: absolute;
  inset: -70px 0;
  animation: drift 90s linear infinite alternate;
}

.star {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--color-star);
  opacity: 0.5;
  animation: twinkle var(--dur) ease-in-out var(--delay) infinite;
}

/* Entry screen */
.intro {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
  text-align: center;
  transition: opacity 1s ease, transform 1s ease;
}

.intro-kicker {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(13px, 3.6vw, 20px);
  font-weight: 400;
  letter-spacing: 0.3em;
  color: var(--color-accent);
  animation: rise 1.4s ease both;
}

.intro-clock {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(64px, 12vw, 140px);
  line-height: 1;
  animation: rise 1.6s ease 0.25s both;
}

.intro-text {
  margin: 0;
  max-width: 560px;
  font-size: clamp(21px, 4.6vw, 28px);
  line-height: 1.35;
  animation: rise 1.6s ease 0.5s both;
}

.btn-open {
  margin-top: 8px;
  padding: 16px 44px;
  border: 1px solid var(--color-accent);
  border-radius: 999px;
  background: var(--color-subtle);
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.24em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.5s ease, transform 0.5s ease;
  animation: rise 1.6s ease 0.75s both;
}

.btn-open:hover {
  background: var(--color-hover);
  transform: translateY(-2px);
}

/* App screen */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease 0.2s;
}

.is-app .app {
  opacity: 1;
  pointer-events: auto;
}

.is-app .intro {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.04);
}

.clock {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(52px, 8vw, 104px);
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0 40px var(--color-accent-glow);
}

.progress {
  position: absolute;
  top: 34px;
  left: 40px;
}

/* Progress as an orb (fills from the bottom) */
.orb {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-orb);
  border: 2px solid var(--color-accent);
  box-shadow: 0 0 30px var(--color-glow);
}

.orb-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(to top, var(--color-accent), var(--color-orb-fill));
  opacity: 0.9;
  transition: height 1s linear;
}

.hud {
  position: absolute;
  left: 40px;
  bottom: 40px;
  display: grid;
  gap: 12px;
}

.phase-label {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.16em;
  color: var(--color-accent);
}

.rewards:empty {
  display: none;
}

/* Floating windows */
.win {
  position: absolute;
  left: var(--x, 60px);
  top: var(--y, 120px);
  width: var(--w, 340px);
  max-height: calc(100vh - var(--y, 120px) - 100px);
  overflow-y: auto;
  z-index: 3;
  border-radius: var(--radius);
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px var(--color-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.6s ease, transform 0.6s ease, visibility 0s 0.6s;
}

.win.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.6s ease, transform 0.6s ease, visibility 0s;
}

.win-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-divider);
  cursor: grab;
  touch-action: none;
}

.win-title {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.16em;
}

.win-min {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
}

.win-min:hover {
  background: var(--color-hover);
}

.win-body {
  display: grid;
  gap: 18px;
  padding: 16px 20px 20px;
}

.divider {
  height: 1px;
  background: var(--color-divider);
}

.slider-row {
  display: grid;
  gap: 6px;
  font-size: 22px;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--color-accent);
}

.mixer-list {
  display: grid;
  gap: 18px;
}

.empty {
  margin: 0;
  font-size: 19px;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.text-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-input-border);
  border-radius: 10px;
  background: var(--color-input);
  font-size: 20px;
  outline: none;
}

.text-input:disabled {
  opacity: 0.5;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 22px;
}

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

.stepper output {
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.step {
  width: 34px;
  height: 34px;
  border: 1px solid var(--color-control);
  border-radius: 50%;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

.step:hover {
  background: var(--color-hover);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 22px;
  cursor: pointer;
}

.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: var(--color-track);
  cursor: pointer;
  transition: background 0.5s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-knob);
  transition: left 0.4s ease;
}

.switch:checked {
  background: var(--color-accent);
}

.switch:checked::after {
  left: 23px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

/* Dock: floating pill at the bottom, hides after a few idle seconds */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 28px;
  z-index: 4;
  padding: 0 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  transition: opacity 0.9s ease, transform 0.9s ease;
}

.dock.is-hidden {
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
}

.dock-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  margin: 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-dock);
  backdrop-filter: blur(18px);
}

.dock-btn {
  position: relative;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.1em;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.4s ease;
}

.dock-btn:hover {
  background: var(--color-hover);
}

.dock-btn.is-primary {
  background: var(--color-active);
}

.dock-btn .dot {
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 5px;
  height: 5px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--color-accent);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.dock-btn[aria-expanded="true"] .dot {
  opacity: 1;
}

.dock-sep {
  width: 1px;
  height: 26px;
  margin: 0 6px;
  background: var(--color-separator);
}

.warnings {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: grid;
  gap: 8px;
  max-width: 320px;
}

.warnings:empty {
  display: none;
}

.warning {
  padding: 8px 12px;
  border-left: 4px solid var(--color-warning);
  border-radius: 6px;
  background: var(--color-panel);
  font-size: 17px;
}

/* Focus mode (step 14): hides everything except the timer and progress. */
body.focus-mode .hide-in-focus {
  display: none;
}

/* Phones: windows centered under the clock, dock scrolls sideways. */
@media (max-width: 719px) {
  .clock {
    top: 28px;
  }

  .progress {
    top: 112px;
    left: 50%;
    transform: translateX(-50%);
  }

  .hud {
    left: 16px;
    bottom: 96px;
  }

  .win {
    left: 50%;
    top: 180px;
    translate: -50% 0;
    width: min(var(--w, 340px), calc(100vw - 24px));
    max-height: calc(100vh - 280px);
  }

  .dock {
    bottom: 14px;
    touch-action: pan-x;
  }

  .dock-btn {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* Reduced motion (ARCHITECTURE.md, D25): no animation, instant changes. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes drift {
  from { transform: translateY(0); }
  to { transform: translateY(-60px); }
}

@keyframes twinkle {
  0%,
  100% { opacity: 0.25; }
  50% { opacity: 0.95; }
}

@keyframes mist {
  from { transform: translateX(-6%); }
  to { transform: translateX(6%); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
