/* components.css - the reusable furniture. */

/* ======================================================================
   Site navigation. A bar on a phone, a rail on a wide screen.
   ====================================================================== */

.sitenav {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.sitenav__inner {
  width: min(100% - 1rem, calc(var(--wide) + 8rem));
  margin-inline: auto;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: var(--gap-2);
}

.sitenav__mark {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-decoration: none;
  padding-right: 0.35rem;
}
.sitenav__mark span {
  color: var(--ink-faint);
  font-weight: 400;
}

.sitenav__links {
  display: flex;
  gap: 0.1rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sitenav__links::-webkit-scrollbar {
  display: none;
}

.sitenav__links a {
  display: block;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: var(--radius);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.sitenav__links a:hover {
  background: var(--paper-sunk);
  color: var(--ink);
}
.sitenav__links a[aria-current='true'] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.controls {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

/* On a phone the bar is wider than the screen, and that is fine as long as
   the BAR is what scrolls. Measured at a real 375 px viewport before this
   rule existed: the mark and the two control groups are both nowrap and come
   to 519 px together, .sitenav__inner had no overflow of its own so that
   spilled and dragged the whole document to 527 px wide, and the links list
   was squeezed to a client width of ZERO, so the section links could not be
   reached at all. Giving the inner bar the scrolling instead of the list
   fixes both: the page stops scrolling sideways and every link is reachable
   by pushing the bar. Above 60rem, which is the breakpoint this file already
   uses, nothing changes. */
@media (max-width: 59.99rem) {
  .sitenav__inner {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }
  .sitenav__inner::-webkit-scrollbar { display: none; }
  .sitenav__mark,
  .controls { flex: 0 0 auto; }
  .sitenav__links {
    flex: 0 0 auto;
    overflow-x: visible;
    min-width: 0;
  }
}

/* ======================================================================
   Buttons, toggles, controls
   ====================================================================== */

.btn,
.seg button {
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover,
.seg button:hover {
  background: var(--paper-sunk);
}
.btn[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}
.seg button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--rule);
  background: transparent;
  padding: 0.4rem 0.7rem;
}
.seg button:last-child {
  border-right: 0;
}
.seg button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.togglebar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: var(--gap-3);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  padding: 0.32rem 0.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper-raised);
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1.2;
}
.chip:hover {
  background: var(--paper-sunk);
}
.chip[aria-pressed='true'] {
  color: var(--ink);
  border-color: currentColor;
  background: var(--paper-raised);
  font-weight: 500;
}
.chip__swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  background: var(--sw, var(--ink-faint));
  border: 1px solid rgb(0 0 0 / 0.2);
  flex: none;
}
.chip[aria-pressed='false'] .chip__swatch {
  background: transparent;
  border-style: dashed;
}

input[type='range'] {
  accent-color: var(--accent);
  width: 100%;
  min-height: 2rem;
}

.field {
  display: grid;
  gap: 0.2rem;
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
.field > span {
  color: var(--ink-soft);
}
.field input[type='number'],
.field input[type='text'],
.field select {
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
  width: 100%;
}

/* A component placeholder must have real height before it mounts. An empty
   div is zero pixels tall, and a zero-area target never reports as
   intersecting, so the lazy-mount observer would never fire for it and the
   figure would never appear at all. This also reserves the space so nothing
   jumps when the diagram arrives. */
[data-component]:not([data-mounted]) {
  display: block;
  min-height: 16rem;
  border: 1px dashed var(--rule);
  border-radius: var(--radius-lg);
  margin: var(--gap-4) 0;
}
[data-component][data-mounted] {
  display: block;
  border: 0;
  min-height: 0;
}

/* ======================================================================
   Figures
   ====================================================================== */

.fig {
  margin: var(--gap-4) 0;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--gap-3);
  box-shadow: var(--shadow-1);
}
.fig > svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.fig__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap-2);
  margin-bottom: var(--gap-2);
}
.fig__title {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--step-0);
  margin: 0;
}
.fig figcaption,
.fig__note {
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin-top: var(--gap-2);
  line-height: 1.5;
}
.fig__photos {
  display: grid;
  gap: var(--gap-3);
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
}
.fig__photos figure {
  margin: 0;
}
.fig__photos img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
}
.fig__photos figcaption {
  margin-top: 0.5rem;
}
.fig__scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.fig__readout {
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: var(--step--1);
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin-top: var(--gap-2);
}
.fig__readout b {
  color: var(--ink);
  font-weight: 600;
}

/* ======================================================================
   Verification markers. Every claim that is not verified says so.
   ====================================================================== */

.mark {
  font-family: var(--font-ui);
  font-size: 0.68em;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.1em 0.42em;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
  vertical-align: 0.15em;
  margin-inline: 0.15em;
  cursor: help;
}
.mark--primary {
  color: var(--mark-primary);
}
.mark--secondary {
  color: var(--mark-secondary);
}
.mark--derived {
  color: var(--mark-derived);
}
.mark--contested {
  color: var(--mark-contested);
}
.mark--inferred {
  color: var(--mark-inferred);
}
.mark--unverified {
  color: var(--mark-unverified);
  background: color-mix(in srgb, var(--mark-unverified) 12%, transparent);
}

/* A whole block that rests on unverified ground. */
.caveat {
  border-left: 3px solid var(--mark-unverified);
  background: color-mix(in srgb, var(--mark-unverified) 7%, transparent);
  padding: var(--gap-2) var(--gap-3);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: var(--gap-3) 0;
  font-size: var(--step--1);
}
.caveat--contested {
  border-left-color: var(--mark-contested);
  background: color-mix(in srgb, var(--mark-contested) 8%, transparent);
}
.caveat--inferred {
  border-left-color: var(--mark-inferred);
  background: color-mix(in srgb, var(--mark-inferred) 8%, transparent);
}
.caveat__label {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.2rem;
}

/* ======================================================================
   Tables
   ====================================================================== */

.tablewrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin: var(--gap-3) 0;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-ui);
  font-size: var(--step--1);
}
th,
td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
thead th {
  background: var(--paper-sunk);
  font-weight: 600;
  color: var(--ink-soft);
  position: sticky;
  top: 0;
}
tbody tr:last-child td {
  border-bottom: 0;
}
td.num,
th.num {
  text-align: right;
}

/* ======================================================================
   Cards and small print
   ====================================================================== */

.cards {
  display: grid;
  gap: var(--gap-2);
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin: var(--gap-3) 0;
}
.card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--gap-2) var(--gap-3);
  background: var(--paper-raised);
}
.card h4 {
  margin-bottom: 0.25rem;
}
.card p {
  margin: 0;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.stat {
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.05;
  display: block;
}
.stat + .stat__label {
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin-top: var(--gap-2);
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.legend i {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
  background: var(--sw);
  flex: none;
}

/* ======================================================================
   The panorama
   ====================================================================== */

.pano {
  position: relative;
  background: linear-gradient(180deg, var(--sky-high), var(--sky-low));
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--rule);
}
.pano__scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.pano svg {
  display: block;
  height: clamp(240px, 46vw, 460px);
  width: auto;
  /* The global `max-width: 100%` on svg would squash a 3,800 px wide strip
     into the column and kill the horizontal scroll, which is the whole point
     of the panorama. */
  max-width: none;
}
.pano__scrollhint {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  color: var(--ink-soft);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  pointer-events: none;
}

/* A halo behind label text, so a name stays readable over terrain of any
   brightness. paint-order puts the stroke behind the fill, which is the only
   way to do this in SVG without duplicating every text node. */
.label {
  font-family: var(--font-ui);
  paint-order: stroke fill;
  stroke: var(--paper);
  stroke-width: 3.5px;
  stroke-linejoin: round;
  fill: var(--ink);
}
.label--dim {
  opacity: 0.55;
}
.leader {
  stroke: var(--ink-soft);
  stroke-width: 1;
  stroke-dasharray: 2 2;
}

/* ======================================================================
   Stepper for the deep-time cross section
   ====================================================================== */

.stepper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: var(--gap-2);
}
.stepper__track {
  display: flex;
  flex: 1 1 14rem;
  gap: 2px;
  min-width: 10rem;
}
.stepper__tick {
  flex: 1;
  height: 0.6rem;
  background: var(--rule);
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 2px;
}
.stepper__tick[aria-current='true'] {
  background: var(--accent);
}
.stepper__tick:hover {
  background: var(--rule-strong);
}

/* ======================================================================
   Sources
   ====================================================================== */

.sources {
  font-size: var(--step--1);
}
.sources dt {
  font-family: var(--font-ui);
  font-weight: 600;
  margin-top: var(--gap-2);
}
.sources dd {
  margin: 0.1rem 0 0;
  color: var(--ink-soft);
}

.footer {
  border-top: 1px solid var(--rule);
  padding-block: var(--gap-4) var(--gap-5);
  font-size: var(--step--1);
  color: var(--ink-faint);
}

@media (min-width: 60rem) {
  .split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--gap-4);
    align-items: start;
  }
}
