/* --------------------------------------
   VARIABLES
-------------------------------------- */
:root {
  --bg: #fefefe;
  --text: #1a1a1a;
  --muted: #888;
  --accent: #43aa8b;
  --surface: #f0f0f0;
  --surface-hover: #e4e4e4;
  --border: #e0e0e0;
  --progress-bg: #ececec;
}

body.dark {
  --bg: #121212;
  --text: #f1f1f1;
  --muted: #666;
  --accent: #43aa8b;
  --surface: #222;
  --surface-hover: #2e2e2e;
  --border: #2a2a2a;
  --progress-bg: #333;
}

/* --------------------------------------
   BASE
-------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
  transition: background 0.2s, color 0.2s;
}

/* --------------------------------------
   TIMER CONTAINER
-------------------------------------- */
.timer-container {
  width: 100%;
  max-width: 460px;
  text-align: center;
}

/* --------------------------------------
   TIME DISPLAY
-------------------------------------- */
#time {
  font-family: 'Roboto Mono', monospace;
  font-size: 4rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  line-height: 1;
  margin: 0 0 0.75rem;
}

/* --------------------------------------
   PROGRESS BAR
-------------------------------------- */
.progress-bar {
  height: 20px;
  background: var(--progress-bg);
  border-radius: 30px;
  margin: 0 auto 1.75rem;
  max-width: 250px;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 30px;
  transition: width 1s linear;
}

/* duration-input is hidden — time is set via keyboard digit input */
#duration-input {
  display: none;
}

/* --------------------------------------
   PRIMARY CONTROLS
-------------------------------------- */
.controls-primary {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  width: fit-content;
  margin: 0 auto 1.75rem;
}

.controls-primary button {
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  padding: 0.6rem 1.75rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

#start {
  background: var(--accent);
  color: #1a1a1a;
}

#start:hover {
  opacity: 0.88;
}

#pause {
  background: var(--surface);
  color: var(--text);
}

#stop,
#reset,
#minus-1,
#plus-5,
#plus-10 {
  background: var(--surface);
  color: var(--muted);
}

#pause:hover,
#stop:hover,
#reset:hover,
#minus-1:hover,
#plus-5:hover,
#plus-10:hover {
  background: var(--surface-hover);
}

#minus-1,
#plus-5,
#plus-10 {
  font-size: 0.82rem;
  padding: 0.45rem 0;
}

#start, #pause, #stop, #reset {
  grid-column: span 3;
}

#minus-1, #plus-5, #plus-10 {
  grid-column: span 2;
}

.controls-primary button:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* --------------------------------------
   BLINK (paused state)
-------------------------------------- */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.blink {
  animation: blink 1s step-start infinite;
}

/* --------------------------------------
   HEATMAP
-------------------------------------- */
.heatmap {
  display: grid;
  grid-template-columns: repeat(15, 14px);
  gap: 3px;
  width: fit-content;
  margin: 0 auto 0.75rem;
  padding: 1.75rem 0 0.25rem;
}

.day {
  width: 14px;
  height: 14px;
  background: #ddd;
  border-radius: 3px;
  cursor: default;
}

body.dark .day { background: #2a2a2a; }

.day[data-level='1'] { background: #b7e4d8; }
.day[data-level='2'] { background: #6dcbb0; }
.day[data-level='3'] { background: #43aa8b; }
.day[data-level='4'] { background: #2d7a63; }

body.dark .day[data-level='1'] { background: #1a3d33; }
body.dark .day[data-level='2'] { background: #2d7a63; }
body.dark .day[data-level='3'] { background: #43aa8b; }
body.dark .day[data-level='4'] { background: #4ecdc4; }

.day.today {
  outline: 1.5px solid var(--text);
  outline-offset: 1px;
}

/* --------------------------------------
   DRAWER TRIGGER (fixed top-right)
-------------------------------------- */
.drawer-trigger {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 8;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.drawer-trigger:hover {
  color: var(--text);
}

/* --------------------------------------
   DRAWER FOOTER
-------------------------------------- */
.drawer-footer {
  padding: 1rem 0 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.drawer-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.drawer-footer a:hover {
  color: var(--text);
}

/* --------------------------------------
   SCRIM
-------------------------------------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 9;
}

.scrim.show {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------
   SIDE DRAWER
-------------------------------------- */
.side-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(300px, 88vw);
  background: var(--bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
  padding: 1.5rem 1.25rem;
}

.side-drawer.open {
  transform: translateX(0);
}

.drawer-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  float: right;
  transition: color 0.15s;
}

.drawer-close:hover {
  color: var(--text);
}

.drawer-section {
  clear: both;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.drawer-section:last-child {
  border-bottom: none;
}

.drawer-app-name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.drawer-about {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.drawer-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.drawer-section label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0.5rem;
}

.label-icon {
  font-size: 15px;
  color: var(--muted);
  flex-shrink: 0;
}

.btn-icon {
  font-size: 14px;
  vertical-align: middle;
  line-height: 1;
}

.drawer-section input[type='checkbox'] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* --------------------------------------
   THEME TOGGLE
-------------------------------------- */
.theme-toggle {
  display: flex;
  width: 100%;
  background: var(--surface);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.theme-toggle button {
  flex: 1;
  font-size: 0.72rem;
  font-family: inherit;
  padding: 0.3rem 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle button:hover {
  color: var(--text);
}

.theme-toggle button.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

body.dark .theme-toggle button.active {
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* --------------------------------------
   DRAWER ACTIONS
-------------------------------------- */
.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.drawer-actions button {
  font-size: 0.78rem;
  font-family: inherit;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.drawer-actions button:hover {
  background: var(--surface-hover);
}

/* --------------------------------------
   SHORTCUTS
-------------------------------------- */
.shortcut-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.shortcut-list span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.shortcut-list kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.8em;
  flex-shrink: 0;
  background: var(--surface);
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 0.72rem;
  font-family: inherit;
  color: var(--text);
}

/* --------------------------------------
   BURST / CELEBRATE
-------------------------------------- */
.drawer-burst-section {
}

.drawer-burst-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

.burst-btn {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.burst-btn:hover {
  background: var(--surface-hover);
}

/* --------------------------------------
   ADD FOCUS ROW
-------------------------------------- */
.add-focus-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.add-focus-input,
.add-focus-btn {
  flex: 1;
  font-size: 0.78rem;
  font-family: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  box-sizing: border-box;
}

.add-focus-input {
  background: var(--bg);
  color: var(--text);
  appearance: textfield;
  -moz-appearance: textfield;
}

.add-focus-input::-webkit-inner-spin-button,
.add-focus-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.add-focus-btn {
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}

.add-focus-btn:hover {
  background: var(--surface-hover);
}

/* --------------------------------------
   SOUNDS
-------------------------------------- */
.sounds-section {
  margin-top: 1.75rem;
  width: 100%;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0.5rem;
}

.sounds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.sounds-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}

.sounds-master-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  line-height: 1;
}

.sounds-master-btn:hover {
  color: var(--text);
}

.sounds-master-btn .material-symbols-outlined {
  font-size: 16px;
}

.sounds-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.sound-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sound-icon {
  font-size: 18px;
  color: var(--muted);
  width: 1.5rem;
  flex-shrink: 0;
  text-align: center;
  user-select: none;
  cursor: pointer;
  transition: opacity 0.15s, color 0.15s;
}

.sound-icon.muted {
  opacity: 0.25;
}

.sound-slider {
  flex: 1;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--val, 0%),
    var(--surface) var(--val, 0%),
    var(--surface) 100%
  );
}

.sound-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}

.sound-slider::-webkit-slider-thumb:active {
  transform: scale(1.25);
}

.sound-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* --------------------------------------
   HEATMAP EMPTY STATE
-------------------------------------- */
.heatmap-empty {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin: 0 auto 0.75rem;
  opacity: 0.6;
}

/* --------------------------------------
   FOCUS SUMMARY
-------------------------------------- */
.focus-summary {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin: 0 auto 0.5rem;
  min-height: 1em;
}

/* --------------------------------------
   PRIVACY & ATTRIBUTION
-------------------------------------- */
.drawer-privacy {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.drawer-attribution {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
  opacity: 0.7;
}

.drawer-attribution a {
  color: var(--muted);
  text-decoration: none;
}

.drawer-attribution a:hover {
  color: var(--text);
}

/* --------------------------------------
   CONFETTI CANVAS
-------------------------------------- */
canvas#burst {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 5;
}

/* --------------------------------------
   RESPONSIVE — MOBILE
-------------------------------------- */

/* Extra small (iPhone SE 320px) */
@media (max-width: 350px) {
  #time {
    font-size: 3.25rem;
  }
  .controls-primary button {
    font-size: 0.85rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}
