/* Dreamscope theme on top of Bootstrap 5.3. Colors are tokens; dark mode
 * redefines them under [data-bs-theme="dark"]. */

:root,
[data-bs-theme="light"] {
  --ds-accent: #5b3fd1;
  --ds-accent-rgb: 91, 63, 209;
  --ds-accent-hover: #4a31b5;
  --ds-accent-soft: rgba(91, 63, 209, .09);
  --ds-surface: #ffffff;
  --ds-surface-2: #f3f1fa;
  --ds-border: rgba(40, 30, 90, .11);
  --ds-shadow: 0 1px 2px rgba(30, 20, 70, .05), 0 4px 16px rgba(30, 20, 70, .05);
  --ds-muted: #6b6880;
  /* Dataset colors are the same in both themes: charts keep them after a
     theme switch. Only the text and grid colors change. */
  --ds-chart-1: #7b5cf5;
  --ds-chart-1-fill: rgba(123, 92, 245, .78);
  --ds-chart-2: #dc4f96;
  --ds-chart-muted: rgba(135, 140, 162, .45);
  --ds-chart-grid: rgba(40, 30, 90, .09);

  --bs-body-bg: #f7f6fb;
  --bs-body-color: #23212e;
  --bs-emphasis-color: #14121d;
  --bs-secondary-color: #6b6880;
  --bs-tertiary-bg: #efedf7;
  --bs-border-color: #dedbea;
  --bs-border-color-translucent: rgba(40, 30, 90, .12);
  --bs-primary: var(--ds-accent);
  --bs-primary-rgb: var(--ds-accent-rgb);
  --bs-primary-bg-subtle: #ebe6fb;
  --bs-primary-border-subtle: #cbbff3;
  --bs-primary-text-emphasis: #3a2696;
  --bs-link-color: #5338c4;
  --bs-link-color-rgb: 83, 56, 196;
  --bs-link-hover-color: #3a2696;
  --bs-link-hover-color-rgb: 58, 38, 150;
  --bs-focus-ring-color: rgba(91, 63, 209, .3);
}

[data-bs-theme="dark"] {
  color-scheme: dark;
  --ds-accent: #8f78f5;
  --ds-accent-rgb: 143, 120, 245;
  --ds-accent-hover: #a593ff;
  --ds-accent-soft: rgba(143, 120, 245, .14);
  --ds-surface: #171827;
  --ds-surface-2: #1e2033;
  --ds-border: rgba(190, 180, 255, .11);
  --ds-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .25);
  --ds-muted: #a09db8;
  --ds-chart-grid: rgba(200, 195, 255, .09);

  --bs-body-bg: #0e0f1a;
  --bs-body-color: #dddbea;
  --bs-emphasis-color: #f4f3fb;
  --bs-secondary-color: #a09db8;
  --bs-secondary-bg: #1e2033;
  --bs-tertiary-bg: #1b1d2e;
  --bs-border-color: #2e3047;
  --bs-border-color-translucent: rgba(190, 180, 255, .12);
  --bs-primary: var(--ds-accent);
  --bs-primary-rgb: var(--ds-accent-rgb);
  --bs-primary-bg-subtle: #251f4a;
  --bs-primary-border-subtle: #3d327a;
  --bs-primary-text-emphasis: #c6baff;
  --bs-link-color: #ab9bff;
  --bs-link-color-rgb: 171, 155, 255;
  --bs-link-hover-color: #cdc3ff;
  --bs-link-hover-color-rgb: 205, 195, 255;
  --bs-focus-ring-color: rgba(143, 120, 245, .35);
}

body {
  background: var(--bs-body-bg);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }
a.btn:hover, .nav-link:hover, .dropdown-item:hover, .list-group-item-action:hover, a.ds-card-link:hover { text-decoration: none; }

h1, h2, h3, h4, .h1, .h2, .h3, .h4 { letter-spacing: -.015em; font-weight: 650; }
.page-title { font-size: 1.75rem; margin-bottom: .25rem; }
.page-subtitle { color: var(--ds-muted); margin-bottom: 1.5rem; }
.section-title { font-size: 1.1rem; font-weight: 650; margin: 2rem 0 .75rem; }
.text-muted, .text-body-secondary { color: var(--ds-muted) !important; }

/* Buttons */
.btn-primary {
  --bs-btn-bg: var(--ds-accent);
  --bs-btn-border-color: var(--ds-accent);
  --bs-btn-hover-bg: var(--ds-accent-hover);
  --bs-btn-hover-border-color: var(--ds-accent-hover);
  --bs-btn-active-bg: var(--ds-accent-hover);
  --bs-btn-active-border-color: var(--ds-accent-hover);
  --bs-btn-disabled-bg: var(--ds-accent);
  --bs-btn-disabled-border-color: var(--ds-accent);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
}
.btn-outline-primary {
  --bs-btn-color: var(--ds-accent);
  --bs-btn-border-color: var(--ds-accent);
  --bs-btn-hover-bg: var(--ds-accent);
  --bs-btn-hover-border-color: var(--ds-accent);
  --bs-btn-active-bg: var(--ds-accent);
  --bs-btn-active-border-color: var(--ds-accent);
}
.btn-ghost {
  --bs-btn-color: var(--bs-body-color);
  --bs-btn-hover-bg: var(--bs-tertiary-bg);
  --bs-btn-hover-color: var(--bs-emphasis-color);
  --bs-btn-border-color: transparent;
  --bs-btn-hover-border-color: var(--ds-border);
}

/* Navbar: a night-sky band in both themes */
.ds-navbar {
  background: linear-gradient(100deg, #120f26 0%, #221a4d 55%, #2c1c55 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.ds-navbar .nav-link { color: rgba(255, 255, 255, .72); border-radius: .5rem; padding-inline: .7rem !important; }
.ds-navbar .nav-link:hover { color: #fff; }
.ds-navbar .nav-link.active { color: #fff; background: rgba(255, 255, 255, .1); }
.ds-navbar .btn-primary { --bs-btn-bg: #7b5cf0; --bs-btn-border-color: #7b5cf0; --bs-btn-hover-bg: #8d72f7; --bs-btn-hover-border-color: #8d72f7; }
.ds-navsearch .form-control { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #fff; min-width: 12rem; }
.ds-navsearch .form-control::placeholder { color: rgba(255, 255, 255, .5); }
.ds-theme-btn { border: 0; }
.navbar-logo { width: 104px; }
.dropdown-item.active, .dropdown-item:active { background: var(--ds-accent); color: #fff; }

/* Cards */
.ds-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: 14px;
  box-shadow: var(--ds-shadow);
}
.ds-card-body { padding: 1.25rem 1.4rem; }
@media (max-width: 575.98px) { .ds-card-body { padding: 1rem; } }
.ds-card-header {
  padding: .85rem 1.4rem;
  border-bottom: 1px solid var(--ds-border);
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
a.ds-card-link { color: inherit; display: block; transition: border-color .15s, transform .15s; }
a.ds-card-link:hover { border-color: rgba(var(--ds-accent-rgb), .45); }
.card { --bs-card-bg: var(--ds-surface); --bs-card-border-color: var(--ds-border); }

/* Forms */
.form-control, .form-select { background-color: var(--ds-surface); border-color: var(--bs-border-color); }
.form-control:focus, .form-select:focus { border-color: rgba(var(--ds-accent-rgb), .6); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--ds-accent); border-color: var(--ds-accent); }
.form-label, .col-form-label { font-weight: 500; font-size: .92rem; }
.auth-wrap { max-width: 26rem; margin: 2rem auto; }
.auth-wrap .ds-card-body { padding: 1.75rem; }
textarea#id_text { min-height: 16rem; font-family: var(--ds-serif); font-size: 1.05rem; line-height: 1.6; }
/* On phones the keyboard plus the sticky navbar hide the top of a tall box, so keep it short. */
@media (max-width: 575.98px) {
  textarea#id_text { height: 11rem; min-height: 8rem; scroll-margin-top: 4.5rem; }
}

/* Dream text */
:root { --ds-serif: ui-serif, "Iowan Old Style", "Charter", "Bitstream Charter", "Palatino Linotype", Georgia, serif; }
.dream-text { font-family: var(--ds-serif); font-size: 1.08rem; line-height: 1.72; max-width: 72ch; color: var(--bs-body-color); }
.dream-text p:last-child { margin-bottom: 0; }
.dream-title { font-weight: 650; font-size: 1.6rem; margin-bottom: .35rem; }
.dream-snippet { font-family: var(--ds-serif); color: var(--ds-muted); font-size: .96rem; line-height: 1.55; }

/* Meta and tags */
.meta { color: var(--ds-muted); font-size: .9rem; }
.meta i { opacity: .8; }
.tag-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .6rem; margin: 0 .3rem .35rem 0;
  border-radius: 999px; font-size: .84rem;
  background: var(--ds-accent-soft); color: var(--bs-body-color);
  border: 1px solid transparent;
}
a.tag-pill:hover { border-color: rgba(var(--ds-accent-rgb), .4); text-decoration: none; }
.tagicon { font-size: 1.05rem; }
.kicker {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 650;
  color: var(--ds-accent);
}
.badge-soft { background: var(--ds-accent-soft); color: var(--bs-primary-text-emphasis); font-weight: 600; }

/* Entry list on the journal page */
.year-heading { font-size: .82rem; font-weight: 700; letter-spacing: .08em; color: var(--ds-muted); margin: 1.6rem 0 .5rem; text-transform: uppercase; }
.entry-list { border-radius: 14px; overflow: hidden; }
.entry-row {
  display: grid; grid-template-columns: 4.2rem 1fr auto; gap: 1rem; align-items: start;
  padding: .85rem 1.2rem; color: inherit; border-bottom: 1px solid var(--ds-border);
}
.entry-row:last-child { border-bottom: 0; }
.entry-row:hover { background: var(--ds-surface-2); text-decoration: none; }
.entry-date { text-align: center; line-height: 1.1; padding-top: .1rem; }
.entry-date .d { font-size: 1.35rem; font-weight: 650; color: var(--bs-emphasis-color); }
.entry-date .m { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ds-muted); }
.entry-row .title { font-weight: 600; color: var(--bs-emphasis-color); }
.entry-row .snippet { color: var(--ds-muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry-row .snippet.untitled { color: var(--bs-body-color); -webkit-line-clamp: 3; }
.entry-row .icons { white-space: nowrap; font-size: .95rem; }
@media (max-width: 575.98px) {
  .entry-row { grid-template-columns: 3.2rem 1fr; padding: .75rem .9rem; gap: .75rem; }
  .entry-row .icons { grid-column: 2; }
}

/* Stats */
.stat-tile { padding: 1.1rem 1.3rem; }
.stat-tile .value { font-size: 1.9rem; font-weight: 700; color: var(--bs-emphasis-color); line-height: 1.1; }
.stat-tile .label { color: var(--ds-muted); font-size: .86rem; }
.chart-box { position: relative; }

/* Review */
.theme-chain { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.theme-chain li { display: flex; align-items: center; gap: .5rem; }
.theme-chain .phrase {
  padding: .45rem .9rem; border-radius: 999px; font-weight: 550;
  background: var(--ds-accent-soft); color: var(--bs-primary-text-emphasis);
  border: 1px solid rgba(var(--ds-accent-rgb), .22);
}
.theme-chain .sep { color: var(--ds-muted); }
.review-hero {
  background: linear-gradient(130deg, rgba(var(--ds-accent-rgb), .12), rgba(208, 66, 138, .08));
}
.review-slot .dream-snippet { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.review-slot.empty { border-style: dashed; box-shadow: none; background: transparent; }
.review-slot.featured .dream-snippet { -webkit-line-clamp: 10; font-size: 1.02rem; color: var(--bs-body-color); }
.similar-score { font-variant-numeric: tabular-nums; }

/* Search highlights: bright marks with dark text, so they read in both themes */
.highlight-0, .highlight-1, .highlight-2, .highlight-3, .highlight-4 { color: #16141f; border-radius: 3px; padding: 0 .1em; }
.highlight-0 { background-color: #fde047; }
.highlight-1 { background-color: #86efac; }
.highlight-2 { background-color: #7dd3fc; }
.highlight-3 { background-color: #f9a8d4; }
.highlight-4 { background-color: #fdba74; }

/* Pagination */
.ds-pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.25rem; }

.sticky { position: sticky; top: 0; }
.min-w-0 { min-width: 0; }
@media (min-width: 768px) { .border-end-md { border-right: 1px solid var(--ds-border); } }
details.ds-search > summary::-webkit-details-marker { display: none; }
details.ds-search[open] > summary { border-bottom: 1px solid var(--ds-border); }
details.ds-search:not([open]) > summary { border-bottom: 0; }
.tarot-img { width: 80px; }
.h-scroll { height: 90vh; position: fixed; overflow: scroll; }
.alert { border-radius: 12px; }
