/* BKKx 3D Atlas — sharp edges, no rounded corners, no shadows.
   Mirrors the BKKx public site aesthetic: ink, paper, signal yellow.
   Atlas-specific UI sits in .atlas-*; everything else follows the
   house rules. */

:root {
  --ink: #11120f;
  --paper: #f1efe8;
  --paper-strong: #fffdf5;
  --signal: #c9ff38;
  --orange: #ff6b35;
  --muted: #a4a69b;
  --line: rgba(241, 239, 232, 0.18);
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); }

body { font-family: var(--font-body); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; cursor: pointer; }
button { font: inherit; }

::selection { color: var(--ink); background: var(--signal); }

.atlas-page {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  grid-template-rows: auto 1fr;
  grid-template-areas: "header header" "map panel";
  background: var(--ink);
  color: var(--paper);
}

.atlas-header {
  grid-area: header;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 18px clamp(20px, 3vw, 48px);
  background: rgba(17, 18, 15, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 1;
}
.wordmark b { color: var(--signal); font-size: 34px; }

.atlas-header-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.atlas-eyebrow {
  color: var(--signal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.atlas-header-meta strong {
  font-family: var(--font-display);
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 800;
  letter-spacing: -0.05em;
}
.atlas-header-meta small { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }

.atlas-header-nav {
  display: flex; align-items: center; gap: 22px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.atlas-header-nav a { transition: color 180ms ease; }
.atlas-header-nav a:hover, .atlas-header-nav a:focus-visible { color: var(--signal); }

.atlas-map { grid-area: map; position: relative; width: 100%; height: 100%; background: #0a0b08; }
.atlas-map :where(.maplibregl-canvas) { outline: none; }
.atlas-map :where(.maplibregl-ctrl-attrib) { background: rgba(17, 18, 15, 0.7); color: var(--muted); font-size: 10px; }
.atlas-map :where(.maplibregl-ctrl-attrib a) { color: var(--paper); }
.atlas-map :where(.maplibregl-ctrl-group) { border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(17, 18, 15, 0.86); box-shadow: none; }
.atlas-map :where(.maplibregl-ctrl button) { background-color: transparent; filter: invert(1) hue-rotate(180deg); }

.atlas-panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px clamp(22px, 2.6vw, 36px) 32px;
  overflow-y: auto;
  background: #0d0e0b;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.atlas-quick-heading {
  margin: 6px 0 14px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.atlas-layers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.atlas-layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.atlas-layer-toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: border-color 160ms ease;
}
.atlas-layer-toggle:hover { border-color: var(--signal); }
.atlas-layer-toggle input[type="checkbox"] {
  appearance: none;
  width: 32px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  position: relative;
  cursor: pointer;
  margin: 0;
  transition: background 160ms ease, border-color 160ms ease;
}
.atlas-layer-toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.4);
  transition: transform 160ms ease, background 160ms ease;
}
.atlas-layer-toggle input[type="checkbox"]:checked {
  background: var(--signal);
  border-color: var(--signal);
}
.atlas-layer-toggle input[type="checkbox"]:checked::after {
  transform: translateX(14px);
  background: var(--ink);
}
.atlas-layer-name strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--paper);
}
.atlas-layer-name small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.atlas-layer-state {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.atlas-layer-toggle input[type="checkbox"]:checked ~ .atlas-layer-state { color: var(--signal); }

.atlas-eyebrow-sub {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
}

.atlas-layer-list-sub { gap: 4px; }

.atlas-layer-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.atlas-layer-sub {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 28px;
  font-size: 11px;
  letter-spacing: 0.01em;
  color: var(--muted);
  cursor: pointer;
  border: 1px solid transparent;
  border-top: none;
}
.atlas-layer-sub:hover { color: var(--paper); }
.atlas-layer-sub input[type="checkbox"] {
  appearance: none;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  position: relative;
  cursor: pointer;
  margin: 0;
  transition: background 160ms ease, border-color 160ms ease;
}
.atlas-layer-sub input[type="checkbox"]:checked {
  background: var(--signal);
  border-color: var(--signal);
}

.atlas-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: none;
  background: rgba(0, 0, 0, 0.18);
}
.atlas-legend[hidden] { display: none; }
.atlas-legend-row {
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.atlas-legend-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.atlas-labs {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.atlas-labs-blurb {
  margin: 0;
  color: #d2d4ca;
  font-size: 13px;
  line-height: 1.7;
}
.atlas-labs-blurb strong {
  color: var(--signal);
  font-weight: 800;
}
.atlas-paper-btn {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--signal);
  background: var(--signal);
  color: var(--ink);
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease;
}
.atlas-paper-btn:hover, .atlas-paper-btn:focus-visible {
  background: var(--paper-strong);
  border-color: var(--paper-strong);
  color: var(--ink);
}
.atlas-paper-btn-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.7;
}
.atlas-paper-btn-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.atlas-labs-list {
  margin: 0;
  padding: 0 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #d2d4ca;
  font-size: 13px;
  line-height: 1.6;
}
.atlas-labs-list strong {
  display: block;
  color: var(--paper);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 2px;
}
.atlas-labs-rant {
  margin: 6px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--signal);
  background: rgba(201, 255, 56, 0.05);
  color: #d2d4ca;
  font-size: 13px;
  line-height: 1.7;
}

.atlas-area-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.atlas-area-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: left;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.atlas-area-btn:hover, .atlas-area-btn:focus-visible {
  border-color: var(--signal);
  color: var(--signal);
  transform: translateX(2px);
}
.atlas-area-btn.is-active {
  color: var(--ink);
  background: var(--signal);
  border-color: var(--signal);
}
.atlas-area-btn .atlas-area-num {
  color: inherit;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.72;
}
.atlas-area-btn.is-active .atlas-area-num { opacity: 0.55; }

.atlas-active {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.atlas-active[hidden] { display: none; }

.atlas-active-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 2.4vw, 38px);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 0.96;
}
.atlas-active-thai { margin: 0; color: var(--muted); font-size: 14px; }
.atlas-active-chapter { margin: 8px 0 0; color: var(--signal); font-size: 10px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.atlas-active-desc { margin: 8px 0 0; color: #d2d4ca; font-size: 14px; line-height: 1.7; }
.atlas-active-stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; margin: 14px 0 0; padding: 0;
}
.atlas-active-stats div {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.atlas-active-stats dt { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.atlas-active-stats dd { margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 800; }
.atlas-active-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  list-style: none; margin: 14px 0 0; padding: 0;
}
.atlas-active-tags li {
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.atlas-share {
  margin-top: 18px;
  padding: 12px 16px;
  border: 1px solid var(--signal);
  background: transparent;
  color: var(--ink);
  background-color: var(--signal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.atlas-share:hover, .atlas-share:focus-visible { background: var(--paper-strong); border-color: var(--paper-strong); }

.atlas-panel-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}
.atlas-panel-foot a { color: var(--paper); border-bottom: 1px solid rgba(255, 255, 255, 0.22); }

.atlas-data {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.atlas-data-heading {
  margin: 6px 0 10px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.atlas-data-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.atlas-data-list li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.atlas-data-list li:hover { border-color: var(--signal); }
.atlas-data-list a {
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.atlas-data-list a:hover, .atlas-data-list a:focus-visible { color: var(--signal); }
.atlas-data-list small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.atlas-data-extra {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}
.atlas-data-extra code {
  padding: 1px 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 9px;
}

@media (max-width: 1000px) {
  .atlas-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(55vh, 1fr) auto;
    grid-template-areas: "header" "map" "panel";
  }
  .atlas-panel { border-left: 0; border-top: 1px solid rgba(255, 255, 255, 0.16); max-height: 45vh; }
  .atlas-header-nav a:not([href^="https"]) { display: none; }
  .atlas-area-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
