/* ════════════════════════════════════════════════════════════
   LiveTimeTools — Countdown Timer
   timer.css  (matches timer.html: tm-* classes)
   Global elements (body, header, h1, .container, .hero, .breadcrumb)
   are styled by main.css and are intentionally NOT touched here.
   ════════════════════════════════════════════════════════════ */

:root {
  --tm-surface: #0c1220;
  --tm-surface2: #111a2e;
  --tm-border: #1e2d4a;
  --tm-accent: #00e5ff;
  --tm-accent2: #ff6b35;
  --tm-accent3: #7c3aed;
  --tm-accent3-text: #a78bfa;
  --tm-text: #e8edf5;
  --tm-text2: #8899b4;
  --tm-gold: #ffd166;
  --tm-green: #06ffa5;
  --tm-red: #ff4060;
  --tm-sans:  'Inter', sans-serif;
  --tm-mono: 'JetBrains Mono', monospace;
}

/* `hidden` attribute must always win over display rules below */
.timer-page [hidden] { display: none !important; }

.timer-page { position: relative; }
.timer-page *, .timer-page *::before, .timer-page *::after { box-sizing: border-box; }

/* ── Hero badge ── */
.tm-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  margin-bottom: 16px;
  border: 1px solid rgba(124, 58, 237, .35);
  border-radius: 100px;
  background: rgba(124, 58, 237, .05);
  color: var(--tm-accent3-text);
  font-size: 14px;
  letter-spacing: 1px;
}

/* ── Focus ring (keyboard users) ── */
.timer-page button:focus-visible,
.timer-page input:focus-visible,
.timer-page select:focus-visible,
.timer-page summary:focus-visible {
  outline: 2px solid var(--tm-accent);
  outline-offset: 2px;
}

/* ════════ QUICK PRESETS ════════ */
.tm-presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 20px;
}
.tm-pill {
  padding: 9px 18px;
  border: 1px solid var(--tm-border);
  border-radius: 100px;
  background: transparent;
  color: var(--tm-text2);
  font-family: var(--tm-sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.tm-pill:hover {
  border-color: var(--tm-accent3);
  color: var(--tm-accent3-text);
  background: rgba(124, 58, 237, .08);
}

/* ════════ TOOLBAR ════════ */
.tm-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}
.tm-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--tm-border);
  border-radius: 10px;
  background: var(--tm-surface);
  color: var(--tm-text2);
  font-family: var(--tm-sans);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.tm-tool:hover,
.tm-tool[aria-expanded="true"] {
  border-color: var(--tm-accent3);
  color: var(--tm-accent3-text);
}
.tm-tool[aria-expanded="true"] { background: rgba(124, 58, 237, .08); }

/* ════════ TEMPLATES PANEL ════════ */
.tm-templates {
  margin-bottom: 24px;
  padding: 18px 20px;
  border: 1px solid var(--tm-border);
  border-radius: 16px;
  background: var(--tm-surface);
}
.tm-templates h2 {
  margin: 0 0 12px;
  color: var(--tm-text2);
  font-family: var(--tm-mono);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
}
.tm-tpl-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.tm-tpl-empty {
  color: var(--tm-text2);
  font-size: 15px;
  font-style: italic;
}
.tm-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--tm-border);
  border-radius: 100px;
  background: var(--tm-surface2);
  overflow: hidden;
  transition: border-color .2s;
}
.tm-chip:hover { border-color: var(--tm-accent); }
.tm-chip-use,
.tm-chip-del {
  border: 0;
  background: transparent;
  color: var(--tm-text);
  font-family: var(--tm-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.tm-chip-use { padding: 8px 6px 8px 14px; }
.tm-chip-del {
  padding: 8px 12px 8px 6px;
  color: var(--tm-text2);
}
.tm-chip-del:hover { color: var(--tm-red); }
.tm-tpl-save {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tm-tpl-save input {
  padding: 9px 12px;
  border: 1px solid var(--tm-border);
  border-radius: 8px;
  background: var(--tm-surface2);
  color: var(--tm-text);
  font-family: var(--tm-sans);
  font-size: 15px;
}
.tm-tpl-save input::placeholder { color: var(--tm-text2); }
.tm-tpl-save input:focus { outline: none; border-color: var(--tm-accent); }
#tmTplName { flex: 1 1 180px; min-width: 0; }
#tmTplMin { flex: 0 0 110px; width: 110px; }

/* ════════ TIMERS GRID ════════ */
.tm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.tm-empty {
  grid-column: 1 / -1;
  padding: 28px 12px;
  color: var(--tm-text2);
  font-size: 15px;
  text-align: center;
}

/* ── Card ── */
.tm-card {
  position: relative;
  padding: 24px;
  border: 1px solid var(--tm-border);
  border-radius: 20px;
  background: var(--tm-surface);
  color: var(--tm-text);
  overflow: hidden;
  transition: border-color .3s, box-shadow .3s, opacity .2s;
}
.tm-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--tm-accent3), transparent);
  opacity: .6;
}
.tm-card.is-running {
  border-color: rgba(124, 58, 237, .5);
  box-shadow: 0 0 30px rgba(124, 58, 237, .1);
}
.tm-card.is-paused { border-color: rgba(255, 209, 102, .3); }
.tm-card.is-done {
  border-color: rgba(255, 64, 96, .5);
  box-shadow: 0 0 30px rgba(255, 64, 96, .15);
  animation: tmDonePulse 1s ease-in-out infinite;
}
.tm-card.is-dragging { opacity: .4; border-color: var(--tm-accent); }
.tm-card.is-drag-over {
  border-color: var(--tm-green);
  box-shadow: 0 0 0 2px rgba(6, 255, 165, .3) inset;
}
@keyframes tmDonePulse {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 64, 96, .15); }
  50%      { box-shadow: 0 0 40px rgba(255, 64, 96, .35); }
}

/* ── Card top row ── */
.tm-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.tm-handle,
.tm-move,
.tm-del {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--tm-text2);
  font-family: var(--tm-sans);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.tm-handle { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.tm-handle:active { cursor: grabbing; }
.tm-handle:hover { color: var(--tm-text); }
.tm-move, .tm-del { border-color: var(--tm-border); }
.tm-move { font-size: 15px; }
.tm-move:hover:not(:disabled) { border-color: var(--tm-accent3); color: var(--tm-accent3-text); }
.tm-move:disabled { opacity: .3; cursor: not-allowed; }
.tm-del:hover { border-color: var(--tm-red); color: var(--tm-red); }

/* Up/down buttons are for touch devices; mouse users drag the handle */
@media (hover: hover) and (pointer: fine) {
  .tm-move { display: none; }
}

.tm-label {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 4px 2px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--tm-text);
  font-family: var(--tm-sans);
  font-size: 15px;
  font-weight: 700;
}
.tm-label::placeholder { color: var(--tm-text2); }
.tm-label:hover { border-bottom-color: var(--tm-border); }
.tm-label:focus { outline: none; border-bottom-color: var(--tm-accent); }

/* ── Cycle badge ── */
.tm-cycle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: fit-content;
  margin: 0 auto 10px;
  padding: 4px 10px;
  border: 1px solid rgba(124, 58, 237, .25);
  border-radius: 100px;
  background: rgba(124, 58, 237, .08);
  color: var(--tm-accent3-text);
  font-family: var(--tm-mono);
  font-size: 15px;
}

/* ── Progress ring ── */
.tm-ring {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.tm-ring svg { width: 140px; height: 140px; }
.tm-ring-bg { fill: none; stroke: var(--tm-border); stroke-width: 8; }
.tm-ring-prog {
  fill: none;
  stroke: var(--tm-accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset .3s linear, stroke .3s;
}
.tm-card.is-running .tm-ring-prog { stroke: var(--tm-accent3); }
.tm-card.is-low .tm-ring-prog     { stroke: var(--tm-accent2); }
.tm-card.is-done .tm-ring-prog    { stroke: var(--tm-red); }
.tm-ring-time {
  fill: var(--tm-text);
  font-family: var(--tm-mono);
  font-size: 20px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}
.tm-card.is-long .tm-ring-time { font-size: 16px; }
.tm-ring-lbl {
  fill: var(--tm-text2);
  font-family: var(--tm-sans);
  font-size: 10px;
  letter-spacing: 2px;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* ── H / M / S inputs ── */
.tm-time {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  transition: opacity .2s;
}
.tm-time.is-locked { opacity: .4; }
.tm-tblock {
  padding: 10px 8px;
  border: 1px solid var(--tm-border);
  border-radius: 10px;
  background: var(--tm-surface2);
  text-align: center;
  transition: border-color .2s;
}
.tm-tblock:focus-within { border-color: var(--tm-accent3); }
.tm-tblock label {
  display: block;
  margin-bottom: 4px;
  color: var(--tm-text2);
  font-family: var(--tm-mono);
  font-size: 11px;
  letter-spacing: 2px;
}
.tm-tblock input {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--tm-text);
  font-family: var(--tm-mono);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.tm-tblock input:focus { outline: none; }
.tm-tblock input:disabled { cursor: not-allowed; }
.tm-tblock input::-webkit-inner-spin-button,
.tm-tblock input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Alarm + repeat ── */
.tm-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.tm-mini {
  display: block;
  margin-bottom: 3px;
  color: var(--tm-text2);
  font-family: var(--tm-mono);
  font-size: 12px;
  letter-spacing: 1px;
}
.tm-settings select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--tm-border);
  border-radius: 8px;
  background: var(--tm-surface2);
  color: var(--tm-text);
  font-family: var(--tm-sans);
  font-size: 12px;
}
.tm-settings select:focus { outline: none; border-color: var(--tm-accent3); }
.tm-repeat {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}
.tm-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--tm-text2);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.tm-check input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--tm-accent3);
}
.tm-count {
  width: 52px;
  padding: 6px;
  border: 1px solid var(--tm-border);
  border-radius: 6px;
  background: var(--tm-surface2);
  color: var(--tm-text);
  font-family: var(--tm-mono);
  font-size: 15px;
  text-align: center;
}
.tm-count:focus { outline: none; border-color: var(--tm-accent3); }
.tm-count:disabled { opacity: .4; cursor: not-allowed; }

/* ── Buttons ── */
.tm-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.tm-btn {
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: var(--tm-sans);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: box-shadow .2s, transform .2s, border-color .2s, color .2s;
}
.tm-btn-start {
  border-color: var(--tm-accent3);
  background: var(--tm-accent3);
  color: #fff;
}
.tm-btn-start:hover:not(:disabled) {
  box-shadow: 0 0 20px rgba(124, 58, 237, .4);
  transform: translateY(-1px);
}
.tm-btn-reset {
  border-color: var(--tm-border);
  background: transparent;
  color: var(--tm-text2);
}
.tm-btn-reset:hover { border-color: var(--tm-text2); color: var(--tm-text); }
.tm-btn:disabled { opacity: .5; cursor: not-allowed; }
.tm-save-tpl {
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--tm-border);
  border-radius: 10px;
  background: transparent;
  color: var(--tm-text2);
  font-family: var(--tm-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.tm-save-tpl:hover { border-color: var(--tm-gold); color: var(--tm-gold); }

.tm-done-msg {
  margin-top: 8px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 64, 96, .1);
  color: var(--tm-red);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
  animation: tmBlink 1s infinite;
}
@keyframes tmBlink { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* ── Add timer ── */
.tm-add {
  display: block;
  width: 100%;
  padding: 20px;
  border: 2px dashed var(--tm-border);
  border-radius: 20px;
  background: transparent;
  color: var(--tm-text2);
  font-family: var(--tm-sans);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.tm-add:hover {
  border-color: var(--tm-accent3);
  color: var(--tm-accent3-text);
  background: rgba(124, 58, 237, .05);
}

/* ════════ HOW IT WORKS ════════ */
.tm-heading { margin: 48px 0 28px; text-align: center; }
.tm-heading h2 {
  margin: 0 0 8px;
  color: var(--tm-text);
  font-size: clamp(22px, 3.5vw, 30px);
  font-weight: 800;
  letter-spacing: -1px;
}
.tm-heading p {
  max-width: 520px;
  margin: 0 auto;
  color: var(--tm-text2);
  font-size: 15px;
}
.tm-how {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 48px;
}
.tm-how-card {
  padding: 20px 18px;
  border: 1px solid var(--tm-border);
  border-radius: 16px;
  background: var(--tm-surface);
  text-align: left;
  transition: border-color .2s, transform .2s;
}
.tm-how-card:hover { border-color: var(--tm-accent3); transform: translateY(-3px); }
.tm-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: rgba(124, 58, 237, .12);
  color: var(--tm-accent3-text);
  font-family: var(--tm-mono);
  font-size: 15px;
  font-weight: 700;
}
.tm-how-card h3 {
  margin: 0 0 6px;
  color: var(--tm-text);
  font-size: 15px;
  font-weight: 800;
}
.tm-how-card p {
  margin: 0;
  color: var(--tm-text2);
  font-size: 15px;
  line-height: 1.6;
}

/* ════════ FAQ (native <details>) ════════ */
.tm-faq { margin-bottom: 48px; }
.tm-faq-item {
  margin-bottom: 10px;
  border: 1px solid var(--tm-border);
  border-radius: 14px;
  background: var(--tm-surface);
  overflow: hidden;
  transition: border-color .2s;
}
.tm-faq-item:hover { border-color: rgba(124, 58, 237, .3); }
.tm-faq-item[open] { border-color: var(--tm-accent3); }
.tm-faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  color: var(--tm-text);
  font-size: 15px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
.tm-faq-item summary::-webkit-details-marker { display: none; }
.tm-faq-item summary::marker { content: ''; }
.tm-faq-item summary::after {
  content: '+';
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--tm-border);
  border-radius: 6px;
  color: var(--tm-text2);
  font-size: 15px;
  line-height: 1;
  transition: transform .3s, color .2s, border-color .2s;
}
.tm-faq-item[open] summary::after {
  transform: rotate(45deg);
  border-color: var(--tm-accent3);
  color: var(--tm-accent3-text);
}
.tm-faq-item p {
  margin: 0;
  padding: 0 20px 18px;
  color: var(--tm-text2);
  font-size: 15px;
  line-height: 1.7;
}
.tm-faq-item p strong { color: var(--tm-text); }
.tm-faq-item code {
  padding: 1px 6px;
  border: 1px solid var(--tm-border);
  border-radius: 4px;
  background: var(--tm-surface2);
  color: var(--tm-accent3-text);
  font-family: var(--tm-mono);
  font-size: 15px;
}

/* ════════ TOAST ════════ */
.tm-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100000;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border: 1px solid rgba(6, 255, 165, .3);
  border-radius: 12px;
  background: var(--tm-surface);
  color: var(--tm-text);
  font-family: var(--tm-sans);
  font-size: 15px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: opacity .3s, transform .3s;
}
.tm-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ════════ RESPONSIVE ════════ */
@media (max-width: 760px) {
  .tm-how { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .tm-how { grid-template-columns: 1fr; }
  .tm-grid { grid-template-columns: 1fr; }
  .tm-settings { grid-template-columns: 1fr; }
  .tm-card { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tm-card.is-done,
  .tm-done-msg { animation: none; }
  .tm-ring-prog,
  .tm-how-card,
  .tm-toast { transition: none; }
}
