/* style.css — noir detective look. Everything is plain CSS, no preprocessor.
   Layout model: a single always-one-column view. The root screen is the known-locations
   list; selecting one slides in a location-detail screen; interviewing slides in a
   response screen; investigating a scene slides in the scene viewer. Evidence/People/Log/
   Pinboard live behind top tabs that drop a panel down from the header; Evidence and
   People have their own nested slide-stack inside that panel. */
:root {
  --bg: #15171c; --bg2: #1d2027; --bg3: #262a33; --line: #343945;
  --ink: #e8e4da; --ink-dim: #a9a49a; --ink-mute: #726d64;
  --paper: #f1e9d6; --paper-ink: #2a2620; --paper-line: #d9cdb2;
  --amber: #e1a63b; --amber-dim: #9c7222; --red: #c23b32; --green: #4f9d69; --blue: #4d84c4;
  --radius: 8px; --shadow: 0 6px 18px rgba(0,0,0,.45);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --slide-ms: 260ms;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: clamp(15px, 1.1vw, 19px);  }
button { font: inherit; color: inherit; background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--amber-dim); background: #2e333d; }
button.primary { background: var(--amber); color: #1a1408; border-color: var(--amber); font-weight: 600; }
button.primary:hover { background: #f0b647; }
button.danger { border-color: var(--red); color: #f2a59f; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input:focus, textarea:focus, select:focus { outline: 1px solid var(--amber-dim); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--ink-dim); } .mute { color: var(--ink-mute); }
.small { font-size: 12.5px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--bg3); border: 1px solid var(--line); color: var(--ink-dim); vertical-align: middle; }
.badge.kind-physical { border-color: #7a5a2c; color: #e2b06a; }
.badge.kind-document { border-color: #4c6a8a; color: #9dc0e8; }
.badge.kind-digital { border-color: #3f7a5a; color: #8fd4ac; }
.badge.kind-lead { border-color: #7a3f6a; color: #dc9cc8; }
.badge.crime { border-color: var(--red); color: #f2a59f; }
.badge.police { border-color: var(--blue); color: #a9c8ea; }
.badge.spec-badge { border-color: var(--amber-dim); color: var(--amber); }
.cost { font-family: var(--mono); font-size: 12px; color: var(--amber); }
.back-btn { margin-bottom: 10px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-mute); margin: 14px 0 6px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- app shell ---------- */
#app { display: grid; grid-template-rows: auto 1fr; height: 100%; position: relative; }
.hdr-clock { text-align: center; }
#clock { font-family: var(--mono); font-size: 18px; letter-spacing: .04em; }
#clock-left { font-size: 11px; color: var(--ink-dim); }
#time-bar { height: 4px; background: var(--bg3); border-radius: 2px; margin: 3px auto 1px; width: 140px; overflow: hidden; }
#time-bar i { display: block; height: 100%; background: var(--amber); width: 0; transition: width .3s; }
#cost-preview { height: 16px; font-family: var(--mono); font-size: 12px; color: var(--amber); }
#cost-preview:empty::before { content: "\00a0"; }

#main { position: relative; min-height: 0; overflow: hidden; }

/* ---------- generic slide-stack (used by the location stack and inside a flap) ---------- */
.screenstack { position: relative; width: 100%; height: 100%; overflow: hidden; }
.slide-frame { position: absolute; inset: 0; overflow: auto; background: var(--bg); padding: 14px; transform: translateX(0); transition: transform var(--slide-ms) ease; }
.slide-frame.entering { transform: translateX(100%); }
.slide-frame.slide-back { transform: translateX(-100%); }
.slide-frame.slide-fwd-out { transform: translateX(100%); }

/* ---------- root: known-locations list ---------- */
.loc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.loc-card { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); cursor: pointer; height: auto; aspect-ratio: 4/3; }
.loc-card:hover { border-color: var(--amber-dim); }
.loc-card.here { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(225,166,59,.25); }
.loc-card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.loc-card-label { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 6px; flex-wrap: wrap; padding: 8px 10px; background: linear-gradient(to top, rgba(10,11,14,.92), rgba(10,11,14,.15) 70%); }
.loc-card-label .name { font-weight: 600; font-size: clamp(13.5px, 2.2vw, 17px); flex: 1 1 auto; min-width: 0; }
.loc-card-label .tag { font-size: 11px; color: var(--ink-dim); background: rgba(0,0,0,.35); padding: 1px 6px; border-radius: 8px; }

/* ---------- location detail ---------- */
.loc-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.loc-detail-right .convo-line:first-of-type { margin-top: 4px; }
@media (max-width: 700px) {
  .loc-detail-grid { grid-template-columns: 1fr; }
}
.loc-img { width: 100%; aspect-ratio: 16/7; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--bg3); display: block; }
.loc-cover-wrap { position: relative; border-radius: 6px; overflow: hidden; }
.loc-cover-wrap .loc-img { border-radius: 0; border: none; }
.loc-cover-name { position: absolute; top: 0; left: 0; right: 0; padding: 14px 10px 24px; text-align: center; font-size: clamp(18px, 3vw, 26px); font-weight: 600; background: linear-gradient(to bottom, rgba(10,11,14,.85), rgba(10,11,14,0)); }
.loc-name { font-size: clamp(18px, 3vw, 24px); margin-top: 10px; }
.loc-desc { color: var(--ink-dim); font-size: 14px; line-height: 1.45; margin: 4px 0 10px; }
.present-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
@media (min-width: 561px) and (max-width: 1024px) { .present-list { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .present-list { grid-template-columns: repeat(2, 1fr); } }
.person { position: relative; aspect-ratio: 3/4; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); cursor: pointer; transition: border-color .15s; }
.person:hover { border-color: var(--amber-dim); }
.card img.thumb { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; background: var(--bg); }
.person-cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.person-cover-label { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px; background: linear-gradient(to top, rgba(10,11,14,.92), rgba(10,11,14,.1) 75%); }
.person-cover-label .name { font-weight: 600; font-size: 13.5px; }
.person-cover-label .role { font-size: 11px; color: var(--ink-dim); }


/* ---------- interview/response screen ---------- */
.response-screen .dlg { margin-bottom: 0; }

/* ---------- top flap tabs + dropdown panel ---------- */
#flap-tabs { display: flex; align-items: center; gap: 6px; padding: 6px 14px; background: var(--bg2); border-bottom: 1px solid var(--line); position: relative; z-index: 15; flex-wrap: wrap; }
.tabs-spacer { flex: 1 1 auto; }
#flap-tabs button[data-flap] { background: transparent; border: 1px solid transparent; border-radius: 6px 6px 0 0; padding: 8px 12px; color: var(--ink-dim); }
#flap-tabs button[data-flap]:hover { color: var(--ink); }
#flap-tabs button[data-flap].active { color: var(--ink); border-color: var(--line); border-bottom-color: var(--bg); background: var(--bg); }
#flap-tabs button .n { font-size: 11px; color: var(--ink-mute); margin-left: 4px; }
#flap-overlay { position: absolute; inset: 0; top: 0; z-index: 30; background: rgba(8,9,12,.6); display: flex; align-items: flex-start; justify-content: center; }
#flap-panel { width: 100%; height: 82vh; background: var(--bg2); border: 1px solid var(--line); border-top: none; border-radius: 0 0 12px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; transform: translateY(-100%); transition: transform var(--slide-ms) ease; }
#flap-overlay.show #flap-panel { transform: translateY(0); }
.flap-hd { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.flap-hd span { flex: 1; font-weight: 600; font-size: 16px; }
#flap-body { min-height: 0; flex: 1; position: relative; overflow: hidden; }
#flap-stack { height: 100%; }
#flap-log, #flap-pin { height: 100%; padding: 14px; overflow: auto; }
#flap-pin { padding: 0; display: flex; flex-direction: column; }

/* ---------- flap: evidence/people lists + cards (also reused in the flap slide-frames) ---------- */
.filter { margin-bottom: 8px; width: 100%; }
.cardlist { display: flex; flex-direction: column; gap: 6px; }
.card { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg3); cursor: pointer; }
.card:hover { border-color: var(--amber-dim); }
.card.ev { background: var(--paper); color: var(--paper-ink); border-color: var(--paper-line); }
.card.ev .desc, .card.ev .role { color: #6b6152; }
.card .body { min-width: 0; flex: 1; } .card .name { font-weight: 600; font-size: 14px; }
.card .desc { font-size: 12px; line-height: 1.35; color: var(--ink-dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .role { font-size: 12px; color: var(--ink-dim); }
.card img.thumb.sq { border-radius: 4px; }
.card.new { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.9); box-shadow: 0 0 0 6px rgba(225,166,59,.4);} 100% { transform: none; } }
.card.expanded .desc { -webkit-line-clamp: unset; }

/* evidence: pick a target (person or specialist) */
.evidence-target-list { display: flex; flex-direction: column; gap: 6px; }
.evidence-target { display: flex; justify-content: space-between; align-items: center; text-align: left; padding: 9px 12px; }
.evidence-target.here { border-color: var(--amber-dim); }
.evidence-target .tag { font-size: 11px; color: var(--ink-dim); }
.evidence-target .tag.mute { color: var(--ink-mute); }

/* inline confirm card (travel-before-showing) — appears within the target-list screen, not a new slide */
.inline-confirm { border: 1px solid var(--amber-dim); background: #2a2519; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; animation: fadein .2s; }
.inline-confirm p { margin: 0 0 10px; line-height: 1.45; }
.inline-confirm .actions-row { margin-top: 0; }

/* people: BIO + conversation */
.person-modal-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.person-modal-head img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex: none; }
.person-modal-head .role { color: var(--ink-dim); font-size: 14px; }
.person-bio { line-height: 1.5; color: var(--ink-dim); margin-bottom: 6px; }
.convo-line { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: var(--bg3); }
.convo-line .top { display: flex; gap: 8px; font-size: 12px; color: var(--ink-dim); margin-bottom: 4px; }
.convo-line .top .t { font-family: var(--mono); color: var(--amber); }
.convo-line .top .title { font-weight: 600; color: var(--ink); }
.convo-line .text { line-height: 1.45; white-space: pre-line; }
.ask-list { display: flex; flex-direction: column; gap: 6px; }
.ask-list button { text-align: left; padding: 8px 10px; }

/* ---------- dialogue result element (reused: response screen, evidence/ask results) ---------- */
.dlg { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--bg3); animation: fadein .25s; }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px);} to { opacity: 1; transform: none;} }
.dlg .head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.dlg .head img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.dlg .who { font-weight: 600; } .dlg .what { font-size: 12px; color: var(--ink-dim); }
.dlg .text { line-height: 1.5; white-space: pre-line; }
.dlg.generic .text { color: var(--ink-dim); font-style: italic; }
.dlg .gained { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.dlg .gained span { background: var(--paper); color: var(--paper-ink); padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.dlg.event { border-color: var(--amber-dim); background: #2a2519; }
.dlg.briefing { background: var(--paper); color: var(--paper-ink); border-color: var(--paper-line); }
.dlg.briefing .what, .dlg.briefing .who { color: #5a5044; }
.dlg .meta { display: flex; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--ink-mute); }

/* ---------- log ---------- */
.log-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.log-tools input { flex: 1; min-width: 180px; }
.logentry { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; background: var(--bg3); }
.logentry .top { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-dim); }
.logentry .top .t { font-family: var(--mono); color: var(--amber); }
.logentry .top .title { color: var(--ink); font-weight: 600; flex: 1; }
.logentry .text { margin: 6px 0; line-height: 1.45; white-space: pre-line; }
.logentry.generic .text { color: var(--ink-dim); font-style: italic; }
mark { background: var(--amber); color: #1a1408; padding: 0 2px; border-radius: 2px; }

/* ---------- pinboard ---------- */
.pb-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pb-tools select { max-width: 260px; }
.pb-tools button.active { border-color: var(--amber); background: #2b2a20; }
#pb-canvas { position: relative; flex: 1; min-height: 0; overflow: auto; background: #6f4e2f radial-gradient(rgba(0,0,0,.15) 1px, transparent 1px) 0 0/10px 10px; background-blend-mode: multiply; }
#pb-inner { position: relative; width: 2400px; height: 1600px; }
#pb-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#pb-svg line { stroke: #c9302c; stroke-width: 3; stroke-linecap: round; pointer-events: stroke; cursor: pointer; }
#pb-svg line:hover { stroke: #ff5a52; }
#pb-svg text { fill: #fff; font-size: 12px; paint-order: stroke; stroke: rgba(0,0,0,.6); stroke-width: 3px; pointer-events: none; }
.pbcard { position: absolute; width: 170px; background: var(--paper); color: var(--paper-ink); border-radius: 4px; padding: 8px 10px 8px; box-shadow: 0 4px 10px rgba(0,0,0,.45); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
.pbcard::before { content: ""; position: absolute; top: -6px; left: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--red); transform: translateX(-50%); box-shadow: 0 1px 2px rgba(0,0,0,.5); }
.pbcard.char { background: #e9e2d0; } .pbcard.loc { background: #d8e2ea; } .pbcard.spec { background: #dfe8d8; }
.pbcard img { width: 100%; height: 70px; object-fit: cover; border-radius: 3px; display: block; margin-bottom: 6px; }
.pbcard .name { font-weight: 600; font-size: 13px; } .pbcard .sub { font-size: 11px; color: #6b6152; }
.pbcard.linksrc { outline: 3px solid var(--amber); }
.pbcard .x { position: absolute; right: 4px; top: 2px; font-size: 12px; color: #9a8f7c; cursor: pointer; }
.pb-empty { position: absolute; left: 20px; top: 20px; color: rgba(255,255,255,.7); font-size: 14px; max-width: 360px; }

/* ---------- generic overlay (scene viewer, endgame, menu) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8,9,12,.78); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay .panel { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.overlay .panel.narrow { width: min(560px, 100%); }
.overlay .panel > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.overlay .panel > header h2 { flex: 1; margin: 0; font-size: 18px; }
.overlay .panel > .content { padding: 14px 16px; overflow: auto; min-height: 0; }

/* scene viewer slides in from the right like any other screen, full-bleed */
.overlay.slide-overlay { background: transparent; padding: 0; align-items: stretch; justify-content: stretch; transform: translateX(100%); transition: transform var(--slide-ms) ease; pointer-events: none; }
.overlay.slide-overlay.show { transform: translateX(0); pointer-events: auto; }
.overlay.slide-overlay .panel { width: 100%; height: 100%; border-radius: 0; border: none; }

/* ---------- designed confirm/alert (replaces window.confirm/alert everywhere) ---------- */
#confirm-overlay { z-index: 200; animation: fadein .15s; }
#confirm-overlay.closing { opacity: 0; transition: opacity .15s; }
.confirm-card { background: var(--bg2); border: 1px solid var(--amber-dim); border-radius: 12px; padding: 18px 20px; width: min(420px, 100%); box-shadow: var(--shadow); }
.confirm-card h3 { font-size: 15px; }
.confirm-card p { line-height: 1.5; margin: 0 0 14px; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- drag ghost (kept for the speak button ripple-free click area, harmless if unused) ---------- */
#drag-ghost { position: fixed; z-index: 1000; pointer-events: none; opacity: .9; }

/* ---------- menu ---------- */
.caselist { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 560px) { .caselist { grid-template-columns: 1fr; } }
.caselist .case { text-align: left; padding: 0; display: block; overflow: hidden; }
.caselist .case .case-img { display: block; width: 100%; height: 160px; object-fit: cover; }
.caselist .case .case-body { padding: 12px; }
.caselist .case .t { font-weight: 600; font-size: 16px; } .caselist .case .s { color: var(--ink-dim); font-size: 13px; }
.menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.brief { background: var(--paper); color: var(--paper-ink); padding: 14px 16px; border-radius: 8px; line-height: 1.55; white-space: pre-line; font-size: 15px; }
 

/* ---------- scene viewer internals ---------- */
#scene-view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #0c0d10; cursor: grab; touch-action: none; }
#scene-view.panning { cursor: grabbing; }
#scene-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#scene-stage > img, #scene-stage > svg.bg { position: absolute; left: 0; top: 0; display: block; }
.hotspot { position: absolute; border-radius: 6px; cursor: pointer; transition: box-shadow .15s, background .15s; }
.hotspot:hover { background: rgba(225,166,59,.10); box-shadow: inset 0 0 0 2px rgba(225,166,59,.55); }
.hotspot.found { box-shadow: inset 0 0 0 2px rgba(79,157,105,.7); background: rgba(79,157,105,.12); }
.hotspot.seen:not(.found) { box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.scene-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#scene-msg { position: absolute; left: 12px; right: 12px; bottom: 12px; background: rgba(29,32,39,.95); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; max-width: 560px; line-height: 1.45; box-shadow: var(--shadow); }
#scene-msg .gained { color: var(--amber); font-weight: 600; margin-top: 4px; }
#scene-msg .x { float: right; cursor: pointer; color: var(--ink-dim); margin-left: 10px; }

/* ---------- endgame ---------- */
.quiz-q { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: var(--bg3); }
.quiz-q .q { font-weight: 600; margin-bottom: 8px; } .quiz-q .pts { color: var(--ink-mute); font-weight: 400; font-size: 12px; }
.quiz-q label { display: block; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.quiz-q label:hover { background: var(--bg2); }
.quiz-q label input { margin-right: 8px; }
.quiz-q.ok { border-color: var(--green); } .quiz-q.bad { border-color: var(--red); }
.quiz-q .expl { margin-top: 8px; font-size: 13px; color: var(--ink-dim); line-height: 1.45; }
.scorebox { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; text-align: center; }
.scorebox div { background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.scorebox b { display: block; font-size: 26px; font-family: var(--mono); color: var(--amber); }
.scorebox .rank b { font-size: 18px; font-family: var(--font); }
.debrief { background: var(--paper); color: var(--paper-ink); padding: 14px 16px; border-radius: 8px; line-height: 1.55; white-space: pre-line; margin-top: 12px; }
.timeline { list-style: none; padding: 0; margin: 10px 0; }
.timeline li { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.timeline li .t { font-family: var(--mono); color: var(--amber); }
.deadends li { margin-bottom: 6px; line-height: 1.4; }

/* ---------- toast ---------- */
#toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--amber-dim); padding: 8px 14px; border-radius: 8px; z-index: 200; box-shadow: var(--shadow); font-size: 14px; max-width: 80vw; }

/* ---------- responsive: relative sizing only, layout stays single-column everywhere ---------- */
@media (max-width: 480px) {
  .scorebox { grid-template-columns: 1fr 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}
