/* app.css — 5 Minute Miracle PWA
   Design tokens match the confirmed brand system now live on the marketing
   site (5minutemiracleapp.com): deep teal primary, warm cream background,
   flat terracotta accent (CTAs/energy moments only, never a gradient), soft
   sage for cards/dividers/secondary badges. --amber/--coral are kept as
   variable names (existing call sites throughout this file reference them)
   but both now alias --accent so every flat usage inherits the new color
   without needing individual edits; the two-tone --gradient variable is
   rebuilt from --primary/--primary-light instead, since accent itself may
   never appear in a gradient. The signature box-breathing circle motif
   (4-4-4-4, Chapter 7) keeps its gradient treatment via --gradient, just in
   the new palette. */

@import url('https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@400;600;700&family=Open+Sans:wght@400;600&display=swap');

:root {
  --bg: #F6F1E7;
  --surface: #EFE8D8;
  --surface-raised: #D9E2D8;
  --border: #C7D6CB;
  --text: #2B2A26;
  --text-muted: #6E6A5E;
  --text-faint: #A69C87;
  --primary: #1E6B62;
  --primary-light: #3D8F82;
  --accent: #D97A3E;
  --amber: var(--accent);
  --coral: var(--accent);
  --gradient: linear-gradient(135deg, var(--primary), var(--primary-light));
  --success: #6FCF97;
  --danger: #E8654F;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font-display: 'Josefin Sans', sans-serif;
  --font-body: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

h1, h2, h3, .display, .title-lg, .title-md { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }

a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.hidden { display: none !important; }

/* ---- Layout shells ---- */
.screen { flex: 1; display: flex; flex-direction: column; padding: 24px 20px 32px; max-width: 480px; margin: 0 auto; width: 100%; }
.screen-center { justify-content: center; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; max-width: 480px; margin: 0 auto; width: 100%; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 18px; }
.brand-mark { width: 28px; height: 28px; border-radius: 50%; background: var(--gradient); display: inline-block; }
.icon-btn { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 8px; border-radius: 50%; }
.icon-btn:hover { background: var(--surface); color: var(--text); }

/* ---- Typography helpers ---- */
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; color: var(--text-muted); font-weight: 600; }
.title-lg { font-size: 34px; line-height: 1.15; margin: 10px 0 8px; }
.title-md { font-size: 24px; line-height: 1.2; margin: 0 0 8px; }
.subtitle { color: var(--text-muted); font-size: 15px; line-height: 1.5; margin: 0 0 24px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 999px; padding: 15px 24px; font-size: 15px; font-weight: 600; cursor: pointer; transition: transform 0.15s ease, opacity 0.15s ease; width: 100%; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--text); }
.btn-primary:hover { opacity: 0.92; }
.btn-secondary { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 12px; }
.btn-ghost:hover { color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--danger); padding: 12px; }
.btn-row { display: flex; gap: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field textarea { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 16px; font-family: inherit; }
.field input:focus, .field textarea:focus { border-color: var(--amber); }
.field textarea { resize: vertical; min-height: 80px; }
.form-error { background: rgba(232, 101, 79, 0.12); color: #A83E2C; border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.form-note { color: var(--text-muted); font-size: 13px; margin-top: 16px; text-align: center; }
.form-note a { color: var(--primary); text-decoration: none; font-weight: 600; }
.banner { display: flex; align-items: center; gap: 10px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.banner strong { color: var(--text); }
.banner-action { margin-left: auto; background: none; border: none; color: var(--amber); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }

/* ---- Cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; margin-bottom: 16px; }

/* ---- Home screen ---- */
.greeting-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.streak-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.streak-stat { background: var(--surface); border-radius: var(--radius-md); padding: 16px 8px; text-align: center; border: 1px solid var(--border); }
.streak-stat .num { font-family: var(--font-display); font-size: 28px; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.streak-stat .lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.phase-pill { display: inline-block; font-size: 12px; color: var(--text-muted); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; margin-bottom: 20px; }
.ritual-btn { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; margin-bottom: 12px; cursor: pointer; text-align: left; width: 100%; color: var(--text); }
.ritual-btn:hover { border-color: var(--amber); }
.ritual-btn.done { opacity: 0.55; }
.ritual-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--gradient); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.ritual-copy .t { font-weight: 600; font-size: 15px; }
.ritual-copy .s { font-size: 13px; color: var(--text-muted); }
.ritual-check { margin-left: auto; color: var(--success); font-size: 18px; }

/* ---- Breathing circle (signature element) ---- */
.breathing-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; }
.breathing-circle { width: 180px; height: 180px; border-radius: 50%; background: var(--gradient); opacity: 0.85; transition: transform 4s ease-in-out; box-shadow: 0 0 60px rgba(30, 107, 98, 0.25); }
.breathing-circle.inhale { transform: scale(1.35); }
.breathing-circle.hold { transform: scale(1.35); }
.breathing-circle.exhale { transform: scale(0.75); }
.breathing-circle.pause { transform: scale(0.75); }
.breathing-label { margin-top: 28px; font-family: var(--font-display); font-size: 22px; }
.breathing-sub { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

/* ---- Routine flow chrome ---- */
.routine-flow { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: flex; flex-direction: column; }
.routine-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; }
.routine-progress { flex: 1; display: flex; gap: 6px; margin: 0 16px; }
.routine-progress .seg { flex: 1; height: 3px; border-radius: 2px; background: var(--border); }
.routine-progress .seg.active { background: var(--accent); }
.routine-progress .seg.done { background: var(--amber); opacity: 0.5; }
.routine-body { flex: 1; display: flex; flex-direction: column; padding: 0 24px 24px; max-width: 480px; margin: 0 auto; width: 100%; }
.routine-timer { font-family: var(--font-display); font-size: 20px; color: var(--text-muted); text-align: center; margin-bottom: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--text-muted); }
.chip.selected { background: var(--accent); color: var(--text); border-color: transparent; font-weight: 600; }
.gratitude-inputs .field input { margin-bottom: 8px; }

/* ---- Celebration / badge ---- */
.celebration { display: flex; flex-direction: column; align-items: center; text-align: center; flex: 1; justify-content: center; }
.celebration .badge-img { width: 140px; height: 140px; border-radius: 50%; margin-bottom: 20px; box-shadow: var(--shadow); }
.celebration .badge-fallback { width: 140px; height: 140px; border-radius: 50%; background: var(--gradient); margin-bottom: 20px; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 40px; color: #150c04; }

/* ---- History / list ---- */
.entry-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.entry-date { width: 56px; flex-shrink: 0; text-align: center; }
.entry-date .d { font-family: var(--font-display); font-size: 20px; }
.entry-date .m { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.entry-dots { display: flex; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dot.on { background: var(--gradient); }
.entry-text { font-size: 13px; color: var(--text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lock-card { text-align: center; padding: 32px 20px; }
.lock-card .lock-icon { font-size: 32px; margin-bottom: 12px; }

/* ---- Settings ---- */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); }
.settings-row .l { font-size: 15px; }
.settings-row .s { font-size: 13px; color: var(--text-muted); }
.toggle { width: 44px; height: 26px; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; border: none; flex-shrink: 0; }
.toggle.on { background: var(--accent); }
.toggle .knob { width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); position: absolute; top: 3px; left: 3px; transition: transform 0.2s ease; }
.toggle.on .knob { transform: translateX(18px); }

/* ---- Nav ---- */
.tabbar { display: flex; border-top: 1px solid var(--border); background: var(--bg); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: none; border: none; color: var(--text-faint); font-size: 10px; cursor: pointer; }
.tab.active { color: var(--amber); }
.tab .ic { font-size: 20px; }

/* ---- Bottom sheet / modal ---- */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 60; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); border-radius: 24px 24px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); width: 100%; max-width: 480px; margin: 0 auto; max-height: 85vh; overflow-y: auto; }

/* ---- Values chips (onboarding) ---- */
.values-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }

/* ---- Misc ---- */
.center-note { text-align: center; color: var(--text-muted); font-size: 14px; padding: 40px 20px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.15); border-top-color: var(--amber); animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .breathing-circle { transition: none; }
  .spinner { animation: none; }
}

@media (min-width: 500px) {
  .screen { padding-top: 40px; }
}
