/* ═══════════════════════════════════════════════
   Destiny — CSS (dark theme matching Hatch spaces)
   ═══════════════════════════════════════════════ */

:root {
  color-scheme: dark;
  /* Health dashboard palette */
  --bg: #0d1117;
  --surface: rgba(22, 27, 34, 0.85);
  --surface-2: rgba(30, 37, 48, 0.7);
  --surface-solid: #161c32;
  --text: #e6edf3;
  --dim: #7d8590;
  --border: rgba(125, 133, 144, 0.12);
  --accent: #6366f1;
  --radius: 20px;

  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.1);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.1);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.1);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.1);
  --purple: #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.1);
  --cyan: #22d3ee;
  --cyan-bg: rgba(34, 211, 238, 0.1);
  --teal: #2dd4bf;
  --teal-bg: rgba(45, 212, 191, 0.1);
  --rose: #fb7185;
  --rose-bg: rgba(251, 113, 133, 0.1);

  /* Goals palette additions */
  --goals-accent: #D4A574;
  --goals-accent-glow: rgba(212, 165, 116, 0.12);
  --goals-bg: #0a0e1a;
  --goals-surface: rgba(22, 28, 50, 0.7);
  --goals-border: rgba(45, 53, 85, 0.5);
  --goals-dim: #7b86a6;
  --success: #64ffda;
  --danger: #ff6b6b;
  --sky: #38bdf8;
  --violet: #a78bfa;
  --warning: #fbbf24;

  --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: var(--font-sans); background: var(--bg); color: var(--text); min-height: 100vh; }
::selection { background: rgba(99, 102, 241, 0.3); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(125,133,144,0.2); border-radius: 3px; }

/* ── Animations ── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shake { 0%,100%{transform:translateX(0)} 15%,45%,75%{transform:translateX(-6px)} 30%,60%,90%{transform:translateX(6px)} }
@keyframes ringDraw { from { stroke-dashoffset: var(--ring-circ); } to { stroke-dashoffset: var(--ring-off); } }
@keyframes softPulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.fade-up { animation: fadeUp 0.5s ease-out both; }
.slide-up { animation: slideUp 0.5s ease-out forwards; opacity: 0; }
.shake { animation: shake 0.5s ease-in-out; }
.pulse-soft { animation: softPulse 2s ease-in-out infinite; }
.ring-arc { animation: ringDraw 1.2s cubic-bezier(0.4,0,0.2,1) forwards; stroke-linecap: round; }

/* ── Password Gate ── */
.gate-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.gate-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 40px; text-align: center; max-width: 400px; width: 100%;
  backdrop-filter: blur(20px);
}
.gate-title { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.gate-sub { color: var(--dim); font-size: 14px; margin-bottom: 24px; }
.gate-input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 16px; outline: none;
  font-family: var(--font-sans); text-align: center; letter-spacing: 2px;
}
.gate-input:focus { border-color: var(--accent); }
.gate-error { color: var(--red); font-size: 13px; margin-top: 8px; }

/* ── Portal Picker ── */
.portal-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px; gap: 16px;
}
.portal-header { text-align: center; margin-bottom: 16px; }
.portal-header h1 { font-size: 36px; font-weight: 700; }
.portal-header p { color: var(--dim); margin-top: 8px; }
.portal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; max-width: 500px; width: 100%; }
.portal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px; text-align: center; cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.portal-card:hover { transform: scale(1.03); border-color: var(--accent); box-shadow: 0 0 24px rgba(99,102,241,0.08); }
.portal-icon { font-size: 40px; margin-bottom: 12px; }
.portal-label { font-size: 16px; font-weight: 600; }
.portal-desc { font-size: 12px; color: var(--dim); margin-top: 4px; }

/* ── Layout ── */
.app-container { max-width: 900px; margin: 0 auto; padding: 16px 16px 80px; }
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding: 8px 0; }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-back { background: none; border: none; color: var(--dim); cursor: pointer; padding: 8px; border-radius: 8px; display: flex; align-items: center; }
.header-back:hover { background: var(--surface-2); }
.header h1 { font-size: 24px; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; color: var(--dim); cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 6px;
}
.header-btn:hover { border-color: var(--accent); color: var(--text); }

/* ── Tabs ── */
.tab-bar {
  display: flex; gap: 4px; overflow-x: auto; padding: 4px; margin-bottom: 20px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 12px;
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--dim);
  transition: all 0.2s;
}
.tab-btn.active { background: rgba(99,102,241,0.1); color: var(--accent); border-color: rgba(99,102,241,0.2); }
.tab-btn:hover:not(.active) { color: var(--text); background: var(--surface-2); }

/* ── Glass Card ── */
.glass-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(20px); margin-bottom: 12px;
}
.glass-card-p { padding: 16px; }
@media (min-width: 640px) { .glass-card-p { padding: 20px; } }

/* ── Section Title ── */
.section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-icon {
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.section-label { font-size: 20px; font-weight: 600; }

/* ── Metric Grid ── */
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 640px) { .metric-grid-3 { grid-template-columns: repeat(3, 1fr); } .metric-grid-4 { grid-template-columns: repeat(4, 1fr); } }
.metric-tile {
  border-radius: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--border);
}
.metric-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); margin-bottom: 4px; }
.metric-value { font-size: 22px; font-weight: 700; font-family: var(--font-mono); }
.metric-unit { font-size: 13px; color: var(--dim); margin-left: 4px; }
.metric-sub { font-size: 11px; color: var(--dim); margin-top: 2px; }

/* ── Marker Card (Labs) ── */
.marker-card { cursor: pointer; transition: opacity 0.2s; }
.marker-card:hover { opacity: 0.9; }
.marker-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.marker-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.marker-name { font-size: 13px; font-weight: 700; margin-left: 8px; }
.marker-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500;
}
.marker-value { font-size: 28px; font-weight: 700; font-family: var(--font-mono); }
.marker-target { font-size: 11px; color: var(--dim); margin-top: 2px; }
.marker-chart { height: 180px; margin-top: 12px; }
.marker-explanation {
  font-size: 13px; line-height: 1.6; padding: 12px; border-radius: 12px; margin-top: 12px;
}

/* ── Timeline ── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: linear-gradient(to bottom, var(--goals-accent), var(--border)); border-radius: 1px;
}
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot {
  position: absolute; left: -28px; top: 4px; width: 18px; height: 18px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.timeline-dot.completed { background: var(--goals-accent); box-shadow: 0 0 12px rgba(212,165,116,0.4); }
.timeline-dot.pending { background: var(--surface-solid); border: 2px solid var(--border); }
.timeline-dot.active { background: var(--surface-solid); border: 2px solid var(--goals-accent); box-shadow: 0 0 12px rgba(212,165,116,0.25); }

/* ── Goal Card ── */
.goal-card {
  background: var(--goals-surface); backdrop-filter: blur(24px);
  border: 1px solid var(--goals-border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 16px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.goal-card:hover { transform: translateY(-3px); box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
.goal-card-inner { padding: 20px; }
@media (min-width: 640px) { .goal-card-inner { padding: 28px; } }
.goal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.goal-header-left { display: flex; align-items: center; gap: 12px; }
.goal-icon-wrap {
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.goal-title { font-size: 20px; font-weight: 700; }
.goal-subtitle { font-size: 13px; color: var(--goals-dim); margin-top: 2px; }
.goal-badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
}

/* ── Progress Bar ── */
.progress-track { height: 8px; background: rgba(45,53,85,0.5); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 1.2s cubic-bezier(0.16,1,0.3,1); }

/* ── Park Chips ── */
.park-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 12px; font-size: 14px;
  background: rgba(26,31,54,0.6); border: 1px solid var(--goals-border);
}
.park-chip.visited { border-color: rgba(100,255,218,0.3); background: rgba(100,255,218,0.06); }
.park-chip.pending-park { border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.06); }

/* ── Tab Pills (Goals) ── */
.tab-pills {
  display: flex; gap: 4px; padding: 4px; border-radius: 12px; margin-bottom: 20px;
  background: rgba(26,31,54,0.6); border: 1px solid var(--goals-border); overflow-x: auto;
}
.tab-pill {
  flex-shrink: 0; padding: 8px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; border: 1px solid transparent;
  background: transparent; color: var(--goals-dim); transition: all 0.2s;
}
.tab-pill.active { background: rgba(212,165,116,0.15); color: var(--goals-accent); border-color: rgba(212,165,116,0.3); }

/* ── Mission Control Strip ── */
.mission-strip {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px; margin-bottom: 24px;
  scrollbar-width: none;
}
.mission-strip::-webkit-scrollbar { display: none; }
.mission-pill {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border-radius: 16px; padding: 10px 12px; min-width: 68px; cursor: pointer;
  background: rgba(26,31,54,0.6); border: 1px solid transparent;
  transition: all 0.2s;
}
.mission-pill:hover { transform: scale(1.05); }
.mission-emoji { font-size: 16px; }
.mission-value { font-size: 14px; font-weight: 700; }
.mission-sub { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--goals-dim); }

/* ── Supplement check ── */
.sup-check {
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: all 0.2s; border: 2px solid var(--border); background: var(--surface-2);
}
.sup-check.taken { border-color: var(--teal); background: var(--teal); }

/* ── Chart Container ── */
.chart-container { position: relative; width: 100%; }
.chart-container canvas { width: 100% !important; }

/* ── Urgent strip ── */
.urgent-strip {
  border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
  background: rgba(239,68,68,0.04); border: 1px solid rgba(239,68,68,0.15);
}
.urgent-header {
  padding: 10px 16px; display: flex; align-items: center; gap: 8px;
  background: rgba(239,68,68,0.08); border-bottom: 1px solid rgba(239,68,68,0.1);
}
.urgent-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--danger); }
.urgent-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid rgba(239,68,68,0.06);
}
.urgent-item:last-child { border-bottom: none; }

/* ── Section divider ── */
.section-divider { height: 1px; background: linear-gradient(to right, transparent, var(--border), transparent); margin: 12px 0; }

/* ── Adherence heatmap ── */
.adherence-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.adherence-cell {
  aspect-ratio: 1; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; transition: all 0.2s; position: relative;
}

/* ── Responsive ── */
@media (max-width: 639px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .portal-grid { grid-template-columns: 1fr; }
  .header h1 { font-size: 20px; }
}
