/* Extreme Matter Atlas · shared design system */

:root {
  --bg: #04060c;
  --bg2: #0a0f1e;
  --panel: #0d1326;
  --panel2: #141b33;
  --ink: #f2f5ff;
  --muted: #93a3c4;
  --line: #1e2a4a;
  --line-bright: #2c3c6b;
  --accent: #22d3ee;
  --accent2: #a78bfa;
  --font-display: 'Unbounded', 'Arial Black', sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  /* element category colours */
  --cat-alkali: #fb7185;
  --cat-alkaline: #fb923c;
  --cat-transition: #fbbf24;
  --cat-post-transition: #a3e635;
  --cat-metalloid: #2dd4bf;
  --cat-nonmetal: #22d3ee;
  --cat-halogen: #60a5fa;
  --cat-noble: #a78bfa;
  --cat-lanthanide: #e879f9;
  --cat-actinide: #f472b6;
  --cat-unknown: #64748b;
}

/* per-page accent pairs: every page on the site sets its pair here and nowhere
   else, so the whole palette reads in one screen. A page's own <style> block
   carries its layout only. Adding a page means adding a line here. */
body[data-page="index"]       { --accent: #22d3ee; --accent2: #a78bfa; }
body[data-page="table"]       { --accent: #2dd4bf; --accent2: #a3e635; }
body[data-page="extremes"]    { --accent: #fbbf24; --accent2: #fb7185; }
body[data-page="gnome"]       { --accent: #818cf8; --accent2: #22d3ee; }
body[data-page="crystal"]     { --accent: #a3e635; --accent2: #2dd4bf; }
body[data-page="meta"]        { --accent: #e879f9; --accent2: #fbbf24; }
body[data-page="engineering"] { --accent: #fb923c; --accent2: #fde047; }
body[data-page="frontiers"]   { --accent: #38bdf8; --accent2: #e879f9; }
body[data-page="anomalies"]   { --accent: #67e8f9; --accent2: #fbbf24; }
body[data-page="vimana"]      { --accent: #c084fc; --accent2: #fbbf24; }
body[data-page="beyond"]      { --accent: #f0abfc; --accent2: #67e8f9; }
body[data-page="claimed"]     { --accent: #f472b6; --accent2: #fbbf24; }
body[data-page="cymatics"]    { --accent: #22d3ee; --accent2: #fbbf24; }
body[data-page="resonance"]   { --accent: #fde047; --accent2: #f472b6; }
body[data-page="redmercury"]  { --accent: #fb7185; --accent2: #7dd3fc; }
body[data-page="elements115"] { --accent: #fb923c; --accent2: #c084fc; }
body[data-page="zeropoint"]   { --accent: #67e8f9; --accent2: #c084fc; }
body[data-page="scifi"]       { --accent: #fb7185; --accent2: #38bdf8; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
  min-height: 100vh;
}

::selection { background: var(--accent); color: #04060c; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

img, canvas, svg { max-width: 100%; }

/* ---------- layout ---------- */

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 22px; }

main { position: relative; z-index: 1; }

section { padding: 56px 0; }

.divider {
  height: 1px; border: 0; margin: 0;
  background: linear-gradient(90deg, transparent, var(--line-bright), transparent);
}

.two-col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start;
}
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- header / nav (injected by nav.js) ---------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(4, 6, 12, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-header .nav-bar {
  max-width: 1160px; margin: 0 auto; padding: 12px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700; font-size: 14px; letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; filter: brightness(1.2); }

.pill-nav {
  display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto;
  list-style: none;
}
.pill-nav a {
  display: inline-block; padding: 6px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  border: 1px solid transparent; transition: all .18s ease;
  white-space: nowrap;
}
.pill-nav a:hover { color: var(--ink); border-color: var(--line-bright); text-decoration: none; }
.pill-nav a.active {
  color: #04060c;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* wing dropdowns */
.wing-holder { position: relative; display: flex; --w1: #c084fc; --w2: #fbbf24; }
.wing-holder[data-wing="elements"] { --w1: #22d3ee; --w2: #a78bfa; }
.wing-holder[data-wing="patterns"] { --w1: #2dd4bf; --w2: #a3e635; }
.wing-holder[data-wing="engines"]  { --w1: #c084fc; --w2: #fb7185; }
.wing-holder[data-wing="making"]   { --w1: #fb923c; --w2: #fde047; }
.wing-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-body); font-size: 13px; font-weight: 700;
  color: var(--w1); white-space: nowrap;
  background: color-mix(in srgb, var(--w1) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--w1) 45%, transparent);
  transition: all .18s ease;
}
.wing-btn:hover {
  background: color-mix(in srgb, var(--w1) 20%, transparent);
  border-color: var(--w1);
}
.wing-btn.active {
  color: #04060c;
  background: linear-gradient(90deg, var(--w1), var(--w2));
  border-color: transparent;
  box-shadow: 0 0 18px color-mix(in srgb, var(--w1) 45%, transparent);
}
.wing-btn .caret { font-size: 10px; transition: transform .2s ease; }
.wing-holder.open .wing-btn .caret { transform: rotate(180deg); }

.wing-menu {
  display: none; list-style: none;
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 60;
  min-width: 258px; padding: 10px;
  border-radius: 16px;
  background: rgba(8, 6, 20, 0.98);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid color-mix(in srgb, var(--w1) 40%, transparent);
  box-shadow: 0 26px 60px -22px rgba(0, 0, 0, 0.95);
}
.wing-holder.open .wing-menu { display: block; }
.wing-menu .wing-head {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--w1);
  padding: 4px 10px 9px; line-height: 1.4;
  border-bottom: 1px solid color-mix(in srgb, var(--w1) 22%, transparent);
  margin-bottom: 6px;
}
.wing-menu a {
  display: block; padding: 9px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  border: 1px solid transparent;
}
.wing-menu a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--w1) 14%, transparent);
  text-decoration: none;
}
.wing-menu a.active {
  color: #04060c; background: linear-gradient(90deg, var(--w1), var(--w2));
}

.site-footer .foot-nav .foot-head {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  margin: 14px 0 6px; break-inside: avoid;
}
.site-footer .foot-nav .foot-head:first-child { margin-top: 0; }

/* menu button: hidden until the pill row stops fitting */
.menu-btn {
  display: none;
  margin-left: auto;
  align-items: center; gap: 9px;
  min-height: 44px; padding: 8px 16px;
  border-radius: 12px; cursor: pointer;
  background: var(--panel2);
  border: 1px solid var(--line-bright);
  color: var(--ink);
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
}
.menu-btn:hover { border-color: var(--accent); }
.menu-lines { display: inline-flex; flex-direction: column; gap: 4px; width: 18px; }
.menu-lines i {
  display: block; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: transform .2s ease, opacity .2s ease;
}
.menu-open .menu-lines i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-open .menu-lines i:nth-child(2) { opacity: 0; }
.menu-open .menu-lines i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* narrow screens: a proper drop-down menu, no sideways scrolling */
@media (max-width: 900px) {
  .site-header .nav-bar { gap: 12px; padding: 10px 16px; flex-wrap: nowrap; }
  .brand { font-size: 13px; }
  .menu-btn { display: inline-flex; }

  .pill-nav {
    display: none;
    position: absolute; left: 0; right: 0; top: 100%;
    margin: 0; padding: 12px 16px 18px;
    background: rgba(6, 9, 20, 0.98);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line-bright);
    box-shadow: 0 26px 50px -24px rgba(0, 0, 0, 0.9);
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .menu-open .pill-nav { display: grid; }
  .pill-nav a {
    display: flex; align-items: center;
    min-height: 46px; padding: 10px 16px;
    font-size: 15.5px; border-radius: 12px;
    border-color: var(--line);
    background: var(--panel);
  }
  .pill-nav a.active { border-color: transparent; }
}

@media (max-width: 430px) {
  .menu-word { display: none; }
  .menu-btn { padding: 8px 14px; }
}

@media (max-width: 330px) {
  .pill-nav { grid-template-columns: 1fr; }
}

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

.hero {
  position: relative; overflow: hidden;
  padding: 92px 0 72px;
  border-bottom: 1px solid var(--line);
}

.orbs { position: absolute; inset: 0; pointer-events: none; }
.orbs::before, .orbs::after, .orbs .orb3 {
  content: ""; position: absolute; border-radius: 50%;
  filter: blur(70px); opacity: 0.42;
}
.orbs::before {
  width: 480px; height: 480px; top: -160px; right: -80px;
  background: radial-gradient(circle, var(--accent), transparent 65%);
  animation: drift 14s ease-in-out infinite alternate;
}
.orbs::after {
  width: 420px; height: 420px; bottom: -200px; left: -100px;
  background: radial-gradient(circle, var(--accent2), transparent 65%);
  animation: drift 18s ease-in-out infinite alternate-reverse;
}
.orbs .orb3 {
  width: 260px; height: 260px; top: 30%; left: 42%;
  background: radial-gradient(circle, var(--accent2), transparent 60%);
  opacity: 0.18; animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(50px, 34px, 0) scale(1.12); }
}

.kicker {
  display: inline-block; margin-bottom: 18px;
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px; padding: 5px 14px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.display {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin-bottom: 22px;
  background: linear-gradient(100deg, var(--ink) 15%, var(--accent) 55%, var(--accent2) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.lede {
  font-size: clamp(17px, 2.2vw, 21px);
  color: var(--muted); max-width: 46em; line-height: 1.6;
}
.lede strong { color: var(--ink); }

h2 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(22px, 3.4vw, 32px); line-height: 1.2;
  margin-bottom: 16px;
}
h2 .hue {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h3 {
  font-family: var(--font-display); font-weight: 500;
  font-size: 18px; margin-bottom: 10px;
}
p + p { margin-top: 14px; }
section p { max-width: 62em; }

/* ---------- cards ---------- */

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.card {
  position: relative; border-radius: 18px; padding: 26px 24px;
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.card h3 { margin-bottom: 8px; }
.card p { font-size: 15px; color: var(--muted); }

a.card-link { color: var(--ink); display: block; }
a.card-link:hover { text-decoration: none; }
a.card-link:hover .card, .card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  box-shadow: 0 14px 40px -18px color-mix(in srgb, var(--accent) 55%, transparent);
}

.card .card-glyph {
  font-size: 26px; margin-bottom: 12px; display: block;
  filter: drop-shadow(0 0 12px color-mix(in srgb, var(--accent) 60%, transparent));
}

/* ---------- buttons / controls ---------- */

.btn {
  display: inline-block; padding: 11px 22px; border-radius: 12px;
  min-height: 44px; /* thumb-sized on a phone */
  font-weight: 700; font-size: 15px; font-family: var(--font-body);
  color: #04060c; cursor: pointer; border: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 24px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform .15s ease, filter .15s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.1); text-decoration: none; }
.btn.ghost {
  color: var(--ink); background: transparent;
  border: 1px solid var(--line-bright); box-shadow: none;
}
.btn.ghost:hover { border-color: var(--accent); }

.control-row {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  margin: 18px 0;
}
.control { display: flex; flex-direction: column; gap: 5px; }
.control label {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
.control select, .control input[type="text"], .control input[type="search"] {
  background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line-bright); border-radius: 10px;
  padding: 8px 12px; font-size: 14.5px; font-family: var(--font-body);
  min-height: 44px; /* thumb-sized on a phone */
}
.control select:focus, .control input:focus { border-color: var(--accent); outline: none; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 180px; height: 6px; border-radius: 999px;
  background: var(--line-bright); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 70%, transparent);
  border: 2px solid #04060c;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 2px solid #04060c;
}

/* ---------- panels, stats, bars ---------- */

.panel {
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 24px; margin: 22px 0;
}

.note {
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  border-radius: 0 14px 14px 0;
  padding: 16px 20px; margin: 22px 0;
  font-size: 15px; color: var(--muted);
}
.note strong { color: var(--ink); }

.stat-row {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin: 26px 0;
}
.stat {
  border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; text-align: left;
  background: linear-gradient(160deg, var(--panel2), var(--panel));
}
.stat .num {
  display: block; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(22px, 3vw, 30px); line-height: 1.15; margin-bottom: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat .lbl { font-size: 13px; color: var(--muted); line-height: 1.4; }

.bar-row { display: grid; grid-template-columns: 130px 1fr 84px; gap: 10px; align-items: center; margin: 7px 0; font-size: 14px; }
.bar-row .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .val { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); text-align: right; }
.bar {
  height: 16px; border-radius: 999px; min-width: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 14px -2px color-mix(in srgb, var(--accent) 60%, transparent);
  transition: width .5s ease;
}
@media (max-width: 560px) { .bar-row { grid-template-columns: 92px 1fr 70px; } }

/* ---------- tags ---------- */

.tag {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.06em;
  border: 1px solid var(--line-bright); color: var(--muted);
  vertical-align: middle;
}
.tag.est { border-style: dashed; }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; margin: 22px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 560px; }
.data-table th {
  text-align: left; font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  padding: 12px 16px; border-bottom: 1px solid var(--line-bright);
  background: var(--panel2);
}
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }

/* ---------- canvas / demo frames ---------- */

.canvas-frame {
  border: 1px solid var(--line-bright); border-radius: 18px;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg2), var(--bg));
  padding: 14px; margin: 22px 0;
  box-shadow: inset 0 0 60px -30px color-mix(in srgb, var(--accent) 35%, transparent);
}
.canvas-frame canvas { display: block; width: 100%; height: auto; border-radius: 10px; touch-action: none; }

/* ---------- drawer (element detail etc.) ---------- */

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 80;
  width: min(420px, 92vw);
  background: linear-gradient(180deg, var(--panel2), var(--bg2));
  border-left: 1px solid var(--line-bright);
  box-shadow: -30px 0 80px -30px rgba(0, 0, 0, 0.8);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s;
  overflow-y: auto; overscroll-behavior: contain; padding: 26px;
}
.drawer.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s;
}
.drawer .close-x {
  position: absolute; top: 14px; right: 14px;
  background: none; border: 1px solid var(--line-bright); color: var(--muted);
  border-radius: 50%; width: 34px; height: 34px; font-size: 16px; cursor: pointer;
}
.drawer .close-x:hover { color: var(--ink); border-color: var(--accent); }

/* the dimmed sheet behind an open drawer */
.scrim {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(4, 6, 12, 0.62);
  opacity: 0; pointer-events: none;
  transition: opacity .28s ease;
}
.scrim.on { opacity: 1; pointer-events: auto; }

/* ---------- sources ---------- */

.src-list { list-style: none; margin: 14px 0; }
.src-list li {
  font-size: 14px; color: var(--muted);
  padding: 9px 0 9px 0; border-bottom: 1px dashed var(--line);
}
.src-list li:last-child { border-bottom: 0; }

/* ---------- footer (injected by nav.js) ---------- */

.site-footer {
  margin-top: 70px; border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg), var(--bg2));
  padding: 44px 0 54px;
}
.site-footer .cols {
  max-width: 1160px; margin: 0 auto; padding: 0 22px;
  display: flex; flex-wrap: wrap; gap: 34px; justify-content: space-between;
}
.site-footer .foot-brand {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 8px;
}
.site-footer p { font-size: 13.5px; color: var(--muted); max-width: 40em; }
.site-footer ul { list-style: none; columns: 2; gap: 34px; }
.site-footer ul li { margin: 4px 0; }
.site-footer ul a { color: var(--muted); font-size: 13.5px; }
.site-footer ul a:hover { color: var(--ink); }
.site-footer .fine { margin-top: 26px; font-size: 12.5px; color: var(--muted); opacity: 0.8; }

/* ---------- element tiles (periodic table + strips) ---------- */

.el-tile {
  border-radius: 8px; padding: 5px 4px 4px; cursor: pointer;
  border: 1px solid transparent; text-align: left; position: relative;
  color: #04060c; font-family: var(--font-body); line-height: 1.1;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.el-tile .z { font-size: 9px; font-weight: 600; opacity: 0.75; display: block; }
.el-tile .sym { font-size: 15px; font-weight: 800; display: block; }
.el-tile:hover, .el-tile:focus-visible {
  transform: scale(1.14); z-index: 5;
  box-shadow: 0 6px 22px -6px rgba(0, 0, 0, 0.9);
  filter: brightness(1.15);
}
.cat-alkali          { background: var(--cat-alkali); }
.cat-alkaline        { background: var(--cat-alkaline); }
.cat-transition      { background: var(--cat-transition); }
.cat-post-transition { background: var(--cat-post-transition); }
.cat-metalloid       { background: var(--cat-metalloid); }
.cat-nonmetal        { background: var(--cat-nonmetal); }
.cat-halogen         { background: var(--cat-halogen); }
.cat-noble           { background: var(--cat-noble); }
.cat-lanthanide      { background: var(--cat-lanthanide); }
.cat-actinide        { background: var(--cat-actinide); }
.cat-unknown         { background: var(--cat-unknown); color: var(--ink); }

/* ---------- periodic table component (assets/ptable.js) ----------
   The hub and the full chart page mount the same component, so every
   class it builds lives here rather than in either page's own block. */

/* the grid rides inside .table-scroll, and keeps its sideways swipe to itself */
.ptable-frame {
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.ptable {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  gap: 4px;
  min-width: 980px;
  padding: 12px;
}
.ptable .el-tile {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden; padding: 4px 4px 5px;
}
.ptable .el-tile .z { font-size: 9px; letter-spacing: 0.02em; }
.ptable .el-tile .sym {
  font-size: clamp(13px, 1.4vw, 17px); letter-spacing: -0.01em; margin: 1px 0;
}
.ptable .el-tile .nm {
  display: block; font-size: 7.5px; font-weight: 600; opacity: 0.78;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ptable .el-tile .pv {
  display: none; font-family: var(--font-mono); font-size: 8px; font-weight: 600;
  opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ptable.mode-prop .el-tile .nm { display: none; }
.ptable.mode-prop .el-tile .pv { display: block; }
.ptable.mode-prop .el-tile { color: #04060c; }
.ptable.mode-prop .el-tile.no-data { color: var(--muted); }
.ptable .el-tile.dim { opacity: 0.13; filter: saturate(0.25); }
.ptable .el-tile.dim:hover, .ptable .el-tile.dim:focus-visible { opacity: 0.5; }
.ptable.show-records .el-tile.has-rec {
  box-shadow: 0 0 0 2px var(--ink), 0 0 22px 1px rgba(242, 245, 255, 0.55);
  z-index: 3;
}
.ptable .el-tile.picked { outline: 2px solid var(--ink); outline-offset: 2px; }

/* the dashed gaps in rows six and seven, where the two loose rows belong */
.ptable-ph {
  aspect-ratio: 1 / 1; border: 1px dashed var(--line-bright); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--font-mono); font-size: 8.5px; line-height: 1.2; color: var(--muted);
}
.ptable-series {
  grid-column: 1 / 4; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 10px; text-align: right; line-height: 1.25;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em; color: var(--muted);
}
.ptable-gap { grid-column: 1 / -1; height: 18px; }

/* the colour key, filled by the component when a page passes it one */
.ptable-legend {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 10px;
}
.ptable-legend .ramp {
  height: 14px; flex: 1 1 200px; min-width: 160px; border-radius: 999px;
  border: 1px solid var(--line-bright);
  background: linear-gradient(90deg, #60a5fa, #2dd4bf, #a3e635, #fbbf24, #fb7185);
}
.ptable-legend .end {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink); white-space: nowrap;
}
.ptable-legend .nodata {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
}
.ptable-legend .nodata i {
  width: 15px; height: 15px; border-radius: 4px; display: inline-block;
  background: #121b33; border: 1px solid var(--line-bright);
}
.ptable-legend-note { font-size: 14.5px; color: var(--muted); max-width: 64em; }
.ptable-search-status {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); min-height: 1.2em;
}
.ptable-hint { font-size: 13.5px; color: var(--muted); margin-top: 6px; }

.ptable-fam-key {
  list-style: none; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); margin-top: 18px;
}
.ptable-fam-key li {
  display: grid; grid-template-columns: 36px 1fr; gap: 13px; align-items: start;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px;
  background: linear-gradient(160deg, var(--panel2), var(--panel));
}
.ptable-fam-key .sw {
  width: 36px; height: 36px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center;
  color: #04060c; font-weight: 800; font-size: 12px;
}
.ptable-fam-key b { display: block; font-size: 14.5px; margin-bottom: 2px; }
.ptable-fam-key .d { font-size: 13.5px; color: var(--muted); line-height: 1.45; }

/* the element card, written into the drawer by the component */
.el-card .el-head {
  display: flex; gap: 15px; align-items: flex-start; padding-right: 44px; margin-bottom: 14px;
}
.el-card .el-badge {
  width: 78px; height: 78px; flex: 0 0 auto; border-radius: 16px; color: #04060c;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.el-card .el-badge .s {
  font-family: var(--font-display); font-weight: 900; font-size: 27px; line-height: 1;
}
.el-card .el-badge .n { font-family: var(--font-mono); font-size: 10px; margin-top: 4px; }
.el-card .el-name {
  font-family: var(--font-display); font-weight: 700; font-size: 25px; line-height: 1.1;
  margin-bottom: 9px;
}
.el-card .prop {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.el-card .prop .k { font-size: 13.5px; color: var(--muted); }
.el-card .prop .v { font-family: var(--font-mono); font-size: 14px; text-align: right; }
.el-card .prop .plain {
  grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); line-height: 1.45;
}
.el-card .sec-h {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent); margin: 22px 0 8px;
}
.el-card .rec-list { list-style: none; }
.el-card .rec-list li {
  font-size: 14px; padding: 10px 13px; margin-bottom: 8px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  border-left: 3px solid var(--accent);
}
.el-card .drawer-note {
  margin-top: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
@media (max-width: 620px) {
  .el-card .el-badge { width: 64px; height: 64px; }
  .el-card .el-badge .s { font-size: 22px; }
}

/* ---------- misc ---------- */

.mono { font-family: var(--font-mono); font-size: 0.92em; }

/* Reveal is opt-in: the class below is added by nav.js once it is running.
   Without JavaScript, or if the script is throttled or dropped on a long page,
   every block stays visible instead of the page going dark. */
html.reveal-on .reveal { opacity: 0; transform: translateY(18px); transition: opacity .5s ease, transform .5s ease; }
html.reveal-on .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
  html { scroll-behavior: auto; }
  html.reveal-on .reveal { opacity: 1; transform: none; }
}

/* ---------- previous and next ---------- */

.page-turn {
  max-width: 1160px; margin: 0 auto; padding: 26px 22px 4px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.page-turn-slot {
  display: flex; flex-direction: column; gap: 3px;
  min-height: 76px; padding: 15px 18px;
  border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  color: var(--ink); justify-content: center;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
a.page-turn-slot:hover {
  text-decoration: none; transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  box-shadow: 0 14px 34px -20px color-mix(in srgb, var(--accent) 60%, transparent);
}
.page-turn .turn-next { text-align: right; align-items: flex-end; }
.turn-dir {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent);
}
.turn-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 1.2; }
.turn-wing { font-size: 12.5px; color: var(--muted); }
.page-turn-slot:empty, span.page-turn-slot { border: 0; background: none; box-shadow: none; }

@media (max-width: 620px) {
  .page-turn { grid-template-columns: 1fr; }
  .page-turn .turn-next { text-align: left; align-items: flex-start; }
  span.page-turn-slot { display: none; }
}

/* ---------- back to top ---------- */

.to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 45;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 12px 18px;
  border-radius: 999px; cursor: pointer;
  font-family: var(--font-body); font-size: 14px; font-weight: 700;
  color: #04060c;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.9);
  opacity: 0; visibility: hidden; transform: translateY(14px);
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.to-top.show {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .22s ease, transform .22s ease, visibility 0s;
}
.to-top:hover { filter: brightness(1.1); }
.to-top span[aria-hidden] { font-size: 16px; line-height: 1; }

@media (max-width: 520px) {
  .to-top { right: 14px; bottom: 14px; padding: 12px 15px; }
  .to-top-word { display: none; }
}
body[data-page="beyondtable"] { --accent: #a78bfa; --accent2: #22d3ee; }
body[data-page="outofphase"]  { --accent: #67e8f9; --accent2: #f0abfc; }
body[data-page="tesla"]       { --accent: #fde047; --accent2: #38bdf8; }
