/* Gospel Bookmarks - base stylesheet.
   Deliberately small and plain for now. The visual design pass belongs in
   phase 3 alongside the responsive and accessibility work; this exists so the
   phase 2 screens are usable while real content goes in. */

:root {
  --ground: #f7f7f5;
  --surface: #ffffff;
  --ink: #1a1a18;
  --ink-2: #55554f;
  --ink-3: #86867d;
  --rule: #dedcd5;
  --accent: #185e6b;
  --accent-ink: #ffffff;
  --danger: #9c2b25;
  --ok: #2c6b47;
  --radius: 4px;

  /* Highlight colours (plan §09) - must stay in sync with
     highlights.models.HighlightColor. */
  --hl-yellow: #fdf1a0;
  --hl-green: #b9e6b0;
  --hl-blue: #b8dcf5;
  --hl-pink: #f7c6dd;
  --hl-orange: #fad2a6;
  --hl-ink: var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #14161a;
    --surface: #1c1f24;
    --ink: #e8e8e4;
    --ink-2: #b3b3ac;
    --ink-3: #83837c;
    --rule: #2f343b;
    --accent: #56b6c4;
    --accent-ink: #10262b;
    --danger: #e0847c;
    --ok: #79c199;

    --hl-yellow: #6b5e12;
    --hl-green: #285c2c;
    --hl-blue: #234a63;
    --hl-pink: #6b2b49;
    --hl-orange: #6b3d12;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  background: var(--surface);
  padding: .5rem .75rem;
  border-radius: var(--radius);
}

/* --- Header ---------------------------------------------------------------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  padding: .9rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}

.brand { font-weight: 650; text-decoration: none; color: var(--ink); }
.site-nav, .site-account { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.site-account { margin-left: auto; }

.site-search { margin: 0; }
.site-search input {
  padding: .35rem .6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  width: 11rem;
}
.whoami { color: var(--ink-3); font-size: .9rem; }
.inline-form { display: inline; margin: 0; }

.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

/* --- Layout ---------------------------------------------------------------- */

main { max-width: 62rem; margin: 0 auto; padding: 1.5rem; }
.detail { max-width: 44rem; }
.prose { max-width: 42rem; }

h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.muted { color: var(--ink-3); font-size: .9rem; }
.empty { color: var(--ink-2); padding: 1.5rem 0; }

/* --- Messages -------------------------------------------------------------- */

.messages { list-style: none; margin: 0; padding: .75rem 1.5rem; }
.message {
  padding: .6rem .9rem;
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  margin-bottom: .4rem;
}
.message--success { border-left-color: var(--ok); }
.message--error { border-left-color: var(--danger); }

/* --- Cards ----------------------------------------------------------------- */

.card-list { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .75rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.card h2, .card h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.card h2 .swatch { vertical-align: middle; margin-right: .4rem; }
.card p { margin: .25rem 0; color: var(--ink-2); }

.item-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }

.badge {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .15rem .45rem;
  border-radius: 2px;
  background: var(--ground);
  border: 1px solid var(--rule);
  color: var(--ink-2);
}
.badge--public { border-color: var(--ok); color: var(--ok); }
.badge--unlisted { border-color: var(--accent); color: var(--accent); }

.topic-list { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; padding: 0; }
.topic {
  font-size: .8rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  background: var(--ground);
  border: 1px solid var(--rule);
  color: var(--ink-2);
}

/* --- Detail ---------------------------------------------------------------- */

.byline { color: var(--ink-2); margin: 0 0 .5rem; }
.bookmark-url { word-break: break-all; }

.quote-body {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.quote-body footer { color: var(--ink-2); font-size: .92rem; margin-top: .5rem; }
.talk-body { white-space: normal; }

/* --- Timeline -------------------------------------------------------------- */

.timeline { list-style: none; margin: 1rem 0; padding: 0 0 0 1.25rem; border-left: 2px solid var(--rule); }
.timeline-event { padding: 0 0 1.5rem 1rem; position: relative; }
.timeline-event::before {
  content: "";
  position: absolute;
  left: -1.4rem;
  top: .5rem;
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-event h2 { margin: .2rem 0 .4rem; font-size: 1.1rem; }
.event-date { color: var(--ink-3); font-size: .85rem; margin: 0; }
.event-location { color: var(--ink-3); font-size: .85rem; margin: 0 0 .4rem; font-style: italic; }
.timeline-event img { max-width: 100%; height: auto; border-radius: var(--radius); margin: .5rem 0; }
.event-quote {
  margin: .6rem 0;
  padding: .7rem 1rem;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .92rem;
  color: var(--ink-2);
}

/* --- Stats ----------------------------------------------------------------- */

.stat-row {
  list-style: none;
  margin: 1rem 0 2rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .75rem;
}
.stat a {
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.stat-n { display: block; font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.stat-l { display: block; color: var(--ink-3); font-size: .85rem; }

/* --- Forms ----------------------------------------------------------------- */

.stacked-form { max-width: 38rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .92rem; }

.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="date"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.field--error input, .field--error textarea, .field--error select { border-color: var(--danger); }
.field ul.errorlist { color: var(--danger); font-size: .85rem; margin: .25rem 0 0; padding-left: 1rem; }
.help { color: var(--ink-3); font-size: .85rem; margin: .25rem 0 0; }

/* --- Buttons --------------------------------------------------------------- */

.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.actions--small { margin-top: .5rem; font-size: .88rem; }

.button {
  display: inline-block;
  padding: .45rem .9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.button--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button--danger { border-color: var(--danger); color: var(--danger); }

/* --- Pagination & footer --------------------------------------------------- */

.pagination { display: flex; gap: 1rem; align-items: center; margin: 1.5rem 0; }
.site-footer { border-top: 1px solid var(--rule); padding: 1.5rem; color: var(--ink-3); font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* --- Favourites & collections ---------------------------------------------- */

.filter-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; }

.chip {
  display: inline-block;
  padding: .2rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  text-decoration: none;
  font-size: .88rem;
}
.chip--on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.card .inline-form { display: inline-flex; gap: .4rem; align-items: center; margin-right: .75rem; }
.card .inline-form select { padding: .3rem; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--ground); color: var(--ink); font: inherit; }

/* Visible to screen readers only. */
.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;
}

/* --- Topics ---------------------------------------------------------------- */

.search-form { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; max-width: 34rem; }
.search-form--filtered { max-width: 48rem; }
.search-form input[type="text"] {
  flex: 1 1 14rem;
  padding: .5rem .6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.search-form select {
  flex: 0 1 10rem;
  padding: .5rem .6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.topic-grid {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: .6rem;
}
.topic-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .7rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.topic-name { font-weight: 600; text-decoration: none; }

/* --- Scriptures ------------------------------------------------------------ */

.volume { margin-bottom: 2rem; }
.book-list {
  list-style: none;
  margin: .5rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: .3rem .8rem;
}

.verse-list { list-style: none; margin: 1rem 0; padding: 0; max-width: 44rem; }
.verse { padding: .6rem 0; border-bottom: 1px solid var(--rule-soft, var(--rule)); }
.verse p { margin: .2rem 0; }
.verse-ref { font-weight: 600; font-size: .9rem; text-decoration: none; }
.verse-number { color: var(--ink-3); font-size: .8rem; font-weight: 600; }
.verse-list--chapter .verse { display: grid; grid-template-columns: 2rem 1fr; gap: .5rem; }

.report-link { font-size: .88rem; color: var(--ink-3); align-self: center; margin-left: .5rem; }

/* --- allauth pages (login, signup, password reset, MFA, sessions) ---------- */
/* allauth's element templates (allauth/elements/*.html) emit bare, unclassed
   form / p / label / input / button tags - there is no .field wrapper to hang
   the usual form rules off, so this styles the tags directly, scoped to
   .auth-page so it cannot leak onto forms elsewhere in the site. */

.auth-page { max-width: 26rem; margin: 0 auto; }
.auth-page h1 { margin-bottom: 1rem; }
.auth-page p { margin: .6rem 0; }
.auth-page a { color: var(--accent); }

.auth-page form { display: flex; flex-direction: column; gap: 1rem; margin: 1.25rem 0; }
.auth-page form p { margin: 0; display: flex; flex-direction: column; gap: .3rem; }

.auth-page label { font-weight: 600; font-size: .92rem; }

.auth-page input:not([type="checkbox"]):not([type="radio"]),
.auth-page textarea,
.auth-page select {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.auth-page input[type="checkbox"],
.auth-page input[type="radio"] { margin-right: .4rem; }

/* Field errors: allauth prints {{ attrs.errors }} as raw markup immediately
   before the <p> that wraps the field. */
.auth-page form ul { color: var(--danger); font-size: .85rem; margin: 0; padding-left: 1.1rem; }

/* Buttons and button-styled links share one look; allauth renders a submit
   as <button> and a same-purpose action (e.g. "Resend code") as <a>. */
.auth-page button,
.auth-page form a[href] {
  display: inline-block;
  padding: .5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  align-self: flex-start;
}

.auth-page hr { border: none; border-top: 1px solid var(--rule); margin: 1.5rem 0; }

/* --- Highlighting (plan §09) ------------------------------------------------ */
/* static/js/highlights.js measures character offsets against this element's
   plain text content, so nothing here may add or remove characters - only
   `white-space: pre-wrap` stands in for the `linebreaks` filter used
   elsewhere, reproducing line breaks visually without restructuring the DOM. */

.highlightable { white-space: pre-wrap; }

.highlight-mark {
  border-radius: 2px;
  padding: 0 .1em;
  cursor: pointer;
  color: var(--hl-ink);
}
.highlight-mark--yellow { background: var(--hl-yellow); }
.highlight-mark--green { background: var(--hl-green); }
.highlight-mark--blue { background: var(--hl-blue); }
.highlight-mark--pink { background: var(--hl-pink); }
.highlight-mark--orange { background: var(--hl-orange); }

.highlight-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: .6rem 0;
  padding: .5rem .75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}
/* Author rules otherwise beat the UA [hidden] rule on equal specificity -
   this is what actually keeps the toolbar hidden until a selection is made. */
.highlight-toolbar[hidden] { display: none; }

.highlight-toolbar__label { font-size: .85rem; color: var(--ink-2); }

.highlight-toolbar__cancel { padding: .3rem .7rem; font-size: .85rem; }

.highlight-swatch {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  padding: 0;
  cursor: pointer;
}
.highlight-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.highlight-swatch--yellow { background: var(--hl-yellow); }
.highlight-swatch--green { background: var(--hl-green); }
.highlight-swatch--blue { background: var(--hl-blue); }
.highlight-swatch--pink { background: var(--hl-pink); }
.highlight-swatch--orange { background: var(--hl-orange); }

.highlight-orphan-notice { font-size: .85rem; color: var(--ink-3); margin-top: .5rem; }
