/* ============================================================
   KITCHEN TIMERS — Enterprise Edition
   Samsung Family Hub ~21" touchscreen, Samsung Internet
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

:root {
  /* Surfaces */
  --bg:        #080c10;
  --surface:   #0d1117;
  --surface-2: #161b22;
  --surface-3: #21262d;

  /* Borders */
  --border:   rgba(240,246,252,0.07);
  --border-2: rgba(240,246,252,0.14);

  /* Text */
  --text:   #e6edf3;
  --text-2: #8b949e;
  --text-3: #484f58;

  /* Brand */
  --accent:      #f97316;
  --accent-glow: rgba(249,115,22,0.35);
  --danger:      #f85149;
  --success:     #3fb950;

  /* Timer tag colours */
  --c-red:    #f85149;
  --c-orange: #f97316;
  --c-yellow: #e3b341;
  --c-green:  #3fb950;
  --c-teal:   #39c5cf;
  --c-blue:   #2f81f7;
  --c-purple: #a371f7;
  --c-pink:   #f778ba;

  /* Motion */
  --ease:   cubic-bezier(0.2, 0, 0, 1);
  --spring: cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Warm brand glow anchored at the top */
body {
  background-image:
    radial-gradient(ellipse 80% 280px at 50% -40px,
      rgba(249,115,22,0.09) 0%,
      transparent 100%);
  min-height: 200vh;
}

/* ── Samsung Internet chrome-collapse scroll trick ── */
#scroll-spacer { height: 1px; width: 100%; }

#app {
  position: relative;
  min-height: 100vh;
  padding: 0 20px 120px;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 4px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.22em;
  flex-shrink: 0;
}

.brand-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(249,115,22,0.2), 0 0 14px var(--accent);
  animation: pulse 3s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.55; transform: scale(0.78); }
}

.brand-text {
  background: linear-gradient(135deg, #e6edf3 0%, #484f58 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.clock {
  margin-left: auto;
  font-size: 19px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  letter-spacing: 0.08em;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-3);
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.icon-btn:active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* ============================================================
   TIMER GRID
   ============================================================ */
.timer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

/* ============================================================
   TIMER CARD
   ============================================================ */
.timer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* 2 px colour strip pinned to the top edge + layered depth */
  box-shadow:
    inset 0 2px 0 var(--card-color),
    0 1px 3px rgba(0,0,0,0.55),
    0 6px 20px rgba(0,0,0,0.25);
  transition:
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

/* Subtle colour wash from the top-left corner */
.timer-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, var(--card-color) 0%, transparent 42%);
  opacity: 0.05;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.timer-card.running {
  border-color: var(--border-2);
  box-shadow:
    inset 0 2px 0 var(--card-color),
    0 2px 6px rgba(0,0,0,0.55),
    0 8px 28px rgba(0,0,0,0.3);
}
.timer-card.running::before { opacity: 0.09; }

.timer-card.finished {
  animation: cardAlarm 0.55s ease-in-out infinite;
  border-color: var(--card-color);
}
.timer-card.finished::before { opacity: 0.18; }

@keyframes cardAlarm {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}

/* ── Card inner ── */
.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.card-color-tag {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--card-color);
  box-shadow: 0 0 7px var(--card-color);
  flex-shrink: 0;
}

.card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-close {
  background: transparent;
  border: 0;
  color: var(--text-3);
  padding: 4px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}
.card-close:active { opacity: 1; color: var(--danger); }

.card-time {
  font-size: 62px;
  font-weight: 300;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 4px 0;
  position: relative;
  z-index: 1;
  color: var(--text);
  line-height: 1;
  transition: color 0.3s var(--ease);
}
.card-time.warn   { color: var(--c-yellow); }
.card-time.danger { color: var(--card-color); }

.card-progress {
  height: 2px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.card-progress-bar {
  height: 100%;
  background: var(--card-color);
  width: 0;
  transition: width 0.3s linear;
  box-shadow: 0 0 8px var(--card-color);
}

.card-controls {
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.card-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 13px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.1s var(--spring);
}
.card-btn:active {
  background: var(--surface-2);
  border-color: var(--border-2);
  transform: scale(0.95);
}
.card-btn.primary {
  background: var(--card-color);
  border-color: transparent;
  color: #000;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.card-btn.primary:active {
  filter: brightness(0.82);
  transform: scale(0.95);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-3);
  margin: auto 0;
}
.empty-state.visible { display: flex; }
.empty-state h2 {
  margin: 18px 0 8px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-2);
}
.empty-state p {
  margin: 0;
  font-size: 15px;
  color: var(--text-3);
}
.empty-icon { opacity: 0.22; }

/* ============================================================
   FLOATING ACTION BUTTON
   ============================================================ */
.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 68px; height: 68px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(249,115,22,0.4),
    0 8px 28px rgba(249,115,22,0.42),
    0 2px 6px rgba(0,0,0,0.5);
  transition: transform 0.15s var(--spring), box-shadow 0.15s var(--ease);
  z-index: 50;
}
.fab:active {
  transform: scale(0.9);
  box-shadow:
    0 0 0 1px rgba(249,115,22,0.3),
    0 4px 14px rgba(249,115,22,0.3),
    0 1px 4px rgba(0,0,0,0.5);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(12px) saturate(0.8);
  -webkit-backdrop-filter: blur(12px) saturate(0.8);
}

.modal-panel {
  position: relative;
  background: rgba(13,17,23,0.97);
  border: 1px solid var(--border-2);
  border-radius: 26px;
  padding: 26px;
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 24px 80px rgba(0,0,0,0.75),
    0 8px 24px rgba(0,0,0,0.5);
  backdrop-filter: blur(32px) saturate(1.4);
  -webkit-backdrop-filter: blur(32px) saturate(1.4);
  animation: modalIn 0.22s var(--spring) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 2px;
}
.modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* ── Name + mic ── */
.name-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.name-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 15px 18px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-user-select: text;
  user-select: text;
}
.name-input:focus {
  border-color: rgba(249,115,22,0.6);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}
.name-input::placeholder { color: var(--text-3); }

.mic-btn {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  width: 60px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s var(--spring);
}
.mic-btn:active { transform: scale(0.93); }
.mic-btn.listening {
  background: rgba(248,81,73,0.12);
  border-color: var(--danger);
  color: var(--danger);
}

.mic-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 17px;
  border: 1.5px solid var(--danger);
  opacity: 0;
  pointer-events: none;
}
.mic-btn.listening .mic-pulse {
  animation: micRing 1.4s ease-out infinite;
}
@keyframes micRing {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.38); }
}

.mic-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  min-height: 14px;
  text-align: center;
  letter-spacing: 0.03em;
  margin-top: -10px;
}
.mic-status.error { color: var(--danger); }

/* ── Time picker ── */
.picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 8px;
}

.picker-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 72px;
}

.picker-value {
  font-size: 52px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  padding: 4px 0;
  min-width: 72px;
  text-align: center;
}

.picker-arrow {
  background: transparent;
  border: 0;
  color: var(--text-3);
  font-size: 16px;
  padding: 8px 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.1s, background 0.1s, transform 0.1s var(--spring);
  line-height: 1;
}
.picker-arrow:active {
  background: var(--surface-3);
  color: var(--accent);
  transform: scale(0.88);
}

.picker-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.2em;
  margin-top: 2px;
}

.picker-sep {
  font-size: 36px;
  font-weight: 200;
  color: var(--text-3);
  margin-top: -24px;
  padding: 0 2px;
  line-height: 1;
}

/* ── Presets ── */
.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.preset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 10px;
  padding: 11px 4px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.1s var(--spring);
}
.preset:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  transform: scale(0.93);
}

/* ── Color picker ── */
.color-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.color-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.2em;
  flex-shrink: 0;
}

.colors {
  display: flex;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}

.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--c);
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform 0.15s var(--spring), box-shadow 0.15s, border-color 0.15s;
  padding: 0;
}
.color-swatch.active {
  border-color: var(--text);
  transform: scale(1.18);
  box-shadow: 0 0 14px var(--c);
}

/* ── Modal actions ── */
.modal-actions {
  display: flex;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.btn {
  flex: 1;
  padding: 17px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s var(--spring), box-shadow 0.15s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:active { background: var(--surface-3); }

.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 800;
  box-shadow: 0 4px 18px rgba(249,115,22,0.35);
}
.btn-primary:active {
  filter: brightness(0.87);
  box-shadow: 0 2px 8px rgba(249,115,22,0.2);
}

/* ============================================================
   ALARM OVERLAY
   ============================================================ */
.alarm-overlay {
  position: fixed;
  inset: 0;
  background: #050810;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.alarm-overlay[hidden] { display: none; }

.alarm-pulse {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 50%,
    var(--alarm-color, var(--danger)) 0%,
    transparent 65%
  );
  animation: alarmBreath 1.1s ease-in-out infinite;
  opacity: 0.5;
}
@keyframes alarmBreath {
  0%, 100% { transform: scale(0.88); opacity: 0.35; }
  50%       { transform: scale(1.08); opacity: 0.65; }
}

.alarm-content {
  position: relative;
  text-align: center;
  z-index: 1;
  padding: 20px;
}

.alarm-emoji {
  font-size: 96px;
  line-height: 1;
  animation: alarmRock 0.45s ease-in-out infinite;
}
@keyframes alarmRock {
  0%, 100% { transform: rotate(-12deg); }
  50%       { transform: rotate(12deg); }
}

.alarm-name {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 24px 0 6px;
  word-break: break-word;
  padding: 0 24px;
}

.alarm-sub {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-2);
  margin-bottom: 52px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.alarm-dismiss {
  background: #fff;
  color: #000;
  border: 0;
  padding: 20px 64px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.14em;
  border-radius: 100px;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.25),
    0 12px 40px rgba(255,255,255,0.2);
  transition: transform 0.1s var(--spring), box-shadow 0.15s;
}
.alarm-dismiss:active {
  transform: scale(0.93);
  box-shadow: 0 4px 18px rgba(255,255,255,0.12);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .brand { font-size: 18px; }
  .clock { font-size: 16px; }
  .timer-grid { grid-template-columns: 1fr; }
  .card-time { font-size: 52px; }
  .picker-value { font-size: 42px; }
  .picker-col { min-width: 60px; }
  .presets { grid-template-columns: repeat(3, 1fr); }
  .alarm-emoji { font-size: 76px; }
  .alarm-name { font-size: 38px; }
  .alarm-dismiss { padding: 18px 48px; font-size: 18px; }
}

/* Family Hub — large portrait touchscreen */
@media (min-width: 1000px) {
  .timer-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  .card-time { font-size: 72px; }
}

/* ============================================================
   WAKE LOCK DURATION PICKER
   ============================================================ */
.wl-wrap {
  position: relative;
}

/* Eye button — extends .icon-btn */
.wl-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  transition: color 0.15s, background 0.15s, border-color 0.15s, padding 0.2s var(--spring);
}

.wl-btn.active {
  background: rgba(249,115,22,0.12);
  border-color: rgba(249,115,22,0.5);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(249,115,22,0.15);
}

.wl-remaining {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  min-width: 0;
}

/* Dropdown panel */
.wl-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: flex;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  padding: 10px;
  z-index: 60;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 8px 32px rgba(0,0,0,0.55),
    0 2px 8px rgba(0,0,0,0.4);
  animation: panelIn 0.18s var(--spring) both;
  white-space: nowrap;
}
.wl-panel[hidden] { display: none; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.wl-opt {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.1s var(--spring);
}
.wl-opt:active,
.wl-opt.selected {
  background: rgba(249,115,22,0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.wl-opt:active { transform: scale(0.92); }
