/* ────────────────────────────────────────────────────────────
   Timer Stack — In-browser preview runner
   A minimalist, self-contained full-screen runner overlay.
   Themed at runtime via the stack's --ts-tint custom property.
   ──────────────────────────────────────────────────────────── */

.ts-runner-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 120% at 50% 0%,
      color-mix(in srgb, var(--ts-tint, var(--brandPrimary)) 22%, #0d0d0f) 0%,
      #0d0d0f 60%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #f2f2f2;
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-font-smoothing: antialiased;
}

.ts-runner-overlay.is-open { opacity: 1; }

.ts-runner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  /* Bounded card so the runner reads as a distinct surface on the backdrop. */
  padding: 26px 24px 22px;
  border-radius: 28px;
  background: rgba(18, 18, 22, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

/* ── Top bar ── */
.ts-runner-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ts-runner-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  min-width: 0;
}

.ts-runner-name .material-symbols-rounded {
  font-size: 22px;
  color: var(--ts-tint, var(--brandPrimary));
  flex-shrink: 0;
}

.ts-runner-name .ts-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ts-runner-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #f2f2f2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.ts-runner-close:hover { background: rgba(255, 255, 255, 0.12); }

.ts-runner-round {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(242, 242, 242, 0.55);
}

/* ── Progress dial ── */
.ts-dial {
  position: relative;
  width: 260px;
  height: 260px;
  max-width: 72vw;
  max-height: 72vw;
}

.ts-dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.ts-dial-track { stroke: rgba(255, 255, 255, 0.08); }

.ts-dial-progress {
  stroke: var(--ts-tint, var(--brandPrimary));
  stroke-linecap: round;
  transition: stroke-dashoffset 0.2s linear;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--ts-tint, var(--brandPrimary)) 55%, transparent));
}

.ts-dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
}

.ts-dial-icon {
  display: inline-flex;
  margin-bottom: 2px;
  will-change: transform, opacity;
}

.ts-dial-icon .material-symbols-rounded {
  font-size: 48px;
  color: var(--ts-tint, var(--brandPrimary));
}

/* The symbol gently breathes (scale + fade) while a timer is counting. */
.ts-runner.is-running .ts-dial-icon {
  animation: ts-breathe 3.4s ease-in-out infinite;
}

@keyframes ts-breathe {
  0%, 100% { transform: scale(0.94); opacity: 0.6; }
  50%      { transform: scale(1.12); opacity: 1; }
}

.ts-time {
  font-size: 3.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
}

/* Passthrough overtime reads in the accent colour. */
.ts-runner.is-overrun .ts-time { color: var(--ts-tint, var(--brandPrimary)); }

.ts-label {
  font-size: 1.0rem;
  font-weight: 600;
  color: rgba(242, 242, 242, 0.85);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Up next ── */
.ts-up-next {
  min-height: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(242, 242, 242, 0.5);
}
.ts-up-next b { color: rgba(242, 242, 242, 0.8); font-weight: 700; }

/* ── Controls ── */
.ts-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.ts-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #f2f2f2;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.ts-btn:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
.ts-btn:active { transform: scale(0.94); }
.ts-btn .material-symbols-rounded { font-size: 26px; }

/* The play/pause control is always the app's core primary (neon orange),
   independent of the per-category accent on the ring. */
.ts-btn-primary {
  width: 76px;
  height: 76px;
  background: var(--brand-primary, var(--brandPrimary));
  border-color: transparent;
  box-shadow: 0 10px 30px rgba(244, 127, 0, 0.45);
}
.ts-btn-primary:hover { background: var(--brand-primary, var(--brandPrimary)); filter: brightness(1.08); }
.ts-btn-primary .material-symbols-rounded { font-size: 36px; color: var(--onBrandPrimary); }

/* ── End-of-timer behaviour (Auto / Manual / Passthrough) ── */
.ts-mode-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.ts-mode {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  gap: 2px;
}

.ts-mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(242, 242, 242, 0.62);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ts-mode-btn:hover { color: #f2f2f2; }
.ts-mode-btn.is-active {
  background: var(--ts-tint, var(--brandPrimary));
  color: #fff;
}

.ts-mode-caption {
  font-size: 0.72rem;
  color: rgba(242, 242, 242, 0.45);
  min-height: 16px;
}

/* ── Info Container (App-only teasers) ── */
.ts-info-container {
  width: 100%;
  display: flex;
  overflow-x: auto;
  gap: 12px;
  padding: 4px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.ts-info-container::-webkit-scrollbar {
  display: none;
}

.ts-info-card {
  flex: 0 0 calc(100% - 8px);
  scroll-snap-align: center;
  position: relative;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px;
  overflow: hidden;
  text-align: left;
  min-height: 80px;
  display: flex;
  align-items: center;
}

.ts-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.ts-card-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #111;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Music Card Content */
.ts-music-content, .ts-media-content {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  opacity: 0.6; /* Dimmed because it's app-only */
}

.ts-music-art {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #5b21b6, #db2777);
  color: #fff;
}
.ts-music-art .material-symbols-rounded { font-size: 26px; }

.ts-media-art {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255,255,255,0.7);
}
.ts-media-art .material-symbols-rounded { font-size: 26px; }

.ts-music-info, .ts-media-info { flex: 1; min-width: 0; }
.ts-music-title, .ts-media-title { font-size: 0.95rem; font-weight: 700; color: #fff; }
.ts-music-sub, .ts-media-sub {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ts-music-bar {
  margin-top: 8px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.ts-music-bar span {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
}

/* HealthKit Grid Content */
.ts-health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  opacity: 0.6;
}
.ts-health-metric {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ts-metric-icon .material-symbols-rounded {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.6);
}
.ts-metric-val {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

/* ── Footer (app-only upsell) ── */
.ts-runner-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.ts-cap-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(242, 242, 242, 0.55);
  font-size: 0.72rem;
  font-weight: 600;
}
.ts-cap-chip .material-symbols-rounded { font-size: 15px; }

.ts-runner-hint {
  font-size: 0.72rem;
  color: rgba(242, 242, 242, 0.4);
}

/* ── Completion state ── */
.ts-runner.is-done .ts-dial-progress { stroke: var(--ts-tint, var(--brandPrimary)); }
.ts-done-badge {
  display: none;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--ts-tint, var(--brandPrimary));
}
.ts-runner.is-done .ts-done-badge { display: inline-flex; }
.ts-runner.is-done .ts-dial-icon,
.ts-runner.is-done .ts-time,
.ts-runner.is-done .ts-label { display: none; }
.ts-runner.is-done .ts-up-next { visibility: hidden; }

/* Trigger button used on the share page */
.ts-try-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 14px 32px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  margin-bottom: 16px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.ts-try-button:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.1); }
.ts-try-button .material-symbols-rounded { font-size: 20px; }

@media (prefers-reduced-motion: reduce) {
  .ts-runner-overlay, .ts-dial-progress, .ts-btn { transition: none; }
  .ts-runner.is-running .ts-dial-icon { animation: none; }
}
