/* Thunderhead — narrative UI: the dialogue panel and the journal.
   Uses the variables and the keycap from styles.css; add this link after it.
   Nothing here needs JS to animate: the components only toggle classes. */

/* =====================================================================================
   DIALOGUE
   ===================================================================================== */
.dlg {
  --dlg-accent: var(--gold);
  --dlg-accent-2: var(--gold2);
  --dlg-glow: rgba(224, 178, 90, 0.22);
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 8;
  display: flex; justify-content: center;
  padding: 0 clamp(14px, 4vw, 46px) clamp(14px, 3vh, 30px);
  pointer-events: none;
  opacity: 0; visibility: hidden; transform: translateY(24px);
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.16, 0.84, 0.3, 1), visibility 0s linear 0.3s;
}
.dlg.is-open {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity 0.22s ease, transform 0.34s cubic-bezier(0.16, 0.84, 0.3, 1), visibility 0s linear 0s;
}
.dlg.is-ringer { --dlg-accent: var(--glass); --dlg-accent-2: #c9f0ff; --dlg-glow: rgba(143, 224, 255, 0.20); }

.dlg-panel {
  position: relative; pointer-events: auto; cursor: pointer;
  width: min(960px, 100%);
  display: flex; align-items: flex-start; gap: 18px;
  padding: 18px 22px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(120% 140% at 12% 0%, rgba(143, 224, 255, 0.055), rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, rgba(17, 23, 44, 0.92) 0%, rgba(9, 13, 26, 0.95) 58%, rgba(5, 8, 16, 0.97) 100%);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(7px) saturate(1.06); -webkit-backdrop-filter: blur(7px) saturate(1.06);
}
/* the gold hairline along the top edge, fading out at both ends */
.dlg-panel::before {
  content: ''; position: absolute; left: 16px; right: 16px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--dlg-accent), transparent);
  opacity: 0.9;
}
/* a breath of the speaker's colour under the panel */
.dlg-panel::after {
  content: ''; position: absolute; left: 8%; right: 8%; bottom: -14px; height: 22px; border-radius: 50%;
  background: var(--dlg-glow); filter: blur(12px); opacity: 0.7; pointer-events: none;
}
.dlg.is-ringer .dlg-panel { flex-direction: row-reverse; }

/* ---- portrait ---- */
.dlg-portrait {
  position: relative; flex: 0 0 96px; width: 96px; height: 96px;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: #06090f;
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.75), 0 6px 18px rgba(0, 0, 0, 0.5);
}
.dlg-portrait::after {
  content: ''; position: absolute; inset: 0; border-radius: 11px; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 -14px 22px rgba(0, 0, 0, 0.55);
}
.dlg-portrait-canvas { display: block; width: 100%; height: 100%; }
.dlg.no-portrait .dlg-portrait { display: none; }

/* ---- speaker + line ---- */
.dlg-body { flex: 1 1 auto; min-width: 0; }
.dlg-name {
  font-family: var(--serif); font-variant-caps: small-caps;
  text-transform: uppercase; letter-spacing: 0.22em;
  font-size: calc(12px * var(--fs)); line-height: 1;
  color: var(--dlg-accent); margin-bottom: 9px;
  display: flex; align-items: center; gap: 10px;
}
.dlg-name::after { content: ''; flex: 1 1 auto; height: 1px; background: linear-gradient(90deg, var(--line), transparent); opacity: 0.7; }
.dlg.is-narration .dlg-name { display: none; }

.dlg-text {
  font-family: var(--serif); font-size: calc(19px * var(--fs)); line-height: 1.5;
  color: var(--ink); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
  min-height: 3em; white-space: pre-wrap;
}
.dlg.is-narration .dlg-text { font-style: italic; color: var(--dim); }
.dlg.is-typing .dlg-text::after {
  content: '▌'; margin-left: 2px; color: var(--dlg-accent); opacity: 0.85;
  animation: dlg-caret 0.75s steps(1) infinite;
}
@keyframes dlg-caret { 50% { opacity: 0.08; } }

/* ---- choices ---- */
.dlg-choices { display: none; flex-direction: column; gap: 6px; margin-top: 12px; }
.dlg.is-choosing .dlg-choices { display: flex; }

.dlg-choice {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-width: 0; margin: 0; padding: 8px 14px;
  font-family: var(--serif); font-size: calc(16px * var(--fs)); letter-spacing: 0.01em; text-align: left;
  color: var(--ink); cursor: pointer;
  background: rgba(3, 5, 12, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  opacity: 0; transform: translateY(5px);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.dlg.is-choosing .dlg-choice { opacity: 1; transform: none; }
.dlg-choice:hover { background: rgba(224, 178, 90, 0.07); border-color: rgba(255, 255, 255, 0.22); box-shadow: none; transform: none; }
.dlg-choice:focus, .dlg-choice:focus-visible { outline: none; transform: none; box-shadow: none; }
.dlg-choice.is-focused, .dlg-choice.is-focused:hover {
  border-color: var(--gold2);
  background: linear-gradient(90deg, rgba(224, 178, 90, 0.22), rgba(224, 178, 90, 0.05));
  box-shadow: 0 0 18px rgba(224, 178, 90, 0.22), inset 0 0 0 1px rgba(255, 210, 122, 0.16);
  transform: translateX(3px);
}
.dlg-choice-mark { color: var(--gold2); opacity: 0; transition: opacity 0.15s; font-size: 0.9em; }
.dlg-choice.is-focused .dlg-choice-mark { opacity: 1; }
.dlg-choice-text { flex: 1 1 auto; min-width: 0; }
.dlg-choice.is-locked, .dlg-choice.is-locked:hover {
  opacity: 0.45; color: var(--dim); cursor: default;
  background: rgba(3, 5, 12, 0.35); border-color: rgba(255, 255, 255, 0.06); border-style: dashed; box-shadow: none; transform: none;
}
.dlg-choice.is-spent { pointer-events: none; }
.dlg-choice.is-spent:not(.is-focused) { opacity: 0.35; }
/* a little padlock, drawn rather than typed, so it matches the panel at any size */
.dlg-lock {
  flex: 0 0 auto; position: relative; width: 10px; height: 8px; margin-left: 6px; margin-top: 4px;
  border: 1px solid currentColor; border-radius: 2px;
}
.dlg-lock::before {
  content: ''; position: absolute; left: 2px; right: 2px; bottom: 100%; height: 5px;
  border: 1px solid currentColor; border-bottom: 0; border-radius: 4px 4px 0 0;
}

/* ---- footer: "[X] continue · [LB] leave" ---- */
/* The two verbs share one row. The continue half fades with the line (it is meaningless over a set
   of answers); the leave half is up for the whole conversation, because walking out is always on. */
.dlg-foot { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 10px; }
.dlg-continue {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  font-family: var(--mono); font-size: calc(10px * var(--fs)); letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--dim); opacity: 0; transition: opacity 0.22s ease;
}
.dlg-continue.is-on { opacity: 0.95; }
.dlg.is-choosing .dlg-continue { visibility: hidden; }   /* no dead row under the choices */
.dlg-continue .keycap, .dlg-leave .keycap { font-size: calc(10px * var(--fs)); }
.dlg-continue-word, .dlg-leave-word { opacity: 0.85; }
.dlg-leave {
  display: flex; align-items: center; gap: 8px; min-width: 0; padding: 3px 10px;
  font-family: var(--mono); font-size: calc(10px * var(--fs)); letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--dim); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; opacity: 0.8; transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}
.dlg-leave:hover, .dlg-leave:focus-visible { opacity: 1; border-color: var(--dlg-accent); background: rgba(224, 178, 90, 0.12); outline: none; }
.dlg-chev { color: var(--dlg-accent); animation: dlg-nudge 1.5s ease-in-out infinite; }
@keyframes dlg-nudge { 0%, 100% { transform: translateX(0); opacity: 0.75; } 50% { transform: translateX(3px); opacity: 1; } }

/* while a conversation is up, the combat furniture gets out of the way; while the journal is open,
   the touch controls stop taking taps meant for the book */
.has-dialogue .hud-bottom { opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.has-journal .touch-ui { opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }

/* =====================================================================================
   JOURNAL
   ===================================================================================== */
.jr {
  position: absolute; inset: 0; z-index: 12;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 3vh, 34px) clamp(12px, 4vw, 40px);
  pointer-events: none; opacity: 0; visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.jr.is-open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.2s ease, visibility 0s linear 0s; }
.jr-scrim { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 32%, rgba(10, 16, 32, 0.6), rgba(3, 5, 11, 0.9)); }

.jr-panel {
  position: relative; width: min(1020px, 100%); max-height: min(86vh, 780px);
  display: flex; flex-direction: column;
  padding: 20px 24px 14px;
  border: 1px solid var(--line); border-radius: 16px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(143, 224, 255, 0.05), rgba(0, 0, 0, 0) 55%),
    linear-gradient(180deg, rgba(14, 19, 38, 0.96), rgba(6, 9, 18, 0.97));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transform: translateY(12px) scale(0.992);
  transition: transform 0.26s cubic-bezier(0.16, 0.84, 0.3, 1);
}
.jr.is-open .jr-panel { transform: none; }

.jr-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.jr-headtext { min-width: 0; }
.jr-kicker { font-family: var(--mono); font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--glass); opacity: 0.8; }
.jr-title { font-family: var(--serif); font-size: calc(28px * var(--fs)); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink); margin-top: 4px; }
.jr-hearts { display: flex; align-items: center; gap: 5px; }
.jr-hearts-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); margin-right: 4px; }
.jr-pip { width: 13px; height: 12px; border-radius: 3px 3px 7px 7px; background: linear-gradient(180deg, #ffe08a, #ff9a3a); box-shadow: 0 0 8px rgba(255, 170, 60, 0.45); }

.jr-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; padding: 16px 0 6px; min-height: 0; flex: 1 1 auto; }
.jr-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.jr-col-kit { border-left: 1px solid rgba(224, 178, 90, 0.18); padding-left: 24px; }
.jr-colhead { font-family: var(--mono); font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.jr-subhead { font-family: var(--mono); font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--dim); margin: 4px 0 8px; }
.jr-list { overflow-y: auto; overscroll-behavior: contain; padding-right: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.jr-list::-webkit-scrollbar { width: 6px; }
.jr-list::-webkit-scrollbar-thumb { background: rgba(224, 178, 90, 0.28); border-radius: 3px; }
.jr-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.03); }
.jr-empty { font-family: var(--serif); font-style: italic; color: var(--dim); font-size: calc(15px * var(--fs)); }

/* ---- quest rows ---- */
.jr-quest {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; min-width: 0; margin: 0; padding: 11px 14px;
  text-align: left; font-family: var(--sans); font-size: calc(14px * var(--fs)); color: var(--ink); cursor: pointer;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08); border-left: 2px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.2s;
}
.jr-quest:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.16); box-shadow: none; transform: none; }
.jr-quest:focus, .jr-quest:focus-visible { outline: none; transform: none; box-shadow: none; }
.jr-quest.is-main { border-left-color: var(--gold); background: linear-gradient(90deg, rgba(224, 178, 90, 0.12), rgba(224, 178, 90, 0.02)); }
.jr-quest.is-focused, .jr-quest.is-focused:hover {
  border-color: var(--gold2); border-left-color: var(--gold2);
  background: linear-gradient(90deg, rgba(224, 178, 90, 0.2), rgba(224, 178, 90, 0.04));
  box-shadow: 0 0 18px rgba(224, 178, 90, 0.18);
}
.jr-quest.is-done { opacity: 0.48; }
.jr-quest.is-done.is-focused { opacity: 0.72; }

.jr-q-mark { flex: 0 0 auto; font-size: 13px; line-height: 1.5; color: var(--gold); }
.jr-quest.is-done .jr-q-mark { color: var(--gold2); }
.jr-q-body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.jr-q-top { display: flex; align-items: baseline; gap: 10px; }
.jr-q-name { font-family: var(--serif); font-size: calc(17px * var(--fs)); letter-spacing: 0.03em; color: var(--ink); }
.jr-quest.is-main .jr-q-name { color: var(--gold2); }
.jr-q-tag { margin-left: auto; font-family: var(--mono); font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 4px; padding: 2px 5px; }
.jr-quest.is-main .jr-q-tag { color: var(--gold); border-color: rgba(224, 178, 90, 0.4); }
.jr-q-summary {
  margin-top: 5px; color: var(--dim); font-size: calc(13px * var(--fs)); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.jr-quest.is-open .jr-q-summary { -webkit-line-clamp: 99; }
.jr-q-stage { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: calc(13px * var(--fs)); color: var(--glass); }
.jr-q-stagetext { min-width: 0; }
.jr-q-dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--glass); box-shadow: 0 0 0 3px rgba(143, 224, 255, 0.14); animation: jr-pulse 2s ease-in-out infinite; }
.jr-quest.is-done .jr-q-stage { color: var(--dim); }
.jr-quest.is-done .jr-q-dot { background: var(--gold); box-shadow: none; animation: none; }
@keyframes jr-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(143, 224, 255, 0.12); } 50% { box-shadow: 0 0 0 6px rgba(143, 224, 255, 0.04); } }
.jr-q-journal {
  font-family: var(--serif); font-style: italic; font-size: calc(14px * var(--fs)); line-height: 1.5; color: var(--ink);
  max-height: 0; opacity: 0; overflow: hidden; transition: max-height 0.28s ease, opacity 0.2s ease, margin 0.2s ease;
}
.jr-quest.is-open .jr-q-journal { max-height: 220px; opacity: 0.9; margin-top: 10px; }

/* ---- runes & items ---- */
.jr-card { display: flex; align-items: flex-start; gap: 11px; padding: 9px 11px; border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 9px; background: rgba(255, 255, 255, 0.02); }
.jr-sigil {
  flex: 0 0 auto; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--gold2); border: 1px solid rgba(224, 178, 90, 0.35); border-radius: 7px;
  background: radial-gradient(circle at 50% 30%, rgba(224, 178, 90, 0.18), rgba(0, 0, 0, 0));
  text-shadow: 0 0 10px rgba(255, 210, 122, 0.5);
}
.jr-rune { border-color: rgba(224, 178, 90, 0.2); }
.jr-item .jr-sigil { color: var(--glass); border-color: rgba(143, 224, 255, 0.3); background: radial-gradient(circle at 50% 30%, rgba(143, 224, 255, 0.14), rgba(0, 0, 0, 0)); text-shadow: 0 0 10px rgba(143, 224, 255, 0.4); }
.jr-card-body { display: flex; flex-direction: column; min-width: 0; }
.jr-card-name { font-family: var(--serif); font-size: calc(15px * var(--fs)); color: var(--ink); }
.jr-card-desc { margin-top: 3px; font-size: calc(12px * var(--fs)); line-height: 1.4; color: var(--dim); }
.jr-card-effect { margin-top: 4px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--gold); }

.jr-foot { display: flex; gap: 18px; justify-content: center; padding-top: 12px; border-top: 1px solid var(--line); }
.jr-legend { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); }
.jr-legend-word { opacity: 0.85; }

/* =====================================================================================
   REDUCED MOTION — the panels appear and disappear, they just stop moving.
   ===================================================================================== */
body.reduce-motion .dlg,
body.reduce-motion .dlg-panel,
body.reduce-motion .dlg-choice,
body.reduce-motion .dlg-continue,
body.reduce-motion .jr,
body.reduce-motion .jr-panel,
body.reduce-motion .jr-quest,
body.reduce-motion .jr-q-journal { transition: none !important; transform: none !important; }
body.reduce-motion .dlg-chev,
body.reduce-motion .dlg.is-typing .dlg-text::after,
body.reduce-motion .jr-q-dot { animation: none !important; }
body.reduce-motion .dlg { visibility: hidden; }
body.reduce-motion .dlg.is-open { visibility: visible; }
body.reduce-motion .jr { visibility: hidden; }
body.reduce-motion .jr.is-open { visibility: visible; }
@media (prefers-reduced-motion: reduce) {
  .dlg, .dlg-panel, .dlg-choice, .jr, .jr-panel, .jr-quest { transition-duration: 0.01s; }
  .dlg-chev, .jr-q-dot, .dlg.is-typing .dlg-text::after { animation: none; }
}

/* =====================================================================================
   NARROW SCREENS
   ===================================================================================== */
@media (max-width: 900px) {
  /* one column: the whole grid scrolls, and each column must take its content's height —
     leave min-height at 0 here and the lists spill out of their rows and overlap each other */
  .jr-cols { grid-template-columns: minmax(0, 1fr); gap: 14px; overflow-y: auto; overscroll-behavior: contain; }
  .jr-col { min-height: auto; }
  .jr-col-kit { border-left: 0; border-top: 1px solid rgba(224, 178, 90, 0.18); padding-left: 0; padding-top: 14px; }
  .jr-list { overflow: visible; max-height: none; padding-right: 0; }
}
@media (max-width: 720px) {
  .dlg { padding: 0 10px 10px; }
  .dlg-panel { gap: 12px; padding: 13px 14px 10px; border-radius: 12px; }
  .dlg-portrait { flex-basis: 62px; width: 62px; height: 62px; border-radius: 10px; }
  .dlg-text { font-size: calc(16px * var(--fs)); min-height: 2.6em; }
  .dlg-choice { font-size: calc(15px * var(--fs)); padding: 9px 12px; }
  .dlg-name { font-size: calc(11px * var(--fs)); margin-bottom: 6px; }
  .jr-panel { padding: 14px 14px 10px; max-height: 92vh; border-radius: 12px; }
  .jr-title { font-size: calc(21px * var(--fs)); }
  .jr-q-name { font-size: calc(15px * var(--fs)); }
  .jr-foot { gap: 10px; flex-wrap: wrap; }
}
@media (max-height: 520px) {
  .dlg-text { min-height: 2em; }
  .dlg-panel { padding: 12px 16px 10px; }
}
