/* ============================================================
   Begin in Belief — v1 styles
   Tokens per CLAUDE.md Design Foundations (approved 2026-07-14).
   Light mode only; custom properties keep dark mode cheap in v2.
   ============================================================ */

/* ---------- self-hosted fonts (no third-party requests) ----------
   Variable woff2, latin subset. Fallbacks are metric-matched to the web
   fonts (size-adjust/overrides computed from the actual font tables) so
   font-display: swap causes no layout shift when the real face lands. */

@font-face {
  font-family: 'Libre Baskerville';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/libre-baskerville-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Baskerville';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/libre-baskerville-var-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('fonts/inter-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Baskerville Fallback';
  src: local('Georgia');
  size-adjust: 115.9437%;
  ascent-override: 83.6613%;
  descent-override: 23.2872%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  size-adjust: 107.151%;
  ascent-override: 90.4098%;
  descent-override: 22.5113%;
  line-gap-override: 0%;
}

:root {
  /* palette */
  --bg-1: #f4e9e1;            /* warm sand */
  --bg-2: #e8d5e4;            /* soft lilac */
  --bg-3: #d6e2ea;            /* pale blue */
  --ink: #33272a;             /* primary text */
  --ink-soft: #5a4c51;        /* secondary text — ≥4.5:1 on all page regions */
  --card: rgba(255, 255, 255, 0.55);
  --card-solid: rgba(255, 255, 255, 0.82); /* fallback when backdrop-filter unsupported */
  --card-border: rgba(255, 255, 255, 0.7);
  --accent-text: #833f68;     /* plum — the only accent used for text/UI; nearest
                                 4.5:1-compliant shade to the requested #85416a */
  --accent-decor: #b5838d;    /* dusty rose — decorative only, never text */
  --accent-2: #e5989b;        /* lighter rose — decorative numerals */
  --chip-border: #8a7078;     /* ≥3:1 boundary on card + chip fills */
  --on-ink: #fdf6f2;          /* light text on --ink surfaces */
  --shadow: 0 20px 60px -20px rgba(80, 50, 60, 0.35);
  --shadow-btn: 0 12px 30px -12px rgba(50, 30, 40, 0.6);

  /* type */
  --font-serif: 'Libre Baskerville', 'Libre Baskerville Fallback', Georgia, serif;
  --font-ui: 'Inter', 'Inter Fallback', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* rhythm */
  --radius-card: 26px;
  --radius-pill: 100px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
  position: relative;
}

/* ---------- ambient background ----------
   Gentle drift for a peaceful ambient sensation (approved spec): transform/
   opacity only (GPU-composited), 48–64s alternating cycles with a few vw of
   travel — imperceptible as "motion", never a pulse. The `from` keyframe is
   the at-rest state, so the page looks complete if animations never run
   (sandboxed previews), and the global reduced-motion block below disables
   the drift entirely, leaving this static composed gradient. */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.5; }
.orb.a { width: 45vw; height: 45vw; background: #f6c8bd; top: -12vw; left: -10vw; }
.orb.b { width: 38vw; height: 38vw; background: #c9b6e4; bottom: -14vw; right: -8vw; }
.orb.c { width: 30vw; height: 30vw; background: #bfe0d8; top: 40vh; right: 30vw; }

@media (prefers-reduced-motion: no-preference) {
  .orb.a { animation: drift-a 48s ease-in-out infinite alternate; }
  .orb.b { animation: drift-b 56s ease-in-out infinite alternate; }
  .orb.c { animation: drift-c 64s ease-in-out infinite alternate; }
}
@keyframes drift-a {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(9vw, 6vw) scale(1.12); }
}
@keyframes drift-b {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-8vw, -9vw) scale(1.15); }
}
@keyframes drift-c {
  from { transform: translate(0, 0); opacity: 0.5; }
  to   { transform: translate(7vw, -8vw); opacity: 0.3; }
}

/* ---------- layout ---------- */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5rem) 1.5rem 5rem;
  text-align: center;
}

#view { outline: none; }

/* Zero layout shift: nav + footer paint only after the first view render —
   hidden elements can't visibly move when content lands, so no min-height
   reservation is needed on #view (short pages keep the footer close). */
.site-nav, .site-footer { visibility: hidden; }
body.ready .site-nav, body.ready .site-footer { visibility: visible; }

/* ---------- header ---------- */
.site-header .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
/* the site name is a home link: always returns to today */
.eyebrow-link {
  color: var(--accent-text);
  text-decoration: none;
}
.eyebrow-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

.site-header h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 6.5vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 0.6rem;
}
.site-header h1 em { font-style: italic; color: var(--accent-text); }

/* ---------- daily view ---------- */
.view-date {
  color: var(--ink-soft);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.theme-line {
  margin-top: 2rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-text);
}
.theme-line .theme-name { color: var(--ink); }

.cards { margin-top: 1.6rem; display: grid; gap: 1.3rem; }

.card {
  position: relative;
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  --card-pad: clamp(1.8rem, 5vw, 2.6rem);
  padding: var(--card-pad);
  box-shadow: var(--shadow);
  text-align: left;
  opacity: 1;
  transform: translateY(0);
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  overflow: hidden;
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .card {
    background: var(--card);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
  }
}
/* "now reading" indicator while audio speaks this card: the 1px border
   recolors and an inset ring adds a second pixel — reads as a 2px border
   with zero layout shift (box-shadow occupies no layout space) */
.card.is-reading {
  border-color: var(--accent-text);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--accent-text);
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.25s; }
.card:nth-child(3) { animation-delay: 0.4s; }

/* Cards are visible at rest; animation only travels from the hidden
   keyframe (sandboxed previews may never run animations). */
@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-main { position: static; }

/* corner badge (per Figma node 10:139): translucent rose circle, white
   glyph centered, fully inside the card's top-left corner. Decorative +
   aria-hidden, so contrast-exempt like the old ghosts. */
.card .num {
  position: absolute;
  top: 0.625rem;
  left: 0.625rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(229, 152, 155, 0.4); /* --accent-2, translucent */
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600; /* real weight — LB variable spans 400–700 */
  font-size: 1.5rem;
  line-height: 1;
}

.card .affirmation {
  font-family: var(--font-serif);
  font-weight: 450; /* real weight — LB variable spans 400–700 */
  font-size: clamp(1.2rem, 3.4vw, 1.6rem);
  line-height: 1.5;
  color: var(--ink);
  text-align: center;
  padding: 0 1.75rem; /* symmetric; corner badge clears the text block */
}

/* ---------- quote ----------
   Shares the .card glass treatment; overrides below keep it the "guest":
   smaller serif than the affirmations, italic, with a decorative quotes
   glyph where the affirmation cards carry their numeral. */
.quote {
  margin-top: 1.6rem;
  --card-pad: clamp(1.6rem, 4.5vw, 2.2rem);
  padding: var(--card-pad);
}
.quote .num .icon {
  width: 1.15rem;
  height: 1.15rem;
  transform: scaleX(-1); /* opening-quote orientation for the left corner */
}
.quote blockquote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.15rem, 3vw, 1.35rem);
  line-height: 1.55;
  color: var(--ink);
  text-align: center;
  padding: 0 1.75rem; /* symmetric; corner badge clears the text block */
}
.quote figcaption {
  margin-top: 0.8rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  text-align: center;
}
.quote .quote-label {
  font-size: 0.78rem;
  color: var(--ink-soft);
  opacity: 0.85;
}

/* ---------- icons (Phosphor, inlined SVG, currentColor) ---------- */
.icon { width: 1em; height: 1em; flex: none; }
.chip .icon { width: 0.95em; height: 0.95em; }
.streak-line .icon { width: 0.9em; height: 0.9em; vertical-align: -0.08em; color: var(--accent-decor); }

/* ---------- actions ---------- */
.actions { margin-top: 1.4rem; display: flex; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--chip-border);
  background: rgba(255, 255, 255, 0.4);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-family: var(--font-ui);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 32px;
}
.chip:hover { background: #fff; }
.chip[aria-pressed="true"] {
  background: var(--accent-text);
  color: #fff;
  border-color: var(--accent-text);
}

/* ---------- toolbar ---------- */
.toolbar {
  margin-top: 2.6rem;
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.btn {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}
.btn-primary { background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-btn); }
.btn-primary[disabled] { opacity: 0.75; box-shadow: none; cursor: default; }
.btn-ghost { background: rgba(255, 255, 255, 0.5); color: var(--ink); border: 1px solid var(--card-border); }
.btn-ghost:hover { background: #fff; }

/* ---------- nav + footer ---------- */
.site-nav {
  margin-top: 2.2rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  display: flex;
  justify-content: center;
  gap: 0.7rem;
}
.site-nav a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.site-nav a:hover { color: var(--ink); }

.site-footer {
  margin-top: 3rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.7;
}
/* streak slot is reserved even while empty (brief: nothing renders until
   the first completion) so its appearance never shifts the footer */
.streak-line { min-height: 1.4em; }

/* ---------- privacy page ---------- */
.privacy-card {
  margin-top: 2rem;
  animation: none;
}
.privacy-lede {
  font-family: var(--font-serif);
  font-weight: 600; /* real weight — LB variable covers 400–700 */
  font-size: clamp(1.35rem, 3.4vw, 1.65rem);
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 1.2rem;
}
.privacy-card p {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--ink);
}
.privacy-card p + p { margin-top: 1rem; }
.privacy-card p.privacy-promise {
  font-family: var(--font-serif);
  font-style: italic; /* real italic axis — LB italic variable is loaded */
  color: var(--ink-soft);
}

/* muted privacy link under the footer note */
.footer-links { margin-top: 0.6rem; font-size: 0.78rem; }
.footer-links a {
  color: var(--ink-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.footer-links a:hover { color: var(--ink); }

.noscript-note {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- saved view ---------- */
.view-heading {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.5rem;
  margin-top: 0.5rem;
}
.saved-list {
  list-style: none;
  margin-top: 1.6rem;
  display: grid;
  gap: 1.1rem;
}
.card--saved { padding: clamp(1.3rem, 4vw, 1.8rem); animation: none; }
.item-meta {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent-text);
  margin-bottom: 0.6rem;
  text-align: center;
}
.affirmation--saved { font-size: 1.1rem; line-height: 1.55; padding: 0; }
.saved-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.55;
  text-align: center;
}
.saved-author { margin-top: 0.5rem; font-size: 0.85rem; color: var(--ink-soft); text-align: center; }
/* empty saved state: decorative illustration + heading + note */
.empty-art {
  margin: 2.5rem auto 0;
  max-width: 280px;
}
.empty-art svg { display: block; width: 100%; height: auto; }
.empty-heading {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.4rem;
  color: var(--ink);
  margin-top: 1.4rem;
}
.empty-note {
  margin-top: 0.7rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.8;
}

/* ---------- archive view ---------- */
/* serif subheader directly under the site header (per owner reference) */
.view-sub-heading {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.2rem, 3vw, 1.45rem);
  color: var(--ink);
}
.archive-list {
  list-style: none;
  margin-top: 1.6rem;
  text-align: left;
}
.archive-list li + li { border-top: 1px solid rgba(120, 90, 100, 0.16); }
.archive-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.85rem 0.6rem;
  text-decoration: none;
  border-radius: 10px;
}
.archive-link:hover { background: rgba(255, 255, 255, 0.45); }
.archive-date { color: var(--ink); font-size: 0.95rem; }
.archive-theme {
  color: var(--accent-text);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  text-align: right;
}

/* ---------- utility ---------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- error state ---------- */
.error-note {
  margin-top: 3rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ---------- hover motion (only when motion is welcome) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .card { transition: border-color 0.3s ease, box-shadow 0.3s ease; }
  .chip, .btn { transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease, color 0.25s ease; }
  .chip:hover, .btn:hover { transform: translateY(-2px); }
  .chip:hover { box-shadow: 0 8px 20px -8px rgba(120, 80, 90, 0.4); }
}

/* ---------- focus (visible everywhere, WCAG 2.4.7) ---------- */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- reduced motion: nothing moves, everything readable at rest ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
