/* ═══════════════════════════════════════════════════════════════════════
 * Shared header layout + actions.
 * Used on: index (Coach), compass, compass-v2, chronicle, mirror.
 *
 * Contains:
 *  1) Stacked date pill (DAY over MON DD) — consistent across all pages
 *  2) Mobile h1 stacking (LUCIDITY over page name) — consistent layout
 *  3) Notification bell + commitments button + dropdown panel
 *
 * Loaded ALONGSIDE each page's own CSS. Later rules win where there's overlap
 * (CSS specificity is matched, so source order matters — link this AFTER the
 * page's own CSS to make these the canonical header styles).
 * ═══════════════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────────────
 * 1) CANONICAL TOP NAV LOGO — same mark + wordmark scale on every app page
 * ─────────────────────────────────────────────────────────────────────── */
.app-header .logo {
  gap: 12px;
}

.app-header .logo-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}

.app-header .logo h1 {
  font-size: 17px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  column-gap: 12px;
  height: calc(64px + var(--app-safe-top, env(safe-area-inset-top, 0px)));
  padding-right: max(32px, env(safe-area-inset-right, 0px));
  padding-left: max(32px, env(safe-area-inset-left, 0px));
}

.app-header .logo {
  min-width: 0;
  overflow: hidden;
}

.app-header .header-status,
.app-header .header-meta {
  width: max-content;
  min-width: max-content;
  gap: 8px;
  justify-content: flex-end;
}

/* ───────────────────────────────────────────────────────────────────────
 * 2) STACKED DATE PILL — line 1: weekday, line 2: month + day
 * ─────────────────────────────────────────────────────────────────────── */
.date-pill.date-compact,
.status-pill.status-date.date-compact {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 12px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
  border-radius: var(--r-md, 8px);
  background: var(--bg-raised);
  border: 1px solid var(--glass-border);
  flex-shrink: 0;
  min-height: 0;
}

.date-pill.date-plan-trigger,
.status-pill.status-date.date-plan-trigger {
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.date-pill.date-plan-trigger:hover,
.status-pill.status-date.date-plan-trigger:hover,
.date-pill.date-plan-trigger.is-open,
.status-pill.status-date.date-plan-trigger.is-open {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.date-pill.date-compact .date-weekday,
.status-pill.status-date.date-compact .date-weekday {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  color: var(--text-primary);
  text-transform: uppercase;
  white-space: nowrap;
}

.date-pill.date-compact .date-monthday,
.status-pill.status-date.date-compact .date-monthday {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Date plan preview panel ─────────────────────────────────────────── */
.date-plan-panel {
  position: fixed;
  top: calc(var(--app-header-total-height) + 8px);
  right: 16px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100dvh - 100px));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl, 14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  z-index: 210;
  overflow: hidden;
  animation: notifPanelIn 0.18s ease-out;
}
.date-plan-panel[hidden] { display: none; }

.date-plan-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--glass-border);
}

.date-plan-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.date-plan-title {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

.date-plan-close {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm, 5px);
  transition: all 0.15s ease;
}
.date-plan-close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.date-plan-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.date-plan-section {
  padding: 10px 12px;
  border-radius: var(--r-md, 8px);
}
.date-plan-section + .date-plan-section {
  margin-top: 2px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.date-plan-section h3 {
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.date-plan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.date-plan-list li {
  position: relative;
  padding-left: 14px;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.45;
}

.date-plan-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.66em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-morning);
  opacity: 0.8;
}

.date-plan-list.is-prose li {
  padding-left: 0;
  color: var(--text-primary);
  font-size: 13.5px;
}
.date-plan-list.is-prose li::before { display: none; }

.date-plan-muted,
.date-plan-empty {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.date-plan-empty {
  padding: 24px 16px 12px;
  text-align: center;
}

.date-plan-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 16px);
  min-height: 34px;
  margin: 8px;
  padding: 7px 12px;
  border-radius: var(--r-md, 8px);
  border: 1px solid rgba(139, 231, 255, 0.34);
  background: var(--accent-morning-dim);
  color: var(--accent-morning);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.date-plan-cta:hover {
  background: rgba(139, 231, 255, 0.2);
  border-color: rgba(139, 231, 255, 0.48);
}
.date-plan-cta.is-subtle {
  margin-top: 4px;
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--glass-border);
}

/* ───────────────────────────────────────────────────────────────────────
 * 3) MOBILE H1 STACKING — "LUCIDITY" over the page name (COACH/COMPASS/…)
 *    Lets the right cluster (bell + commitments + avatar + date pill) breathe.
 *    Breakpoint matches the existing mobile threshold across all pages.
 * ─────────────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .app-header {
    padding-right: max(18px, env(safe-area-inset-right, 0px));
    padding-left: max(18px, env(safe-area-inset-left, 0px));
  }
}

@media (max-width: 768px) {
  .app-header .date-pill.date-compact,
  .app-header .status-pill.status-date.date-compact {
    flex: 0 1 auto;
    min-width: 0;
  }

  .app-header .logo h1 {
    display: flex !important;
    flex-direction: column;
    gap: 2px;
    line-height: 1;
    font-size: 15px;
    letter-spacing: 0.16em;
    /* override any nowrap/overflow from page CSS — items are already on their own rows */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .app-header .logo h1 span {
    display: block;
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 400;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
  }

  .app-header .header-status,
  .app-header .header-meta {
    gap: 8px;
  }
}

@media (max-width: 600px) {
  .app-header .logo h1,
  .app-header .logo h1 span {
    font-size: 14px;
  }
  .date-pill.date-compact,
  .status-pill.status-date.date-compact {
    padding: 3px 9px;
  }
  .date-pill.date-compact .date-weekday,
  .status-pill.status-date.date-compact .date-weekday {
    font-size: 10px;
  }
  .date-pill.date-compact .date-monthday,
  .status-pill.status-date.date-compact .date-monthday {
    font-size: 9.5px;
  }
}

@media (max-width: 380px) {
  .app-header .logo h1,
  .app-header .logo h1 span {
    font-size: 12.5px;
    letter-spacing: 0.14em;
  }
  .date-pill.date-compact,
  .status-pill.status-date.date-compact {
    padding: 3px 7px;
  }
  .date-pill.date-compact .date-weekday,
  .status-pill.status-date.date-compact .date-weekday {
    font-size: 9.5px;
  }
  .date-pill.date-compact .date-monthday,
  .status-pill.status-date.date-compact .date-monthday {
    font-size: 9px;
  }
}

/* ───────────────────────────────────────────────────────────────────────
 * 4) NOTIFICATION BELL + COMMITMENTS BUTTON + PANEL
 * ─────────────────────────────────────────────────────────────────────── */

/* ── Notification bell ────────────────────────────────────────────────── */
.notif-bell {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md, 8px);
  border: 1px solid var(--glass-border);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.notif-bell:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.notif-bell.has-notifications {
  color: var(--text-secondary);
}

.notif-bell.is-open {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

/* Lilac badge — matches the new calmer style from index.css */
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent-evening);
  color: var(--bg-deep);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  letter-spacing: 0.2px;
  box-shadow: 0 0 0 2px var(--bg-deep), 0 0 8px var(--accent-evening-glow);
  pointer-events: none;
}
.notif-badge[hidden] { display: none; }

/* ── Commitments button ───────────────────────────────────────────────── */
.commitments-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md, 8px);
  border: 1px solid var(--glass-border);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  text-decoration: none;
  flex-shrink: 0;
}

.commitments-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.commitments-btn.is-open {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ── Actionables panel (dropdown under commitments button) ───────────── */
.actionables-panel {
  position: fixed;
  top: calc(var(--app-header-total-height) + 8px);
  right: 16px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100dvh - 100px));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl, 14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  z-index: 210;
  overflow: hidden;
  animation: notifPanelIn 0.18s ease-out;
}
.actionables-panel[hidden] { display: none; }

.actionables-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--glass-border);
}

.actionables-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.actionables-title {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

.actionables-close {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm, 5px);
  transition: all 0.15s ease;
}
.actionables-close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.actionables-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.actionables-section {
  padding: 8px 6px 10px;
}
.actionables-section + .actionables-section {
  border-top: 1px solid rgba(255,255,255,0.06);
}

.actionables-section h3 {
  margin: 2px 6px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.actionables-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.actionable-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px 8px;
  border-radius: var(--r-md, 8px);
  transition: background 0.15s ease, opacity 0.15s ease;
}
.actionable-item:hover { background: rgba(255,255,255,0.03); }
.actionable-item.is-completing { opacity: 0.7; }

.actionable-check {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1px solid rgba(139, 231, 255, 0.42);
  background: rgba(139, 231, 255, 0.08);
  color: var(--accent-morning);
  font-size: 13px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.actionable-check:hover:not(:disabled) {
  background: rgba(139, 231, 255, 0.18);
  border-color: rgba(139, 231, 255, 0.7);
}
.actionable-check:active:not(:disabled) { transform: scale(0.94); }
.actionable-check:disabled { cursor: default; }

.actionable-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.actionable-title {
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
}

.actionable-body {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.actionable-meta {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.12px;
}

.actionable-item.is-done .actionable-title,
.actionable-item.is-done .actionable-body {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(217, 215, 230, 0.55);
}
.actionable-item.is-done .actionable-check {
  background: var(--accent-morning-dim);
  border-color: rgba(139, 231, 255, 0.65);
}

.actionables-empty,
.actionables-muted {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.actionables-empty {
  padding: 28px 16px;
  text-align: center;
}

/* ── Notification panel (dropdown under bell) ─────────────────────────── */
.notif-panel {
  position: fixed;
  top: calc(var(--app-header-total-height) + 8px);
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: min(480px, calc(100dvh - 100px));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl, 14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  z-index: 200;
  overflow: hidden;
  animation: notifPanelIn 0.18s ease-out;
}
.notif-panel[hidden] { display: none; }

@keyframes notifPanelIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--glass-border);
}

.notif-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

.notif-panel-close {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--r-sm, 5px);
  transition: all 0.15s ease;
}
.notif-panel-close:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.notif-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.notif-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.notif-item {
  padding: 10px 12px;
  border-radius: var(--r-md, 8px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background 0.15s ease;
}
.notif-item + .notif-item { margin-top: 2px; }
.notif-item:hover { background: rgba(255,255,255,0.03); }

.notif-item-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}

.notif-item-body {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.notif-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.notif-item-when {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.15px;
  flex-shrink: 0;
}
.notif-item-when.is-overdue { color: #fb7185; }

.notif-item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.notif-action {
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: var(--r-sm, 5px);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.notif-action:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.18);
}
.notif-action.is-primary {
  border-color: rgba(139, 231, 255, 0.3);
  color: var(--accent-morning);
  background: var(--accent-morning-dim);
}
.notif-action.is-primary:hover {
  background: rgba(139, 231, 255, 0.22);
  box-shadow: 0 0 12px var(--accent-morning-glow);
}

/* ── Mobile responsive: smaller bell + button ────────────────────────── */
@media (max-width: 480px) {
  .notif-bell, .commitments-btn { width: 30px; height: 30px; }
  .notif-panel,
  .date-plan-panel,
  .actionables-panel {
    right: 12px;
    width: min(360px, calc(100vw - 24px));
  }
}

@media (max-width: 360px) {
  .notif-bell, .commitments-btn { width: 28px; height: 28px; }
  .notif-bell svg, .commitments-btn svg { width: 16px; height: 16px; }
}
