:root {
  --ink: #07100b;
  --ink-soft: #0d1711;
  --ink-raised: #121f17;
  --forest: #1b3023;
  --parchment: #efe5d0;
  --parchment-soft: #bdb29b;
  --parchment-dim: #817c70;
  --gold: #c9a45a;
  --gold-bright: #efd18a;
  --rust: #a65b38;
  --green: #77b68a;
  --line: rgba(230, 211, 168, 0.16);
  --line-strong: rgba(230, 211, 168, 0.3);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 78% 9%, rgba(64, 107, 75, 0.18), transparent 25rem),
    linear-gradient(180deg, #09120d 0, var(--ink) 47rem);
  color: var(--parchment);
  font-family: var(--sans);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background-image: url("/assets/astonia/world/cameron/00012000.png");
  background-repeat: repeat;
  background-size: 84px;
  content: "";
  image-rendering: pixelated;
  opacity: 0.018;
  pointer-events: none;
}

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

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

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

h1,
h2,
h3,
p,
dl {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.03;
}

h1 {
  margin-bottom: 1.25rem;
  font-size: clamp(3.5rem, 8vw, 7.8rem);
}

h2 {
  margin-bottom: 1.1rem;
  font-size: clamp(2.5rem, 5vw, 5rem);
}

code {
  font-family: var(--mono);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 1rem;
  transform: translateY(-180%);
  border: 1px solid var(--gold);
  background: var(--parchment);
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.codex-header {
  display: flex;
  width: min(1500px, calc(100% - 64px));
  min-height: 94px;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-inline: auto;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--parchment);
  text-decoration: none;
}

.wordmark-seal {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  transform: rotate(45deg);
  border: 1px solid rgba(240, 210, 141, 0.55);
  background: rgba(3, 9, 6, 0.72);
  color: transparent;
  font-family: var(--serif);
  font-size: 0.78rem;
}

.wordmark-seal::after {
  content: "IA";
  transform: rotate(-45deg);
  color: var(--gold-bright);
}

.wordmark strong,
.wordmark small {
  display: block;
}

.wordmark strong {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.wordmark small {
  color: var(--parchment-dim);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.codex-header nav,
footer nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.codex-header nav a,
footer nav a {
  color: var(--parchment-soft);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.codex-header nav a:hover,
footer nav a:hover {
  color: var(--gold-bright);
}

.codex-header .play-link {
  padding: 0.65rem 1rem;
  border: 1px solid rgba(203, 168, 95, 0.62);
  color: var(--gold-bright);
}

.codex-hero {
  display: grid;
  width: min(1320px, calc(100% - 64px));
  min-height: 590px;
  align-items: center;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.65fr);
  gap: clamp(4rem, 9vw, 10rem);
  margin-inline: auto;
  padding: 6rem 0 5rem;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.eyebrow span {
  width: 27px;
  height: 1px;
  background: currentColor;
}

.lede {
  max-width: 760px;
  margin-bottom: 2rem;
  color: var(--parchment-soft);
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.2vw, 1.6rem);
  line-height: 1.55;
}

.provenance {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
}

.source-state {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.7rem;
  border: 1px solid rgba(119, 182, 138, 0.3);
  background: rgba(35, 83, 49, 0.2);
  color: #b7d6bb;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.source-state i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #78bc8b;
  box-shadow: 0 0 12px rgba(119, 182, 138, 0.7);
}

.provenance > a {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  color: var(--parchment-soft);
  font-size: 0.8rem;
  text-decoration: none;
}

.provenance > a:hover span {
  color: var(--gold-bright);
}

.provenance code {
  color: var(--gold);
}

.folio {
  position: relative;
  padding: 4rem 2.3rem 2.4rem;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(145deg, rgba(203, 168, 95, 0.08), transparent 45%),
    rgba(13, 24, 17, 0.75);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.folio::before,
.folio::after {
  position: absolute;
  width: 36px;
  height: 36px;
  content: "";
}

.folio::before {
  top: 10px;
  left: 10px;
  border-top: 1px solid var(--gold);
  border-left: 1px solid var(--gold);
}

.folio::after {
  right: 10px;
  bottom: 10px;
  border-right: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
}

.folio-number {
  position: absolute;
  top: -1rem;
  right: 1rem;
  color: rgba(203, 168, 95, 0.09);
  font-family: var(--serif);
  font-size: 9rem;
  line-height: 1;
}

.folio p {
  position: relative;
  color: var(--parchment-soft);
  font-family: var(--serif);
  font-size: 1.06rem;
}

.folio a {
  position: relative;
  color: var(--gold-bright);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
}

.count-band {
  border-block: 1px solid var(--line);
  background: rgba(12, 23, 16, 0.78);
}

.count-band dl {
  display: grid;
  width: min(1500px, calc(100% - 64px));
  grid-template-columns: repeat(7, 1fr);
  margin: 0 auto;
}

.count-band dl div {
  padding: 1.6rem 1rem;
  border-left: 1px solid var(--line);
  text-align: center;
}

.count-band dl div:last-child {
  border-right: 1px solid var(--line);
}

.count-band dt {
  margin-bottom: 0.15rem;
  color: var(--gold-bright);
  font-family: var(--serif);
  font-size: clamp(1.45rem, 2.5vw, 2.2rem);
  line-height: 1;
}

.count-band dd {
  margin: 0;
  color: var(--parchment-dim);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.explorer-shell,
.method {
  width: min(1500px, calc(100% - 64px));
  margin-inline: auto;
  padding: 7rem 0;
}

.explorer-heading {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 0.6fr);
  gap: 4rem;
  align-items: end;
  margin-bottom: 2.5rem;
}

.explorer-heading h2 {
  margin-bottom: 0;
}

.explorer-heading > p {
  margin-bottom: 0.65rem;
  color: var(--parchment-soft);
}

.explorer-panel {
  border: 1px solid var(--line-strong);
  background: rgba(10, 20, 14, 0.86);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.28);
}

.dataset-tabs {
  display: flex;
  padding: 0 1rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-color: var(--gold-dark, #765c2d) transparent;
}

.dataset-tabs button {
  flex: 0 0 auto;
  padding: 1.15rem 1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--parchment-dim);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dataset-tabs button span {
  margin-left: 0.3rem;
  color: rgba(203, 168, 95, 0.64);
  font-family: var(--mono);
  font-size: 0.63rem;
}

.dataset-tabs button:hover {
  color: var(--parchment);
}

.dataset-tabs button[aria-selected="true"] {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(150px, 210px) minmax(110px, 135px);
  gap: 1rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.toolbar label {
  display: grid;
  gap: 0.45rem;
}

.toolbar label > span:first-child {
  color: var(--parchment-dim);
  font-size: 0.6rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.search-box {
  display: flex;
  height: 46px;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line-strong);
  background: #08110c;
}

.search-box:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(203, 168, 95, 0.12);
}

.search-box svg {
  width: 18px;
  fill: none;
  stroke: var(--parchment-dim);
  stroke-linecap: round;
  stroke-width: 1.6;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--parchment);
}

.search-box input::placeholder {
  color: #68675f;
}

.search-box kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--parchment-dim);
  font-family: var(--mono);
  font-size: 0.65rem;
}

.toolbar select {
  height: 46px;
  padding: 0 2.2rem 0 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #08110c;
  color: var(--parchment);
  cursor: pointer;
}

.result-meta {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
}

.result-meta p {
  margin: 0;
  color: var(--parchment-soft);
  font-size: 0.78rem;
}

.result-meta strong {
  color: var(--parchment);
  font-weight: 700;
}

.result-meta button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  border-block: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: left;
}

th {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line-strong);
  background: #0f1b14;
  color: var(--parchment-dim);
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  max-width: 380px;
  padding: 0.85rem 1rem;
  overflow: hidden;
  border-bottom: 1px solid rgba(230, 211, 168, 0.08);
  color: var(--parchment-soft);
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

tbody tr:hover,
tbody tr:focus-within {
  background: rgba(203, 168, 95, 0.06);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.primary-cell {
  color: var(--parchment);
  font-family: var(--serif);
  font-size: 0.96rem;
}

td code {
  color: var(--gold);
  font-size: 0.7rem;
}

.record-button {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.flag-list {
  display: flex;
  gap: 0.3rem;
}

.flag-list span {
  padding: 0.18rem 0.4rem;
  border: 1px solid rgba(203, 168, 95, 0.19);
  background: rgba(203, 168, 95, 0.05);
  color: #c7baa0;
  font-family: var(--mono);
  font-size: 0.57rem;
}

.muted {
  color: var(--parchment-dim);
}

.loading-cell,
.empty-cell {
  height: 250px;
  color: var(--parchment-dim);
  text-align: center;
}

.loading-mark {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 0.5rem;
  animation: spin 900ms linear infinite;
  border: 1px solid var(--line-strong);
  border-top-color: var(--gold);
  border-radius: 50%;
  vertical-align: -2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.pagination {
  display: grid;
  min-height: 68px;
  align-items: center;
  grid-template-columns: 1fr auto 1fr;
  padding: 0.75rem 1.25rem;
}

.pagination p {
  margin: 0;
  color: var(--parchment-dim);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.pagination button {
  width: fit-content;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--parchment-soft);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
}

.pagination button:last-child {
  justify-self: end;
}

.pagination button:not(:disabled):hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.method {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(4rem, 9vw, 10rem);
  border-top: 1px solid var(--line);
}

.method-copy > p {
  color: var(--parchment-soft);
}

.method-copy dl {
  margin: 2rem 0;
  border-top: 1px solid var(--line);
}

.method-copy dl div {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 1.5rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.method-copy dt {
  color: var(--parchment-dim);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.method-copy dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.method-copy dd code {
  color: var(--gold);
  font-size: 0.72rem;
}

.method-copy a {
  color: var(--gold-bright);
}

.legal-note {
  padding: 1rem 1.2rem;
  border-left: 2px solid var(--gold);
  background: rgba(203, 168, 95, 0.05);
  font-size: 0.82rem;
}

body > footer {
  display: flex;
  width: min(1500px, calc(100% - 64px));
  min-height: 100px;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-inline: auto;
  border-top: 1px solid var(--line);
}

body > footer p {
  margin: 0;
  color: var(--parchment-dim);
  font-family: var(--serif);
}

dialog {
  width: min(880px, calc(100% - 32px));
  max-height: min(860px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #0b1510;
  color: var(--parchment);
  box-shadow: 0 45px 120px rgba(0, 0, 0, 0.75);
}

dialog::backdrop {
  background: rgba(1, 5, 3, 0.82);
  backdrop-filter: blur(4px);
}

dialog > article {
  display: flex;
  max-height: min(860px, calc(100vh - 32px));
  flex-direction: column;
}

dialog header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(203, 168, 95, 0.08), transparent);
}

dialog header p {
  margin-bottom: 0.25rem;
  color: var(--gold);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

dialog header h2 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

#close-dialog {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--parchment-soft);
  cursor: pointer;
  font-family: var(--serif);
  font-size: 1.6rem;
  line-height: 1;
}

#record-content {
  padding: 1.5rem;
  overflow: auto;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
}

.record-field {
  min-width: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(230, 211, 168, 0.1);
  background: rgba(0, 0, 0, 0.12);
}

.record-field.wide {
  grid-column: 1 / -1;
}

.record-field dt {
  margin-bottom: 0.28rem;
  color: var(--parchment-dim);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.record-field dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--parchment-soft);
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.record-field dd code {
  color: var(--gold-bright);
  font-size: 0.7rem;
}

dialog article > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
}

dialog footer a,
dialog footer button {
  border: 0;
  background: transparent;
  color: var(--gold-bright);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.noscript {
  position: fixed;
  z-index: 20;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--gold);
  background: #151209;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .codex-hero,
  .method {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .codex-hero {
    padding-top: 4rem;
  }

  .folio {
    max-width: 620px;
  }

  .count-band dl {
    grid-template-columns: repeat(4, 1fr);
  }

  .count-band dl div:nth-child(4) {
    border-right: 1px solid var(--line);
  }

  .count-band dl div:nth-child(n + 5) {
    border-top: 1px solid var(--line);
  }

  .explorer-heading {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) 1fr 0.7fr;
  }
}

@media (max-width: 700px) {
  .codex-header,
  .codex-hero,
  .count-band dl,
  .explorer-shell,
  .method,
  body > footer {
    width: min(100% - 32px, 1500px);
  }

  .codex-header {
    min-height: 76px;
  }

  .codex-header nav > a:not(.play-link) {
    display: none;
  }

  .codex-hero {
    min-height: 0;
    padding: 4.5rem 0;
  }

  .provenance {
    align-items: flex-start;
    flex-direction: column;
  }

  .provenance > a {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }

  .count-band dl {
    grid-template-columns: repeat(2, 1fr);
  }

  .count-band dl div:nth-child(n) {
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .count-band dl div:nth-child(-n + 2) {
    border-top: 0;
  }

  .count-band dl div:nth-child(even) {
    border-right: 1px solid var(--line);
  }

  .explorer-shell,
  .method {
    padding: 4.5rem 0;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  th,
  td {
    padding-inline: 0.75rem;
  }

  .method-copy dl div {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  body > footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 1.5rem 0;
  }

  footer nav {
    flex-wrap: wrap;
  }

  .record-grid {
    grid-template-columns: 1fr;
  }

  .record-field.wide {
    grid-column: auto;
  }

  dialog article > footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .loading-mark {
    animation: none;
  }
}
