/*
 * SPDX-License-Identifier: AGPL-3.0-only
 * Copyright (C) 2026 Aristocles <https://github.com/Aristocles>
 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* NOTE: do NOT put overflow-x:hidden on html/body — that disables
   pinch-to-zoom on iOS Safari. Width constraints + per-component
   overflow handling (see app.js & eh-schedule-card) are the right
   layer for preventing horizontal growth. */
html, body {
  max-width: 100vw;
}

/* ===== THEME VARIABLES ===== */
:root, [data-theme="light"] {
  --bg-page: #f5f7fa;
  --bg-card: #ffffff;
  --bg-nav: #ffffff;
  --bg-input: #f1f5f9;
  --bg-hover: rgba(0,0,0,0.04);
  --bg-active: rgba(14,165,233,0.08);
  --bg-overlay: rgba(0,0,0,0.3);
  --bg-disabled: #e2e8f0;

  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --border-subtle: #f1f5f9;

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-disabled: #94a3b8;
  --text-inverse: #ffffff;

  --accent: #0ea5e9;
  --accent-hover: #38bdf8;
  --accent-bg: rgba(14,165,233,0.1);
  --accent-dark: #0284c7;

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-nav: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-glow: 0 0 16px rgba(14,165,233,0.15);

  --chart-grid: #e2e8f0;
  --chart-text: #64748b;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg-page: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-nav: #121220;
  --bg-input: #252540;
  --bg-hover: rgba(255,255,255,0.05);
  --bg-active: rgba(0,212,170,0.1);
  --bg-overlay: rgba(0,0,0,0.7);
  --bg-disabled: #333;

  --border: #2a2a4a;
  --border-hover: #4a4a6a;
  --border-subtle: #1a1a30;

  --text-primary: #e0e0e0;
  --text-secondary: #8888aa;
  --text-muted: #555566;
  --text-disabled: #666;
  --text-inverse: #0f0f1a;

  --accent: #00d4aa;
  --accent-hover: #00eabb;
  --accent-bg: rgba(0,212,170,0.1);
  --accent-dark: #00b894;

  --success: #44ff88;
  --warning: #ffaa00;
  --danger: #ff4444;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-nav: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 16px rgba(0,212,170,0.2);

  --chart-grid: #2a2a4a;
  --chart-text: #8888aa;

  color-scheme: dark;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  transition: background 0.3s, color 0.3s;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.accent-teal { color: var(--accent); }
.accent-amber { color: var(--warning); }
.accent-red { color: var(--danger); }
.accent-green { color: var(--success); }

/* Progress bar */
.progress-bar {
  background: var(--border);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
}

/* Sleep stage bar */
.sleep-bar {
  display: flex;
  height: 24px;
  border-radius: 6px;
  overflow: hidden;
}

.sleep-bar > div {
  transition: width 0.5s ease;
}

/* Ring animation */
@keyframes ring-fill {
  from { stroke-dashoffset: var(--circumference); }
  to { stroke-dashoffset: var(--offset); }
}

/* Sparkline */
.sparkline {
  display: inline-block;
  vertical-align: middle;
}

/* Calendar cell hover */
.cal-cell {
  cursor: pointer;
  transition: all 0.15s;
}

.cal-cell:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Chart containers */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 5vh;
  overflow-y: auto;
}

.overlay-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 700px;
  width: 95%;
  padding: 24px;
  margin-bottom: 5vh;
}
