/* ============================================================================
   An Atlas of Imperial Careers — night-atlas + blue-book register
   Two surfaces, one method: the dark map is the data/territory; the parchment
   panel is the printed List it was drawn from.
   ========================================================================== */
:root{
  --ink:#0E1622;        /* night-atlas ground */
  --ink-2:#0a1019;      /* deeper wells */
  --paper:#E7DCC4;      /* blue-book parchment */
  --paper-2:#DBCDAE;    /* parchment shadow/edge */
  --co:#8FB8EE;         /* Colonial Office steel-blue */
  --io:#E8B24C;         /* India Office gold */
  --oxblood:#7A2E2A;    /* printers' red — year-rail, active */
  --slate:#2A3340;      /* ink-on-paper text */
  --slate-2:#5b6675;    /* secondary ink */
  --gold-soft:#ffd98a;  /* luminous HUD gold (from the videos) */
  --serif:"Newsreader",Georgia,"Times New Roman",serif;
  --mono:"IBM Plex Mono",ui-monospace,Menlo,Consolas,monospace;
  --sans:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --reg-w:392px;       /* parchment register width; timeline tracks its edge */
  --edge:28px;         /* gutter for masthead / rail / timeline */
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden;background:var(--ink);color:#e7eef6;font-family:var(--sans)}
button{font-family:inherit;cursor:pointer}

/* ---- map + arc canvas ---------------------------------------------------- */
#map{position:absolute;inset:0;background:var(--ink);z-index:1}
#arc-canvas{position:absolute;inset:0;z-index:400;pointer-events:none}
.leaflet-control-attribution{font-size:10px;background:rgba(14,22,34,.6)!important;color:#6b7889!important}
.leaflet-control-attribution a{color:#8794a6!important}
.leaflet-control-zoom{display:none}

/* ---- masthead ------------------------------------------------------------ */
#masthead{position:absolute;z-index:600;top:22px;left:var(--edge);max-width:540px;
  text-shadow:0 2px 14px rgba(0,0,0,.8);pointer-events:none}
#masthead .kicker{font-family:var(--mono);font-size:11px;letter-spacing:.16em;
  text-transform:uppercase;color:var(--gold-soft);opacity:.85}
#masthead h1{margin:.18em 0 0;font-family:var(--serif);font-weight:400;
  font-size:clamp(26px,3.4vw,42px);letter-spacing:.01em;color:#fbf4e3;line-height:1.02}
#masthead .standfirst{margin:.5em 0 0;font-family:var(--serif);font-size:16px;
  font-weight:300;color:#d7e0ea;max-width:30em;line-height:1.4}
#masthead .standfirst span{color:var(--gold-soft);font-variant-numeric:tabular-nums}

/* ---- service / filter rail ---------------------------------------------- */
#rail{position:absolute;z-index:600;left:var(--edge);bottom:96px;display:flex;flex-direction:column;
  gap:8px;align-items:flex-start}
.svc{display:flex;align-items:center;gap:9px;border:1px solid rgba(255,255,255,.14);
  background:rgba(12,20,32,.72);backdrop-filter:blur(6px);color:#cdd7e3;
  padding:8px 13px 8px 11px;border-radius:3px;font-size:13px;letter-spacing:.01em;
  transition:opacity .15s,border-color .15s}
.svc i{width:11px;height:11px;border-radius:2px;display:inline-block}
.svc-co i{background:var(--co)} .svc-io i{background:var(--io)}
.svc em{font-family:var(--mono);font-style:normal;font-size:11px;color:#8b97a7;margin-left:4px;
  font-variant-numeric:tabular-nums}
.svc:not(.on){opacity:.38}
.svc-co.on{border-color:rgba(143,184,238,.55)} .svc-io.on{border-color:rgba(232,178,76,.55)}
#rail-reset{background:none;border:none;color:#8794a6;font-size:12px;
  padding:2px 4px;text-decoration:underline;text-underline-offset:3px;opacity:.8}
#rail-reset:hover{opacity:1;color:#cdd7e3}

/* ---- timeline ------------------------------------------------------------ */
#timeline{position:absolute;z-index:600;left:var(--edge);right:var(--reg-w);bottom:26px;
  display:flex;align-items:center;gap:14px}
#tl-play{width:40px;height:40px;flex:0 0 auto;border-radius:50%;border:1px solid rgba(255,255,255,.22);
  background:rgba(12,20,32,.8);color:var(--gold-soft);font-size:14px;line-height:1}
#tl-play:hover{border-color:var(--gold-soft)}
#tl-track{position:relative;flex:1 1 auto;height:54px}
#tl-hist{position:absolute;inset:0;width:100%;height:100%}
#tl-range{position:absolute;left:0;right:0;bottom:-2px;width:100%;margin:0;background:transparent;
  -webkit-appearance:none;appearance:none}
#tl-range::-webkit-slider-runnable-track{height:2px;background:rgba(255,255,255,.22)}
#tl-range::-moz-range-track{height:2px;background:rgba(255,255,255,.22)}
#tl-range::-webkit-slider-thumb{-webkit-appearance:none;width:3px;height:54px;margin-top:-52px;
  background:var(--gold-soft);box-shadow:0 0 10px rgba(255,217,138,.7);border:0;border-radius:0;cursor:ew-resize}
#tl-range::-moz-range-thumb{width:3px;height:54px;background:var(--gold-soft);border:0;border-radius:0;cursor:ew-resize}
#tl-year{font-family:var(--mono);font-size:30px;font-weight:600;color:var(--gold-soft);
  flex:0 0 auto;width:2.8em;text-align:right;font-variant-numeric:tabular-nums;
  text-shadow:0 2px 10px rgba(0,0,0,.7)}

/* ============================================================================
   PARCHMENT REGISTER — the signature surface
   ========================================================================== */
#register{position:absolute;z-index:650;top:0;right:0;bottom:0;width:var(--reg-w);
  background:
    radial-gradient(120% 80% at 80% -10%, rgba(255,255,255,.35), transparent 60%),
    linear-gradient(180deg,var(--paper) 0%, var(--paper-2) 100%);
  color:var(--slate);box-shadow:-14px 0 40px rgba(0,0,0,.45);
  display:flex;flex-direction:column;border-left:1px solid #c9b994}
#register::before{content:"";position:absolute;inset:0;pointer-events:none;opacity:.5;
  background-image:repeating-linear-gradient(180deg,transparent 0 27px,rgba(122,46,42,.045) 27px 28px)}

#reg-search{position:relative;padding:16px 20px 12px;border-bottom:1px solid #cbbc98;flex:0 0 auto}
#search-box{width:100%;padding:9px 12px;border:1px solid #b6a47e;border-radius:3px;
  background:rgba(255,255,255,.4);font-family:var(--serif);font-size:15px;color:var(--slate)}
#search-box::placeholder{color:#8a7f66;font-style:italic}
#search-box:focus{outline:none;border-color:var(--oxblood);box-shadow:0 0 0 2px rgba(122,46,42,.15)}
#search-results{position:absolute;left:20px;right:20px;top:58px;z-index:5;margin:0;padding:0;
  list-style:none;background:#f3ecda;border:1px solid #b6a47e;border-radius:3px;max-height:320px;
  overflow:auto;box-shadow:0 12px 28px rgba(0,0,0,.25)}
#search-results li{padding:7px 12px;font-size:13.5px;border-bottom:1px solid #e3d8bf;cursor:pointer;
  display:flex;justify-content:space-between;gap:8px;align-items:baseline}
#search-results li:hover,#search-results li.sel{background:#e7dcc0}
#search-results li .nm{font-family:var(--serif)}
#search-results li .tag{font-family:var(--mono);font-size:10px;padding:1px 5px;border-radius:2px;color:#fff;flex:0 0 auto}
.tag.co{background:#4f76ad}.tag.io{background:#b07d24}

#reg-body{flex:1 1 auto;overflow-y:auto;padding:18px 20px 24px}
#reg-foot{flex:0 0 auto;display:flex;justify-content:space-between;align-items:center;
  padding:9px 20px;border-top:1px solid #cbbc98;font-family:var(--mono);font-size:10.5px;color:#7d7257}
#neo-badge{display:inline-flex;align-items:center;gap:6px}
#neo-badge::before{content:"";width:7px;height:7px;border-radius:50%;background:#b3322c}
#neo-badge.on::before{background:#3f8a4a}
#reg-foot a{color:#7d7257;text-decoration:underline;text-underline-offset:2px}
.foot-links{display:flex;gap:14px;align-items:center}
#to-schools{color:#8a5a2b;font-weight:500}

/* ---- register: default / summary state ---------------------------------- */
.reg-h{font-family:var(--mono);font-size:11px;letter-spacing:.14em;text-transform:uppercase;
  color:var(--oxblood);margin:0 0 10px;padding-bottom:6px;border-bottom:1.5px solid var(--oxblood)}
.reg-lede{font-family:var(--serif);font-size:15.5px;line-height:1.5;color:#3c4452;margin:0 0 16px}
.stat-row{display:flex;gap:18px;margin:14px 0 18px;font-variant-numeric:tabular-nums}
.stat{flex:1}
.stat b{display:block;font-family:var(--mono);font-size:23px;color:var(--slate);font-weight:600}
.stat span{font-size:11px;color:var(--slate-2);text-transform:uppercase;letter-spacing:.06em}
.tour-list{list-style:none;margin:6px 0 0;padding:0}
.tour-list li{padding:12px 0;border-top:1px solid #cbbc98;cursor:pointer}
.tour-list li:hover .tl-t{color:var(--oxblood)}
.tl-t{font-family:var(--serif);font-size:17px;color:var(--slate);margin-bottom:2px}
.tl-b{font-size:12.5px;color:var(--slate-2);line-height:1.4}

/* ---- register: Record of Services (signature) --------------------------- */
.ros-name{font-family:var(--serif);font-weight:500;font-size:23px;letter-spacing:.04em;
  line-height:1.1;color:var(--slate);margin:0}
.ros-name .giv{display:block;font-size:15px;font-weight:400;letter-spacing:.02em;color:#4a5260;margin-top:2px}
.ros-meta{font-family:var(--mono);font-size:11px;color:var(--slate-2);margin:8px 0 4px;
  display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.ros-meta .corp{padding:1px 6px;border-radius:2px;color:#fff;font-size:10px}
.ros-meta a{color:var(--oxblood)}
.ros-rule{border:0;border-top:1.5px solid var(--oxblood);margin:10px 0 4px}
.ros-list{margin:0;padding:0;list-style:none}
.ros-entry{display:grid;grid-template-columns:3.4em 1fr;gap:12px;padding:7px 0;
  border-left:2px solid var(--oxblood);padding-left:13px;margin-left:2px;position:relative;cursor:pointer}
.ros-entry:hover,.ros-entry.on{background:rgba(122,46,42,.07)}
.ros-entry .yr{font-family:var(--mono);font-size:13px;color:var(--oxblood);font-weight:500;
  padding-top:1px;font-variant-numeric:tabular-nums}
.ros-entry .pos{font-family:var(--serif);font-size:15px;color:#2c333f;line-height:1.32}
.ros-entry .pl{display:block;font-size:12px;font-variant:small-caps;letter-spacing:.04em;color:var(--slate-2)}
.ros-entry .pos em{font-style:italic;color:#7a6a3f}
.ros-entry .role-link{color:inherit;text-decoration:none;cursor:pointer;
  border-bottom:1px dotted rgba(122,46,42,.5)}
.ros-entry .role-link:hover{color:var(--oxblood);border-bottom-color:var(--oxblood)}
.ros-entry .role-link.on{color:var(--oxblood);border-bottom-style:solid}
.ros-note{font-size:12px;color:var(--slate-2);font-style:italic;margin-top:12px;padding-top:10px;
  border-top:1px dotted #b6a47e}

/* ---- register: place corridor view -------------------------------------- */
.reg-hint{font-family:var(--sans);font-size:10px;letter-spacing:0;text-transform:none;color:var(--slate-2);font-weight:400}
.cor-list{list-style:none;margin:6px 0 0;padding:0;font-size:13px}
.cor-list li{display:flex;justify-content:space-between;gap:10px;padding:6px 8px;margin:0 -8px;border-top:1px solid #d6c9a9}
.cor-list .ct{font-family:var(--mono);color:var(--oxblood);font-variant-numeric:tabular-nums}
.cor-row{cursor:pointer;border-radius:3px}
.cor-row:hover{background:rgba(122,46,42,.08)}
.cor-row.on{background:rgba(122,46,42,.14)}
.ppl-list{list-style:none;margin:8px 0 0;padding:0;font-size:13.5px}
.ppl-list li{padding:5px 8px;margin:0 -8px;cursor:pointer;font-family:var(--serif);
  display:flex;justify-content:space-between;align-items:baseline;border-bottom:1px solid #e0d4b8}
.ppl-list li:hover{color:var(--oxblood);background:rgba(122,46,42,.06)}
.ppl-list .py{font-family:var(--mono);font-size:11px;color:var(--slate-2);font-variant-numeric:tabular-nums}

/* ---- guided-tour overlay ------------------------------------------------ */
#tour{position:absolute;inset:0;z-index:800;background:rgba(8,13,22,.35);
  display:flex;align-items:flex-end;justify-content:flex-start;pointer-events:none}
#tour[hidden]{display:none}
#tour-card{pointer-events:auto}
#tour-card{margin:0 0 120px var(--edge);max-width:430px;
  background:linear-gradient(180deg,var(--paper),var(--paper-2));color:var(--slate);
  padding:22px 24px;border-radius:4px;box-shadow:0 20px 50px rgba(0,0,0,.55);border:1px solid #c9b994}
#tour-title{font-family:var(--serif);font-size:22px;color:var(--slate);margin-bottom:8px}
#tour-caption{font-family:var(--serif);font-size:16px;line-height:1.5;color:#3c4452;margin:0 0 18px;min-height:3em}
#tour-nav{display:flex;align-items:center;gap:14px}
#tour-dots{flex:1 1 auto;display:flex;gap:6px}
#tour-dots i{width:7px;height:7px;border-radius:50%;background:#bcab85;display:inline-block}
#tour-dots i.on{background:var(--oxblood)}
#tour-next{background:var(--oxblood);color:#fff;border:0;padding:8px 16px;border-radius:3px;font-size:13px}
#tour-skip{background:none;border:0;color:var(--slate-2);font-size:12.5px;text-decoration:underline;text-underline-offset:3px}

/* ============================================================================
   MEDIUM — laptops (≈13–16"). The full-desktop chrome is sized for a 27–32"
   display; here it crowds. We keep the same two surfaces but draw the register
   narrower and step the type/stat scale down a notch so the map breathes.
   Disjoint from the mobile range below (min-width:821) so the two never fight.
   ========================================================================== */
@media (min-width:821px) and (max-width:1536px){
  :root{--reg-w:clamp(312px,25vw,360px);--edge:20px}

  /* masthead: smaller display, keep the thesis (standfirst) but tighter */
  #masthead{top:16px;max-width:44vw}
  #masthead h1{font-size:clamp(23px,2.7vw,33px)}
  #masthead .standfirst{font-size:14px;margin-top:.4em;line-height:1.35}

  /* filter rail + timeline ride a little lower-profile */
  #rail{bottom:86px;gap:7px}
  .svc{padding:7px 11px;font-size:12px}
  #rail-bridges,#rail-schools{padding:6px 11px}
  #tl-play{width:36px;height:36px}
  #tl-track{height:46px}
  #tl-range::-webkit-slider-thumb{height:46px;margin-top:-44px}
  #tl-range::-moz-range-thumb{height:46px}
  #tl-year{font-size:23px}

  /* register interior: trim padding + step the type scale down one notch so
     a corridor list and the guided tours both fit without scrolling */
  #reg-search{padding:13px 16px 10px}
  #search-box{font-size:14px}
  #reg-body{padding:14px 16px 20px}
  .reg-h{font-size:10px;margin-bottom:8px;padding-bottom:5px}
  .reg-lede{font-size:14px;line-height:1.45;margin-bottom:12px}
  .stat-row{gap:12px;margin:10px 0 14px}
  .stat b{font-size:19px}
  .stat span{font-size:10px}
  .cor-list{font-size:12px}
  .cor-list li{padding:5px 8px}
  .tour-list li{padding:10px 0}
  .tl-t{font-size:15px}
  .tl-b{font-size:12px}
  .ros-name{font-size:20px}
  .ros-entry .pos{font-size:14px}
  #reg-foot{padding:8px 16px}
}

/* Short laptops (≤860px tall) get an extra vertical squeeze regardless of width:
   the masthead and timeline are the chrome most likely to crowd the map here. */
@media (min-width:821px) and (max-height:860px){
  #masthead{top:14px}
  #masthead h1{font-size:clamp(22px,2.4vw,30px)}
  #masthead .standfirst{font-size:13.5px;margin-top:.35em}
  #rail{bottom:80px;gap:6px}
  #tl-track{height:42px}
  #tl-range::-webkit-slider-thumb{height:42px;margin-top:-40px}
  #tl-range::-moz-range-thumb{height:42px}
  #tour-card{margin-bottom:96px}
}

/* ============================================================================
   MOBILE — the chrome folds down for phones; the map (and its arcs) keep most
   of the screen, and the parchment register becomes a draggable bottom sheet
   (peek → half → full), driven by mobile-sheet.js.
   ========================================================================== */
@media (max-width:820px){
  :root{--peek:58px}

  /* compact masthead, full bleed, never blocking taps */
  #masthead{top:12px;left:16px;right:16px;max-width:none}
  #masthead h1{font-size:clamp(21px,6.6vw,30px)}
  #masthead .standfirst{font-size:13px;line-height:1.35;max-width:26em}

  /* service filters: one horizontally-scrollable row of chips, above the timeline */
  #rail{left:10px;right:10px;bottom:calc(var(--peek) + 64px);flex-direction:row;flex-wrap:nowrap;
    gap:8px;align-items:center;overflow-x:auto;padding:2px 2px 4px;-webkit-overflow-scrolling:touch;
    scrollbar-width:none}
  #rail::-webkit-scrollbar{display:none}
  .svc,#rail-bridges,#rail-schools,#rail-reset{flex:0 0 auto;white-space:nowrap}
  .svc{padding:9px 13px}

  /* timeline: full width, sitting just above the peeking sheet */
  #timeline{left:12px;right:12px;bottom:calc(var(--peek) + 8px);gap:10px}
  #tl-play{width:38px;height:38px}
  #tl-track{height:46px}
  #tl-range::-webkit-slider-thumb{height:46px;margin-top:-44px;width:4px}
  #tl-range::-moz-range-thumb{height:46px;width:4px}
  #tl-year{font-size:21px;width:2.5em}

  /* ---- the bottom sheet (only once mobile-sheet.js has upgraded it) ------- */
  body.mobile-sheet #register{top:auto;left:0;right:0;bottom:0;width:100%;height:var(--peek);
    border-left:0;border-top:1px solid #c9b994;box-shadow:0 -16px 44px rgba(0,0,0,.55);
    transition:height .26s cubic-bezier(.4,0,.2,1);z-index:700;overflow:hidden}
  body.mobile-sheet #register.sheet-half{height:54vh}
  body.mobile-sheet #register.sheet-full{height:92vh}
  /* in the peek state only the grab handle shows */
  body.mobile-sheet #register.sheet-peek>*:not(.sheet-handle){display:none}

  .sheet-handle{flex:0 0 auto;display:flex;align-items:center;justify-content:center;gap:12px;
    position:relative;height:var(--peek);cursor:grab;touch-action:none;user-select:none;
    border-bottom:1px solid #cbbc98}
  .sheet-handle:active{cursor:grabbing}
  .sheet-grip{position:absolute;top:9px;left:50%;transform:translateX(-50%);
    width:42px;height:4px;border-radius:3px;background:#b6a47e}
  .sheet-hint{font-family:var(--mono);font-size:11px;letter-spacing:.12em;text-transform:uppercase;
    color:var(--oxblood);margin-top:6px}

  /* bigger touch targets inside the register */
  #search-box{padding:11px 12px;font-size:16px}   /* 16px keeps iOS from zooming on focus */
  #search-results{max-height:50vh}
  #search-results li{padding:11px 12px}
  .ros-entry{padding:10px 0 10px 13px}
  .tour-list li,.cor-list li,.ppl-list li,.br-row{padding-top:11px;padding-bottom:11px}

  /* guided tour card sits above the peeking sheet, full width */
  #tour{align-items:flex-end}
  #tour-card{margin:0 14px calc(var(--peek) + 16px);max-width:none;width:auto;padding:18px 18px 16px}
  #tour-caption{min-height:0}
}
/* very short screens (landscape phones): drop the standfirst to free the map */
@media (max-width:820px) and (max-height:560px){
  #masthead .standfirst{display:none}
}
@media (prefers-reduced-motion:reduce){*{scroll-behavior:auto}
  body.mobile-sheet #register{transition:none}}

/* ---- Two Services (cross-corpus bridge) view ----------------------------- */
#rail-bridges{background:linear-gradient(90deg,rgba(143,184,238,.16),rgba(232,178,76,.16));
  border:1px solid rgba(255,255,255,.18);color:#dfe7f1;font-size:12px;font-weight:500;
  padding:7px 12px;border-radius:5px;letter-spacing:.02em;transition:.15s}
#rail-bridges:hover{border-color:rgba(255,255,255,.4);color:#fff}
#rail-schools{background:rgba(12,20,32,.72);backdrop-filter:blur(6px);
  border:1px solid rgba(208,150,63,.4);color:#e3c891;font-size:12px;font-weight:500;
  padding:7px 12px;border-radius:5px;letter-spacing:.02em;text-decoration:none;transition:.15s}
#rail-schools:hover{border-color:rgba(208,150,63,.75);color:#f3dcab}
.br-list{list-style:none;margin:8px 0 4px;padding:0}
.br-row{display:flex;align-items:baseline;justify-content:space-between;gap:10px;
  padding:6px 8px;margin:0 -8px;cursor:pointer;border-bottom:1px solid rgba(42,51,64,.08)}
.br-row:hover{background:rgba(122,46,42,.06)}
.br-nm{font-family:var(--serif);font-size:14.5px;color:var(--slate);font-weight:500}
.br-row:hover .br-nm{color:var(--oxblood)}
.br-nm .giv{color:var(--slate-2);font-weight:400}
.br-meta{display:flex;align-items:center;gap:8px;flex:none;white-space:nowrap}
.cf{font-family:var(--mono);font-size:10px;font-weight:600;width:15px;height:15px;line-height:15px;
  text-align:center;border-radius:50%;color:#fff}
.cf-A{background:#3f7d4e} .cf-B{background:#9a7d2c} .cf-C{background:#8a8f99}
.br-st{font-family:var(--mono);font-size:12px;color:var(--slate-2);font-variant-numeric:tabular-nums}
.br-st b{font-weight:600} .br-st b.co{color:#3b62a0} .br-st b.io{color:#9a6c14} .br-st i{color:#aab;font-style:normal;margin:0 1px}
.br-sec{margin:6px 0 2px}
.br-svc{font-family:var(--mono);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;
  margin:12px 0 6px;display:flex;align-items:baseline;gap:8px}
.br-svc-n{font-family:var(--sans);font-size:10.5px;font-weight:400;text-transform:none;letter-spacing:0;color:var(--slate-2)}

/* ---- bridge career: two-lane time strip + trace --------------------------- */
.br-legend{display:flex;align-items:center;gap:14px;margin:10px 0 6px;font-size:11.5px;color:var(--slate-2)}
.br-legend i{display:inline-block;width:9px;height:9px;border-radius:2px;margin-right:5px;vertical-align:baseline}
.br-legend b{font-family:var(--mono);color:var(--slate);font-weight:600}
#br-trace{margin-left:auto;background:var(--oxblood);color:#fff;border:0;border-radius:3px;
  padding:4px 10px;font-size:11px;letter-spacing:.02em}
#br-trace:hover{filter:brightness(1.12)}
.br-strip{position:relative;margin:2px 0 2px;padding-bottom:14px}
.br-strip svg{width:100%;height:34px;display:block;overflow:visible}
.br-yr{position:absolute;bottom:0;font-family:var(--mono);font-size:10px;color:var(--slate-2)}
.br-yr.l{left:0} .br-yr.r{right:0}
.br-cyr{position:absolute;top:-2px;transform:translateX(-50%);font-family:var(--mono);
  font-size:10px;color:var(--oxblood);font-weight:600;pointer-events:none}
.br-b{font-family:var(--mono);font-size:10.5px;color:var(--slate-2);font-weight:400}
.br-amb{color:#b07d24;font-weight:700;cursor:help}
