/*
 * Saffron Almanac v2 — the full editorial design system for the website.
 * Loaded after style.css + account.css; overrides at equal-or-higher
 * specificity. Shares its tokens with the app's "Saffron Ethereal" system
 * (dasha-app-ui/src/index.css) so web and app read as one product:
 * warm ivory ground, paper cards with hairlines, espresso ink, quiet
 * saffron, grand Cormorant display type, pill controls, charts as dark
 * prints in gold-lined cream mats.
 *
 * Structural contract: no selector the app JS or e2e suite depends on is
 * removed or renamed — this file only restyles. Rollback = remove one <link>.
 */

:root {
  /* Ground & paper (app parity) */
  --bg-primary: #f6f1e8;
  --surface-1: #fdfbf7;
  --surface-2: #f8f3e9;
  --surface-3: #f1eadd;
  --tint-strong: #eddfc4;
  --tint-soft: #f6efdf;
  --hairline: rgba(42, 33, 24, 0.1);
  --hairline-strong: rgba(42, 33, 24, 0.18);
  --gold-hairline: rgba(201, 162, 94, 0.45);

  /* Ink & accents (app parity) */
  --text-primary: #2a2118;
  --text-secondary: #6e6253;
  --accent-bronze: #8a6a36;
  --accent-bronze-strong: #6f5527;
  --accent-bronze-soft: rgba(138, 106, 54, 0.1);
  --ink: #2a2118;
  --ink-soft: #3a2f22;

  /* Signature chart frame */
  --chart-night: #1c1712;
  --chart-gold: #c9a25e;

  /* Geometry & elevation */
  --radius-card: 20px;
  --radius-inner: 14px;
  --shadow-soft:
    0 1px 2px rgba(42, 33, 24, 0.04), 0 8px 24px rgba(42, 33, 24, 0.06);
  --shadow-lift:
    0 2px 6px rgba(42, 33, 24, 0.05), 0 18px 44px rgba(42, 33, 24, 0.1);

  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Manrope", "Inter", -apple-system, sans-serif;
}

/* ================================================================== */
/* 1. GROUND — atmospheric wash without background-attachment:fixed    */
/*    (the old `fixed` wash broke compositing while scrolled)          */
/* ================================================================== */

html {
  background: var(--bg-primary);
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(
      90% 55% at 50% -8%,
      rgba(255, 250, 238, 0.9) 0%,
      rgba(255, 250, 238, 0) 60%
    ),
    radial-gradient(
      70% 45% at 88% 0%,
      rgba(237, 223, 196, 0.5) 0%,
      rgba(237, 223, 196, 0) 55%
    ),
    var(--bg-primary);
}

::selection {
  background: rgba(138, 106, 54, 0.2);
}

/* ================================================================== */
/* 2. TYPE — grand editorial display, quiet captions                   */
/* ================================================================== */

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  font-weight: 600;
}

.workspace-section-title {
  font-size: clamp(2.3rem, 5vw, 3.3rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.workspace-section-title em,
h1 em,
h2 em,
.accent-em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent-bronze);
}

.workspace-section-subtitle,
.section-subtitle {
  color: var(--text-secondary);
  line-height: 1.66;
  max-width: 58ch;
  font-size: 0.95rem;
}

/* Eyebrows: one quiet grammar everywhere */
.section-kicker,
.sidebar-kicker,
.workspace-kicker,
.command-kicker,
.active-profile-eyebrow,
.welcome-reading-kicker,
.workspace-action-kicker,
.busy-kicker {
  font-family: var(--font-body);
  letter-spacing: 0.2em;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-bronze);
}

.mini-heading,
.panel-title {
  font-family: var(--font-body);
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-bronze-strong);
}

.helper-copy,
.muted-copy,
.micro-copy,
.meta-copy,
.field-note {
  color: var(--text-secondary);
}

.reading-copy {
  line-height: 1.7;
  color: var(--ink-soft);
}

/* The sidebar's kicker+heading pairs said everything twice — keep the
   serif heading, retire the duplicate kicker line above it. */
.command-section-head .section-kicker {
  display: none;
}

.command-section-head h3 {
  font-size: 1.35rem;
  font-weight: 600;
}

/* Editorial pull-quote */
.vedic-quote,
.welcome-quote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--gold-hairline);
  border-radius: var(--radius-inner);
  padding: 16px 18px;
}

/* Ornamental divider: hairline — diamond — hairline */
.divider-ornament {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--accent-bronze);
  margin: 26px 0;
}

.divider-ornament::before,
.divider-ornament::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline-strong);
}

/* ================================================================== */
/* 3. WORKSPACE SHELL — topbar, canvas, footer                         */
/* ================================================================== */

.workspace-topbar {
  /* No backdrop-filter anywhere in this theme: full-viewport blurs raster
     brutally on software/headless renderers and low-end devices. */
  background: color-mix(in srgb, var(--surface-1) 96%, transparent);
  border-bottom: 1px solid var(--hairline);
  box-shadow: none;
}

.workspace-profile-pill,
.workspace-status-pill {
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  color: var(--text-primary);
  font-size: 0.78rem;
  box-shadow: none;
}

.workspace-status-pill .status-dot,
.status-dot {
  background: #7d9b60;
  box-shadow: 0 0 0 3px rgba(125, 155, 96, 0.18);
}

.status-dot.yellow {
  background: #c9a25e;
  box-shadow: 0 0 0 3px rgba(201, 162, 94, 0.2);
}

.site-footer {
  border-top: 1px solid var(--hairline);
  color: var(--text-secondary);
  background: transparent;
}

.brand-link {
  color: var(--accent-bronze-strong);
}

/* ================================================================== */
/* 4. COMMAND PANEL (left) — quiet paper column                        */
/* ================================================================== */

.command-panel-frame {
  background: var(--surface-1);
  border-right: 1px solid var(--hairline);
  box-shadow: none;
}

.command-section {
  border: none;
  background: transparent;
}

.command-section-strap,
.command-section-helper {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.6;
}

.profile-context-card,
.command-profile-summary {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: none;
}

/* ================================================================== */
/* 5. READING NAV — glyph tiles, espresso active pill                  */
/* ================================================================== */

.tab-btn {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  box-shadow: none;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease;
}

.tab-btn:hover {
  background: var(--surface-2);
  border-color: var(--hairline-strong);
  transform: none;
}

.tab-btn-icon {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-bronze);
  background: var(--accent-bronze-soft);
  border: 1px solid var(--gold-hairline);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  min-width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.tab-btn-label {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0;
}

.tab-btn small {
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.62rem;
  font-weight: 600;
}

.tab-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  box-shadow:
    inset 0 0 0 1px rgba(201, 162, 94, 0.5),
    var(--shadow-soft);
  color: #f6efdf;
}

.tab-btn.active .tab-btn-label {
  color: #fdfbf7;
}

.tab-btn.active small {
  color: rgba(246, 239, 223, 0.72);
}

.tab-btn.active .tab-btn-icon {
  background: rgba(201, 162, 94, 0.16);
  border-color: rgba(201, 162, 94, 0.6);
  color: #dfc08c;
}

/* ================================================================== */
/* 6. CARDS — paper hierarchy                                          */
/* ================================================================== */

.card,
.tab-panel,
.reading-card,
.metric-card,
.snapshot-box,
.detail-block,
.support-panel,
.compat-person-card,
.welcome-reading-brief,
.profile-list-surface {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.metric-card,
.snapshot-box,
.detail-block {
  border-radius: var(--radius-inner);
  box-shadow: none;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 600;
}

/* One tinted focal surface per view */
.premium-surface,
.section-hero-card,
.accent-card {
  background: linear-gradient(165deg, var(--tint-strong), var(--tint-soft) 70%);
  border: 1px solid var(--gold-hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.section-hero-aside {
  background: color-mix(in srgb, var(--surface-1) 78%, transparent);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-inner);
}

.section-hero-aside h2,
.section-hero-aside h3 {
  font-size: 1.5rem;
  line-height: 1.22;
}

/* Educational footnote — was an emoji callout, now a manicule note */
.learn-more {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--gold-hairline);
  border-radius: var(--radius-inner);
  color: var(--ink-soft);
  line-height: 1.65;
}

/* ================================================================== */
/* 7. CONTROLS — one pill grammar (app parity)                         */
/* ================================================================== */

.btn,
.btn-secondary,
.date-preset,
.quick-q,
.profile-hub-btn,
.workspace-action-btn,
.chat-depth-btn,
.feedback-btn,
.reading-drawer-close,
.command-close,
.desktop-studio-close {
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.btn:hover,
.btn-secondary:hover,
.date-preset:hover,
.quick-q:hover {
  background: var(--surface-3);
  border-color: var(--hairline-strong);
  transform: none;
}

/* Primary action: espresso ink pill, tracked caps (the app's btn-primary) */
.btn-primary,
.primary-btn,
.account-submit {
  border-radius: 999px;
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fdfbf7;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover,
.primary-btn:hover,
.account-submit:hover {
  background: var(--ink-soft);
  border-color: var(--ink-soft);
  transform: none;
}

.btn-primary:disabled,
.primary-btn:disabled {
  background: var(--surface-3);
  border-color: var(--surface-3);
  color: var(--text-secondary);
  box-shadow: none;
}

/* Gold moment — reserved for premium/upgrade CTAs */
.account-premium-btn {
  background: var(--accent-bronze);
  border-color: var(--accent-bronze);
  color: #fdfbf7;
  box-shadow: 0 4px 16px rgba(138, 106, 54, 0.26);
}

.account-premium-btn:hover {
  background: var(--accent-bronze-strong);
  border-color: var(--accent-bronze-strong);
}

.chat-depth-btn.active,
.date-preset.active,
.gochara-theme-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fdfbf7;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--accent-bronze);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Forms — underline fields on paper (app's form-control) */
.form-group input,
.form-group select,
.form-group textarea {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline-strong);
  border-radius: 0;
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: border-color 160ms ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-bottom-color: var(--accent-bronze);
  outline: none;
  box-shadow: none;
}

.form-group label {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Expandables — quiet accordion rows */
.expandable {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-inner);
  background: var(--surface-1);
}

.expandable-header {
  background: transparent;
}

.expandable-header:hover {
  background: var(--surface-2);
}

.expandable-header .arrow {
  color: var(--accent-bronze);
}

.expandable-meta {
  color: var(--text-secondary);
}

/* ================================================================== */
/* 8. DATA — chips, badges, tables, meters                             */
/* ================================================================== */

.info-badge,
.info-badge-inline,
.chip-row > *,
.chat-context-pill,
.gochara-theme-pill {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.badge-warning {
  background: rgba(201, 162, 94, 0.14);
  border: 1px solid rgba(201, 162, 94, 0.5);
  color: #7a5a22;
}

.badge-danger {
  background: rgba(178, 58, 58, 0.08);
  border: 1px solid rgba(178, 58, 58, 0.3);
  color: #a03434;
}

.tone-green {
  color: #5c7d44;
}
.tone-red {
  color: #a03434;
}

.table-wrap {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.data-table th {
  font-family: var(--font-body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent-bronze-strong);
  border-bottom: 1px solid var(--hairline-strong);
  background: transparent;
}

.data-table td {
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-soft);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--surface-2);
}

.fav-bar {
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.fav-bar .fill {
  background: linear-gradient(90deg, var(--accent-bronze), var(--chart-gold));
  border-radius: 999px;
}

.retro-mark {
  color: var(--accent-bronze);
  font-weight: 700;
}

/* ================================================================== */
/* 9. SIGNATURE — charts as dark prints in gold-lined cream mats       */
/* ================================================================== */

#natal-chart-north,
#natal-chart-south,
#natal-chart-navamsa,
.chart-box {
  background: var(--surface-1);
  border: 1px solid var(--gold-hairline);
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow:
    inset 0 0 0 1px rgba(201, 162, 94, 0.14),
    var(--shadow-soft);
}

#natal-chart-north h4,
#natal-chart-south h4,
#natal-chart-navamsa h4,
.chart-box h4 {
  color: var(--accent-bronze);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.66rem;
  font-weight: 700;
  text-align: center;
  margin: 2px 0 12px;
  font-family: var(--font-body);
}

#natal-chart-north svg,
#natal-chart-south svg,
#natal-chart-navamsa svg,
.chart-box svg {
  border-radius: 10px;
  display: block;
  width: 100%;
  height: auto;
  box-shadow: 0 10px 26px rgba(28, 23, 18, 0.22);
}

.chart-placeholder {
  color: var(--text-secondary);
  text-align: center;
  padding: 28px 12px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
}

/* ================================================================== */
/* 10. CHAT — guided-reading room                                      */
/* ================================================================== */

.chat-avatar {
  font-family: var(--font-display);
  background: var(--accent-bronze-soft);
  border: 1px solid var(--gold-hairline);
  color: var(--accent-bronze);
  border-radius: 999px;
}

.chat-header-name {
  font-family: var(--font-display);
  font-weight: 600;
}

.chat-header-status,
.chat-header-context {
  color: var(--text-secondary);
}

.chat-bubble .bubble-body {
  border-radius: 18px;
  line-height: 1.66;
}

.chat-bubble.assistant .bubble-body {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--gold-hairline);
  box-shadow: var(--shadow-soft);
}

.chat-bubble.user .bubble-body {
  background: var(--ink);
  color: #f6efdf;
  border: 1px solid var(--ink);
}

.bubble-label {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent-bronze);
}

.bubble-time {
  color: var(--text-secondary);
}

.chat-context-banner {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-inner);
}

.typing-indicator span {
  background: var(--accent-bronze);
}

#chat-input,
.chat-input {
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  color: var(--text-primary);
}

#chat-input:focus,
.chat-input:focus {
  border-color: var(--accent-bronze);
  box-shadow: 0 0 0 3px var(--accent-bronze-soft);
}

/* Markdown inside answers */
.inline-code,
.code-block {
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--ink-soft);
}

.md-quote {
  border-left: 2px solid var(--gold-hairline);
  color: var(--text-secondary);
  font-style: italic;
}

/* ================================================================== */
/* 11. MODALS & OVERLAYS — consent, account, drawers, busy veil        */
/* ================================================================== */

.consent-backdrop,
.command-panel-backdrop,
.reading-drawer-backdrop,
.desktop-studio-backdrop {
  background: rgba(42, 33, 24, 0.45);
}

.consent-panel,
.account-panel-shell,
.reading-drawer-panel,
.busy-panel {
  background: var(--surface-1);
  border: 1px solid var(--gold-hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lift);
}

.consent-panel h2,
.account-panel-shell h2 {
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  line-height: 1.1;
}

/* Ornament rule under modal titles */
.consent-panel h2::after,
.account-panel-shell h2::after {
  content: "";
  display: block;
  width: 44px;
  height: 2px;
  margin-top: 12px;
  background: linear-gradient(90deg, var(--chart-gold), rgba(201, 162, 94, 0));
}

.consent-check {
  background: var(--surface-2);
  border: 1px solid var(--gold-hairline);
  border-radius: var(--radius-inner);
}

.sheet-handle {
  background: var(--hairline-strong);
  border-radius: 999px;
}

.busy-overlay {
  background: rgba(246, 241, 232, 0.92);
}

.busy-message {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.busy-spinner,
.spinner {
  border-color: var(--surface-3);
  border-top-color: var(--accent-bronze);
}

/* Account modal internals (overrides account.css) */
.account-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline-strong);
  border-radius: 0;
}

.account-input:focus {
  border-bottom-color: var(--accent-bronze);
  outline: none;
  box-shadow: none;
}

.account-field-label {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.account-entry-btn {
  border: 1px solid var(--gold-hairline);
  background: var(--surface-1);
  color: var(--accent-bronze-strong);
  border-radius: 999px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.account-premium {
  background: linear-gradient(165deg, var(--tint-strong), var(--tint-soft) 70%);
  border: 1px solid var(--gold-hairline);
  border-radius: var(--radius-card);
}

.account-premium h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
}

/* ================================================================== */
/* 12. WELCOME (pre-chart) — editorial landing                         */
/* ================================================================== */

.welcome-hero .section-kicker {
  display: block;
}

.welcome-hero h2,
.welcome-hero h1 {
  font-size: clamp(2.2rem, 5vw, 3rem);
  line-height: 1.05;
}

.welcome-step {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-inner);
}

.welcome-reading-item {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-inner);
  background: var(--surface-1);
}

.welcome-reading-item:hover {
  border-color: var(--gold-hairline);
  background: var(--surface-2);
}

/* ================================================================== */
/* 13. TOASTS & MISC                                                   */
/* ================================================================== */

.toast {
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lift);
}

.toast.error {
  border-color: rgba(178, 58, 58, 0.4);
  color: #a03434;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(138, 106, 54, 0.24);
  border-radius: 999px;
  border: 2px solid var(--bg-primary);
}

/* ================================================================== */
/* 14. MOTION DISCIPLINE                                               */
/* ================================================================== */

.fade-in-up {
  animation-duration: 320ms;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
