/* ═══════════════════════════════════════════════════════════════
   XHALE — Design System v2
   Locked palette: warm sandy + Deep Sage + Soft Teal
   Sand grain texture · Bloom mood icons · Botanical pillars
   Light + Dark mode via [data-theme] on <body>
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. FONTS ─────────────────────────────────────────────────
   Cormorant Garamond → large greetings + affirmation quotes
   Quicksand          → headings, labels, buttons
   Nunito             → body text, forms
   (Load in each page's <head>:
   https://fonts.googleapis.com/css2?family=Quicksand:wght@500;600;700&family=Nunito:wght@400;600;700&family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&display=swap)
*/

/* ── 2. DESIGN TOKENS ───────────────────────────────────────── */
:root {
  /* Core palette — light mode */
  --bg:            #F5E9D6;   /* warm sandy */
  --surface:       #FFFFFF;   /* cards */
  --surface-soft:  #FAF4EA;   /* subtle panels */
  --border:        #E0D3BC;   /* warm card border */

  --sage:          #6F8F7A;   /* primary */
  --sage-deep:     #4A7062;   /* pressed / emphasis */
  --sage-tint:     #EAF4EE;   /* selected pill bg */
  --teal:          #79B8AE;   /* secondary */
  --teal-deep:     #5B9E94;   /* soul accent */
  --peach:         #C4825A;   /* money accent */
  --peach-soft:    #F4A77B;   /* highlights */

  --text:          #26302B;   /* deep charcoal */
  --text-soft:     #96A08D;   /* muted */
  --text-faint:    #AAB5A5;   /* disabled / unselected */

  --on-sage:       #FAF4EA;   /* text on sage buttons/nav */

  /* Shape + motion */
  --radius-card:   18px;
  --radius-btn:    12px;
  --radius-pill:   14px;
  --shadow-card:   0 1px 3px rgba(38, 48, 43, 0.06);
  --transition:    0.2s ease;
}

/* Dark mode — warm dark, not cold black */
[data-theme="dark"] {
  --bg:            #1C1814;
  --surface:       #262019;
  --surface-soft:  #2E271F;
  --border:        #3A322A;

  --sage:          #8FAF9A;
  --sage-deep:     #A8C4B2;
  --sage-tint:     #2A332E;
  --teal:          #8FC4BB;
  --teal-deep:     #79B0A6;
  --peach:         #D89A72;
  --peach-soft:    #E8B48E;

  --text:          #EDE6DA;
  --text-soft:     #A89F92;
  --text-faint:    #7A7268;

  --on-sage:       #1C1814;

  --shadow-card:   0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ── 3. BASE ────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  margin: 0;
  min-height: 100vh;
  position: relative;
  transition: background-color var(--transition), color var(--transition);
}

/* Sand grain — SVG feTurbulence noise as a fixed overlay.
   WHY a data URI: no extra HTTP request, no extra markup in pages,
   and it sits behind all content via z-index. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.42 0 0 0 0 0.53 0 0 0 0 0.45 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

[data-theme="dark"] body::before { opacity: 0.35; }

/* All page content must sit above the grain layer */
main, nav, .bottom-nav { position: relative; z-index: 1; }

h1, h2, h3 {
  font-family: 'Quicksand', sans-serif;
  color: var(--sage);
}

/* ── 4. NAV ─────────────────────────────────────────────────── */
#navBar {
  background-color: var(--sage);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;   /* anchor for the centered logo */
}

/* WHY absolute centering: with different-width items on each side,
   flexbox alone can't keep the logo dead-center. Absolute positioning
   centers it against the nav itself, on every screen size. */
.nav-logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Quicksand', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--on-sage);
  letter-spacing: 0.04em;
  text-decoration: none;   /* logo is a link home — no underline */
}

.nav-logo:hover { opacity: 0.85; }

/* Log Out pushes itself (and the moon after it) to the right edge */
#logoutBtn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--on-sage);
  font-weight: 700;
  font-family: 'Quicksand', sans-serif;
  font-size: 0.9rem;
  padding: 6px 10px;
}

#logoutBtn:hover { background: rgba(255, 255, 255, 0.18); border-radius: 8px; }

#menuButton {
  background-color: transparent;
  color: var(--on-sage);
  border: none;
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  cursor: pointer;
}

#dropdownMenu {
  background-color: var(--sage);
  padding: 10px 0;
}

#dropdownMenu a {
  display: block;
  color: var(--on-sage);
  text-decoration: none;
  padding: 10px 20px;
  font-family: 'Nunito', sans-serif;
  transition: background-color var(--transition);
}

#dropdownMenu a:hover { background-color: var(--teal); }

/* Theme toggle button (lives in nav) */
#themeToggle {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--on-sage);
  transition: background var(--transition);
}

#themeToggle:hover { background: rgba(255, 255, 255, 0.3); }

/* ── 5. LAYOUT ──────────────────────────────────────────────── */
main {
  max-width: 700px;
  margin: 0 auto;
  padding: 28px 18px 90px;
}

/* Hero greeting block */
.hero-greeting {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.2rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.15;
  margin: 0 0 4px;
}

.hero-greeting em {
  font-style: italic;
  color: var(--sage);
}

.hero-sub {
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 0 0 4px;
}

.page-subtitle {
  font-family: 'Nunito', sans-serif;
  color: var(--text-soft);
  margin: 4px 0 24px;
  font-size: 0.9rem;
}

/* Section labels between cards */
.section-label {
  font-family: 'Nunito', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-soft);
  margin: 20px 0 8px 4px;
}

/* Streak / status badges */
.badge-row { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sage-deep);
  font-family: 'Nunito', sans-serif;
}

.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); }
.badge-dot.teal { background: var(--teal); }

/* ── 6. CARDS ───────────────────────────────────────────────── */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 14px;
  transition: background-color var(--transition), border-color var(--transition);
}

.card h2 {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sage);
  margin: 0 0 14px;
}

/* Legacy: pageCard + greetingCard kept as aliases */
.pageCard, #greetingCard {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  margin: 30px auto;
  max-width: 600px;
  padding: 28px 32px;
}

#greetingCard h1 {
  color: var(--sage);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 10px;
  text-align: center;
}

#greetingCard p {
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.6;
  text-align: center;
}

#welcomeGreeting { text-align: center; font-size: 28px; margin: 0 0 10px; }

#dailyQuote {
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--teal);
  font-size: 17px;
  margin: 0;
}

/* ── 7. MOOD SELECTOR (Bloom Stages) ────────────────────────── */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mood-pill {
  border-radius: var(--radius-pill);
  padding: 12px 4px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  transition: all var(--transition);
}

.mood-pill:hover { border-color: var(--sage); transform: translateY(-1px); }

/* WHY per-bloom color instead of one gray tone: a flower has color
   whether or not it's picked. Each stage gets its own accent so the
   row reads as a gradient of feeling, not four identical gray boxes
   with one exception. Colors mirror the SVG fills already used inside
   each icon (peach/rose for bloom, sage for stem, teal-gray for wilt). */
.mood-pill[data-mood*="Great"] { color: #C97A4A; }   /* warm terracotta bloom */
.mood-pill[data-mood*="Good"]  { color: #6F8F7A; }   /* sage — half open */
.mood-pill[data-mood*="Okay"]  { color: #8FA0A8; }   /* dusty blue-gray bud */
.mood-pill[data-mood*="Low"]   { color: #9B8FA8; }   /* muted mauve wilt */

.mood-pill[data-mood*="Great"]:hover { border-color: #C97A4A; }
.mood-pill[data-mood*="Good"]:hover  { border-color: #6F8F7A; }
.mood-pill[data-mood*="Okay"]:hover  { border-color: #8FA0A8; }
.mood-pill[data-mood*="Low"]:hover   { border-color: #9B8FA8; }

.mood-pill.selected {
  background: var(--sage-tint);
  border-width: 2px;
  font-weight: 700;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(38, 48, 43, 0.08);
}

.mood-pill[data-mood*="Great"].selected { border-color: #C97A4A; background: #FBEEE5; }
.mood-pill[data-mood*="Good"].selected  { border-color: #6F8F7A; background: var(--sage-tint); }
.mood-pill[data-mood*="Okay"].selected  { border-color: #8FA0A8; background: #EAEFF1; }
.mood-pill[data-mood*="Low"].selected   { border-color: #9B8FA8; background: #F1ECF4; }

/* Bloom SVGs inherit currentColor from the pill's own text color above */
.mood-pill svg { opacity: 0.75; }
.mood-pill.selected svg { opacity: 1; }

/* ── 8. PILLAR TILES ────────────────────────────────────────── */
.pillar-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.pillar-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  transition: transform var(--transition), border-color var(--transition);
}

.pillar-tile:hover { transform: translateY(-2px); border-color: var(--sage); }

.pillar-tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 14px; }

.pillar-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pillar-icon.mind   { background: var(--sage); }
.pillar-icon.health { background: var(--teal); }
.pillar-icon.soul   { background: var(--teal-deep); }
.pillar-icon.money  { background: var(--peach); }

.pillar-name {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.pillar-status {
  font-family: 'Nunito', sans-serif;
  font-size: 0.7rem;
  color: var(--text-soft);
  margin: 2px 0 0;
}

/* ── 9. AFFIRMATION ─────────────────────────────────────────── */
.affirmation {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.55rem;
  font-weight: 600;         /* was 400 — thin italic serif at small sizes
                                is hard to read, especially with glasses */
  font-style: italic;
  color: var(--text);        /* full-strength charcoal, not a soft/tinted color */
  line-height: 1.55;
  border-left: 3px solid var(--teal);
  padding-left: 16px;
  margin: 0 0 14px;
}

/* The dashboard's daily quote gets a touch more room since it's the
   first thing read on page load — legibility matters most there. */
#dailyQuote.affirmation {
  font-size: 1.4rem;
}

@media (min-width: 900px) {
  .affirmation { font-size: 1.7rem; }
  #dailyQuote.affirmation { font-size: 1.55rem; }
}

/* ── 10. FORMS ──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; margin-bottom: 14px; }

.form-group label {
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.form-group input,
.form-group select,
.form-group textarea,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="time"], input[type="date"],
textarea, select {
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: var(--bg);
  color: var(--text);
  outline: none;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus,
input:focus, textarea:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--teal) 35%, transparent);
}

/* ── 11. BUTTONS ────────────────────────────────────────────── */
button {
  font-family: 'Quicksand', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-btn);
  background-color: var(--sage);
  color: var(--on-sage);
  cursor: pointer;
  transition: background-color var(--transition), transform var(--transition);
}

button:hover { background-color: var(--sage-deep); }
button:active { transform: scale(0.98); }

.btn-primary {
  background-color: var(--sage);
  color: var(--on-sage);
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius-btn);
  padding: 12px 24px;
  cursor: pointer;
  margin-top: 6px;
}

.btn-primary:hover { background-color: var(--sage-deep); }

.btn-secondary {
  background-color: transparent;
  color: var(--sage);
  border: 2px solid var(--sage);
  border-radius: var(--radius-btn);
  padding: 10px 20px;
  margin-top: 6px;
  margin-left: 8px;
}

.btn-secondary:hover { background-color: var(--sage-tint); }

.btn-delete {
  background: transparent;
  color: var(--text-faint);
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: 8px;
}

.btn-delete:hover { background: var(--sage-tint); color: var(--sage-deep); }

/* Ghost refresh button (affirmations) */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-soft);
}

.btn-ghost:hover { background: var(--sage-tint); color: var(--sage-deep); }

/* ── 12. LOG ITEMS (expense-item reused on all pages) ───────── */
.expense-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 8px;
  background-color: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  flex-wrap: wrap;
  gap: 6px;
}

.expense-category { font-weight: 700; color: var(--sage); }
.expense-amount   { font-weight: 700; color: var(--peach-soft); }
.expense-date     { color: var(--teal); font-size: 0.8rem; }
.expense-note     { font-style: italic; color: var(--text-soft); font-size: 0.8rem; }

/* ── 13. GOALS ──────────────────────────────────────────────── */
.goal-item {
  display: inline-block;
  background-color: var(--sage-tint);
  color: var(--sage-deep);
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 7px 15px;
  border-radius: 20px;
  margin: 4px;
  border: 1px solid var(--sage);
}

#goalsList { display: flex; flex-wrap: wrap; }

.empty-message { color: var(--text-faint); font-size: 0.85rem; font-style: italic; }

/* ── 14. WATER TRACKER ──────────────────────────────────────── */
#waterDisplay {
  font-family: 'Quicksand', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 12px;
}

.water-bar { display: flex; gap: 5px; margin: 8px 0 14px; }

.water-seg {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: background var(--transition);
}

.water-seg.filled { background: var(--teal); }

/* Legacy emoji glasses kept working */
#waterGlasses { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.glass { font-size: 1.6rem; transition: transform 0.2s; }
.glass.empty { opacity: 0.25; }

/* ── 15. CTA STRIP ──────────────────────────────────────────── */
.cta-strip {
  background: var(--sage);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.cta-title { font-family: 'Quicksand', sans-serif; font-size: 0.9rem; font-weight: 700; color: var(--on-sage); margin: 0; }
.cta-sub   { font-family: 'Nunito', sans-serif; font-size: 0.72rem; color: color-mix(in srgb, var(--on-sage) 70%, transparent); margin: 3px 0 0; }
.cta-arrow { color: var(--on-sage); font-size: 18px; }

/* ── 16. RESPONSIVE ─────────────────────────────────────────── */

/* Phones */
@media (max-width: 480px) {
  main { padding: 22px 14px 90px; }
  .hero-greeting { font-size: 1.9rem; }
  .mood-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
  .pageCard, #greetingCard { padding: 22px 20px; }
}

/* Desktop — use the width instead of a skinny mobile strip.
   WHY: max-width 700px reads as "mobile site" on a laptop. At 900px+
   we widen the container, let the pillar grid go 4-across, and scale
   the hero type up so the page feels designed for the screen. */
@media (min-width: 900px) {
  main {
    max-width: 1100px;
    padding: 44px 36px 100px;
  }

  .hero-greeting { font-size: 3rem; }
  .hero-sub { font-size: 0.95rem; }

  .badge { font-size: 0.82rem; padding: 7px 14px; }

  .card { padding: 26px 30px; }
  .affirmation { font-size: 1.5rem; }

  /* 4 tiles across, Financial spans the full row beneath */
  .pillar-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .pillar-tile { padding: 20px 18px; gap: 12px; }
  .pillar-icon { width: 48px; height: 48px; border-radius: 14px; }
  .pillar-name { font-size: 0.95rem; }
  .pillar-status { font-size: 0.78rem; }

  .cta-strip { padding: 20px 26px; }
  .cta-title { font-size: 1rem; }
  .cta-sub { font-size: 0.8rem; }

  .section-label { font-size: 0.72rem; margin-top: 26px; }
}

/* Extra-wide screens: cap it so lines don't get uncomfortably long */
@media (min-width: 1500px) {
  main { max-width: 1200px; }
}