/* ==========================================================================
   dx — the desk (2026-11)
   Loaded after cartography.css. Navigation that stays put, and motion with a purpose.

   The rules this layer keeps:
   - Navigation never moves under the pointer. The rail (or, on a phone, the tab bar) holds the
     areas; an area's views are one row of tabs pinned across the top of the page, in the same
     place on every page. No tab changes weight or size when it becomes current.
   - One ink mark per navigation slides to the current item (js/ui.js inkTo). It is the only
     thing that moves when you navigate; the labels stay where they are.
   - Motion is short, eases out, and says where you went: a later view enters from the right,
     an earlier one from the left. All of it stops under prefers-reduced-motion.

    1  Tokens            5  View tabs                   9  Search
    2  Rail areas        6  Tab bar                    10  Menus and dialogs
    3  Rail station      7  Page heads                 11  Plates and cards
    4  Masthead          8  View transitions           12  Reduced motion
   ========================================================================== */

/* ---------- 1. Tokens --------------------------------------------------- */
html[data-theme] {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --rail-paper: #f3e6c9;
  --rail-text: #efe3c8;
  --rail-dim: #cbbd9e;
  --rail-ember: #f43a2a;
  --desk-shadow: 0 18px 36px -22px rgba(48, 30, 10, .55), 0 2px 6px -3px rgba(48, 30, 10, .25);
}
html[data-theme="dark"] { --desk-shadow: 0 18px 40px -20px rgba(0, 0, 0, .8), 0 2px 6px -3px rgba(0, 0, 0, .5); }

/* readings never change width as their digits change */
#kpiStrip .kpi b, #clock, #railClock, .hr-ticks, .mono { font-variant-numeric: lining-nums tabular-nums; }

/* ---------- 2. Rail: the six areas (desk) ------------------------------ */
@media screen and (min-width: 921px) {
  #areanav[data-built] {
    position: relative; gap: 0;
    margin: clamp(10px, 2.2vh, 24px) calc(var(--rail-width) * -.07) clamp(6px, 1.4vh, 14px);
  }
  /* the slip: a strip of paper with an ember edge, under the current area */
  .rail-ink {
    position: absolute; left: 0; right: 0; top: 0; height: 0; z-index: 0; pointer-events: none;
    background: var(--rail-paper) var(--paper-image, none); border-left: 3px solid var(--rail-ember);
    box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(80, 50, 20, .08);
    opacity: 0; transition: opacity .25s;
  }
  .rail-ink.is-on { opacity: 1; }
  html[data-theme="dark"] .rail-ink { background: rgba(247, 236, 212, .12); box-shadow: inset 0 0 0 1px rgba(247, 236, 212, .08); }

  #areanav[data-built] a.rail-area {
    position: relative; z-index: 1; display: flex; align-items: baseline; gap: 8px;
    padding: clamp(5px, .75vh, 8px) calc(var(--rail-width) * .07 + 8px);
    border: 0; background: none !important; color: var(--rail-text);
    font: 400 clamp(21px, 1.65vw, 27px)/1.15 var(--display);
    transition: color .35s var(--ease-out);
  }
  #areanav[data-built] a.rail-area:hover { padding-left: calc(var(--rail-width) * .07 + 8px); color: #fff6e3; }
  .ra-label { flex: 1; min-width: 0; transition: transform .35s var(--ease-out); }
  #areanav a.rail-area:hover .ra-label { transform: translateX(4px); }
  .ra-key {
    font: 600 10px/1 var(--display); letter-spacing: .1em; color: var(--rail-dim);
    border: 1px solid currentColor; border-radius: 2px; padding: 3px 4px 2px; align-self: center;
    opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .3s var(--ease-out);
  }
  #areanav a.rail-area:hover .ra-key, #areanav a.rail-area:focus-visible .ra-key { opacity: .8; transform: none; }
  #areanav[data-built] a.rail-area.active { font-style: italic; font-weight: 500; color: #172333; }
  #areanav[data-built] a.rail-area.active .ra-key { color: #6b5d45; }
  html[data-theme="dark"] #areanav[data-built] a.rail-area.active { color: #fff2db; }
  html[data-theme="dark"] #areanav[data-built] a.rail-area.active .ra-key { color: var(--rail-dim); }
  #areanav[data-built] a:focus-visible { outline: 2px solid var(--rail-ember); outline-offset: -2px; }

}

/* ---------- 3. Rail station: a live globe, and the clock -------------- */
.station-plate { display: none; }
@media screen and (min-width: 921px) {
  .station-plate {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    margin: auto 0 0; padding: 14px 4px 4px; border: 0; border-top: 1px solid rgba(232, 222, 199, .3);
    background: none; color: var(--rail-text); cursor: pointer; text-align: center; font: inherit;
  }
  .sp-globe {
    width: clamp(96px, 68%, 140px); height: auto; aspect-ratio: 1; overflow: visible;
    color: rgba(5, 10, 18, .75); transition: transform .6s var(--ease-out);
  }
  .station-plate:hover .sp-globe { transform: rotate(-4deg) scale(1.03); }
  .sp-rim { fill: none; stroke: #e8714a; stroke-width: 1.4; }
  .sp-rim2 { fill: none; stroke: #e8714a; stroke-width: .6; opacity: .7; }
  .sp-sea { fill: #20344a; }
  .sp-grat { fill: none; stroke: rgba(232, 222, 199, .16); stroke-width: .5; }
  .sp-land { fill: #d9c9a6; fill-opacity: .82; stroke: #f3e6c9; stroke-width: .35; stroke-opacity: .6; }
  .sp-dusk { fill: rgba(8, 14, 24, .18); }
  .sp-night { fill: rgba(8, 14, 24, .5); }
  .sp-night + .sp-term { fill: none; }
  .sp-term { stroke: #f08b63; stroke-width: .9; stroke-dasharray: 2 1.6; opacity: .9; }
  .sp-sunmark { color: #ffd08a; }
  .sp-sunmark circle { fill: #ffd08a; }
  .sp-sunmark path { stroke: #ffd08a; stroke-width: 1; stroke-linecap: round; }
  .sp-shade { pointer-events: none; }
  .sp-here circle { fill: var(--rail-ember); stroke: #fff6e3; stroke-width: .9; }
  .sp-here .sp-ping { fill: none; stroke: var(--rail-ember); stroke-width: 1.2; transform-origin: 0 0; animation: sp-ping 2.6s var(--ease-out) infinite; }
  @keyframes sp-ping { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }
  .sp-text { display: grid; gap: 2px; justify-items: center; min-width: 0; max-width: 100%; }
  .sp-text small { font: var(--label); font-size: 10px; letter-spacing: var(--label-track); text-transform: uppercase; color: var(--rail-dim); }
  #sealGrid { font: 600 21px/1.05 var(--display); letter-spacing: .06em; color: #fff6e3; }
  #sealPlace { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: italic 16px/1.2 var(--display); color: var(--rail-text); }
  .sp-sun { font: italic 14.5px/1.25 var(--display); color: var(--rail-dim); }
  .sp-sun[data-state="grayline"] { color: #f08b63; }
  .station-plate:hover #sealGrid { color: #fff; }
  .station-plate:focus-visible { outline: 2px solid var(--rail-ember); outline-offset: 2px; }

  .rail-location { display: flex; justify-content: center; margin: 8px 0 4px; padding: 0; border: 0; }
  .rail-clock { display: flex; align-items: baseline; gap: 6px; }
  .rail-clock b { font: 500 21px/1 var(--display); letter-spacing: .03em; color: #fff6e3; }
  .rail-clock small { font: var(--label); font-size: 10px; letter-spacing: var(--label-track); color: var(--rail-dim); }
  /* the page head carries its own clock; on a desk the rail's is enough */
  #pagehead .ph-meta { display: none; }

  /* a short window keeps the globe, smaller */
  @media (max-height: 860px) { .sp-globe { width: clamp(64px, 44%, 86px); } .station-plate { gap: 4px; padding-top: 10px; } .sp-text small { display: none; } }
}
.rail-clock { display: none; }
@media screen and (min-width: 921px) { .rail-clock { display: flex; } }

/* ---------- 4. Masthead ------------------------------------------------- */
#topbar { transition: box-shadow .3s, background-color .3s; }
html.is-scrolled #topbar { box-shadow: 0 10px 22px -18px rgba(40, 24, 8, .55); }
html[data-theme="dark"].is-scrolled #topbar { box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .8); }
#topbar .top-glyph-btn, #qthChip { transition: color .2s, background-color .2s; }
#topbar .top-glyph-btn svg { transition: transform .35s var(--ease-out); }
#topbar .top-glyph-btn:hover svg { transform: translateY(-1px) rotate(-6deg); }
#themeBtn:hover svg { transform: rotate(180deg); }
#kpiStrip .kpi b { transition: color .4s; }

/* ---------- 5. View tabs: across the top of every page ------------------ */
/* An area's views are a row of tabs pinned at the top of the page, in the same place on every
   page. On a desk the row leads with the area's name, so it reads as "you are in Bands; these
   are its pages". On a phone the tab bar at the foot already names the area. */
#subnav {
  position: sticky; top: 0; z-index: 60; display: flex; gap: 0;
  margin: 0 0 14px; padding: 0 14px; border-bottom: 1px solid var(--line-strong);
  background: var(--bg) var(--paper-image, none);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-behavior: smooth;
  -webkit-mask-image: none; mask-image: none;
  transition: box-shadow .3s;
}
#subnav[hidden] { display: none; }
html.is-scrolled #subnav { box-shadow: 0 10px 20px -16px rgba(40, 24, 8, .6); }
html[data-theme="dark"].is-scrolled #subnav { box-shadow: 0 12px 24px -14px rgba(0, 0, 0, .85); }
html[data-theme] #subnav a {
  position: relative; flex: none; margin: 0; padding: 13px 13px 12px; min-height: 46px; display: flex; align-items: center;
  border: 0; border-radius: 0; background: none; white-space: nowrap;
  font: italic 400 18px/1.1 var(--display); color: var(--dim); font-weight: 400 !important;
  transition: color .25s;
}
html[data-theme] #subnav a:hover { color: var(--txt-bright); }
html[data-theme] #subnav a.active { color: var(--ink-red); background: none; }
#subnav a::after, #subnav a.active::after { display: none !important; }
#subnav a:first-of-type { padding-left: 4px; }
.subnav-area { display: none; }
.subnav-ink {
  position: absolute; left: 0; bottom: -1px; height: 3px; width: 0; z-index: 1; pointer-events: none;
  background: var(--ink-red); border-radius: 2px 2px 0 0; opacity: 0; transition: opacity .2s;
}
.subnav-ink.is-on { opacity: 1; }
@media screen and (max-width: 920px) {
  /* the page head no longer has a row under it to join */
  #pagehead { border-bottom: 0; }
}
@media screen and (min-width: 921px) {
  /* under the sticky masthead, on a faintly darker band of paper, flush to the conditions line */
  html[data-theme] #subnav {
    top: 48px; margin: 0 0 clamp(14px, 2vh, 22px); padding: 0 var(--plate-edge);
    border: 0; border-bottom: 1px solid var(--line-strong);
    background: color-mix(in srgb, var(--bg2) 55%, var(--bg)) var(--paper-image, none);
  }
  html[data-theme="dark"] #subnav { background: color-mix(in srgb, var(--bg2) 70%, var(--bg)) var(--paper-image, none); }
  #content:has(> #subnav:not([hidden])) { padding-top: 0; }
  /* pinned under the masthead, the two read as one stack: one shadow, under the tabs */
  html.is-scrolled body:has(#subnav:not([hidden])) #topbar { box-shadow: none; }
  .subnav-area {
    display: flex; flex: none; align-items: center; margin-right: 8px; padding: 0 18px 0 0;
    border-right: 1px solid var(--line-strong);
    font: 600 11px/1 var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-red); white-space: nowrap;
  }
  html[data-theme] #subnav a { padding: 14px 16px 13px; min-height: 48px; font-size: 19px; }
  #subnav a:first-of-type { padding-left: 16px; }
}

/* ---------- 6. Tab bar (phone, tablet): the rail, folded to the foot ----- */
@media screen and (max-width: 920px) {
  #tabbar {
    grid-template-columns: repeat(6, 1fr);
    background: #182634 url(../assets/atlas/navy.webp); border-top: 3px double #8b8470;
    box-shadow: 0 -10px 24px -16px rgba(10, 16, 24, .6);
  }
  #tabbar a {
    z-index: 1; color: var(--rail-dim); font: italic 500 14px/1 var(--display); letter-spacing: .01em;
    transition: color .3s var(--ease-out);
  }
  #tabbar a svg { transition: transform .4s var(--ease-out), color .3s; }
  #tabbar a.active { color: #fff6e3; }
  #tabbar a.active svg { color: var(--rail-ember); transform: translateY(-2px); }
  #tabbar a::before, #tabbar a.active::before { display: none; }
  .tab-ink {
    position: absolute; top: 0; bottom: 0; left: 0; width: 0; z-index: 0; pointer-events: none;
    background: linear-gradient(rgba(247, 236, 212, .13), rgba(247, 236, 212, .03));
    border-top: 3px solid var(--rail-ember); opacity: 0; transition: opacity .25s;
  }
  .tab-ink.is-on { opacity: 1; }
  html[data-theme] #tabbar :focus-visible { outline: 2px solid var(--rail-ember); outline-offset: -3px; }
}
@media screen and (max-width: 380px) { #tabbar a { font-size: 12.5px; } }

/* ---------- 7. Page heads ----------------------------------------------- */
@media screen and (min-width: 921px) {
  #content { padding-top: 6px; }
  /* Learn's head was boxed together with its view row; the row is above it now */
  body[data-area="learn"][data-view="overview"] #pagehead { border-bottom: 3px double var(--line-strong); padding-bottom: 20px; margin-bottom: 22px; }
}
@media screen and (max-width: 920px) {
  #pagehead { text-align: left; align-items: stretch; }
  #pagehead .ph-main, #pagehead .ph-head { align-items: flex-start; text-align: left; }
}
.ph-kicker a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .2s; }
.ph-kicker a:hover { border-bottom-color: currentColor; }
.ph-sep { margin: 0 .55em; opacity: .55; font-weight: 400; }
@keyframes desk-ink-wipe {
  from { clip-path: inset(-25% 100% -25% -3%); }
  to { clip-path: inset(-25% -6% -25% -3%); }
}
@media (prefers-reduced-motion: no-preference) {
  #pagehead.ph-in .ph-title { animation: desk-ink-wipe .9s var(--ease-out) .05s both, rise-in .6s var(--ease-out) both; }
}

/* ---------- 8. View transitions ----------------------------------------- */
/* A later view enters from the right, an earlier one from the left, the first from below. */
@keyframes desk-from-right { from { opacity: 0; transform: translate3d(22px, 0, 0); } }
@keyframes desk-from-left  { from { opacity: 0; transform: translate3d(-22px, 0, 0); } }
@keyframes desk-from-below { from { opacity: 0; transform: translate3d(0, 14px, 0); } }
#main.is-entering > .view-part > * { animation: desk-from-below .55s var(--ease-out) both; }
#main.is-entering > *, #main.is-entering > .view-part > * { animation-timing-function: var(--ease-out); }
#main.is-entering[data-dir="fwd"] > *, #main.is-entering[data-dir="fwd"] > .view-part > * { animation-name: desk-from-right; }
#main.is-entering[data-dir="back"] > *, #main.is-entering[data-dir="back"] > .view-part > * { animation-name: desk-from-left; }
#main.is-entering > .view-part + .view-part > * { animation-delay: .1s; }
.panel-loading { min-height: 220px; }

/* Plates further down the page settle in as they are scrolled to. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    @keyframes desk-reveal { from { opacity: .001; transform: translate3d(0, 26px, 0); } }
    #main:not(.is-entering) :is(.panel, .idx-card, .idx-group > h2, .atlas-table) {
      animation: desk-reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 120px;
    }
    #main .panel .panel, #main .panel .idx-card { animation: none; }
  }
}

/* Switching theme spills the new ink out from the switch. */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: desk-theme-spill .7s var(--ease-out) both; }
@keyframes desk-theme-spill {
  from { clip-path: circle(0 at var(--vt-x, 90%) var(--vt-y, 0)); }
  to { clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 90%) var(--vt-y, 0)); }
}

/* ---------- 9. Search --------------------------------------------------- */
#headerSearchWrap { transition: border-color .2s, box-shadow .3s, max-width .45s var(--ease-out); }
@media screen and (min-width: 921px) {
  #headerSearchWrap.is-open, #headerSearchWrap:focus-within { max-width: 460px; }
}
#headerSearchDropdown {
  width: min(520px, calc(100vw - 24px)); min-width: 100%; max-height: min(70vh, 560px); padding: 6px 0 0; scroll-padding: 34px 0 48px;
  border: 1px solid var(--line-strong) !important; border-radius: 2px;
  background: var(--bg) var(--paper-image, none) !important; box-shadow: var(--desk-shadow);
  animation: desk-drop .22s var(--ease-out);
  overscroll-behavior: contain;
}
@keyframes desk-drop { from { opacity: 0; transform: translateY(-6px) scale(.985); transform-origin: top left; } }
.hs-group + .hs-group { border-top: 1px solid var(--line2); margin-top: 4px; padding-top: 4px; }
.hs-title { padding: 8px 16px 4px; font: var(--label); font-size: 10.5px; letter-spacing: var(--label-track); text-transform: uppercase; color: var(--ink-red); }
#headerSearchDropdown .header-search-item {
  position: relative; display: flex; align-items: baseline; gap: 10px; margin: 0; padding: 7px 16px; border-radius: 0;
  font: 17px/1.25 var(--display); color: var(--txt); background: none;
}
#headerSearchDropdown .header-search-item::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; background: var(--ember);
  transform: scaleY(0); transition: transform .2s var(--ease-out);
}
#headerSearchDropdown .header-search-item.selected { background: color-mix(in srgb, var(--txt) 6%, transparent); color: var(--txt-bright); }
#headerSearchDropdown .header-search-item.selected::before { transform: none; }
.hs-name { flex: 1; min-width: 0; }
.hs-name small { font: italic 15px var(--display); color: var(--dim); }
.hs-name mark { background: none; color: var(--ink-red); font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.hs-area { flex: none; font: var(--label); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.hs-go { flex: none; width: 14px; font: 13px var(--mono); color: var(--ink-red); opacity: 0; transition: opacity .15s; }
.header-search-item.selected .hs-go { opacity: 1; }
.hs-empty { padding: 16px; font: italic 16px/1.4 var(--display); color: var(--dim); }
.hs-foot {
  position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; padding: 8px 16px;
  border-top: 1px solid var(--line2); background: var(--bg) var(--paper-image, none);
  font: italic 13.5px var(--display); color: var(--dim);
}
.hs-foot kbd { font: 500 10px var(--mono); padding: 1px 4px; margin-right: 2px; border: 1px solid var(--line); border-radius: 2px; }
@media (max-width: 700px) { .hs-foot { display: none; } #headerSearchDropdown { left: 0; right: auto; } }

/* ---------- 10. Menus and dialogs -------------------------------------- */
.glyph-dropdown { animation: desk-drop .2s var(--ease-out); box-shadow: var(--desk-shadow) !important; }
.theme-opt { transition: background-color .15s, color .15s; }
dialog { box-shadow: var(--desk-shadow), 0 0 0 1px var(--line); }
dialog[open] { animation: desk-dialog-in .38s var(--ease-out); }
@keyframes desk-dialog-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
#toast {
  background: var(--bg) var(--paper-image, none); color: var(--txt-bright); border: 1px solid var(--line-strong);
  border-left: 3px solid var(--ember); border-radius: 2px; box-shadow: var(--desk-shadow);
  font: italic 17px/1.3 var(--display); letter-spacing: 0;
  transition: transform .45s var(--ease-out), opacity .3s;
}

/* ---------- 11. Plates and cards --------------------------------------- */
.idx-card, .now-cards > * { position: relative; isolation: isolate; }
.idx-card { transition: border-color .25s, background-color .25s, transform .45s var(--ease-out), box-shadow .45s var(--ease-out); }
.idx-card::after, .now-cards > *::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 30%), color-mix(in srgb, var(--ember) 7%, transparent), transparent 60%);
}
.idx-card:hover::after, .now-cards > *:hover::after { opacity: 1; }
@media (hover: hover) {
  .idx-card:hover { transform: translateY(-3px); box-shadow: var(--desk-shadow); }
}
.idx-card:active { transform: translateY(-1px); transition-duration: .1s; }
.btn { transition: background-color .2s, border-color .2s, color .2s, transform .15s var(--ease-out); }
.btn:active { transform: translateY(1px); }
/* the counting meter keeps its width */
.kpi-counting { font-variant-numeric: tabular-nums; }

/* ---------- 12. Reduced motion ----------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .rail-ink, .subnav-ink, .tab-ink, .ra-label, .ra-key, #tabbar a svg,
  .idx-card, #headerSearchWrap, #topbar .top-glyph-btn svg, #headerSearchDropdown .header-search-item::before {
    transition: none !important;
  }
  #main.is-entering > *, #main.is-entering > .view-part > *, #headerSearchDropdown, .glyph-dropdown, dialog[open],
  #pagehead.ph-in .ph-title { animation: none !important; }
  .idx-card:hover, #tabbar a.active svg { transform: none; }
  ::view-transition-new(root) { animation: none; }
  .sp-here .sp-ping { animation: none; opacity: 0; }
  .sp-globe { transition: none; }
  #subnav { scroll-behavior: auto; }
}

/* ---------- 13. Small fixes the new chrome made visible ----------------- */
/* a find box is chrome, so it speaks in the serif like the masthead search */
#content .idx-find, #content #benchFind { font: italic 18px/1.2 var(--display); letter-spacing: 0; }
/* the shortcuts sheet and audio alerts are desk tools; a phone keeps its masthead to one line of actions */
@media (max-width: 480px) { #topbar #alertsBtn, #topbar #helpBtn { display: none; } #topbar .topbar-glyphs { justify-content: space-around; } }
