/* study-mode — the rules that only ever match inside this engine, moved out of
   core/styles.css so other pages don't download them. Loaded by core/app.js after
   core/styles.css (the ENGINES table's css). */

body.study-mode #profileRoot {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  /* The study's one and only scroller: panels grow to their content and the
     whole page scrolls (no panel scrolls on its own). */
  overflow-y: auto;
  scrollbar-width: thin;
  padding: clamp(16px, 2.6vw, 34px);
  gap: clamp(14px, 2vw, 24px);
  background:
    radial-gradient(1200px 800px at 50% -8%, var(--bg-haze) 0%, var(--bg-1) 45%, var(--bg-0) 100%);
}

/* ---- Identity header -------------------------------------------------- */
#studyHud {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 4px clamp(40px, 7vw, 96px) 0;   /* leave room for the ⌂ Library pill */
  /* The name clears the ⌂ Library pill (which ends ~120px from the edge) at every
     width; on a wide screen this is the same 96px as before. */
  padding-left: max(clamp(40px, 7vw, 96px), calc(124px - clamp(16px, 2.6vw, 34px)));
  flex: none;
}

#studyName {
  margin: 0;
  font-size: clamp(30px, 4.6vw, 56px);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.02;
  color: var(--ink);
}

#studyEpithet {
  margin: 6px 0 0;
  font-size: clamp(14px, 1.5vw, 19px);
  color: var(--accent-soft);
  font-style: italic;
}

#studyMeta { display: flex; gap: 10px; align-items: center; flex: none; }

.study-kind, .study-era {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 13px;
  border-radius: 999px;
  white-space: nowrap;
}

.study-kind {
  color: var(--text-dim);
  background: var(--soft-fill);
  border: 1px solid var(--hairline);
}

.study-era {
  color: var(--on-accent);
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border: 1px solid var(--card-border);
  font-weight: 600;
}

/* Top region: Overview (left) | Character-over-Themes (right). The row
   stretches both columns to the taller one, so the halves stay level. */
.study-top {
  display: flex;
  gap: clamp(12px, 1.4vw, 20px);
}

.study-top > .study-panel--identity { flex: 1 1 0; min-width: 0; }

.study-top__right {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.2vw, 16px);
}

/* Themes soaks up any spare height so the right column's bottom edge lines up
   with Overview's. */
.study-top__right > .study-panel--themes { flex: 1 0 auto; }

/* ---- A panel ---------------------------------------------------------- */
.study-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: clamp(14px, 1.4vw, 22px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
}

/* The tabbed panel shows the active tab at its full height. */
.study-tabs {
  padding: 0;                  /* the tab bar + panes manage their own padding */
}

/* ---- Tab bar ----------------------------------------------------------- */
.study-tabbar {
  display: flex;
  gap: 4px;
  flex: none;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--hairline);
}

.study-tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.04em;
  padding: 11px 18px;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.study-tab__icon { font-size: 18px; line-height: 1; }

.study-tab:hover { color: var(--ink); background: var(--soft-fill); }

.study-tab.is-active {
  color: var(--accent-soft);
  background: var(--card-bg);
  border-color: var(--hairline);
  /* sit on top of the bar's bottom hairline so the active tab reads as joined
     to the pane below it */
  margin-bottom: -1px;
  border-bottom: 1px solid var(--card-bg);
}

.study-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- Tab panes --------------------------------------------------------- */
.study-tabpanes { display: flex; }

.study-tabpane { display: none; flex: 1; min-width: 0; }

.study-tabpane.is-active { display: flex; flex-direction: column; }

/* Tab content gets the padding the panel shell used to provide. */
.study-tabpane > .study-panel__body {
  padding: clamp(14px, 1.4vw, 22px);
}

.study-panel__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}

.study-panel__icon { font-size: 20px; line-height: 1; }

.study-panel__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

/* The body fills whatever height its panel is stretched to. */
.study-panel__body { flex: 1 1 auto; }

/* ---- Overview --------------------------------------------------------- */
.study-lead {
  margin: 0 0 12px;
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.5;
  color: var(--text);
}

.study-prose { color: var(--text-dim); font-size: 15px; line-height: 1.6; }

.study-prose p { margin: 0 0 10px; }

.study-prose strong { color: var(--text); }

.study-prose blockquote {
  margin: 10px 0;
  padding: 4px 0 4px 14px;
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-style: italic;
}

/* ---- Character traits ------------------------------------------------- */
.study-trait-label {
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 4px 0 10px;
}

.study-trait-label:not(:first-child) { margin-top: 18px; }

.study-traits { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.study-trait {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 16px;
  padding: 8px 16px 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--soft-fill);
  color: var(--text);
}

.study-trait__mark { font-weight: 800; font-size: 14px; }

.study-traits--good .study-trait {
  border-color: rgba(var(--good-alt-rgb), 0.45);
  background: rgba(var(--good-alt-rgb), 0.12);
}

.study-traits--good .study-trait__mark { color: var(--good-alt); }

.study-traits--bad .study-trait {
  border-color: rgba(var(--bad-rgb), 0.45);
  background: rgba(var(--bad-rgb), 0.12);
}

.study-traits--bad .study-trait__mark { color: var(--bad); }

/* ---- Generic chips (themes, participants, books) ---------------------- */
.study-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.study-chip {
  font-size: 13.5px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--text);
}

.study-chips--theme .study-chip { color: var(--accent-soft); font-weight: 600; }

/* ---- Scripture reference chips ---------------------------------------- */
.study-refs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- Key events ------------------------------------------------------- */
.study-events { list-style: none; margin: 0; padding: 0; counter-reset: ev; }

.study-event {
  position: relative;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  margin-bottom: 8px;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.study-event:not(:last-child) { border-bottom: 1px solid var(--hairline); border-radius: 12px; }

.study-event.is-expandable { cursor: pointer; }

.study-event.is-expandable:hover,
.study-event.is-expandable:focus-visible {
  background: var(--soft-fill);
  border-color: var(--card-border);
  transform: translateX(2px);
}

.study-event.is-expandable:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: -2px; }

.study-event__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.study-event__title { margin: 0; font-size: 16px; font-weight: 650; color: var(--ink); }

.study-event__more { font-size: 12px; color: var(--accent-soft); white-space: nowrap; flex: none; }

.study-event__summary { margin: 5px 0 0; font-size: 14px; line-height: 1.5; color: var(--text-dim); }

/* ---- Prophecy (Foretold / Fulfilled reference rows) ------------------- */
.study-prophecy__row { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; }

.study-prophecy__row .study-refs { margin: 0; }

.study-prophecy__label {
  flex: none;
  min-width: 70px;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.study-reader-refs .study-prophecy__label { align-self: center; }

/* ---- Names & titles: group headings over relationship-style rows ------- */
.study-names .study-trait-label { font-size: 15px; color: var(--accent-soft); }

/* ---- Relationships ---------------------------------------------------- */
.study-rels { list-style: none; margin: 0; padding: 0; }

.study-rel { padding: 10px 0; }

.study-rel:not(:last-child) { border-bottom: 1px solid var(--hairline); }

.study-rel__head { display: flex; align-items: center; gap: 10px; }

.study-rel__name { font-size: 15.5px; font-weight: 650; color: var(--ink); }

.study-rel__link {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.study-rel__link:hover { color: var(--accent-soft); }

.study-rel__type {
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--soft-fill);
  color: var(--text-dim);
  border: 1px solid var(--hairline);
}

.study-rel__type.type-enemy   { color: var(--bad); border-color: rgba(var(--bad-rgb),.4); background: rgba(var(--bad-rgb),.1); }

.study-rel__type.type-ally,
.study-rel__type.type-disciple { color: var(--good-alt); border-color: rgba(var(--good-alt-rgb),.4); background: rgba(var(--good-alt-rgb),.1); }

.study-rel__type.type-authority { color: var(--accent-soft); border-color: var(--card-border); background: rgba(var(--accent-rgb),.12); }

.study-rel__summary { margin: 5px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--text-dim); }

/* ---- Passages / literary footprint ------------------------------------ */
.study-passages { display: flex; flex-wrap: wrap; gap: 22px 36px; }

.study-passage-col { flex: 1 1 200px; min-width: 180px; }

.study-passage-col--wide { flex-basis: 100%; }

/* In Scripture is its own full tab now, so scale it up: the column subtitles
   (Books / Major sections / Passage index) read largest, with bigger items
   beneath them. */
.study-passages .study-trait-label {
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--accent-soft);
  margin-bottom: 12px;
}

.study-passages .study-chip { font-size: 15.5px; padding: 8px 16px; }

.study-passages .study-ref { font-size: 14.5px; padding: 5px 12px; }

/* ---- Reader refs (inside the shared #detail modal) -------------------- */
.study-reader-refs { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 7px; }

/* ---- Credit (⌂ Library is the shared .lib-link) ------------------------ */
#studyCredit { flex: none; padding-top: 2px; }

.study-theme-menu {
  position: fixed;
  z-index: 21;
  top: 60px;
  right: 24px;
  width: 188px;
  padding: 7px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: grid;
  gap: 2px;
}

.study-theme-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.study-theme-item:hover { background: var(--soft-fill); }

.study-theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 8px rgba(0, 0, 0, 0.25);
}

.study-theme-name { flex: 1; }

.study-theme-check { color: var(--accent-soft); opacity: 0; font-weight: 700; }

.study-theme-item.is-active .study-theme-check { opacity: 1; }

.study-theme-item.is-active { background: var(--soft-fill); }

@media (max-width: 1000px) {
  /* Narrow screens: stack the top region into one column. */
  .study-top { flex-direction: column; }
  
  .study-top > .study-panel--identity,
  .study-top__right,
  .study-top__right > .study-panel { flex: 0 0 auto; }
}

/* Tablets and narrow windows: the name is small enough that the PERSON / era
   badges rise into the top-right 🎨 and light/dark pills (~160px with their
   margin). Keep the badges clear of them; a long name wraps them under it. */
@media (min-width: 641px) and (max-width: 1000px) {
  #studyHud { padding-right: 172px; }
}

@media (max-width: 640px) {
  #studyHud { padding: 30px 4px 0; gap: 10px; }
  
  .study-theme-menu { top: 50px; right: 12px; }
  
  /* Three tabs must fit a phone's width (the page must not scroll sideways):
     drop the icons and tighten; wrap to a second line as a last resort. */
  .study-tabbar { flex-wrap: wrap; }
  
  .study-tab { padding: 10px 12px; font-size: 14px; letter-spacing: 0.02em; }
  
  .study-tab__icon { display: none; }
}

/* A short screen (a phone held sideways) scrolls the theme menu inside itself. */
.study-theme-menu { max-height: calc(100vh - 72px); max-height: calc(100dvh - 72px); overflow-y: auto; }

/* Touch: the 🎨 button, its menu's rows and the relationship names get ~40px
   hit areas without changing how they are drawn. */
@media (pointer: coarse) {
  .study-theme-btn::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 44px; transform: translateY(-50%); }
  .study-theme-item { min-height: 44px; }
  .study-rel__link { position: relative; }
  .study-rel__link::after { content: ""; position: absolute; left: -4px; right: -4px; top: 50%; height: 40px; transform: translateY(-50%); }
}
