/* Skywave · timer.css — sleep timer & wake-up alarm */

/* ---------- dock button & indicators ---------- */
#btn-timer {
  display: grid;
  overflow: visible;
}
#btn-timer svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#btn-timer.on {
  color: var(--amber);
  border-color: var(--amber);
}
#btn-timer.fading {
  box-shadow: 0 0 14px var(--amber-glow);
  animation: timer-pulse 1.8s ease-in-out infinite;
}
@keyframes timer-pulse {
  0%, 100% { border-color: var(--amber); }
  50% { border-color: var(--amber-2); box-shadow: 0 0 20px rgba(255, 181, 71, 0.35); }
}

.timer-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--ink);
  font: 600 10px/16px var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: -0.02em;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--ink-2), 0 0 10px var(--amber-glow);
}

.timer-alarm-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--ink-2), 0 0 8px var(--amber);
}
.timer-alarm-dot.with-sleep {
  top: auto;
  bottom: -2px;
  right: -2px;
}

/* ---------- dialog sheet ---------- */
dialog.sheet.timer-sheet {
  padding: 20px 22px 18px;
  width: min(440px, 92vw);
  max-height: min(90vh, 720px);
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.timer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.timer-head h3 {
  margin: 0;
  font: 400 22px/1.15 var(--serif);
  font-variation-settings: 'opsz' 72;
}
.timer-x {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: none;
  color: var(--dim);
  display: grid;
  place-items: center;
  font-size: 14px;
  flex: none;
}
.timer-x:hover {
  color: var(--amber);
  border-color: var(--line-2);
}

.timer-sec {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.timer-sec:first-of-type {
  padding-top: 12px;
}
.timer-sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.timer-lbl {
  font: 500 10.5px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.timer-status {
  font: 500 12.5px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  text-align: right;
}
.timer-status.on {
  color: var(--amber);
  text-shadow: 0 0 12px var(--amber-glow);
}

/* ---------- sleep section ---------- */
.timer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.timer-chips .chip {
  font-family: var(--mono);
  font-size: 12px;
  padding: 5px 11px;
}
.timer-chips .chip[data-min='0'][aria-pressed='true'] {
  background: var(--ink-3);
  border-color: var(--line-2);
  color: var(--paper-2);
}
.timer-note {
  margin: 9px 0 0;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.4;
}

/* ---------- alarm section ---------- */
.timer-grid {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}
.timer-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.timer-field > span {
  font: 10px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.timer-field input[type='time'],
.timer-field select {
  width: 100%;
  min-width: 0;
  height: 38px;
  background: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 0 10px;
  color: var(--paper);
  color-scheme: dark;
  outline: none;
}
.timer-field input[type='time'] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.timer-field select {
  font-size: 13px;
  text-overflow: ellipsis;
}
.timer-field input[type='time']:focus,
.timer-field select:focus {
  border-color: var(--amber);
}
.timer-field select:disabled,
.timer-field input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.timer-field select option {
  background: var(--ink-2);
  color: var(--paper);
}

.timer-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--amber-2);
}

.timer-wake-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}
.timer-wake-row .toggle {
  font-size: 12.5px;
  color: var(--paper-2);
}
.timer-wake-row .toggle.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.timer-wake-state {
  font: 10.5px var(--mono);
  color: var(--dim);
  white-space: nowrap;
}
.timer-wake-state.on {
  color: var(--leaf);
}

.timer-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
}
.timer-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.timer-actions .btn:not(.ghost):disabled {
  background: var(--ink-3);
  border-color: var(--line-2);
  color: var(--dim);
}

.timer-caveat {
  margin: 11px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--dim);
}

/* ---------- dialog footer ---------- */
.timer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
}
.timer-kbd-hint {
  font-size: 11.5px;
  color: var(--dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- phones ---------- */
@media (max-width: 820px) {
  #btn-timer {
    display: grid;
  }
  dialog.sheet.timer-sheet {
    padding: 18px 16px 16px;
    max-height: 88dvh;
  }
  .timer-chips .chip {
    padding: 7px 12px;
    font-size: 12.5px;
  }
  .timer-field input[type='time'],
  .timer-field select {
    height: 42px;
    font-size: 16px; /* stops iOS Safari zooming on focus */
  }
  .timer-kbd-hint {
    display: none;
  }
  .timer-foot {
    justify-content: flex-end;
  }
}

@media (max-width: 440px) {
  .timer-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  #btn-timer.fading {
    animation: none !important;
  }
}
