/* Our World — "Glass HUD" look.
   All colours live in these tokens; globe.js reads the --map-* ones for the map layers. */
:root {
  --bg: #020608;
  --fg: #dff8ff;
  --muted: #7fb3c2;
  --muted2: #3f6c7a;
  --line: #0f3a46;
  --accent: #5fe6ff;
  --igo: #ffb86b;
  --glass: #04161ccc;
  --glass-line: #2fd4ff66;

  --map-ocean: #082a36;
  --map-land: #0f4a59;
  --map-border: #2fd4ff;
  --map-selected: #2fd4ff;

  --f-body: 'Rajdhani', system-ui, sans-serif;
  --f-num: 'IBM Plex Mono', ui-monospace, monospace;
  --bar: 64px;                 /* height of the search bar zone */
  --sheet: 50dvh;              /* open sheet: its top sits at half the screen */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

@font-face { font-family: 'Rajdhani'; font-weight: 400; font-display: swap; src: url(fonts/rajdhani-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Rajdhani'; font-weight: 600; font-display: swap; src: url(fonts/rajdhani-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); }

[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; min-height: 100lvh; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--fg);
  font: 15px/1.3 var(--f-body); user-select: none; -webkit-user-select: none; touch-action: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Globe ---------- */
#map { position: fixed; inset: 0; z-index: 0; }
/* The glow follows the globe's silhouette: the canvas is transparent outside the sphere.
   Painted by the compositor, so an idle globe costs nothing. */
#map canvas { filter: drop-shadow(0 0 14px #2fd4ff44); outline: none; }
.fade { position: fixed; left: 0; right: 0; pointer-events: none; z-index: 1; }
/* Top: a short, light fade behind the buttons, so they stay readable over the globe. */
.fade.top { top: 0; height: calc(var(--safe-top) + 84px);
  background: linear-gradient(#020608cc calc(var(--safe-top) + 30px), transparent); }
.fade.bottom { bottom: 0; height: calc(var(--bar) + 64px + var(--safe-bottom)); background: linear-gradient(transparent, var(--bg) 70%); }

/* ---------- Top buttons ---------- */
.topbar { position: fixed; top: calc(14px + var(--safe-top)); left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: center; z-index: 6; pointer-events: none; }
.debug { font: 11px var(--f-num); color: var(--muted); }
.btn { pointer-events: auto; position: relative; z-index: 7; width: 42px; height: 42px; display: grid; place-items: center; background: #04161c; border: 1px solid #2fd4ffaa; color: #8ff0ff; }
.btn svg { width: 20px; height: 20px; }
.btn:active { background: #2fd4ff33; }

/* ---------- Search ---------- */
.sheet:not([hidden]) ~ .search, .sheet:not([hidden]) ~ .results { display: none; }
.search { position: fixed; left: 14px; right: 14px; bottom: calc(10px + var(--safe-bottom) + var(--kb, 0px)); height: 44px; z-index: 5;
  display: flex; align-items: center; gap: 10px; padding: 0 14px; color: var(--muted);
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(12px); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; color: var(--fg);
  font: 16px var(--f-body); letter-spacing: .04em; } /* 16px stops iOS zooming into the field */
.search input::placeholder { color: var(--muted2); text-transform: uppercase; letter-spacing: .12em; font-size: 14px; }

.results { position: fixed; left: 14px; right: 14px; bottom: calc(60px + var(--safe-bottom) + var(--kb, 0px)); z-index: 5;
  max-height: calc(var(--vvh, 100dvh) - 60px - var(--safe-bottom) - 70px - var(--safe-top));
  display: flex; flex-direction: column-reverse; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; background: #04161cf2; border: 1px solid var(--glass-line); }
.results button { flex: none; display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.results button:active { background: #2fd4ff22; }
.results img, .results .sym { width: 28px; height: 19px; flex: none; object-fit: cover; }
.results .sym { display: grid; place-items: center; background: #b87333; color: #fff; font: 500 10px var(--f-num); }
.results .name { flex: 1; font-size: 16px; }
.results .kind { font: 11px var(--f-num); letter-spacing: .08em; color: var(--muted2); text-transform: uppercase; }

/* ---------- Sheet ---------- */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; height: var(--sheet); z-index: 4;
  padding: 10px 0 var(--safe-bottom); display: flex; flex-direction: column;
  background: var(--glass); border-top: 1px solid var(--glass-line); backdrop-filter: blur(14px); }
.sheet::before, .sheet::after { content: ""; position: absolute; top: -1px; width: 18px; height: 18px; border-top: 2px solid #8ff0ff; }
.sheet::before { left: 0; border-left: 2px solid #8ff0ff; }
.sheet::after { right: 0; border-right: 2px solid #8ff0ff; }
.sheet header { padding: 0 14px; }
.sheet header > :first-child { padding-right: 34px; }   /* room for the X */
.x { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); z-index: 1; }
.x svg { width: 18px; height: 18px; }
.world { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; padding: 5px 0; border-top: 1px solid var(--line);
  font-size: 14px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.world .n { font: 500 16px var(--f-num); color: var(--fg); letter-spacing: 0; text-transform: none; }

.chips, .badges { display: flex; flex-wrap: wrap; gap: 6px; }
.chips { margin-bottom: 6px; }
.chip { font: 11px var(--f-num); letter-spacing: .04em; padding: 3px 7px; border: 1px solid #ffb86b66; color: var(--igo); }
.title { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.title img, .title .sym { width: 34px; height: 23px; flex: none; object-fit: cover; }
.title .sym { display: grid; place-items: center; background: #b87333; color: #fff; font: 500 12px var(--f-num); }
.title h2 { font-weight: 600; font-size: 28px; letter-spacing: .14em; text-transform: uppercase; line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title .sub { font: 12px var(--f-num); color: var(--muted); margin-left: auto; white-space: nowrap; }
.badges { margin-top: 6px; }
.badge { font: 500 11px var(--f-body); letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border: 1px solid #2fd4ff99; color: #8ff0ff; }
.toggle { margin-left: auto; font: 11px var(--f-num); letter-spacing: .08em; padding: 4px 8px; border: 1px solid var(--muted2); color: var(--muted); }
.toggle[aria-pressed="true"] { border-color: var(--igo); color: var(--igo); background: #ffb86b1a; }
.blurb { margin-top: 6px; color: #b4dbe6; font-size: 16px; max-height: 5.4em; overflow-y: auto; touch-action: pan-y; }

.tabs { display: flex; gap: 20px; padding: 0 14px; margin-top: 8px; border-bottom: 1px solid var(--line); }
.tabs:empty { display: none; }
.tabs button { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; padding: 7px 0; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--fg); box-shadow: inset 0 -2px var(--accent); }

/* Rows: one grid per table, columns set per table with --cols. Never wider than the screen. */
.rows { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; padding: 2px 14px 12px; }
.r { display: grid; grid-template-columns: var(--cols, 1fr auto 44px); align-items: baseline; gap: 8px; width: 100%;
  padding: 6px 0; border-bottom: 1px solid var(--line); text-align: left; font-variant-numeric: tabular-nums; }
button.r:active { background: #2fd4ff1a; }
.r > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r .k { text-transform: uppercase; letter-spacing: .08em; font-size: 15px; color: #b4dbe6; }
.r .n { font: 15px var(--f-num); text-align: right; }
.r .rk { font: 14px var(--f-num); color: var(--accent); text-align: right; }
.r .p { font: 13px var(--f-num); color: #b4dbe6; text-align: right; }
.r .rk.l { text-align: left; }
/* Country > Resources: production and reserves are two separate columns. */
.r .sep { border-left: 1px solid var(--line); padding-left: 8px; }
.r.hd { padding: 4px 0; }
.r.hd > * { font: 13px var(--f-body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.r.igo > * { color: var(--igo); }
.r .rk.top { color: var(--fg); }   /* podium ranks, #1 to #3 */
.badge.top { color: var(--fg); border-color: var(--fg); }
.r.founder .k { color: var(--fg); }
.r.former > *, .r.former .k.c { color: var(--muted2); }
.r.me { background: #2fd4ff14; }
.r .k.c { text-transform: none; letter-spacing: .02em; font-size: 17px; color: var(--fg); }
.asof { padding: 10px 0 0; font: 12px var(--f-num); color: var(--muted); }
.section { padding: 12px 0 4px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* ---------- Portrait only ---------- */
.rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate { display: grid; place-items: center; position: fixed; inset: 0; z-index: 9; background: var(--bg);
    font-size: 18px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
}

