/* ── Custom Properties ─────────────────────────────────── */
:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --idle-color: #2a2a4a;
  --active-color: #e94560;
  --active-glow: rgba(233, 69, 96, 0.45);
  --finished-color: #ff6b35;
  --finished-glow: rgba(255, 107, 53, 0.55);
  --text: #eaeaea;
  --text-dim: #8888aa;
  --ring-track: #0f3460;
  --ring-progress: var(--active-color);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ── Reset & Base ──────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Top Bar ───────────────────────────────────────────── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75em 1.25em;
  background: var(--surface);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.app-title {
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.title-icon {
  font-size: 1.15em;
  line-height: 1;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

/* ── Preset Selector (segmented control) ───────────────── */
.preset-selector {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0.5em;
  padding: 0.15em;
  gap: 0.1em;
}

.preset-btn {
  width: 2.2em;
  height: 2em;
  border: none;
  border-radius: 0.4em;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.preset-btn:hover {
  color: var(--text);
}

.preset-btn:active {
  transform: scale(0.94);
}

.preset-btn.active {
  background: var(--active-color);
  color: #fff;
  box-shadow: 0 0 8px var(--active-glow);
}

.icon-btn {
  width: 2.4em;
  height: 2.4em;
  border-radius: 0.5em;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s ease, transform 0.1s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* ── Burners Container (dynamic centering) ─────────────── */
.burners-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 1.5em;
  padding: 1.5em 0.5em;
  overflow-y: auto;
}

.burners-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5em;
}

.burners-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-items: center;
  align-items: center;
  gap: 1.5em;
}

/* ── Burner Container ──────────────────────────────────── */
.burner {
  position: relative;
  width: min(30vw, 500px);
  min-width: 0;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.15s ease;
}

/* ── SVG Ring ──────────────────────────────────────────── */
.burner-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.burner-ring circle {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
}

.burner-ring .track {
  stroke: var(--ring-track);
}

.burner-ring .progress {
  stroke: var(--ring-progress);
  transition: stroke-dashoffset 0.4s linear, stroke 0.3s ease;
}

.burner:active {
  transform: scale(0.96);
}

/* ── Burner Body (inner circle) ────────────────────────── */
.burner-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25em;
  pointer-events: none;
}

.burner-time {
  font-family: var(--font-mono);
  font-size: min(calc(30vw * 0.15), 65px);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--text);
}

.burner-label {
  font-size: min(calc(30vw * 0.05), 25px);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── Burner Controls (stop + remove) ───────────────────── */
.burner-controls {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  gap: 0.4em;
  pointer-events: auto;
}

.burner-btn {
  width: 3em;
  height: 3em;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s ease;
}

.burner-btn:hover {
  background: rgba(233, 69, 96, 0.75);
}

/* Stop button: only visible on active burners */
.burner-controls .stop-btn {
  display: none;
}

.burner[data-state="active"] .burner-controls .stop-btn {
  display: flex;
}

/* ── Burner States ─────────────────────────────────────── */

/* Idle */
.burner[data-state="idle"] .burner-body {
  opacity: 0.6;
}

.burner[data-state="idle"] .burner-ring .progress {
  stroke-dashoffset: 0;
}

/* Active */
.burner[data-state="active"] {
  box-shadow: 0 0 40px var(--active-glow), inset 0 0 30px var(--active-glow);
}

.burner[data-state="active"] .burner-ring .progress {
  stroke: var(--active-color);
}

.burner[data-state="active"] .burner-body {
  opacity: 1;
}

/* Finished */
.burner[data-state="finished"] {
  box-shadow: 0 0 50px var(--finished-glow), inset 0 0 35px var(--finished-glow);
  animation: pulse-finish 1s ease-in-out infinite;
}

.burner[data-state="finished"] .burner-ring .progress {
  stroke: var(--finished-color);
}

@keyframes pulse-finish {
  0%, 100% {
    box-shadow: 0 0 30px var(--finished-glow), inset 0 0 20px var(--finished-glow);
  }
  50% {
    box-shadow: 0 0 70px var(--finished-glow), inset 0 0 50px var(--finished-glow);
  }
}

/* ── Modal / Config ────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.2s ease;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: 1em;
  padding: 1.5em;
  width: min(90vw, 360px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.25em;
  text-align: center;
  color: var(--text);
}

.form-group {
  margin-bottom: 1em;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.4em;
}

.form-group input[type="number"] {
  width: 100%;
  padding: 0.6em 0.75em;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5em;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font-mono);
  text-align: center;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group input[type="number"]:focus {
  border-color: var(--active-color);
}

.modal-actions {
  display: flex;
  gap: 0.75em;
  margin-top: 1.5em;
}

.btn {
  flex: 1;
  padding: 0.65em 1em;
  border: none;
  border-radius: 0.5em;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--active-color);
  color: #fff;
}

.btn-primary:hover {
  background: #d63a54;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 500px) {
  .burners-container {
    gap: 1em;
    padding: 1em 0.25em;
  }
  .burners-row {
    gap: 1em;
  }
  .burners-group {
    gap: 1em;
  }
}
