/* Elemental Scarcity Calculator
 * Follows the Brgoch Research Group website: Source Sans 3, white paper with hairline rules,
 * UH red for links and the main action, near-square corners. The calculator page keeps a
 * photo hero with a floating card, and element tiles carry family-colored atomic numbers.
 */

:root {
  --paper: #ffffff;
  --surface: #f6f6f4;
  --ink: #141414;
  --ink-muted: #4a4a4a;
  --ink-faint: #6b6b6b;
  --rule: #e4e4e1;
  --rule-strong: #cbcbc7;
  --accent: #c8102e;
  --accent-deep: #a00d25;
  --accent-soft: #fbeaed;
  --header-h: 64px;
  --radius: 3px;
  --shadow-card: 0 1px 2px rgba(20, 20, 20, 0.12), 0 8px 24px rgba(20, 20, 20, 0.12);
  --font: "Source Sans 3", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* element families (atomic-number colors) */
  --Hydrogen: #ec0000;
  --Alkali_metals: #005fff;
  --Alkaline_earth_metals: #0aa896;
  --Transition_metals: #4f9e00;
  --Other_metals: #b332cd;
  --Semiconductors: #0aa3c2;
  --Other_nonmetals: #af9b22;
  --Halogens: #ec0000;
  --Noble_gas: #ff009e;
  --Lanthanides: #946413;
  --Actinides: #ff7f57;
  --Compounds: #141414;

  /* supply-risk bands (DOJ/FTC HHI thresholds) */
  --risk-low: #2e7d32;
  --risk-mid: #c77700;
  --risk-high: #c8102e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font: 17px/1.6 var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: 0.2em; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-weight: 600; line-height: 1.1; margin: 0 0 0.5em; text-wrap: balance; }
p { margin: 0 0 1em; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.link, .prose a, .lead a { color: var(--accent); text-decoration: underline; text-decoration-color: transparent; transition: text-decoration-color 0.15s; }
.link:hover, .prose a:hover, .lead a:hover { text-decoration-color: currentColor; }

.wrap { max-width: 76rem; margin: 0 auto; padding: 0 clamp(16px, 0.5rem + 2.5vw, 40px); }

/* ---- header -------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.site-header .bar { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; flex-direction: column; text-decoration: none; line-height: 1; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { margin-top: 5px; font-size: 12px; color: var(--ink-faint); }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  position: relative;
  display: block;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after { transform: scaleX(1); }

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  margin-right: -8px;
  padding: 0 10px;
  border: 0;
  border-radius: 2px;
  background: none;
  cursor: pointer;
}
.menu-btn span, .menu-btn span::before, .menu-btn span::after {
  display: block;
  height: 1.5px;
  background: var(--ink);
  position: relative;
  transition: transform 0.2s;
}
.menu-btn span::before, .menu-btn span::after { content: ""; position: absolute; left: 0; right: 0; }
.menu-btn span::before { top: -6px; }
.menu-btn span::after { top: 6px; }

/* ---- hero (calculator page) ----------------------------------------------------- */
.hero {
  position: relative;
  isolation: isolate;
  padding: 64px 0 0;
  background: #1c140a url("../img/rare-earth-oxides.jpg") center 40% / cover no-repeat;
  color: #fff;
}
/* Rare-earth oxide powders (USDA ARS, public domain) under a warm dark wash. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(22, 15, 6, 0.72) 0%, rgba(22, 15, 6, 0.5) 55%, rgba(22, 15, 6, 0.35) 100%);
  z-index: -2;
}
.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 140px;
  background: var(--paper);
  clip-path: polygon(0 40%, 50% 0, 100% 40%, 100% 100%, 0 100%);
  z-index: -1;
}
.hero .intro { max-width: 820px; margin: 0 auto 36px; text-align: center; }
.hero h1 { font-size: clamp(32px, 4.2vw, 50px); font-weight: 600; letter-spacing: -0.025em; margin-bottom: 14px; }
.hero p { font-size: clamp(17px, 1.6vw, 20px); opacity: 0.92; margin: 0; }

/* ---- inner page title ---------------------------------------------------------- */
.page-head { padding: 56px 0 40px; }
.page-head h1 { font-size: clamp(36px, 1.65rem + 2.7vw, 60px); letter-spacing: -0.03em; line-height: 1.02; margin: 0 0 18px; }
.page-head p { max-width: 42rem; margin: 0; font-size: clamp(18px, 1.06rem + 0.3vw, 21px); line-height: 1.55; color: var(--ink-muted); }

/* ---- card with formula input and results ----------------------------------------- */
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 24px 28px 28px;
  color: var(--ink);
}
.hero .card { max-width: 1200px; margin: 0 auto; position: relative; border-color: transparent; box-shadow: var(--shadow-card); }

.field-label { display: block; font-size: 14px; color: var(--ink-faint); margin-bottom: 6px; }
.formula-row { display: flex; gap: 12px; align-items: stretch; }
.input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.formula-input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  font: 400 21px/1.2 var(--font);
  padding: 10px 44px 10px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
}
.formula-input::placeholder { color: #8a8a8a; font-size: 18px; }
.formula-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 2px;
  background: none;
  color: var(--ink-faint);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.clear-btn:hover { color: var(--ink); background: var(--surface); }
.clear-btn[hidden] { display: none; }
.hint { font-size: 14px; color: var(--ink-faint); margin: 8px 0 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 2px;
  background: var(--accent);
  color: #fff;
  font: 600 15px/1 var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.button:hover { background: var(--accent-deep); }
.button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule-strong); }
.button.ghost:hover { border-color: var(--ink); }
.button.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.button:disabled { opacity: 0.6; cursor: default; }
.text-btn {
  border: 0;
  background: none;
  padding: 4px 0;
  font: 500 14px/1 var(--font);
  color: var(--ink-muted);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.text-btn:hover { color: var(--accent); }

/* results */
.results:empty { display: none; }
.results { margin-top: 22px; }
.result-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 12px; }
.result-head .formula { font-size: 23px; font-weight: 600; letter-spacing: -0.01em; }
.result-head .actions { margin-left: auto; display: flex; gap: 8px; }
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}
.stat {
  padding: 12px 16px 14px;
  min-width: 0;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.stat .label { font-size: 14px; color: var(--ink-faint); }
.stat .value {
  font-size: 23px;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat .value.na { color: #9a9a9a; font-weight: 400; }
.stat .unit { font-size: 13px; }
.risk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c);
}
.risk::before { content: ""; width: 8px; height: 8px; background: var(--c); }
.risk.low { --c: var(--risk-low); }
.risk.mid { --c: var(--risk-mid); }
.risk.high { --c: var(--risk-high); }
.error { color: var(--accent); margin: 18px 0 0; font-size: 15px; }

/* ---- periodic table -------------------------------------------------------------- */
.band { background: var(--surface); padding: 36px 0 48px; }
.table-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 16px;
}
.tools-label { font-size: 14px; color: var(--ink-faint); }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px 18px; }
.tabs button {
  position: relative;
  border: 0;
  background: none;
  padding: 6px 0;
  font: 500 15px/1.2 var(--font);
  color: var(--ink-muted);
  cursor: pointer;
}
.tabs button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.tabs button:hover, .tabs button[aria-pressed="true"] { color: var(--ink); }
.tabs button[aria-pressed="true"]::after { transform: scaleX(1); }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-faint); }
.heat-legend .ramp { width: 160px; height: 10px; border: 1px solid var(--rule-strong); }
.heat-legend .swatches { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; }
.heat-legend .swatches i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, 0.12); }

.ptable-wrap { container-type: inline-size; }
.ptable {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  gap: 0.5cqi;
  user-select: none;
  -webkit-user-select: none;
}
.ptable .gap-row { grid-column: 1 / -1; height: 1.6cqi; }

.el {
  --c: #777;
  position: relative;
  aspect-ratio: 1 / 1.05;
  display: flex;
  flex-direction: column;
  padding: 0.35cqi 0.4cqi;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--heat, var(--paper));
  color: var(--ink);
  font-family: var(--font);
  text-align: left;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.1s, box-shadow 0.1s, transform 0.1s;
}
.el:hover { border-color: var(--ink); }
.el:active { transform: scale(0.96); }
.el.selected { box-shadow: 0 0 0 2px var(--accent); border-color: var(--accent); }
.el .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 2px; }
.el .z { font-size: 0.78cqi; font-weight: 700; color: var(--c); }
.el .m { font-size: 0.55cqi; color: var(--ink-faint); }
.el .sym { font-size: 1.75cqi; font-weight: 600; margin-top: auto; }
.el .nm { font-size: 0.55cqi; margin-top: 0.25cqi; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.el.nodata { background: #e9e9e6; color: #8d8d8d; }
.el.nodata .z { opacity: 0.6; }
.el.series { cursor: default; background: var(--paper); }
.el.series .sym { font-size: 1.4cqi; color: var(--ink-faint); }
.el.series:hover { border-color: var(--rule-strong); }
.ptable.heat .el:not(.series) .z { color: rgba(0, 0, 0, 0.6); }
.ptable.heat .el.dark { color: #fff; }
.ptable.heat .el.dark .z, .ptable.heat .el.dark .m { color: rgba(255, 255, 255, 0.85); }

.Hydrogen { --c: var(--Hydrogen); }
.Noble_gas { --c: var(--Noble_gas); }
.Alkali_metals { --c: var(--Alkali_metals); }
.Alkaline_earth_metals { --c: var(--Alkaline_earth_metals); }
.Semiconductors { --c: var(--Semiconductors); }
.Other_nonmetals { --c: var(--Other_nonmetals); }
.Halogens { --c: var(--Halogens); }
.Other_metals { --c: var(--Other_metals); }
.Transition_metals { --c: var(--Transition_metals); }
.Lanthanides { --c: var(--Lanthanides); }
.Actinides { --c: var(--Actinides); }

@container (max-width: 1000px) {
  .el .m, .el .nm { display: none; }
  .el .z { font-size: 1cqi; }
  .el .sym { font-size: 2.1cqi; }
}

/* ---- sections ----------------------------------------------------------------------- */
.section { padding: 48px 0; }
.section h2 { font-size: clamp(26px, 1.4rem + 1vw, 34px); letter-spacing: -0.02em; }
.section .lead { max-width: 42rem; color: var(--ink-muted); }

.dropzone {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 24px;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  padding: 22px 24px;
  background: var(--paper);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone p { margin: 0; flex: 1 1 320px; }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }

table.data {
  border: 1px solid var(--rule);
  border-collapse: collapse;
  width: 100%;
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  font-size: 14px;
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--rule);
}
table.data th { font-weight: 600; background: var(--surface); position: sticky; top: 0; }
table.data td.bad { color: var(--accent); white-space: normal; }
table.data tbody tr:hover { background: #fafaf8; }
.table-scroll { overflow: auto; margin-top: 16px; max-height: 70vh; }

/* ---- element information ------------------------------------------------------------- */
.info { display: flex; gap: 28px; align-items: flex-start; }
.info .big {
  flex: 0 0 auto;
  width: 150px;
  padding: 10px 12px;
  border-width: 2px;
  border-color: var(--c);
  cursor: default;
}
.info .big .z { font-size: 18px; }
.info .big .m { font-size: 13px; display: block; }
.info .big .sym { font-size: 56px; }
.info .big .nm { font-size: 15px; display: block; }
.info .results { margin-top: 0; flex: 1; min-width: 0; }
.info .empty { color: var(--ink-faint); margin: 0; align-self: center; }

/* country shares (element information) */
.country-card { margin-bottom: 28px; }
.country-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 14px; }
.country-head h2 { font-size: 22px; letter-spacing: -0.01em; margin: 0; }
.tabs button:disabled { color: #b5b5b0; cursor: default; }
.country-body { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(240px, 1fr); gap: 28px; align-items: start; }
.map-box { position: relative; }
.world { width: 100%; height: auto; display: block; }
.world path { stroke: #ffffff; stroke-width: 0.5; }
.world path.has { cursor: pointer; }
.world path.has:hover { stroke: var(--ink); stroke-width: 1; }
.country-summary { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.country-summary .risk { margin-top: 0; }
.share-list { list-style: none; margin: 0 0 10px; padding: 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.share-list li { display: grid; grid-template-columns: minmax(0, 9em) 1fr 4.2em; align-items: center; gap: 10px; padding: 3px 0; }
.share-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-list .bar { height: 8px; background: var(--surface); }
.share-list .bar i { display: block; height: 100%; }
.share-list .pct { text-align: right; }
.country-card .hint { margin-top: 10px; }

/* ---- plot ------------------------------------------------------------------------------ */
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 22px; margin-bottom: 16px; }
.control { display: flex; flex-direction: column; gap: 6px; }
.control span { font-size: 14px; color: var(--ink-faint); }
select {
  font: 400 16px/1.2 var(--font);
  min-height: 42px;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23141414' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center;
}
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; min-height: 42px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-muted); margin: 0 0 8px; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; }
.legend i.tile { border: 1.5px solid var(--c); border-radius: 2px; background: color-mix(in srgb, var(--c) 20%, white); }
.legend i.diamond { width: 10px; height: 10px; margin: 0 1px; background: var(--c); transform: rotate(45deg); }
.chart-card { background: var(--paper); border: 1px solid var(--rule); padding: 18px 18px 12px; }
.chart-box { position: relative; }
#chart { width: 100%; height: auto; display: block; }
#chart .pt { cursor: pointer; }
#chart rect.pt:hover { stroke-width: 3; }
#chart path.pt:hover { fill: #c8102e; }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  box-shadow: 0 6px 18px rgba(20, 20, 20, 0.12);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: nowrap;
  display: none;
  z-index: 5;
}
.tooltip b { display: block; font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.chips li {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 2px 2px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--paper);
  font-size: 15px;
  font-weight: 600;
}
.chips li.plain { border: 0; padding: 0 0 0 6px; background: none; }
.chips button.x {
  border: 0;
  background: none;
  width: 26px;
  height: 26px;
  border-radius: 2px;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.chips button.x:hover { color: var(--accent); background: var(--accent-soft); }
.export { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 18px; }

details.picker { margin-top: 18px; }
details.picker summary {
  cursor: pointer;
  font-size: 15px;
  color: var(--accent);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
details.picker summary::-webkit-details-marker { display: none; }
details.picker summary::before { content: "▸"; transition: transform 0.15s; }
details.picker[open] summary::before { transform: rotate(90deg); }
details.picker .ptable-wrap { margin-top: 14px; }

/* ---- text pages --------------------------------------------------------------------------- */
.prose { padding-top: 8px; padding-bottom: 72px; }
.prose > * { max-width: 42rem; }
.prose h2 { font-size: clamp(26px, 1.4rem + 1vw, 34px); letter-spacing: -0.02em; margin: 2.2em 0 0.6em; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 21px; margin: 1.6em 0 0.5em; }
.prose li { margin-bottom: 0.4em; }
.prose figure { margin: 2em 0; max-width: 980px; }
.prose figure img { border: 1px solid var(--rule); }
.prose figcaption { font-size: 15px; color: var(--ink-faint); margin-top: 10px; max-width: 42rem; }
.prose pre { background: var(--surface); border: 1px solid var(--rule); padding: 12px 16px; overflow-x: auto; }
.prose .eq { background: var(--surface); padding: 14px 18px; }
.toc { padding-left: 1.2em; margin: 0 0 8px; columns: 2; column-gap: 32px; }
.toc li { margin-bottom: 0.3em; break-inside: avoid; }
.refs li { margin-bottom: 0.7em; }

/* ---- footer --------------------------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--rule); font-size: 15px; color: var(--ink-muted); }
.site-footer .cols { display: grid; grid-template-columns: 5fr 4fr 3fr; gap: 40px 48px; padding-top: 56px; padding-bottom: 56px; }
.site-footer p { margin: 0 0 6px; }
.footer-name { color: var(--ink); font-weight: 600; font-size: 16px; }
.footer-label { font-size: 14px; color: var(--ink-faint); margin-bottom: 10px !important; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { text-decoration: none; transition: color 0.15s; }
.site-footer a:hover { color: var(--ink); }
.site-footer .cite a { color: var(--accent); }
.site-footer .cite p + p { margin-top: 12px; }
.site-footer .cite a:hover { text-decoration: underline; color: var(--accent); }
.logos { display: flex; align-items: center; gap: 24px; margin-top: 18px; }
.logos img { height: 40px; width: auto; }
.footer-bottom { border-top: 1px solid var(--rule); }
.footer-bottom p { padding-top: 20px; padding-bottom: 20px; margin: 0; font-size: 14px; color: var(--ink-faint); }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- responsive ------------------------------------------------------------------------------- */
@media (max-width: 1139px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .menu-btn { display: inline-block; }
  .site-nav {
    position: fixed;
    top: var(--header-h);
    right: 0;
    left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px clamp(16px, 0.5rem + 2.5vw, 40px) 24px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    box-shadow: 0 16px 24px rgba(20, 20, 20, 0.08);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s;
  }
  .site-header.open .site-nav { transform: none; opacity: 1; visibility: visible; }
  .site-header.open .menu-btn span { background: transparent; }
  .site-header.open .menu-btn span::before { transform: translateY(6px) rotate(45deg); }
  .site-header.open .menu-btn span::after { transform: translateY(-6px) rotate(-45deg); }
  .site-nav a { padding: 14px 0; font-size: 22px; border-bottom: 1px solid var(--rule); }
  .site-nav a::after { display: none; }
  .site-nav a[aria-current="page"] { color: var(--accent); }
  .site-footer .cols { grid-template-columns: 1fr 1fr; }
  .site-footer .cols > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  .country-body { grid-template-columns: 1fr; }
  .hero { padding-top: 36px; }
  .hero .intro { margin-bottom: 24px; }
  .card { padding: 18px 16px 20px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 20px; }
  .ptable-wrap { overflow-x: auto; container-type: normal; padding-bottom: 6px; }
  .ptable { min-width: 820px; gap: 4px; }
  .el { padding: 3px 4px; }
  .el .z { font-size: 9px; }
  .el .m, .el .nm { display: none; }
  .el .sym { font-size: 17px; }
  .el.series .sym { font-size: 12px; }
  .ptable .gap-row { height: 10px; }
  .info { flex-direction: column; gap: 18px; }
  .info .big { width: 130px; }
  .result-head .actions { margin-left: 0; }
  .toc { columns: 1; }
  .site-footer .cols { grid-template-columns: 1fr; gap: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  .site-header, .export, .dropzone, .table-tools { display: none !important; }
  .hero { background: none; color: var(--ink); padding-top: 0; }
  .hero::before, .hero::after { display: none; }
}
