/* Boston 1775-1776 viewer (sibling of LucidBox projects/Hanover/web/css/style.css @ a4c3df419).
   Archival parchment UI; fixed left options panel; right inspector card; north arrow & scalebar bottom right;
   blue (i) sources/credits pop-out bottom left. */
:root {
  --bg: #f4efe2; --panel: rgba(250, 246, 236, 0.94); --ink: #2a2116; --muted: #6c604e; --line: #d6c9ae;
  --accent: #3d5a47; --accent-2: #8a4b2a; --field: #fbf8f0;
  --font: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1813; --panel: rgba(30, 27, 21, 0.94); --ink: #ece4d2; --muted: #b2a68f; --line: #4a4233;
    --accent: #8fb49c; --accent-2: #e09a6a; --field: #26221b; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 14px/1.4 var(--font); }
#view { position: fixed; inset: 0; }
#view canvas { display: block; }
#view canvas.pointing { cursor: pointer; }

/* Loading overlay (Hanover pattern) */
#loading {
  position: fixed; inset: 0; display: grid; place-items: center; color: var(--ink); background: var(--bg); z-index: 60;
  padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab));
  transition: opacity 0.45s, background-color 0.5s;
}
#loading.done { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.45s, visibility 0s 0.45s; }
#ldBox { width: min(100%, 400px); padding: 18px 20px 16px; text-align: center; border-radius: 10px; }
#ldHead { margin: 0 0 12px; font-size: 22px; font-style: italic; }
#ldBar { height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--line) 70%, transparent); border: 1px solid var(--line); overflow: hidden; }
#ldFill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width 0.2s linear; }
#ldNow { margin: 10px 0 2px; font-size: 15px; min-height: 1.4em; }
#ldPct { margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
#loading.error #ldErr { margin: 12px 0 14px; font-size: 15px; color: var(--accent-2); }

/* Left controls panel */
#panel {
  position: fixed; top: calc(12px + var(--sat)); left: 12px; bottom: calc(50px + var(--sab)); width: 304px;
  overflow-y: auto; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; z-index: 5; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
}
#panel.collapsed { display: none; }
#panelToggle {
  position: fixed; top: calc(12px + var(--sat)); left: 12px; z-index: 6;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 10px; font: 13px var(--font); color: var(--ink); cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
#panelToggle:hover { border-color: var(--accent); }
body.panel-open #panelToggle { left: 324px; }

h1 { font-size: 23px; margin: 0 0 4px; font-weight: normal; letter-spacing: 0.01em; }
h1 em { color: var(--accent-2); }
h2 { font-size: 15px; margin: 2px 0 6px; font-weight: normal; }
.sub { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.badge {
  display: inline-block; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 4px; padding: 1px 6px; margin-bottom: 6px;
}
section { border-top: 1px solid var(--line); padding: 8px 0; }
.eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.date-row { display: flex; align-items: center; gap: 8px; }
.date-row output { margin-left: auto; font-size: 17px; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.muted { color: var(--muted); margin: 3px 0 0; font-size: 12px; line-height: 1.4; }
.check { display: flex; align-items: center; gap: 6px; margin: 4px 0; cursor: pointer; font-size: 13px; }
.check .n { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="checkbox"] { accent-color: var(--accent); }
#planOpacity { margin: 0 0 4px 22px; width: calc(100% - 22px); }
.buttons { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
button {
  font: 12.5px var(--font); color: var(--ink); background: transparent; border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 8px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.icon { min-width: 2em; text-align: center; }
button.active, button[aria-pressed="true"] {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent);
}
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.disclosure-box {
  margin-top: 6px; padding: 7px 9px; border-radius: 6px; font-size: 11.5px; line-height: 1.42;
  background: color-mix(in srgb, var(--accent-2) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-2) 28%, transparent);
  color: var(--ink);
}
.disclosure-box strong { color: var(--accent-2); }

/* Folded sections (Hanover panelfold.js) */
#panel section.folded > :not(.foldHead) { display: none; }
#panel .foldHead .foldLabel { cursor: pointer; user-select: none; }
#panel h2.foldHead { display: flex; align-items: center; gap: 6px; }
#panel .foldBtn {
  flex: none; width: 22px; height: 22px; padding: 0; border: 0; background: none; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 22px; border-radius: 4px;
}
#panel .date-row .foldBtn { order: 99; margin-left: 2px; }
#panel .foldBtn:hover { background: rgba(127, 127, 127, 0.18); }
#panel .foldBtn span { display: inline-block; transition: transform 0.15s; }
#panel section.folded .foldBtn span { transform: rotate(-90deg); }

/* Right inspector card */
#inspect {
  position: fixed; top: calc(64px + var(--sat)); right: 12px; width: 332px;
  max-height: calc(100% - 190px - var(--sat) - var(--sab)); overflow-y: auto;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; z-index: 6; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
}
#inspect h2 { margin: 0 24px 2px 0; font-size: 17px; }
#inspect .kind { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-style: italic; }
#inspect table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
#inspect th { text-align: left; vertical-align: top; color: var(--muted); font-weight: normal; padding: 2px 8px 2px 0; white-space: nowrap; }
#inspect td { padding: 2px 0; overflow-wrap: anywhere; }
#inspect .note { font-size: 12.5px; line-height: 1.45; margin: 8px 0 0; }
#inspect .src { font-size: 11px; color: var(--muted); margin: 6px 0 0; }
#closeInspect { position: absolute; top: 8px; right: 8px; border: none; font-size: 18px; min-width: 0; padding: 0 6px; }

/* HUD bottom-right: Home, North rose, Scalebar (Hanover exact pattern) */
#homeView {
  position: fixed; right: 18px; bottom: calc(106px + var(--sab)); width: 38px; height: 38px;
  border-radius: 50%; background: var(--panel); border: 1px solid var(--line);
  font-size: 19px; line-height: 1; cursor: pointer; z-index: 4; color: var(--ink); padding: 0;
}
#homeView:hover { border-color: var(--accent); }
#north {
  position: fixed; right: 18px; bottom: calc(60px + var(--sab)); width: 38px; height: 38px;
  border-radius: 50%; background: var(--panel); border: 1px solid var(--line);
  text-align: center; font-size: 11px; line-height: 1; padding-top: 4px; z-index: 4;
  transform: rotate(var(--heading, 0rad));
}
#north span { display: block; color: var(--accent-2); font-size: 13px; }
#north b { font-weight: normal; }
#scalebar {
  position: fixed; right: 18px; bottom: calc(28px + var(--sab)); font-size: 12px;
  display: flex; align-items: center; gap: 6px; z-index: 4;
  background: var(--panel); border: 1px solid var(--line); padding: 2px 7px; border-radius: 4px;
}
#scalebarBar { width: var(--bar, 60px); height: 6px; border: 1.5px solid var(--ink); border-top: none; }

/* Sources & credits pop-out bottom left (Hanover exact pattern) */
#creditsBtn {
  position: fixed; left: 12px; bottom: calc(12px + var(--sab)); z-index: 45; width: 26px; height: 26px;
  padding: 0; border-radius: 50%; border: 0; background: #2f6fb7; color: #fff;
  font: italic 700 15px/26px Georgia, "Times New Roman", serif; text-align: center;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
#creditsBtn:hover, #creditsBtn[aria-expanded="true"] { background: #245a96; }
#credits {
  position: fixed; left: 12px; bottom: calc(46px + var(--sab)); z-index: 45;
  width: min(460px, calc(100vw - 24px)); max-height: min(62vh, 430px); overflow-y: auto;
  font-size: 12px; line-height: 1.48; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
#credits .creditsHead { display: block; margin-bottom: 4px; font-size: 13px; }
#credits p { margin: 5px 0; }

/* TimeWalk logo top-right */
#twLogo {
  position: fixed; top: calc(14px + var(--sat)); right: 16px; z-index: 20; width: 146px; height: auto;
  opacity: 0.78; pointer-events: none; user-select: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* CSS2D Geographic Reference Labels (Hanover paper-tag style) */
.lbl {
  font: 12px var(--font); color: #231a10; background: rgba(250, 246, 236, 0.88);
  padding: 2px 7px; border-radius: 3px; white-space: nowrap; pointer-events: auto; cursor: pointer;
  transform: translateY(-50%); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); border: 1px solid rgba(120, 102, 74, 0.32);
}
.lbl:hover { background: #fffdf7; border-color: var(--accent); }
.lbl-landmark { font-weight: 600; color: #2a2116; }
.lbl-waterway {
  background: rgba(232, 241, 248, 0.86); color: #1d3f5c; font-style: italic;
  letter-spacing: 0.08em; border-color: rgba(45, 92, 128, 0.28);
}

@media (max-width: 720px) {
  #panel { top: auto; left: 10px; right: 10px; bottom: calc(46px + var(--sab)); width: auto; max-height: 44%; }
  body.panel-open #panelToggle { left: 10px; }
  #inspect { left: 10px; right: 10px; width: auto; max-height: 40%; }
  #twLogo { width: 102px; top: calc(12px + var(--sat)); right: 10px; }
}

#panelMin { position:absolute; top:6px; right:6px; width:28px; height:28px; padding:0; font:20px/1 sans-serif; color:var(--ink); background:var(--panel); border:1px solid var(--line); border-radius:4px; cursor:pointer; }
#panel header .badge { max-width:calc(100% - 32px); }
#panelToggle[hidden] { display:none; }
