@import url("tokens.css?v=9");
@import url("nav.css?v=10");

/* The World Through Time — application chrome. Tokens live in tokens.css. */

/* ---------------------------------------------------------------- base */
html, body { height: 100%; }
body {
  margin: 0; position: relative; overflow: hidden;
  background: var(--background); color: var(--foreground);
  font: 400 13px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* one flat card treatment, used by every floating surface */
.surface {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}

/* ---------------------------------------------------------------- layout */
.layout { position: absolute; inset: 0; }
.map-wrap { position: absolute; inset: 0; }
#map {
  position: absolute; inset: 0; overflow: hidden;
  background: radial-gradient(125% 95% at 50% 10%, var(--sea) 0%, var(--sea-deep) 100%);
}

/* ---------------------------------------------------------------- top bar */
/* The header is the shared site header (css/nav.css). On this page the body
   does not scroll, so it is pinned rather than sticky and sits above the map. */
.site-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 700;
  background: color-mix(in srgb, var(--background) 92%, transparent);
}
.site-head-in { width: calc(100% - 32px); }

.ghost {
  background: transparent; color: var(--muted-foreground);
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  padding: 6px 12px; font-size: 12.5px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.ghost:hover { color: var(--accent-foreground); background: var(--accent); }
.ghost-icon { width: 32px; padding: 6px 0; text-align: center; }

.region-select {
  font-size: 12.5px; padding: 6px 28px 6px 11px; max-width: 210px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  background: transparent; color: var(--muted-foreground); appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 51%, calc(100% - 9px) 51%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  transition: background-color .15s, color .15s, border-color .15s;
}
.region-select:hover { color: var(--foreground); background-color: var(--accent); }
.region-select option { background: var(--popover); color: var(--popover-foreground); }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--muted);
}
.seg-btn {
  border: none; background: none; color: var(--muted-foreground);
  font-size: 12px; font-weight: 500; padding: 5px 12px; cursor: pointer;
  border-radius: calc(var(--r-ctl) - 2px); transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--foreground); }
.seg-btn.is-on {
  background: var(--primary); color: var(--primary-foreground); font-weight: 500;
}

/* ---------------------------------------------------------------- map controls */
.map-controls {
  position: absolute; z-index: 690; left: 12px; top: calc(var(--chrome-top) + 14px);
  display: grid; gap: 8px; padding: 11px 12px; max-width: 218px;
  border-radius: var(--r-card);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid var(--border); box-shadow: var(--shadow-2);
  font-size: 12.5px; color: var(--muted-foreground);
}
.ctl { display: flex; align-items: center; gap: 9px; cursor: pointer; line-height: 1.3;
       transition: color .15s; }
.ctl:hover { color: var(--foreground); }
.ctl[hidden], .ctl-range[hidden] { display: none; }
.ctl.is-dim { opacity: .42; pointer-events: none; }
.ctl input[type="checkbox"] { accent-color: var(--primary); width: 14px; height: 14px; margin: 0; }
.ctl-range {
  flex-direction: column; align-items: stretch; gap: 6px; margin-top: 2px;
  padding-top: 9px; border-top: 1px solid var(--border);
  color: var(--faint); font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .04em; text-transform: uppercase;
}
.ctl-select { flex-direction: column; align-items: stretch; gap: 4px; }
input[type="range"] { accent-color: var(--primary); }

.sheet-bar { display: none; }
.proj-select { display: none; }

/* ---------------------------------------------------------------- zoom */
.zoom-ctl {
  /* bottom-right of the map itself, which means clear of the detail panel */
  position: absolute; z-index: 690;
  right: calc(var(--panel-w) + 24px);
  bottom: calc(var(--chrome-bottom) + 12px);
  display: grid; border-radius: var(--r-ctl); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow-2);
  background: color-mix(in srgb, var(--card) 90%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
}
.zoom-ctl button {
  width: 36px; height: 36px; border: none; background: none; cursor: pointer;
  color: var(--foreground); font-size: 17px; line-height: 1; display: grid;
  place-items: center; transition: background .14s;
}
.zoom-ctl button:hover { background: var(--accent); color: var(--accent-foreground); }
.zoom-ctl button:active { background: var(--secondary); }
.zoom-ctl button + button { border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- notices */
.notices {
  position: absolute; z-index: 690; top: calc(var(--chrome-top) + 20px); left: 50%;
  transform: translateX(-50%); display: flex; flex-direction: column; align-items: center;
  gap: 8px; pointer-events: none;
}
.badge-float, .loading {
  padding: 6px 13px; border-radius: 999px; font-size: 11.5px; white-space: nowrap;
  color: var(--muted-foreground);
  background: color-mix(in srgb, var(--card) 90%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--border); box-shadow: var(--shadow-1);
  animation: notice-in .22s ease;
}
@keyframes notice-in { from { opacity: 0; transform: translateY(-6px); } }
.badge-float[hidden], .loading[hidden] { display: none; }

/* ---------------------------------------------------------------- loading */
/* Three layers: a bar at the top of the page while any epoch is in flight, a
   pill naming the century, and a splash over the map until the first draw. */
.loading { display: inline-flex; align-items: center; gap: 8px; padding-left: 10px; }
.spin, .boot-ring {
  border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--c0), var(--c1), var(--c2), var(--c3),
                             var(--c4), var(--c5), var(--c6), var(--c7), var(--c0));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--ring-w)), #000 calc(100% - var(--ring-w) + 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--ring-w)), #000 calc(100% - var(--ring-w) + 1px));
  animation: gh-spin 1s linear infinite;
}
.spin { --ring-w: 2.5px; width: 14px; height: 14px; }
.loading.is-error .spin { display: none; }
@keyframes gh-spin { to { transform: rotate(1turn); } }

.loadbar {
  position: fixed; z-index: 800; top: 0; left: 0; right: 0; height: 3px;
  overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .25s;
}
.loadbar i {
  position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; border-radius: 99px;
  background: linear-gradient(90deg, var(--c0), var(--c2), var(--c3), var(--c1));
  animation: loadbar 1.15s cubic-bezier(.45, 0, .25, 1) infinite;
}
body.is-loading .loadbar { opacity: 1; }
@keyframes loadbar { to { left: 100%; } }

.boot {
  position: absolute; inset: 0; z-index: 695; display: grid; place-content: center;
  justify-items: center; text-align: center;
  background: color-mix(in srgb, var(--background) 68%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: opacity .6s ease, visibility 0s linear .6s;
}
body.is-ready .boot { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-ring { --ring-w: 6px; width: 66px; height: 66px; margin-bottom: 20px; animation-duration: 1.25s; }
.boot-text { margin: 0; font-family: var(--font-serif); font-size: 19px; color: var(--muted-foreground); }
.boot-text b { font-weight: 400; color: var(--foreground); }
.boot-sub {
  margin: 8px 0 0; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint); animation: boot-blink 1.8s ease-in-out infinite;
}
@keyframes boot-blink { 50% { opacity: .35; } }

/* ---------------------------------------------------------------- panel */
.panel {
  position: absolute; z-index: 680; right: 12px;
  top: calc(var(--chrome-top) + 20px); bottom: calc(var(--chrome-bottom) + 12px);
  width: var(--panel-w); overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 18px 22px; border-radius: var(--r-card);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border); box-shadow: var(--shadow-3);
  scrollbar-width: thin;
}
.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}
.panel h2 { margin: 0 0 6px; font-family: var(--font-serif);
            font-size: 17px; font-weight: 400; letter-spacing: -.01em; }
.panel h3 {
  margin: 18px 0 8px; font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 500;
}
.panel p { margin: 0 0 11px; color: var(--muted-foreground); font-size: 13px; }

.pol-title { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 3px; }
.pol-swatch {
  width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; margin-top: 8px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--foreground) 14%, transparent);
}
.pol-name {
  margin: 0; font-family: var(--font-serif); font-size: 22px; font-weight: 400;
  line-height: 1.2; letter-spacing: -.015em; color: var(--card-foreground);
}
.pol-native { font-size: 12.5px; color: var(--faint); margin: 0 0 12px 21px;
              font-family: var(--font-serif); font-style: italic; }

.badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 14px; }
.badge {
  font-size: 10.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--secondary); color: var(--secondary-foreground);
  border: 1px solid var(--border);
}
.badge.warn {
  background: color-mix(in srgb, var(--chart-1) 20%, transparent);
  border-color: color-mix(in srgb, var(--chart-1) 42%, transparent);
  color: var(--foreground);
}

.facts { margin: 0 0 14px; display: grid; grid-template-columns: auto 1fr;
         gap: 7px 14px; font-size: 12.5px; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

.events { margin: 0; padding-left: 0; list-style: none; font-size: 12.5px;
          color: var(--muted-foreground); }
.events li { margin-bottom: 7px; padding-left: 15px; position: relative; }
.events li::before {
  content: ""; position: absolute; left: 0; top: 8px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--faint);
}

.prov {
  margin-top: 15px; padding: 11px 12px; border-radius: var(--r-ctl);
  background: var(--muted); border: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted-foreground); line-height: 1.5;
}
.prov strong { color: var(--foreground); font-weight: 500; }
.prov-warn {
  background: color-mix(in srgb, var(--chart-1) 12%, var(--muted));
  border-color: color-mix(in srgb, var(--chart-1) 34%, transparent);
}
/* A researched entry, as opposed to a one-line stub or a bare source record. */
.badge.good {
  background: color-mix(in srgb, var(--c2) 18%, transparent);
  border-color: color-mix(in srgb, var(--c2) 45%, transparent);
  color: var(--foreground);
}

/* The panel is the summary; this is the door to the full article. */
.readmore {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 18px 0 4px; padding: 11px 14px;
  border-radius: var(--r-ctl); border: 1px solid var(--border);
  background: var(--primary); color: var(--primary-foreground);
  font-size: 12.5px; font-weight: 500; text-decoration: none; line-height: 1.35;
  transition: transform .12s ease, box-shadow .12s ease;
}
.readmore:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.readmore .arrow { transition: transform .15s ease; }
.readmore:hover .arrow { transform: translateX(3px); }

.srcs { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.srcs li { margin-bottom: 6px; }
.srcs a {
  color: var(--muted-foreground); text-decoration: none;
  border-bottom: 1px solid var(--border); transition: color .15s, border-color .15s;
}
.srcs a:hover { color: var(--foreground); border-bottom-color: var(--foreground); }

.ghost-link { text-decoration: none; display: inline-block; line-height: 1.35; }

.links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.links a {
  font-size: 12px; color: var(--foreground); text-decoration: none;
  border-bottom: 1px solid var(--border); transition: border-color .15s;
}
.links a:hover { border-bottom-color: var(--foreground); }

.back {
  background: none; border: none; color: var(--faint); font-size: 12px;
  cursor: pointer; padding: 0; margin-bottom: 12px; transition: color .15s;
}
.back:hover { color: var(--foreground); }

.legend-head { display: flex; align-items: center; gap: 10px; margin: 20px 0 10px; }
.legend-head h3 { margin: 0; flex: 1; }
#legend-filter {
  font-size: 12px; padding: 5px 10px; width: 104px;
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  background: var(--input); color: var(--foreground);
  transition: border-color .15s, width .2s;
}
#legend-filter::placeholder { color: var(--faint); }
#legend-filter:focus { outline: none; border-color: var(--ring); width: 128px; }

.lgroup { margin-bottom: 3px; }
.lgroup > summary {
  cursor: pointer; font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: .09em; color: var(--faint);
  padding: 5px 0; list-style: none; display: flex; align-items: center; gap: 6px;
}
.lgroup > summary::-webkit-details-marker { display: none; }
.lgroup > summary::before {
  content: "›"; font-family: var(--font-sans); font-size: 13px; line-height: 1;
  transition: transform .15s;
}
.lgroup[open] > summary::before { transform: rotate(90deg); }
.lgroup > summary:hover { color: var(--foreground); }
.lgroup > summary .count { margin-left: auto; letter-spacing: 0; opacity: .7; }

.legend { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 1px; }
.legend li {
  display: flex; align-items: center; gap: 10px; font-size: 12.5px;
  color: var(--muted-foreground); cursor: pointer; padding: 4px 7px;
  border-radius: var(--r-ctl); transition: background .14s, color .14s;
}
.legend li:hover, .legend li:focus-visible { background: var(--accent); color: var(--accent-foreground); }
.legend li:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
/* Screen-reader-only text, and a skip link that appears when tabbed to. */
.sr-only, .skip {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip:focus {
  position: fixed; top: 12px; left: 12px; z-index: 10000;
  width: auto; height: auto; clip: auto; margin: 0; padding: 10px 14px;
  background: var(--card); color: var(--foreground); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-2, 0 6px 20px rgba(0,0,0,.15));
  outline: 2px solid var(--ring); outline-offset: 2px;
}

.legend .sw {
  width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--foreground) 14%, transparent);
}
.legend .parts { color: var(--faint); }
.legend .area {
  margin-left: auto; color: var(--faint); font-family: var(--font-mono);
  font-size: 10.5px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.muted { color: var(--muted-foreground); font-size: 12.5px; }

/* ---------------------------------------------------------------- timeline */
.timeline {
  position: absolute; z-index: 700; left: 12px; right: 12px; bottom: 12px;
  padding: 12px 18px 13px; border-radius: var(--r-card);
  background: color-mix(in srgb, var(--card) 90%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
  border: 1px solid var(--border); box-shadow: var(--shadow-3);
}
.tl-head { display: flex; align-items: center; gap: 15px; margin-bottom: 4px; }
.play {
  width: 36px; height: 36px; border-radius: var(--r-ctl); flex: 0 0 auto;
  border: 1px solid var(--border); background: var(--secondary);
  color: var(--secondary-foreground); font-size: 11px; cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.play:hover { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.play:active { transform: scale(.95); }

.year-box { display: flex; align-items: baseline; gap: 6px; }
#year-input {
  width: 106px; font-family: var(--font-mono);
  font-size: 32px; font-weight: 500; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  background: transparent; border: none; color: var(--foreground); padding: 0;
  -moz-appearance: textfield;
}
#year-input::-webkit-outer-spin-button,
#year-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#year-input:focus { outline: none; text-decoration: underline; text-underline-offset: 5px; }
.year-suffix { font-family: var(--font-mono); font-size: 10px; color: var(--faint);
               letter-spacing: .14em; text-transform: uppercase; }
.epoch-note { font-size: 12px; color: var(--faint); margin-left: auto; text-align: right; }

.tl-track { position: relative; padding-bottom: 15px; }
#year-range {
  width: 100%; margin: 0; -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer; height: 20px;
}
#year-range::-webkit-slider-runnable-track {
  height: 3px; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary) 0 var(--fill, 50%),
              var(--input) var(--fill, 50%) 100%);
}
#year-range::-moz-range-track { height: 3px; border-radius: 99px; background: var(--input); }
#year-range::-moz-range-progress { height: 3px; border-radius: 99px; background: var(--primary); }
#year-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--card); border: 1.5px solid var(--primary); margin-top: -6px;
  box-shadow: var(--shadow-1); transition: transform .1s;
}
#year-range::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--primary);
  background: var(--card); box-shadow: var(--shadow-1);
}
#year-range:hover::-webkit-slider-thumb { transform: scale(1.16); }

.ticks { position: relative; height: 14px; margin-top: 3px; }
.tick {
  position: absolute; transform: translateX(-50%); cursor: pointer; top: 0;
  font-family: var(--font-mono); font-size: 9.5px; color: var(--faint);
  white-space: nowrap; padding: 0 3px; transition: color .14s;
}
.tick::before {
  content: ""; display: block; width: 1px; height: 5px; background: var(--border);
  margin: -5px auto 2px; transition: background .14s, height .14s;
}
.tick:hover { color: var(--foreground); }
.tick:hover::before { background: var(--foreground); height: 8px; margin-top: -8px; }
.tick.no-label .tick-label { visibility: hidden; }
.tick.no-label { width: 11px; height: 13px; }

/* ---------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 2000; padding: 26px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--shadow-color) 45%, transparent);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: fade .16s ease;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal-card {
  position: relative; width: 100%; max-width: 640px; max-height: 82vh;
  overflow-y: auto; padding: 28px 32px 32px;
  background: var(--popover); color: var(--popover-foreground);
  border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-3);
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
.modal-close {
  position: absolute; top: 12px; right: 14px; width: 28px; height: 28px;
  background: none; border: none; font-size: 20px; line-height: 1;
  color: var(--faint); cursor: pointer; border-radius: var(--r-ctl);
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--accent); color: var(--accent-foreground); }
.modal-card h2 { margin: 0 0 14px; font-family: var(--font-serif);
                 font-size: 22px; font-weight: 400; letter-spacing: -.02em; }
.modal-card h3 { margin: 22px 0 7px; font-size: 13px; font-weight: 600; color: var(--foreground); }
.modal-card p, .modal-card li { font-size: 13px; color: var(--muted-foreground); line-height: 1.62; }
.modal-card ul { padding-left: 18px; }
.modal-card a { color: var(--foreground); }
.modal-card code {
  font-family: var(--font-mono); font-size: 11.5px;
  background: var(--muted); padding: 1px 5px; border-radius: 4px;
}

/* ---------------------------------------------------------------- map layers */
.gh-leaflet { position: absolute; inset: 0; }
svg.gh-flat { position: absolute; inset: 0; display: block; cursor: grab; touch-action: none; }
svg.gh-flat:active { cursor: grabbing; }
.gh-graticule { stroke: var(--graticule); stroke-width: .7; vector-effect: non-scaling-stroke; }
.gh-land path {
  fill: var(--land); stroke: var(--land-edge); stroke-width: .9;
  vector-effect: non-scaling-stroke;
}
.gh-poly { cursor: pointer; transition: fill-opacity .16s ease; }
.gh-modern-flat path { stroke: var(--foreground); stroke-width: 1.5; opacity: .85; }

.gh-flat-labels { position: absolute; inset: 0; pointer-events: none; z-index: 500; }
/* Leaflet positions this wrapper; the span inside centres itself on the point,
   so the label rides along with the map instead of being re-placed after the fact. */
.gh-marker-label {
  width: 0 !important; height: 0 !important; overflow: visible;
  /* Leaflet marker icons default to pointer-events:auto, which would let a
     label swallow the click meant for the territory underneath it. */
  pointer-events: none !important;
}
.gh-marker-label > .gh-flat-label { left: 0; top: 0; }
.gh-flat-label {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--font-sans); font-size: 11px; font-weight: 500;
  letter-spacing: .005em; color: var(--foreground); white-space: nowrap;
  text-shadow:
     0  1px 3px var(--sea), 0 -1px 3px var(--sea),
     1px 0  3px var(--sea), -1px 0 3px var(--sea),
     0 0 7px var(--sea), 0 0 12px var(--sea);
}

.leaflet-container { background: transparent; font: inherit; }
/* The relief tiles are a light-mode asset; tone them for the dark ramp. */
.dark .leaflet-tile-pane,
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.4) saturate(.35) contrast(1.2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane {
    filter: brightness(.4) saturate(.35) contrast(1.2);
  }
}
/* light mode: desaturate the relief so the territories carry the only hue */
.leaflet-tile-pane { filter: saturate(.25); }

.leaflet-control-attribution {
  background: color-mix(in srgb, var(--card) 88%, transparent) !important;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--faint) !important; font-size: 9.5px !important;
  border-radius: var(--r-ctl) 0 0 0; padding: 3px 8px !important;
}
.leaflet-control-attribution a { color: var(--muted-foreground) !important; }
.leaflet-bar {
  border: 1px solid var(--border) !important; border-radius: var(--r-ctl) !important;
  box-shadow: var(--shadow-2) !important; overflow: hidden;
}
.leaflet-bar a {
  background: color-mix(in srgb, var(--card) 88%, transparent) !important;
  color: var(--foreground) !important; border-bottom-color: var(--border) !important;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.leaflet-bar a:hover { background: var(--accent) !important; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1080px) { :root { --panel-w: 308px; } }

@media (max-width: 860px) {
  :root { --chrome-bottom: 94px; }
  .region-select { padding: 6px 26px 6px 10px; font-size: 12px; }
  .ghost { padding: 6px 10px; font-size: 12px; }
  .seg-btn { padding: 5px 10px; font-size: 11.5px; }

  .panel { left: 12px; right: 12px; width: auto;
           top: auto; height: 40vh; bottom: calc(var(--chrome-bottom) + 10px); }
  /* stacked layout: the sheet is below the map, so the pair goes back to the edge */
  .zoom-ctl { right: 12px; bottom: calc(var(--chrome-bottom) + 40vh + 20px); }

  /* bottom sheet: a bar that opens and closes the panel */
  .sheet-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: calc(100% + 36px); margin: -18px -18px 12px; padding: 12px 18px;
    border: none; border-bottom: 1px solid var(--border); background: none;
    font: inherit; font-size: 13px; color: var(--foreground); cursor: pointer; text-align: left;
    position: sticky; top: -18px; z-index: 1;
    background: color-mix(in srgb, var(--card) 96%, transparent);
  }
  .sheet-chev::before { content: "▾"; font-size: 16px; line-height: 1; color: var(--muted-foreground); }
  .panel.collapsed .sheet-chev::before { content: "▴"; }
  .panel.collapsed { height: auto; padding: 0; overflow: hidden; }
  .panel.collapsed .sheet-bar { width: 100%; margin: 0; border-bottom: none; position: static; }
  .panel.collapsed > :not(.sheet-bar) { display: none !important; }
  .sheet-collapsed .zoom-ctl { bottom: calc(var(--chrome-bottom) + 64px); }
  /* the bar already says what to do */
  .panel-empty > h2, .panel-empty > p { display: none; }
  .map-controls {
    left: 12px; right: 12px; max-width: none;
    grid-auto-flow: column; justify-content: start; gap: 14px; align-items: center;
    overflow-x: auto; padding: 9px 12px; font-size: 11.5px;
  }
  .map-controls .region-select { width: auto; min-width: 118px; }
  .map-controls .seg { display: none; }
  .map-controls .proj-select { display: block; width: auto; min-width: 118px; }
  .ctl-sep { width: 1px; height: 20px; margin: 0 2px; }
  .ctl-link { white-space: nowrap; }
  .map-controls .ctl { white-space: nowrap; }
  .ctl-range { min-width: 118px; border-top: none; padding-top: 0; margin-top: 0; }
  .epoch-note { display: none; }
  #year-input { font-size: 27px; width: 90px; }
}

@media (max-height: 560px) {
  .panel { height: 34vh; }
  .map-controls { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ------------------------------------------- map settings panel additions */
/* The region jump and the projection toggle moved here out of the header, so
   the header can be the same five items on every page of the site. */
.map-controls .region-select { width: 100%; max-width: none; }
.ctl-sep { height: 1px; background: var(--border); margin: 2px 0; }
.ctl-link {
  justify-self: start; padding: 0; background: none; border: 0; cursor: pointer;
  font-size: 12px; color: var(--muted-foreground); text-align: left;
  border-bottom: 1px solid transparent; transition: color .15s, border-color .15s;
}
.ctl-link:hover { color: var(--foreground); border-bottom-color: var(--border); }
.map-controls .seg { width: 100%; }
.map-controls .seg-btn { flex: 1; }
