/* ==========================================================================
   Lesser Light Search — lesserlight.com

   One document, three views. The home view animates into the results view -
   nothing ever reloads - so layout here is written to survive the transition
   rather than to describe two separate pages.
   ========================================================================== */

:root {
  --bg:            #FAFAF8;
  --surface:       #FFFFFF;
  --ink:           #16181A;
  --ink-soft:      #5A6169;
  --ink-faint:     #8A9098;
  --line:          #E4E6E3;
  --line-soft:     #EFF0EE;
  --accent:        #1D5B54;
  --accent-hover:  #17423D;
  --accent-wash:   #E9F2F0;
  --highlight:     #FFF1B8;
  --highlight-edge:#E8CE5C;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20,25,30,.05), 0 1px 1px rgba(20,25,30,.03);
  --shadow-md: 0 4px 16px rgba(20,25,30,.07), 0 1px 3px rgba(20,25,30,.05);
  --shadow-lg: 0 12px 40px rgba(20,25,30,.10), 0 2px 8px rgba(20,25,30,.05);

  --ui:     "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  /* Scripture and prose are set in a serif: these are long passages meant to
     be read like a book, not scanned like an interface. */
  --serif:  "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;

  --header-h: 64px;
  --ease:     cubic-bezier(.22,.61,.36,1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; color: inherit; }

.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;
}

/* --------------------------------------------------------------- masthead */

.masthead {
  position: fixed; inset: 0 0 auto 0; height: var(--header-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 22px;
  background: rgba(250,250,248,.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  z-index: 40;
  /* Hidden on the home view; slides down when results arrive. */
  transform: translateY(-100%);
  opacity: 0;
  transition: transform .42s var(--ease), opacity .3s var(--ease),
              border-color .3s var(--ease);
}
body[data-view="results"] .masthead,
body[data-view="thinking"] .masthead {
  transform: translateY(0);
  opacity: 1;
  border-bottom-color: var(--line);
}

.masthead__brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; color: var(--ink);
  font-weight: 600; font-size: 15px; letter-spacing: -.01em;
  white-space: nowrap; flex: none;
}
.masthead__brand .brand__name { display: none; }
@media (min-width: 900px) { .masthead__brand .brand__name { display: inline; } }

.brand__mark {
  width: 22px; height: 22px; flex: none; border-radius: 6px;
  background: linear-gradient(145deg, var(--accent), #2E8078);
  position: relative;
}
.brand__mark::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(#fff, #fff) center/2px 11px no-repeat,
    linear-gradient(#fff, #fff) center/9px 2px no-repeat;
  background-position: center, center 8px;
  opacity: .92;
}
.brand__mark--lg { width: 40px; height: 40px; border-radius: 11px; }
.brand__mark--lg::after {
  background-size: 3px 20px, 16px 3px;
  background-position: center, center 15px;
}

/* ------------------------------------------------------------- search box */

.searchbar {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  padding: 6px 6px 6px 18px;
  transition: box-shadow .22s var(--ease), border-color .22s var(--ease);
}
.searchbar:focus-within {
  border-color: #C9D6D3;
  box-shadow: var(--shadow-lg), 0 0 0 4px var(--accent-wash);
}

.searchbar__icon,
.searchbar--compact svg {
  width: 19px; height: 19px; flex: none;
  fill: none; stroke: var(--ink-faint); stroke-width: 2;
  stroke-linecap: round;
}

.searchbar input {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: 0; background: transparent;
  padding: 11px 0; font-size: 17px;
}
.searchbar input::placeholder { color: var(--ink-faint); }
.searchbar input::-webkit-search-cancel-button { display: none; }

.searchbar__go {
  flex: none; border: 0; cursor: pointer;
  background: var(--accent); color: #fff;
  padding: 11px 24px; border-radius: 999px;
  font-size: 15px; font-weight: 550; letter-spacing: -.005em;
  transition: background .18s var(--ease), transform .12s var(--ease);
}
.searchbar__go:hover  { background: var(--accent-hover); }
.searchbar__go:active { transform: scale(.97); }

.searchbar--compact {
  flex: 1 1 auto; max-width: 620px;
  padding: 3px 3px 3px 15px; box-shadow: var(--shadow-sm);
}
.searchbar--compact input { padding: 7px 0; font-size: 15px; }
.searchbar--compact button {
  flex: none; width: 34px; height: 34px; border: 0; cursor: pointer;
  border-radius: 50%; background: var(--accent-wash);
  display: grid; place-items: center;
}
.searchbar--compact button svg { stroke: var(--accent); }

/* ------------------------------------------------------------------- home */

.hero {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 40px 22px 80px;
  transition: opacity .32s var(--ease), transform .42s var(--ease);
}
body[data-view="thinking"] .hero,
body[data-view="results"]  .hero {
  opacity: 0; transform: translateY(-28px) scale(.98);
  pointer-events: none;
  position: absolute; inset: 0;
}

.hero__inner { width: 100%; max-width: 720px; text-align: center; }

.hero__title {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 0 0 14px;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 600; letter-spacing: -.028em; line-height: 1.15;
}

.hero__title-soft { color: var(--ink-faint); font-weight: 400; }

.hero__tagline {
  margin: 0 auto 34px;
  max-width: 30em;
  color: var(--ink-soft);
  font-size: 16px; line-height: 1.6;
}

/* --------------------------------------------------------------- epigraph */

/* Ellen White's own phrase, which the site is named after. Set in script and
   held off to the side: it explains the name to anyone who doesn't know it,
   without competing with the search box for attention. */
.epigraph {
  margin: 0;
  position: relative;
  z-index: 1;
}

.epigraph__text {
  margin: 0;
  font-family: "Parisienne", "Snell Roundhand", "Segoe Script", cursive;
  font-size: clamp(19px, 2.5vw, 25px);
  line-height: 1.5;
  color: var(--accent);
  opacity: .82;
}

.epigraph__cite {
  margin-top: 6px;
  font-size: 11.5px;
  letter-spacing: .02em;
  color: var(--ink-faint);
}
.epigraph__cite cite { font-style: italic; }

/* On wide screens it sits beside the search column, angled slightly so it
   reads as a marginal note rather than page furniture. */
@media (min-width: 1080px) {
  .hero__inner { position: relative; }
  .epigraph {
    position: absolute;
    top: 8px;
    left: calc(100% + 40px);
    width: 250px;
    text-align: left;
    transform: rotate(-3.5deg);
    transform-origin: top left;
  }
  .epigraph__text::before {
    content: "";
    display: block;
    width: 34px; height: 1px;
    background: var(--accent);
    opacity: .35;
    margin-bottom: 14px;
  }
}

/* Narrow screens: centred beneath the options, still clearly an aside. */
@media (max-width: 1079px) {
  .epigraph {
    margin: 40px auto 0;
    max-width: 25em;
    padding-top: 26px;
    border-top: 1px solid var(--line);
  }
  .epigraph__text { font-size: clamp(18px, 4.4vw, 22px); }
}

/* ------------------------------------------------------------ scope chips */

.scopes { border: 0; margin: 26px 0 0; padding: 0; }

.scopes__row {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 9px;
}

.chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 15px 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color .18s var(--ease), background .18s var(--ease),
              box-shadow .18s var(--ease), transform .12s var(--ease);
}
.chip:hover   { border-color: #CFD8D6; transform: translateY(-1px); }
.chip:active  { transform: translateY(0); }
.chip input   { position: absolute; opacity: 0; pointer-events: none; }

.chip__check {
  width: 19px; height: 19px; flex: none; border-radius: 6px;
  border: 1.5px solid #CBD2D0; background: var(--surface);
  display: grid; place-items: center;
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.chip__check svg {
  width: 13px; height: 13px;
  fill: none; stroke: #fff; stroke-width: 2.8;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0; transform: scale(.6);
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-wash);
}
.chip:has(input:checked) .chip__check {
  background: var(--accent); border-color: var(--accent);
}
.chip:has(input:checked) .chip__check svg { opacity: 1; transform: scale(1); }
.chip:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-wash); }

.chip__text  { display: flex; flex-direction: column; line-height: 1.25; }
.chip__label { font-size: 14.5px; font-weight: 550; letter-spacing: -.008em; }
.chip__note  { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }

.chip__count {
  font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--ink-faint); padding-left: 3px;
}

/* Secondary chips stagger in when "More sources" is opened. */
@keyframes chipIn {
  from { opacity: 0; transform: translateY(6px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.chip--more { border-style: dashed; color: var(--ink-soft); }
.chip--more .chip__label { font-weight: 500; }
.chip__caret {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .22s var(--ease);
}
.chip--more[aria-expanded="true"] .chip__caret { transform: rotate(180deg); }

/* Sub-options: shown only while their parent scope is selected. */
.scopes__subrow {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px 22px; margin-top: 16px;
}

.subtoggle {
  display: inline-flex; align-items: flex-start; gap: 9px;
  cursor: pointer; font-size: 13.5px; color: var(--ink-soft);
  max-width: 34em; text-align: left;
}
.subtoggle[hidden] { display: none; }
.subtoggle input { position: absolute; opacity: 0; pointer-events: none; }

.subtoggle__track {
  width: 34px; height: 20px; flex: none; margin-top: 1px;
  border-radius: 999px; background: #DDE1DF;
  position: relative;
  transition: background .2s var(--ease);
}
.subtoggle__thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease);
}
.subtoggle:has(input:checked) .subtoggle__track { background: var(--accent); }
.subtoggle:has(input:checked) .subtoggle__thumb { transform: translateX(14px); }
.subtoggle:has(input:focus-visible) .subtoggle__track {
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.subtoggle__label { display: flex; flex-direction: column; }
.subtoggle__hint  { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* --------------------------------------------------------------- thinking */

/* Status phrases drift upward and fade. Nobody should wonder whether the
   page has frozen, so this layer stays visibly alive for the whole wait. */
.thinking {
  position: fixed; inset: var(--header-h) 0 0 0;
  display: grid; place-items: center;
  z-index: 20;
  pointer-events: none;
}
.thinking[hidden] { display: none; }

.thinking__field { position: absolute; inset: 0; overflow: hidden; }

.thinking__phrase {
  position: absolute;
  white-space: nowrap;
  font-size: clamp(14px, 1.9vw, 19px);
  color: var(--ink-faint);
  font-family: var(--serif);
  font-style: italic;
  opacity: 0;
  will-change: transform, opacity;
  animation: drift var(--dur, 9s) var(--ease) forwards;
}
@keyframes drift {
  0%   { opacity: 0; transform: translate3d(0, 26px, 0) scale(.97); }
  18%  { opacity: .85; }
  70%  { opacity: .7; }
  100% { opacity: 0; transform: translate3d(0, -70px, 0) scale(1.02); }
}

.thinking__caption {
  position: relative;
  margin: 0; padding: 12px 26px;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  font-size: 14.5px; font-weight: 500; color: var(--ink-soft);
}
.thinking__caption::after {
  content: ""; display: inline-block; width: 1.2em; text-align: left;
  animation: ellipsis 1.4s steps(4, end) infinite;
}
@keyframes ellipsis {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

@media (prefers-reduced-motion: reduce) {
  .thinking__phrase { animation-duration: .01ms; opacity: .8; }
  .thinking__caption::after { animation: none; content: "..."; }
  .hero, .masthead, .chip, .searchbar { transition-duration: .01ms; }
}

/* -------------------------------------------------------- results (three) */

.serp {
  display: grid;
  grid-template-columns: minmax(200px, 250px) minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--line-soft);
  padding-top: var(--header-h);
  min-height: 100dvh;
  opacity: 0;
  transition: opacity .34s var(--ease);
}
.serp[hidden]  { display: none; }
body[data-view="results"] .serp { opacity: 1; }

.panel {
  background: var(--bg);
  padding: 26px 24px 60px;
  overflow-y: auto;
  max-height: calc(100dvh - var(--header-h));
}
.panel--mid   { background: var(--surface); }
.panel--right { background: var(--bg); }

.panel__empty {
  color: var(--ink-faint); font-size: 14px;
  padding: 30px 4px; line-height: 1.6;
}

/* Passage reading column: set like a book, not like an interface. */
.passage {
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.72;
  max-width: 34em;
}
.passage p { margin: 0 0 1.05em; }

.passage mark {
  background: var(--highlight);
  box-shadow: inset 0 -1px 0 var(--highlight-edge);
  border-radius: 2px;
  padding: .06em 0;
}

@media (max-width: 1040px) {
  .serp { grid-template-columns: minmax(180px, 220px) minmax(0, 1fr); }
  .panel--left { grid-row: span 2; }
}

/* Below 780px the three panels become one swipeable view at a time. */
@media (max-width: 780px) {
  .serp { grid-template-columns: 1fr; padding-bottom: 62px; }
  .panel { display: none; max-height: none; min-height: calc(100dvh - var(--header-h) - 62px); }
  .panel.is-active { display: block; }
  .panelnav { display: flex; }
}

.panelnav {
  position: fixed; inset: auto 0 0 0; z-index: 45;
  display: none;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  gap: 6px;
}
.panelnav[hidden] { display: none !important; }
.panelnav button {
  flex: 1; border: 0; cursor: pointer; background: transparent;
  padding: 9px 6px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 550; color: var(--ink-soft);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.panelnav button.is-active { background: var(--accent-wash); color: var(--accent); }

/* ============================================================== ANSWER ==== */

.answer { max-width: 40em; }

.answer__q {
  margin: 0 0 20px;
  font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  color: var(--ink-soft);
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}

.answer__prose { margin: 0 0 1.1em; font-size: 15.5px; line-height: 1.68; }

.answer__none { color: var(--ink-soft); font-size: 15px; }

.answer__note {
  margin: 26px 0 0; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-faint); line-height: 1.55;
}

/* A quote is a button into the passage: clicking opens it in context. */
.quote {
  margin: 0 0 1.3em; padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: box-shadow .18s var(--ease), border-color .18s var(--ease),
              transform .12s var(--ease);
}
.quote:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.quote:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quote.is-open { background: var(--accent-wash); border-left-width: 4px; }

.quote__text {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 16.5px; line-height: 1.62;
}
.quote__text::before { content: "\201C"; }
.quote__text::after  { content: "\201D"; }

.quote__cite {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px;
  font-size: 12px; color: var(--ink-faint);
}
.quote__work { font-weight: 550; color: var(--ink-soft); }
.quote__ref  { font-variant-numeric: tabular-nums; }
.quote__tag {
  padding: 1px 7px; border-radius: 999px;
  background: var(--line-soft); color: var(--ink-soft); font-size: 10.5px;
  letter-spacing: .03em; text-transform: uppercase;
}
.quote__also { font-style: italic; }

/* ============================================================== READER ==== */

.reader__head { margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.reader__work { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.015em; }
.reader__meta { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.reader__chapter {
  margin: 10px 0 0; font-family: var(--serif); font-style: italic;
  font-size: 15px; color: var(--ink-soft);
}

.tools { display: flex; gap: 7px; margin-top: 14px; }
.tools button {
  border: 1px solid var(--line); background: var(--surface);
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
  font-size: 12.5px; font-weight: 500; color: var(--ink-soft);
  transition: border-color .16s var(--ease), color .16s var(--ease),
              background .16s var(--ease);
}
.tools button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-wash); }

.passage__p { position: relative; margin: 0 0 1.05em; }
.passage__p.is-target {
  background: var(--accent-wash);
  box-shadow: -14px 0 0 var(--accent-wash), 14px 0 0 var(--accent-wash);
  border-radius: 2px;
}
.passage__ref {
  display: inline-block; margin-left: 8px;
  font-family: var(--ui); font-size: 10.5px; color: var(--ink-faint);
  vertical-align: super; font-variant-numeric: tabular-nums;
}

.alsoin { margin-top: 30px; font-size: 13px; }
.alsoin summary { cursor: pointer; color: var(--ink-soft); }
.alsoin ul { list-style: none; margin: 12px 0 0; padding: 0; }
.alsoin li { margin-bottom: 6px; }
.alsolink {
  border: 0; background: transparent; cursor: pointer; text-align: left;
  padding: 3px 0; font-size: 13px; color: var(--accent);
}
.alsolink:hover { text-decoration: underline; }
.alsolink span { color: var(--ink-faint); }

/* ============================================================= BOOK NAV === */

.booknav__scope {
  margin: 0 0 6px; font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-faint);
}
.booknav__title { margin: 0; font-size: 15.5px; font-weight: 600; line-height: 1.3; }
.booknav__author { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.booknav__here {
  margin: 12px 0 16px; padding: 8px 11px;
  background: var(--accent-wash); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--accent); line-height: 1.4;
}
.booknav__list { list-style: none; margin: 0; padding: 0; }
.booknav__none { font-size: 13px; color: var(--ink-faint); }
.chapnav {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 9px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.4; color: var(--ink-soft);
}
.chapnav:hover { background: var(--line-soft); color: var(--ink); }
.chapnav.is-here { background: var(--accent-wash); color: var(--accent); font-weight: 550; }

/* =============================================================== TOAST ==== */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  z-index: 60; padding: 10px 20px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* =============================================================== PRINT ==== */

/* Printing should yield the passage as a clean page: no interface, no
   navigation, black on white, with the citation carried along so a printed
   sheet remains attributable. */
@media print {
  .masthead, .panelnav, .panel--left, .panel--right,
  .tools, .thinking, .hero, .toast, .alsoin { display: none !important; }

  body { background: #fff; color: #000; }
  .serp {
    display: block; padding: 0; background: #fff;
    min-height: auto; opacity: 1;
  }
  .panel { max-height: none; overflow: visible; padding: 0; background: #fff; }
  .panel--mid { display: block !important; }

  .reader__head { border-bottom: 1px solid #ccc; }
  .passage { max-width: none; font-size: 12pt; line-height: 1.6; }
  .passage__p.is-target { background: none; box-shadow: none; font-weight: 600; }
  .passage mark { background: none; box-shadow: none; text-decoration: underline; }
  .passage__ref { color: #666; }

  @page { margin: 2cm; }
}
