/* Timer: shared pomodoro card + top-bar phase pill. */

.timer-card {
  --timer-accent: var(--lamp-soft);
  --timer-glow: transparent;
  position: relative;
  display: flex; flex-direction: column; align-items: stretch; gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-4);
  border-radius: inherit;
  isolation: isolate;
}
.timer-card[data-phase='focus'] { --timer-accent: var(--lamp); --timer-glow: var(--lamp-glow); }
.timer-card[data-phase='break'] { --timer-accent: var(--rose); --timer-glow: var(--rose-glow); }
.timer-card[data-paused='true'] { --timer-glow: transparent; }

/* A warm pool of light behind the ring: blooms in like a lamp switching on. */
.timer-card::before {
  content: ''; position: absolute; z-index: -1;
  left: 50%; top: 46%; width: 78%; aspect-ratio: 1; translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--timer-glow), transparent 72%);
  opacity: 0; filter: blur(14px);
  transition: opacity var(--t-slow) var(--ease), background var(--t-slow) var(--ease);
  pointer-events: none;
}
.timer-card.is-lit::before { opacity: 0.75; }
.timer-card[data-paused='true']::before { opacity: 0; }

/* ---------- header ---------- */
.timer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.timer-title { line-height: 1.2; }
.timer-by {
  margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch;
  transition: color var(--t-med) var(--ease);
}
.timer-head-actions { display: flex; gap: var(--s-1); flex: none; }
.timer-card .timer-head-actions .btn-icon { width: 36px; height: 36px; background: transparent; border-color: transparent; color: var(--text-dim); }
.timer-card .timer-head-actions .btn-icon:hover { background: rgba(243, 233, 216, 0.07); color: var(--text); }
.timer-card .timer-head-actions .btn-icon svg { width: 18px; height: 18px; }
.timer-card .timer-mute[aria-pressed='true'] { background: transparent; box-shadow: none; color: var(--text-dim); }
.timer-card .timer-mute[aria-pressed='false'] { color: var(--text-faint); }
.timer-card .timer-settings-btn[aria-expanded='true'] { color: var(--lamp); background: rgba(255, 179, 92, 0.1); }
.timer-card [data-tip]:hover::after { bottom: auto; top: calc(100% + 6px); }

/* ---------- ring ---------- */
.timer-ring {
  position: relative; width: min(100%, 228px); aspect-ratio: 1; margin: 0 auto;
  display: grid; place-items: center;
}
.timer-ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.timer-ring-track { fill: none; stroke: rgba(243, 233, 216, 0.07); stroke-width: 7; }
.timer-ring-ticks line { stroke: rgba(243, 233, 216, 0.12); stroke-width: 1; stroke-linecap: round; }
.timer-ring-ticks line.is-major { stroke: rgba(243, 233, 216, 0.22); stroke-width: 1.4; }
.timer-ring-fill, .timer-ring-glow {
  fill: none; stroke: var(--timer-accent); stroke-width: 7; stroke-linecap: round;
  transition: stroke var(--t-slow) var(--ease), opacity var(--t-slow) var(--ease);
}
.timer-ring-glow { stroke-width: 10; opacity: 0.55; }
.timer-card[data-phase='idle'] .timer-ring-fill,
.timer-card[data-phase='idle'] .timer-ring-glow { opacity: 0; }
.timer-card[data-paused='true'] .timer-ring-fill { opacity: 0.55; }
.timer-card[data-paused='true'] .timer-ring-glow { opacity: 0; }
.timer-ring-head {
  fill: var(--text); stroke: var(--timer-accent); stroke-width: 2.5;
  filter: drop-shadow(0 0 6px var(--timer-accent));
  transition: opacity var(--t-slow) var(--ease), stroke var(--t-slow) var(--ease);
}
.timer-card[data-phase='idle'] .timer-ring-head { opacity: 0; }

.timer-face { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.timer-round { font-size: 0.6875rem; letter-spacing: 0.16em; }
.timer-digits {
  font-family: var(--font-mono); font-weight: 500;
  font-size: clamp(2.5rem, 5vw, 3.1rem); line-height: 1.05; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1, 'zero' 0;
  color: var(--text);
  text-shadow: 0 0 24px var(--timer-glow);
  transition: color var(--t-slow) var(--ease), text-shadow var(--t-slow) var(--ease), opacity var(--t-med) var(--ease);
}
.timer-card[data-phase='idle'] .timer-digits { color: var(--text-dim); }
.timer-card[data-paused='true'] .timer-digits { opacity: 0.6; }
.timer-phase {
  font-family: var(--font-display); font-variation-settings: 'SOFT' 100; font-style: italic;
  font-size: var(--fs-md); color: var(--timer-accent);
  transition: color var(--t-slow) var(--ease);
}
.timer-card[data-phase='idle'] .timer-phase { color: var(--text-dim); }

/* ---------- round dots ---------- */
.timer-dots { display: flex; justify-content: center; gap: 10px; }
.timer-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(243, 233, 216, 0.12);
  box-shadow: inset 0 0 0 1px rgba(243, 233, 216, 0.16);
  transition: background var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease), transform var(--t-med) var(--ease);
}
.timer-dot.is-done { background: var(--lamp); box-shadow: 0 0 10px var(--lamp-glow); }
.timer-dot.is-current { box-shadow: inset 0 0 0 1.5px var(--timer-accent), 0 0 8px var(--timer-glow); transform: scale(1.15); }

/* ---------- controls ---------- */
.timer-controls { display: flex; align-items: center; justify-content: center; gap: var(--s-3); }
.timer-main {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-width: 132px; min-height: 44px;
}
.timer-main-icon { display: inline-grid; }
.timer-main-icon svg { width: 18px; height: 18px; }
.timer-main-icon svg path { fill: currentColor; }
.timer-main.is-running .timer-main-icon svg path { fill: none; }
.timer-main.is-running {
  background: rgba(243, 233, 216, 0.06); color: var(--text); border-color: var(--glass-line-strong);
}
.timer-main.is-running:hover { background: rgba(243, 233, 216, 0.1); box-shadow: none; }
.timer-card .timer-controls .btn-icon:disabled { opacity: 0.35; cursor: default; }
.timer-card .timer-controls .btn-icon:disabled:hover { background: rgba(243, 233, 216, 0.05); }
.timer-card .timer-controls .btn-icon:disabled:hover::after { display: none; }

/* ---------- settings: presets + custom ---------- */
.timer-settings {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding-top: var(--s-3); border-top: 1px solid var(--glass-line);
  animation: timer-bloom var(--t-med) var(--ease);
}
.timer-settings[hidden] { display: none; }
@keyframes timer-bloom { from { opacity: 0; filter: blur(4px); } }

.timer-chips { display: flex; gap: var(--s-2); }
.timer-chip {
  flex: 1; min-height: 36px; padding: 6px 8px;
  border-radius: var(--r-pill); border: 1px solid var(--glass-line-strong);
  background: transparent; color: var(--text-dim);
  font-family: var(--font-mono); font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
  transition: background var(--t-fast) var(--ease), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-med);
}
.timer-chip:hover { background: rgba(243, 233, 216, 0.06); color: var(--text); }
.timer-chip[aria-pressed='true'] {
  border-color: var(--lamp); color: var(--lamp-soft); background: rgba(255, 179, 92, 0.1);
  box-shadow: 0 0 16px rgba(255, 179, 92, 0.14);
}
.timer-chip-sep { color: var(--text-faint); margin: 0 3px; }

.timer-custom { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: var(--s-2); align-items: end; }
.timer-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.timer-field-label { font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
.timer-card .timer-num {
  padding: 7px 8px; border-radius: var(--r-sm); text-align: center;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--fs-sm);
  -moz-appearance: textfield; appearance: textfield;
}
.timer-card .timer-num::-webkit-outer-spin-button,
.timer-card .timer-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.timer-apply { min-height: 36px; }
.timer-hint { margin: 0; font-size: var(--fs-xs); color: var(--text-faint); line-height: 1.4; }

/* ---------- top-bar pill ---------- */
.timer-pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  max-width: 100%; min-height: 34px; padding: 6px 14px 6px 12px;
  border-radius: var(--r-pill); border: 1px solid var(--glass-line);
  background: var(--glass); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  color: var(--text-dim); font-size: var(--fs-sm); white-space: nowrap;
  transition: border-color var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease), color var(--t-med);
}
.timer-pill:hover { color: var(--text); border-color: var(--glass-line-strong); }
.timer-pill-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--text-faint);
  transition: background var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease);
}
.timer-pill[data-phase='focus'] { border-color: rgba(255, 179, 92, 0.28); box-shadow: 0 0 22px rgba(255, 179, 92, 0.12); }
.timer-pill[data-phase='focus'] .timer-pill-dot { background: var(--lamp); box-shadow: 0 0 8px var(--lamp); }
.timer-pill[data-phase='break'] { border-color: rgba(242, 143, 173, 0.3); box-shadow: 0 0 22px rgba(242, 143, 173, 0.12); }
.timer-pill[data-phase='break'] .timer-pill-dot { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
.timer-pill[data-paused='true'] { box-shadow: none; }
.timer-pill[data-paused='true'] .timer-pill-dot { box-shadow: none; opacity: 0.6; }
.timer-pill-phase { color: var(--text); }
.timer-pill-time { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); }
.timer-pill-sep { color: var(--text-faint); }
.timer-pill-lamps { overflow: hidden; text-overflow: ellipsis; }
.room-top-slot > .timer-pill { flex: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .timer-ring { width: min(100%, 204px); }
  .timer-main { min-width: 116px; }
}
@media (max-width: 900px) {
  .timer-card { display: grid; grid-template-columns: minmax(0, 1fr); }
  .timer-ring { width: min(72vw, 240px); }
  .timer-by { max-width: 30ch; }
}
@media (max-width: 560px) {
  .timer-pill { padding: 6px 12px 6px 10px; gap: 6px; }
  .timer-pill-phase, .timer-pill-sep-phase { display: none; }
}
@media (max-width: 400px) {
  .timer-pill-lamps, .timer-pill-sep-lamps { display: none; }
  .timer-custom { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .timer-apply { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .timer-settings { animation: none; }
  .timer-dot.is-current { transform: none; }
}
