/* Your Dreams Guide — calm, curious, credible, slightly atmospheric.
   Palette sampled directly from the hero image (images/hero.png):
   cream background, charcoal-navy headline, dusty periwinkle accent, warm gold rule.
   See plan.md section 45. */

:root {
  --color-bg: #f7f2ec;
  --color-surface: #ffffff;
  --color-surface-tint: #fbf7f1;
  --color-text: #2d2a2d;
  --color-text-muted: #6f6a66;
  --color-border: #e6ddd0;
  --color-accent: #5c76a8;
  --color-accent-soft: #7692bd;
  --color-link: #4a5f8a;
  --color-gold: #ad8148;
  --color-gold-soft: #d3a071;
  --color-evidence-icon: #4f8f68;
  --color-section-accent: var(--color-gold-soft);
  --color-section-contrast: var(--color-accent-soft);

  --note-interpretation-bg: #eef1f7;
  --note-interpretation-border: #c3cee3;
  --note-evidence-bg: #eef4ee;
  --note-evidence-border: #bdd3bd;
  --note-historical-bg: #faf1e3;
  --note-historical-border: #e6cda0;
  --note-source-bg: #f4f1eb;
  --note-source-border: #ddd4c4;

  --font-body: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-display: "Playfair Display", Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --max-width: 42rem;

  --shadow-sm: 0 1px 3px rgba(45, 42, 45, 0.07), 0 1px 2px rgba(45, 42, 45, 0.05);
  --shadow-md: 0 6px 20px rgba(45, 42, 45, 0.09), 0 2px 6px rgba(45, 42, 45, 0.05);
  --shadow-lg: 0 16px 40px rgba(45, 42, 45, 0.14), 0 4px 14px rgba(45, 42, 45, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1c1a1b;
    --color-surface: #242224;
    --color-surface-tint: #29272a;
    --color-text: #f1ece5;
    --color-text-muted: #ada69d;
    --color-border: #3a3638;
    --color-accent: #93aad6;
    --color-accent-soft: #7692bd;
    --color-link: #a9bce3;
    --color-gold: #dcae74;
    --color-gold-soft: #c9975c;
    --color-evidence-icon: #7fb894;

    --note-interpretation-bg: #232735;
    --note-interpretation-border: #3d4568;
    --note-evidence-bg: #1f2a22;
    --note-evidence-border: #37503b;
    --note-historical-bg: #2b2419;
    --note-historical-border: #5c4a2c;
    --note-source-bg: #242224;
    --note-source-border: #3a3638;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
}

/* Section wayfinding: each top-level section carries one of the site's two
   accent hues through into its H1 rule and article lede — a subtle cue for
   which part of the site you're in, without introducing new colors. The TOC
   always takes the *other* hue, so every article keeps a two-tone contrast
   between its lede and its table of contents, whichever section it's in. */
[data-section="recurring"],
[data-section="nightmares"],
[data-section="lucid"],
[data-section="science"] {
  --color-section-accent: var(--color-accent-soft);
  --color-section-contrast: var(--color-gold-soft);
}
[data-section="dreams"],
[data-section="history"],
[data-section="journal"],
[data-section="psychology"] {
  --color-section-accent: var(--color-gold-soft);
  --color-section-contrast: var(--color-accent-soft);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(118, 146, 189, 0.07), transparent),
    var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.65;
  font-size: 1.125rem;
}

::selection { background: var(--color-gold-soft); color: #2d2a2d; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

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

h1 { font-size: 2.5rem; margin: 1.5rem 0 0; }
h1::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  margin-top: 0.85rem;
  background: var(--color-section-accent);
  border-radius: 2px;
}
h2 { font-size: 1.6rem; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.25rem; margin: 1.75rem 0 0.5rem; }

@media (max-width: 30rem) {
  h1 { font-size: 1.95rem; }
}

.prose li::marker,
.related li::marker {
  color: var(--color-gold-soft);
}

p { margin: 0 0 1.1rem; }

a {
  color: var(--color-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}
a:hover { color: var(--color-accent); text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Editorial "lede" treatment for an article's opening paragraph */
.prose > p:first-child {
  font-size: 1.25rem;
  line-height: 1.7;
  padding-left: 1rem;
  border-left: 3px solid var(--color-section-accent);
}

/* Header */
.site-header {
  background: var(--color-bg);
  box-shadow: 0 1px 0 var(--color-border), 0 2px 10px rgba(45, 42, 45, 0.03);
  padding: 1.1rem 0;
  position: relative;
  z-index: 10;
}
.site-header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-family: var(--font-ui);
}
.site-header__name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.35rem;
  text-decoration: none;
  color: var(--color-text);
}
.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
}
.site-nav a { text-decoration: none; color: var(--color-text-muted); position: relative; }
.site-nav a:hover { color: var(--color-link); }

.site-search {
  display: flex;
  align-items: center;
  margin-left: auto;
}
.site-search input {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 999px 0 0 999px;
  background: var(--color-surface);
  color: var(--color-text);
  width: 9rem;
  max-width: 40vw;
}
.site-search input:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }
.site-search button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--color-border);
  border-left: none;
  border-radius: 0 999px 999px 0;
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}
.site-search button:hover { color: var(--color-link); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: 4rem;
  padding: 2rem 0 2.5rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  position: relative;
}
.site-footer::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 3rem;
  height: 2px;
  background: var(--color-gold-soft);
  border-radius: 2px;
}
.site-footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.site-footer a { color: var(--color-text-muted); }
.site-footer a:hover { color: var(--color-link); }
.site-footer ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  padding: 0;
  margin: 0.6rem 0 1.1rem;
}

/* Breadcrumb */
.breadcrumb { font-family: var(--font-ui); font-size: 0.85rem; margin: 1.25rem 0 0; color: var(--color-text-muted); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; padding: 0; margin: 0; }
.breadcrumb li:not(:last-child)::after { content: "/"; margin: 0 0.4rem; color: var(--color-border); }
.breadcrumb a { text-decoration: none; }

/* Notes */
.note {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  border: 1px solid;
  border-radius: 0.6rem;
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}
.note__icon { flex-shrink: 0; margin-top: 0.15rem; }
.note__body { flex: 1; min-width: 0; }
.note__body p { margin: 0; }
.note__body p + p { margin-top: 0.5rem; }
.note--interpretation { background: var(--note-interpretation-bg); border-color: var(--note-interpretation-border); }
.note--interpretation .note__icon { color: var(--color-accent-soft); }
.note--evidence { background: var(--note-evidence-bg); border-color: var(--note-evidence-border); }
.note--evidence .note__icon { color: var(--color-evidence-icon); }
.note--historical { background: var(--note-historical-bg); border-color: var(--note-historical-border); }
.note--historical .note__icon { color: var(--color-gold); }
.note--source { background: var(--note-source-bg); border-color: var(--note-source-border); font-size: 0.85rem; }
.note--source .note__icon { color: var(--color-text-muted); }
.note__meta { font-style: italic; }
.note__label { font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.75rem; margin-bottom: 0.4rem; }

/* Dream facts */
.dream-facts {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.dream-facts h2 {
  margin: 0 0 0.6rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.dream-facts h2 svg { color: var(--color-gold-soft); }
.dream-facts dl { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; margin: 0; }
.dream-facts dt { color: var(--color-text-muted); }
.dream-facts dd { margin: 0; }

/* TOC */
.toc {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  border-left: 3px solid var(--color-section-contrast);
  padding: 0.35rem 0 0.35rem 1rem;
  margin: 1.5rem 0;
}
.toc__label { font-weight: 700; margin: 0 0 0.4rem; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.04em; color: var(--color-text-muted); }
.toc ol { margin: 0; padding-left: 1.1rem; }
.toc a { color: var(--color-text-muted); transition: color 0.15s ease; }
.toc a:hover { color: var(--color-link); }
.toc a.toc__link--active {
  color: var(--color-section-contrast);
  font-weight: 700;
}

/* Related content */
.related { margin: 2.5rem 0; padding-top: 1.5rem; border-top: 1px solid var(--color-border); }
.related h2 { font-size: 1.25rem; }
.related ul { padding-left: 1.1rem; }

/* Accessibility utility: visually hidden but still readable by screen readers / crawlable */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Homepage */
.hero {
  max-width: 75rem;
  margin: 0 auto 2.5rem;
  padding: 1.75rem 1.25rem 0;
  position: relative;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0.75rem 1.25rem 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 55% 60% at 22% 25%, rgba(211, 160, 113, 0.28), transparent 65%),
    radial-gradient(ellipse 50% 55% at 82% 78%, rgba(118, 146, 189, 0.22), transparent 65%);
  filter: blur(36px);
}
.hero__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.85rem;
  border: 1px solid rgba(45, 42, 45, 0.06);
  box-shadow: var(--shadow-lg);
}
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 2.5rem;
}
.section-grid a {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.1rem 1.1rem 1.2rem;
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-gold-soft);
  border-radius: 0.6rem;
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-surface);
  font-family: var(--font-ui);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.section-grid a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent-soft);
}
.section-grid li:nth-child(3n+2) a { border-top-color: var(--color-accent-soft); }
.section-grid svg { color: var(--color-gold); flex-shrink: 0; }
.section-grid li:nth-child(3n+2) svg { color: var(--color-accent-soft); }

/* Category / hub pages */
.category-list { padding-left: 0; list-style: none; }
.category-list li {
  padding: 0.85rem 0;
  border-top: 1px solid var(--color-border);
}
.category-list li:last-child { border-bottom: 1px solid var(--color-border); }
.category-list a { font-family: var(--font-ui); font-weight: 600; text-decoration: none; }
.category-list a:hover { color: var(--color-link); }

/* Dream theme index: grouped instead of one long A-Z list */
.theme-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 2.5rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
}
.theme-jump a {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--color-text-muted);
  background: var(--color-surface);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-jump a:hover {
  color: var(--color-link);
  border-color: var(--color-accent-soft);
}
.theme-group {
  margin: 2.5rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  scroll-margin-top: 1.5rem;
}
.theme-group h2 { margin-top: 0; }
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.4rem 1rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  font-family: var(--font-ui);
}
.theme-grid a { text-decoration: none; color: var(--color-text); }
.theme-grid a:hover { color: var(--color-link); }

/* Search page */
.search-page { padding-bottom: 2rem; }
.search-form { margin: 1.25rem 0; }
.search-form input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 1.05rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
.search-form input:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }
.search-status {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 1rem;
}
.search-results { list-style: none; padding: 0; margin: 0; }
.search-results__item {
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
}
.search-results__item:last-child { border-bottom: 1px solid var(--color-border); }
.search-results__item a {
  font-family: var(--font-ui);
  font-weight: 700;
  text-decoration: none;
}
.search-results__item a:hover { color: var(--color-link); }
.search-results__section {
  display: inline-block;
  margin-left: 0.6rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.search-results__section--gold { color: var(--color-gold); }
.search-results__section--blue { color: var(--color-accent); }
.search-results__item p {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* 404 page */
.not-found-icon {
  color: var(--color-gold-soft);
  margin: 1.5rem 0 0;
}
