/* Dynasty Studios reader extras: lore (glossary terms, pronunciation, Who's who).
   Colours, type and radii come only from custom properties, so the brand tokens (studio/dynasty/brand/tokens.css,
   or site.css :root) re-skin it. Each --lore-* property can be set by the brand file directly; otherwise it falls
   back to the site's own tokens, then to the current palette (ink #0e0d0c, cream #ece5d8, gold #bca782). */
:root {
  --lore-gold: var(--brand-accent, var(--gold, #bca782));
  --lore-gold-hi: var(--brand-accent-hi, var(--gold-hi, #d8c49c));
  --lore-ink: var(--brand-bg, var(--bg, #0e0d0c));
  --lore-panel: var(--brand-surface, var(--panel, #161412));
  --lore-line: var(--brand-line, var(--line, #2c2823));
  --lore-text: var(--brand-text, var(--text, #ece5d8));
  --lore-muted: var(--brand-muted, var(--muted, #a59d8f));
  --lore-serif: var(--brand-serif, var(--serif, 'Libre Baskerville', Baskerville, Georgia, serif));
  --lore-sans: var(--brand-sans, var(--sans, 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif));
  --lore-focus: var(--brand-focus, var(--focus, var(--lore-gold-hi)));
  --lore-radius: var(--brand-radius, 10px);
  --lore-shadow: var(--brand-shadow, 0 18px 48px rgba(0, 0, 0, .55));
  --lore-term: var(--lore-term-color, var(--lore-gold-hi));
}

/* ---------------------------------------------------------------- the word in the text */
.lore-term {
  font-style: italic;
  color: var(--lore-term);
  text-decoration: underline dotted;
  text-decoration-color: color-mix(in srgb, var(--lore-term) 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  cursor: pointer;
  border-radius: 3px;
  transition: color .15s ease, background-color .15s ease;
}
.lore-term:hover { color: var(--lore-text); text-decoration-color: var(--lore-term); }
.lore-term:focus { outline: none; }
.lore-term:focus-visible { outline: 2px solid var(--lore-focus); outline-offset: 2px; }
.lore-term[aria-expanded="true"] { background: color-mix(in srgb, var(--lore-term) 16%, transparent); color: var(--lore-text); }
/* the read-along highlight keeps working over terms (it paints ranges, not elements) */

/* ---------------------------------------------------------------- shared bits */
.lore-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.lore-x, .lore-say, .lore-launch-btn, .lore-tabs [role="tab"] { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.lore-x { flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--lore-muted); }
.lore-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.lore-x:hover { color: var(--lore-text); background: color-mix(in srgb, var(--lore-text) 8%, transparent); }
.lore-x:focus-visible, .lore-say:focus-visible, .lore-launch-btn:focus-visible, .lore-tabs [role="tab"]:focus-visible,
.lore-pop a:focus-visible, .lore-pane:focus-visible, .lore-pop-term:focus-visible, .lore-panel-h:focus-visible {
  outline: 2px solid var(--lore-focus); outline-offset: 2px;
}
.lore-pop-term:focus:not(:focus-visible), .lore-panel-h:focus:not(:focus-visible) { outline: none; }

.lore-say { display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 36px; padding: 0 14px 0 10px;
  border: 1px solid color-mix(in srgb, var(--lore-gold) 45%, transparent); border-radius: 999px; color: var(--lore-gold-hi);
  font: 500 13px/1 var(--lore-sans); letter-spacing: .02em; }
.lore-say.is-compact { width: 36px; padding: 0; justify-content: center; }
.lore-say svg { width: 16px; height: 16px; fill: currentColor; }
.lore-say .i-wave { display: none; }
.lore-say[data-state="playing"] .i-play { display: none; }
.lore-say[data-state="playing"] .i-wave { display: inline; }
.lore-say[data-state="playing"] .i-wave rect { animation: lore-bar .9s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
.lore-say[data-state="playing"] .i-wave rect:nth-child(2) { animation-delay: .15s; }
.lore-say[data-state="playing"] .i-wave rect:nth-child(3) { animation-delay: .3s; }
.lore-say[data-state="error"] { opacity: .5; }
.lore-say:hover { background: color-mix(in srgb, var(--lore-gold) 14%, transparent); color: var(--lore-text); }
@keyframes lore-bar { 0%, 100% { transform: scaleY(.45); } 50% { transform: scaleY(1); } }

/* ---------------------------------------------------------------- popover */
.lore-pop {
  position: absolute; z-index: 40; max-width: calc(100vw - 32px);
  background: var(--lore-panel); color: var(--lore-text);
  border: 1px solid color-mix(in srgb, var(--lore-gold) 30%, var(--lore-line)); border-radius: var(--lore-radius);
  box-shadow: var(--lore-shadow); padding: 14px 16px 14px 18px; font: 15px/1.55 var(--lore-sans);
}
.lore-pop[hidden] { display: none; }
.lore-pop.is-sheet { position: fixed; left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto !important; max-width: none;
  border-radius: var(--lore-radius) var(--lore-radius) 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); }
.lore-pop-head { display: flex; align-items: flex-start; gap: 10px; }
.lore-pop-head > div { flex: 1; min-width: 0; }
.lore-kind { margin: 2px 0 2px; font: 500 11px/1.3 var(--lore-sans); letter-spacing: .24em; text-transform: uppercase; color: var(--lore-gold); }
.lore-pop-term { margin: 0; font: italic 400 21px/1.3 var(--lore-serif); color: var(--lore-gold-hi); letter-spacing: .01em; overflow-wrap: anywhere; }
.lore-meaning p { margin: 10px 0 0; }
.lore-def { color: var(--lore-text); }
.lore-notgiven { color: var(--lore-gold-hi); font-style: italic; }
.lore-context, .lore-later { color: var(--lore-muted); }
.lore-where, .lore-first, .lore-say-note { margin: 10px 0 0; font-size: 13px; color: var(--lore-muted); }
.lore-say-note { margin-top: 4px; font-size: 12px; }
.lore-where a { color: var(--lore-gold-hi); }

/* ---------------------------------------------------------------- launch buttons */
.lore-launch { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.lore-launch.is-auto { justify-content: center; }
.lore-launch-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px 0 12px;
  border: 1px solid var(--lore-line); border-radius: 999px; color: var(--lore-muted);
  font: 500 12px/1 var(--lore-sans); letter-spacing: .18em; text-transform: uppercase; }
.lore-launch-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.lore-launch-btn:hover { color: var(--lore-text); border-color: color-mix(in srgb, var(--lore-gold) 50%, var(--lore-line)); }

/* ---------------------------------------------------------------- panel (drawer) */
html.lore-open { overflow: hidden; }
.lore-panel { position: fixed; inset: 0; z-index: 60; }
.lore-panel[hidden] { display: none; }
.lore-scrim { position: absolute; inset: 0; background: color-mix(in srgb, var(--lore-ink) 70%, transparent); opacity: 0; transition: opacity .18s ease; }
.lore-panel-box { position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); display: flex; flex-direction: column;
  background: var(--lore-ink); color: var(--lore-text); border-left: 1px solid var(--lore-line); box-shadow: var(--lore-shadow);
  transform: translateX(24px); opacity: 0; transition: transform .18s ease, opacity .18s ease; font: 15px/1.55 var(--lore-sans); }
.lore-panel.is-in .lore-scrim { opacity: 1; }
.lore-panel.is-in .lore-panel-box { transform: none; opacity: 1; }
.lore-panel-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 20px; }
.lore-panel-h { margin: 0; font: 400 18px/1.3 var(--lore-serif); letter-spacing: .04em; }
.lore-tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--lore-line); }
.lore-tabs [role="tab"] { padding: 12px 10px 11px; color: var(--lore-muted); font: 500 12px/1 var(--lore-sans); letter-spacing: .2em;
  text-transform: uppercase; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.lore-tabs [role="tab"][aria-selected="true"] { color: var(--lore-gold-hi); border-bottom-color: var(--lore-gold); }
.lore-pane { flex: 1; overflow: auto; padding: 14px 20px 32px; overscroll-behavior: contain; }
.lore-note { margin: 0 0 14px; font-size: 13px; color: var(--lore-muted); }
.lore-empty, .lore-later-note { color: var(--lore-muted); font-style: italic; }
.lore-later-note { margin: 18px 0 0; font-size: 13px; }

.lore-people { list-style: none; margin: 0; padding: 0; }
.lore-person { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--lore-line); }
.lore-person:first-child { border-top: 0; }
.lore-face { flex: none; width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  border: 1px solid color-mix(in srgb, var(--lore-gold) 45%, transparent); background: var(--lore-panel); }
.lore-mono { display: grid; place-items: center; font: 400 26px/1 var(--lore-serif); color: var(--lore-gold-hi);
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--lore-gold) 18%, var(--lore-panel)), var(--lore-panel) 70%); }
.lore-person-body { min-width: 0; }
.lore-name { margin: 2px 0 0; font: 400 17px/1.3 var(--lore-serif); color: var(--lore-text); }
.lore-aka { margin: 2px 0 0; font-size: 13px; color: var(--lore-gold-hi); font-style: italic; }
.lore-role { margin: 4px 0 0; }
.lore-meta { margin: 4px 0 0; font-size: 12px; letter-spacing: .04em; color: var(--lore-muted); }
.lore-facts { margin: 8px 0 0; padding: 0 0 0 16px; font-size: 14px; }
.lore-facts li { margin: 4px 0 0; }
.lore-fact-ch { color: var(--lore-gold); font-size: 12px; letter-spacing: .04em; }
.lore-rel { margin: 8px 0 0; font-size: 13px; color: var(--lore-muted); }

.lore-words { margin: 0; }
.lore-words dt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; border-top: 1px solid var(--lore-line); }
.lore-words dt:first-child { border-top: 0; padding-top: 0; }
.lore-word { font: italic 400 18px/1.3 var(--lore-serif); color: var(--lore-gold-hi); }
.lore-words dd { margin: 0 0 14px; }
.lore-words .lore-meaning p:first-child { margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .lore-term, .lore-scrim, .lore-panel-box { transition: none; }
  .lore-say[data-state="playing"] .i-wave rect { animation: none; }
}
@media (forced-colors: active) {
  .lore-term { color: LinkText; text-decoration-color: LinkText; }
  .lore-face, .lore-say, .lore-launch-btn { border-color: ButtonText; }
}
@media print { .lore-launch, .lore-pop, .lore-panel { display: none !important; } .lore-term { color: inherit; text-decoration: none; } }
