/* Empires at Their Peak — Imaar Studio */

:root {
  --void: #04070b;          /* page and ocean are the same colour, so the map
                               floats edge to edge with no visible letterbox */
  --deep: #070c12;
  --panel: #0c131b;
  --land: #1c2836;
  --land-hi: #2b3b4f;
  --line: rgba(236, 231, 216, .10);
  --hair: rgba(236, 231, 216, .055);
  --paper: #eee9dc;
  --muted: #78848f;
  --gold: #c9a24b;

  --sel: #c9a24b;           /* rewritten per empire */

  --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --pad: clamp(20px, 4.2vw, 64px);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--void);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line); }
a:hover { text-decoration-color: var(--sel); }
::selection { background: var(--sel); color: var(--void); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.skip {
  position: fixed; left: -9999px; top: 12px; z-index: 200;
  background: var(--panel); padding: 10px 16px; border: 1px solid var(--line);
}
.skip:focus { left: 12px; }

/* A single film-grain plate over everything. Static, one small tile. */
.grain {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  opacity: .30; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

.rubric {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .28em; text-transform: uppercase; color: var(--muted);
  margin: 0;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px var(--pad);
  pointer-events: none;
  transition: opacity .45s var(--ease), transform .45s var(--ease);
}
.topbar > * { pointer-events: auto; }
/* a scrim so the bar reads over the map, fading out below itself */
.topbar::before {
  content: ""; position: absolute; inset: 0 0 -48px; z-index: -1;
  background: linear-gradient(to bottom, rgba(4, 7, 11, .88), rgba(4, 7, 11, 0));
}
/* once the map is behind you, the controls have nothing to control */
.topbar.is-away { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.topbar.is-away > * { pointer-events: none; }

.mark {
  margin: 0;
  font-family: var(--serif); font-variation-settings: "opsz" 30;
  font-size: 15px; font-weight: 500; letter-spacing: -.005em;
  white-space: nowrap;
}
.mark em { font-style: italic; color: var(--sel); transition: color .6s var(--ease); }

.controls { display: flex; align-items: stretch; gap: 8px; }

.ghost {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase;
  background: rgba(10, 16, 23, .55); color: var(--paper);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 15px; cursor: pointer; white-space: nowrap;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: border-color .3s, color .3s, background .3s;
}
.ghost:hover { border-color: var(--sel); color: var(--sel); }
.ghost[aria-pressed="true"] { border-color: var(--sel); color: var(--sel); background: rgba(10, 16, 23, .8); }
.ghost--quiet { color: var(--muted); }
.ghost--sq {
  width: 34px; height: 34px; padding: 0; font-size: 13px; letter-spacing: 0;
  display: grid; place-items: center;
}

.pick {
  display: flex; align-items: center; gap: 9px;
  background: rgba(10, 16, 23, .55);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0 13px 0 15px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: border-color .3s;
}
.pick:hover, .pick:focus-within { border-color: var(--sel); }
.pick__label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.pick select {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; color: var(--paper);
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  padding: 10px 15px 10px 0; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 4px center, right 0 center;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
}
.pick select:focus { outline: none; }
.pick select option { background: var(--panel); color: var(--paper); }

/* ------------------------------------------------------------------ hero */

.hero {
  position: sticky; top: 0; z-index: 1;
  height: 100svh; min-height: 560px;
  overflow: hidden;
}

.plate { position: absolute; inset: 0; animation: dawn 1.4s var(--ease) both; }
@keyframes dawn {
  from { opacity: 0; transform: scale(1.045); }
  to   { opacity: 1; transform: none; }
}

#map {
  display: block; width: 100%; height: 100%;
  touch-action: pan-y; cursor: grab;
}
#map.is-dragging { cursor: grabbing; }

#graticule { fill: none; stroke: var(--hair); stroke-width: .5; }
#rim { fill: none; stroke: rgba(236, 231, 216, .12); stroke-width: .6; }

.country {
  fill: var(--land);
  stroke: rgba(4, 7, 11, .85);
  stroke-width: .4;
  vector-effect: non-scaling-stroke;
  transition: fill .6s cubic-bezier(.4, 0, .2, 1);
}
.country.is-in { stroke: rgba(255, 255, 255, .32); stroke-width: .55; }
.country.is-hover { fill: var(--land-hi); }
.country.is-in.is-hover { filter: brightness(1.3); }

#layer-bloom { mix-blend-mode: screen; pointer-events: none; }
.bloom { stroke: none; }
.bloom--wide { filter: url(#glow-wide); opacity: .8; }
.bloom--tight { filter: url(#glow-tight); opacity: .7; }
/* blurring a continent-sized path every frame is the one thing that can drop
   the framerate, so the bloom sits out any drag or zoom */
.is-moving .bloom { visibility: hidden; }

.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(120% 88% at 50% 42%, transparent 34%, rgba(4, 7, 11, .55) 78%, rgba(4, 7, 11, .92) 100%),
    linear-gradient(to top, rgba(4, 7, 11, .95) 0%, rgba(4, 7, 11, .35) 26%, transparent 48%),
    /* keeps the rail legible where a bright empire runs under it */
    linear-gradient(to left, rgba(4, 7, 11, .74) 0, rgba(4, 7, 11, 0) 250px);
}

.tip {
  position: absolute; z-index: 12; pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  background: rgba(6, 11, 17, .9);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 7px 11px 8px;
  font-size: 12.5px; line-height: 1.2; white-space: nowrap;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .15s;
}
.tip.is-on { opacity: 1; }
.tip b { font-weight: 600; }
.tip i {
  display: block; font-style: normal; margin-top: 4px;
  font-family: var(--mono); font-size: 9px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.tip i.is-in { color: var(--sel); }

/* ------------------------------------------------------------------ rail */

.rail {
  position: absolute; z-index: 6;
  right: var(--pad); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column;
  padding-right: 17px;
}
.rail::after {
  content: ""; position: absolute; right: 4px; top: 6px; bottom: 6px;
  width: 1px; background: var(--hair);
}

.rail__item {
  position: relative;
  display: grid; grid-template-columns: auto auto; align-items: baseline;
  justify-content: end; gap: 12px;
  background: none; border: 0; padding: 6px 0; margin: 0;
  color: var(--muted); font: inherit; text-align: right; cursor: pointer;
  transition: color .3s var(--ease), transform .4s var(--ease);
}
.rail__item:hover { color: var(--paper); transform: translateX(-4px); }
.rail__item[aria-current="true"] { color: var(--paper); }

.rail__yr {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em;
  white-space: nowrap;
  opacity: .62; transition: opacity .3s, color .3s;
}
.rail__name {
  font-size: 12px; font-weight: 500; letter-spacing: .005em; white-space: nowrap;
  transition: color .3s;
}
.rail__item[aria-current="true"] .rail__name {
  font-family: var(--serif); font-variation-settings: "opsz" 30;
  font-weight: 600; font-size: 14.5px; color: var(--c);
}
.rail__item[aria-current="true"] .rail__yr { opacity: 1; color: var(--c); }

.rail__dot {
  position: absolute; right: -17px; top: 50%;
  width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%;
  background: var(--muted); opacity: .45;
  transition: opacity .3s, transform .4s var(--ease), box-shadow .4s;
}
.rail__item:hover .rail__dot { opacity: 1; }
.rail__item[aria-current="true"] .rail__dot {
  background: var(--c); opacity: 1; transform: scale(1.5);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent),
              0 0 14px 2px color-mix(in srgb, var(--c) 65%, transparent);
}

/* --------------------------------------------------------------- billing */

/* a lower third: the rule under the figures spans the full band, not just the
   width the empire's name happened to take */
.billing {
  position: absolute; z-index: 6;
  left: var(--pad); right: calc(var(--pad) + 200px);
  bottom: clamp(30px, 5vh, 58px);
}

.kicker {
  margin: 0 0 16px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .26em; text-transform: uppercase; color: var(--muted);
}
.kicker b { color: var(--sel); font-weight: 400; transition: color .6s var(--ease); }
.kicker span { opacity: .45; margin: 0 9px; }

.display {
  margin: 0;
  font-family: var(--serif);
  font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 1;
  font-weight: 600;
  font-size: clamp(42px, 7.6vw, 118px);
  line-height: .87; letter-spacing: -.032em;
  /* the mask that the name rises out of; padded so descenders survive it */
  overflow: hidden;
  padding-bottom: .1em; margin-bottom: -.1em;
}
.display span { display: block; will-change: transform; }
.display span.rise { animation: rise .85s var(--ease) both; }
@keyframes rise {
  from { transform: translateY(104%) rotate(1.2deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.figures {
  display: flex; flex-wrap: wrap; gap: 10px 40px;
  margin: clamp(20px, 3vh, 34px) 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--hair);
}
.figures > div { min-width: 0; }
.figures dt {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.figures dd {
  margin: 7px 0 0;
  font-family: var(--serif); font-variation-settings: "opsz" 48;
  font-weight: 500; font-size: clamp(19px, 2.1vw, 27px);
  line-height: 1; letter-spacing: -.015em;
  font-variant-numeric: tabular-nums;
  color: var(--sel); transition: color .6s var(--ease);
}
.figures dd small {
  font-family: var(--sans); font-size: .5em; font-weight: 500;
  letter-spacing: .04em; opacity: .7; margin-left: .3em;
}

.zoom {
  position: absolute; z-index: 6;
  right: var(--pad); bottom: clamp(30px, 5vh, 58px);
  display: flex; flex-direction: column; gap: 6px;
}

.cue {
  position: absolute; z-index: 6; left: 50%; bottom: 22px;
  transform: translateX(-50%); margin: 0;
  font-family: var(--mono); font-size: 9px;
  letter-spacing: .3em; text-transform: uppercase; color: var(--muted);
  transition: opacity .5s;
}
.cue span { display: block; animation: breathe 2.8s ease-in-out infinite; }
.cue.is-gone { opacity: 0; }
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: .95; } }

/* ------------------------------------------------------------------ body */

.body {
  position: relative; z-index: 3;
  background: var(--void);
  border-top: 1px solid var(--line);
  box-shadow: 0 -60px 120px rgba(0, 0, 0, .95);
}

/* ---------------------------------------------------------------- dossier */

.dossier {
  padding: clamp(60px, 10vh, 130px) var(--pad) clamp(50px, 8vh, 100px);
  max-width: 1280px; margin: 0 auto;
}

.lede {
  margin: 30px 0 0; max-width: 30ch;
  font-family: var(--serif); font-variation-settings: "opsz" 72, "WONK" 1;
  font-weight: 400;
  font-size: clamp(24px, 3.4vw, 46px);
  line-height: 1.16; letter-spacing: -.018em;
  text-wrap: balance;
}

.spec {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0; margin: clamp(46px, 7vh, 84px) 0 0;
  border-top: 1px solid var(--hair);
}
.spec > div {
  padding: 20px 22px 22px 0;
  border-bottom: 1px solid var(--hair);
}
.spec dt {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.spec dd {
  margin: 10px 0 0;
  font-family: var(--serif); font-variation-settings: "opsz" 36;
  font-weight: 500; font-size: 20px; line-height: 1.2; letter-spacing: -.01em;
}

.extent { margin-top: clamp(46px, 7vh, 84px); }
.extent__head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 8px 24px; margin-bottom: 16px;
}
.extent__val {
  margin: 0;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--paper);
}
.extent__track {
  position: relative; height: 3px;
  background: var(--hair);
}
.extent__fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--sel);
  box-shadow: 0 0 20px 1px color-mix(in srgb, var(--sel) 70%, transparent);
  transition: width .9s var(--ease), background .6s var(--ease);
}
.extent__mark { position: absolute; top: -5px; bottom: -5px; width: 1px; background: var(--line); }
.extent__mark span {
  position: absolute; right: 0; top: 15px; white-space: nowrap;
  font-family: var(--mono); font-size: 9px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}

.overlap { margin-top: clamp(46px, 7vh, 84px); }
.overlap__line {
  margin: 18px 0 0; max-width: 34ch;
  font-family: var(--serif); font-variation-settings: "opsz" 48;
  font-weight: 400; font-size: clamp(20px, 2.4vw, 30px);
  line-height: 1.2; letter-spacing: -.015em;
}
.overlap__line b { font-weight: 600; }
.overlap__line .sw {
  display: inline-block; width: .42em; height: .42em; border-radius: 50%;
  margin-right: .3em; vertical-align: baseline;
}
.overlap__list {
  margin: 20px 0 0; max-width: 78ch;
  font-size: 13.5px; line-height: 1.75; color: var(--muted);
}

/* ------------------------------------------------------------- chronology */

.chrono {
  padding: clamp(60px, 10vh, 130px) var(--pad) clamp(60px, 9vh, 110px);
  max-width: 1280px; margin: 0 auto;
  border-top: 1px solid var(--hair);
}
.chrono__head { max-width: 62ch; margin-bottom: clamp(36px, 6vh, 64px); }
.chrono__head h2 {
  margin: 24px 0 0;
  font-family: var(--serif); font-variation-settings: "opsz" 72, "WONK" 1;
  font-weight: 600; font-size: clamp(26px, 3.6vw, 44px);
  line-height: 1.06; letter-spacing: -.024em;
}
.chrono__note { margin: 18px 0 0; font-size: 14px; line-height: 1.65; color: var(--muted); }

.axis {
  position: relative; height: 18px;
  margin-left: var(--name-w, 170px);
}
.axis span {
  position: absolute; top: 0; transform: translateX(-50%);
  font-family: var(--mono); font-size: 9px;
  letter-spacing: .14em; color: var(--muted); white-space: nowrap;
}
.axis span:first-child { transform: none; }
.axis span:last-child { transform: translateX(-100%); }

.rows { position: relative; display: flex; flex-direction: column; }
.gridlines {
  position: absolute; top: 0; bottom: 0;
  left: var(--name-w, 170px); right: 0; pointer-events: none;
}
.gridlines i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--hair); }

.row {
  display: flex; align-items: center;
  width: 100%; padding: 0; margin: 0;
  background: none; border: 0; border-top: 1px solid var(--hair);
  color: var(--paper); font: inherit; text-align: left; cursor: pointer;
  transition: background .3s;
}
.rows .row:last-child { border-bottom: 1px solid var(--hair); }
.row:hover { background: rgba(236, 231, 216, .025); }
.row[aria-checked="true"] { background: rgba(236, 231, 216, .04); }

.row__name {
  flex: 0 0 var(--name-w, 170px); min-width: 0;
  padding: 15px 20px 15px 0;
  font-family: var(--serif); font-variation-settings: "opsz" 30;
  font-weight: 500; font-size: 15px; letter-spacing: -.008em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .3s;
}
.row[aria-checked="true"] .row__name { font-weight: 600; color: var(--c); }

.row__track { position: relative; flex: 1 1 auto; height: 46px; }
.row__bar {
  position: absolute; top: 50%; height: 2px; transform: translateY(-50%);
  min-width: 2px;
  background: color-mix(in srgb, var(--c) 42%, transparent);
  transition: background .35s, box-shadow .35s, height .35s;
}
.row:hover .row__bar, .row[aria-checked="true"] .row__bar {
  height: 3px;
  background: var(--c);
  box-shadow: 0 0 16px 1px color-mix(in srgb, var(--c) 60%, transparent);
}
.row__peak {
  position: absolute; top: 50%; width: 7px; height: 7px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--void);
  border: 1.5px solid color-mix(in srgb, var(--c) 70%, transparent);
  transition: background .35s, border-color .35s, box-shadow .35s;
}
.row:hover .row__peak, .row[aria-checked="true"] .row__peak {
  background: var(--c); border-color: var(--c);
  box-shadow: 0 0 12px 1px color-mix(in srgb, var(--c) 75%, transparent);
}
.row__yr {
  position: absolute; top: 50%; transform: translateY(-50%);
  padding-left: 14px;
  font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .12em; color: var(--muted); white-space: nowrap;
  opacity: 0; transition: opacity .3s, color .3s;
}
.row__yr--before { padding-left: 0; padding-right: 14px; transform: translate(-100%, -50%); }
.row:hover .row__yr, .row[aria-checked="true"] .row__yr { opacity: 1; }
.row[aria-checked="true"] .row__yr { color: var(--c); }

/* --------------------------------------------------------------- colophon */

.colophon {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 34px 56px;
  padding: clamp(40px, 6vh, 72px) var(--pad) clamp(44px, 7vh, 80px);
  max-width: 1280px; margin: 0 auto;
  border-top: 1px solid var(--hair);
}
.colophon__notes { flex: 1 1 460px; max-width: 68ch; }
.colophon__notes p:not(.rubric) {
  margin: 14px 0 0; font-size: 12px; line-height: 1.7; color: var(--muted);
}
.colophon__notes em { color: var(--paper); opacity: .7; font-style: italic; }

.colophon__credit { flex: 0 0 auto; text-align: right; }
.signature {
  margin: 0;
  font-family: var(--serif); font-variation-settings: "opsz" 30;
  font-size: 15px; font-weight: 500;
}
.signature a { text-decoration-color: var(--gold); }
.repo {
  margin: 9px 0 0;
  font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .rail__name { font-size: 11px; }
  .rail__item[aria-current="true"] .rail__name { font-size: 13px; }
  .billing { right: calc(var(--pad) + 165px); }
}

@media (max-width: 860px) {
  /* the map stops being a full-bleed backdrop and becomes a stacked panel */
  .hero { position: relative; height: auto; min-height: 0; }
  .plate { position: relative; inset: auto; height: 52svh; min-height: 300px; }
  .vignette {
    inset: 0 0 auto; height: 52svh;
    background: radial-gradient(120% 90% at 50% 45%, transparent 40%, rgba(4, 7, 11, .8) 100%);
  }
  .rail {
    position: relative; right: auto; top: auto; transform: none;
    flex-direction: row; overflow-x: auto; gap: 22px;
    padding: 14px var(--pad) 16px; margin: 0;
    border-bottom: 1px solid var(--hair);
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail::after { display: none; }
  .rail__item {
    grid-template-columns: auto; justify-content: start;
    gap: 5px; text-align: left; padding: 2px 0 10px; white-space: nowrap;
  }
  .rail__item:hover { transform: none; }
  .rail__dot { right: auto; left: 0; top: auto; bottom: 0; margin: 0; }
  .billing {
    position: relative; left: auto; right: auto; bottom: auto;
    padding: 28px var(--pad) 34px;
  }
  .zoom { top: calc(52svh - 88px); bottom: auto; }
  .cue { display: none; }
  .body { box-shadow: none; }
}

@media (max-width: 620px) {
  .topbar { padding: 14px var(--pad); }
  .mark { font-size: 13px; }
  .pick__label { display: none; }
  .axis { margin-left: var(--name-w, 108px); }
  .gridlines { left: var(--name-w, 108px); }
  .row__name { flex-basis: var(--name-w, 108px); font-size: 13px; padding-right: 12px; }
  .row__track { height: 40px; }
  .row__yr { display: none; }
  .colophon__credit { text-align: left; }
  .spec > div { padding-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
