/* Themes: every colour is light-dark(light, dark). The OS picks, or the toggle pins it with data-theme. */
@font-face {
  font-family: "Roboto";
  src: url("/fonts/roboto-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Roboto";
  src: url("/fonts/roboto-greek-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

:root {
  --bg: light-dark(#fbfaf8, #141312);
  --surface: light-dark(#ffffff, #1c1b19);
  --sunken: light-dark(#f3f1ed, #23211f);
  --ink: light-dark(#1b1a19, #ece8e2);
  --muted: light-dark(#5d5852, #a9a29a);
  --line: light-dark(#e2ddd5, #36332f);
  --rule: light-dark(#eeeae4, #262422);
  --shadow-color: light-dark(rgb(40 30 20 / 0.08), rgb(0 0 0 / 0.4));
  --shadow: 0 1px 2px var(--shadow-color), 0 8px 24px var(--shadow-color);

  /* The logo's two spectrum colours. Logo only: the interface has its own accent. */
  --logo-red: light-dark(#a21e16, #e86f63);
  --logo-ochre: light-dark(#b96716, #e3a35d);

  /* Interface roles: a calm slate blue, so the logo's red stays the only strong colour. */
  --accent: light-dark(oklch(0.46 0.075 248), oklch(0.80 0.075 248));
  --accent-ink: light-dark(oklch(0.43 0.085 250), oklch(0.82 0.08 248));
  --on-accent: light-dark(#ffffff, #141312);
  --accent-soft: light-dark(oklch(0.95 0.02 248), oklch(0.30 0.035 248));
  --plot: light-dark(oklch(0.45 0.08 250), oklch(0.80 0.08 248));
  --edge: light-dark(oklch(0.60 0.11 65), oklch(0.78 0.10 72));

  /* Meaning, the same in every palette. */
  --danger: light-dark(oklch(0.50 0.15 28), oklch(0.76 0.12 28));
  --note: light-dark(oklch(0.52 0.10 65), oklch(0.80 0.10 75));
  --type-coreloss: light-dark(oklch(0.47 0.07 255), oklch(0.80 0.07 250));
  --type-lowloss: light-dark(oklch(0.50 0.09 70), oklch(0.82 0.09 78));
  --type-zeroloss: var(--muted);
  --type-xrayabs: light-dark(oklch(0.48 0.07 160), oklch(0.80 0.08 160));

  --focus: var(--accent);
  --mark: var(--accent-soft);
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

a { color: var(--accent-ink); text-decoration: none; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-line: underline; }
/* Links inside running text need a cue besides colour; a faint underline is enough. */
:is(p, .prose li, dd) a:not(.button) { text-decoration-line: underline; text-decoration-color: color-mix(in oklab, currentColor 30%, transparent); }
:is(p, .prose li, dd) a:not(.button):hover { text-decoration-color: currentColor; }
.byline a, .site-footer a { text-decoration-line: none !important; }

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

h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 2.25rem 0 0.75rem; letter-spacing: -0.015em; font-weight: 600; }
h1 { font-size: 2rem; margin-top: 1.75rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p, li { max-width: 72ch; }

code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }
pre {
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.wrap { width: min(1320px, 100% - 2rem); margin-inline: auto; }
.wrap.wide { width: min(1920px, 100% - 3rem); }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 1rem; z-index: 10; }

/* Header */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap { display: flex; align-items: center; gap: 1.5rem; padding-block: 0.75rem; flex-wrap: wrap; min-height: 4.5rem; }
.logo { display: block; width: 270px; color: var(--ink); line-height: 0; }
.logo svg { width: 100%; height: auto; }
.site-nav { display: flex; gap: 0.25rem 1.1rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.site-nav a { color: var(--ink); text-decoration: none; font-weight: 500; padding: 0.35rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { border-bottom-color: var(--line); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.account-link { display: inline-flex; align-items: center; gap: 0.5rem; }
.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 600;
  flex: none;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; }
.theme-toggle {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); background: var(--sunken); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }

main { flex: 1; padding-bottom: 4rem; }

.site-footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.875rem; padding-block: 1.5rem 2rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; justify-content: space-between; }
.site-footer a { color: var(--muted); }

.lede { font-size: 1.15rem; color: var(--muted); max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* Home */
.hero-logo { width: min(820px, 100%); margin: 2.5rem 0 0.5rem; color: var(--ink); line-height: 0; }
.hero-logo svg { width: 100%; height: auto; overflow: visible; }
.hero-logo .tagline { fill: var(--muted); }
.scan-head { stroke: var(--accent); stroke-width: 1.5; opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  /* A spectrometer readout: both traces are recorded left to right at the same energy, the head leading. */
  .hero-logo .scan-window { animation: scan 2.6s cubic-bezier(0.32, 0.06, 0.24, 1) 0.2s backwards; }
  .hero-logo .scan-head { animation: scan-head 2.6s cubic-bezier(0.32, 0.06, 0.24, 1) 0.2s; }
  .hero-logo .lettering, .hero-logo .tagline { animation: rise 0.9s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
  .hero-logo .lettering { animation-delay: 0.75s; }
  .hero-logo .tagline { animation-delay: 1.15s; }
}
@keyframes scan { from { transform: translateX(-461px); } }
@keyframes scan-head {
  from { transform: translateX(0); opacity: 0.9; }
  85% { opacity: 0.9; }
  to { transform: translateX(450px); opacity: 0; }
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } }
.home-intro { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 2.5rem 4rem; align-items: start; padding-top: 1rem; }
.home-intro h1 { font-size: 1.75rem; margin-top: 0.5rem; max-width: 30ch; }
.counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.counts a { display: block; padding: 0.9rem 1rem; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.counts a:nth-child(odd) { border-right: 1px solid var(--line); }
.counts a:hover { background: var(--sunken); }
.counts strong { display: block; font-size: 1.6rem; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; }
.counts span { color: var(--muted); font-size: 0.875rem; }
.counts a.all { grid-column: 1 / -1; border-right: 0; border-bottom: 0; }
.quick-search { display: flex; gap: 0.5rem; margin-top: 1.5rem; max-width: 34rem; }
.quick-search input { flex: 1; }
.home-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 2.5rem 4rem; margin-top: 1.5rem; }

/* Forms */
input, select, button { font: inherit; color: inherit; }
input[type="text"], input[type="search"], input[type="number"], select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  min-width: 0;
}
input:hover, select:hover { border-color: var(--muted); }
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.45rem 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.08); text-decoration: none; }
.button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.button.secondary:hover { border-color: var(--muted); }

/* Browse */
.browse { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); gap: 2rem; align-items: start; }
.filters { display: grid; gap: 0.9rem; position: sticky; top: 1rem; }
.filters label, .filters legend { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 0.2rem; }
.filters fieldset { border: 0; margin: 0; padding: 0; }
.filters input[type="text"], .filters input[type="search"], .filters input[type="number"], .filters select { width: 100%; }
.range { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr); gap: 0.35rem; }
.check { display: flex !important; gap: 0.5rem; align-items: center; font-weight: 500 !important; color: var(--ink) !important; font-size: 0.95rem !important; }
.filter-actions { display: flex; gap: 0.5rem; }
.result-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; align-items: baseline; margin: 0.5rem 0 0.75rem; }
.jump-filters { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip { font-size: 0.8rem; background: var(--sunken); border-radius: 999px; padding: 0.15rem 0.7rem; color: var(--ink); text-decoration: none !important; }
a.chip:hover { background: var(--accent-soft); }

details.periodic summary { cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.ptable { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); gap: 2px; margin-top: 0.5rem; }
.ptable label { margin: 0; }
.ptable input { position: absolute; opacity: 0; pointer-events: none; }
.ptable span {
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 600;
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--sunken);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.ptable .has span { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.ptable input:checked + span { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.ptable input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.ptable .gap { grid-column: span 1; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
:is(th, td):first-child { padding-left: 0.25rem; }
th { font-size: 0.75rem; font-weight: 500; color: var(--muted); white-space: nowrap; border-bottom-color: var(--line); }
td a { color: var(--ink); }
td a:hover { color: var(--accent-ink); }
td.title a { font-weight: 500; }
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--ink); }
th a[aria-sort] { color: var(--ink); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in oklab, var(--sunken) 70%, transparent); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.title { min-width: 12rem; }
td.edges { min-width: 7rem; font-size: 0.85rem; }
td.formula-cell { white-space: nowrap; }
.formula sub, .formula sup { font-size: 0.72em; line-height: 0; }
.formula sub i { font-style: italic; }
.type { display: inline-flex; align-items: baseline; gap: 0.45em; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.type::before { content: ""; width: 0.5em; height: 0.5em; border-radius: 50%; background: var(--t, var(--muted)); flex: none; align-self: center; }
.type-coreloss { --t: var(--type-coreloss); }
.type-lowloss { --t: var(--type-lowloss); }
.type-zeroloss { --t: var(--type-zeroloss); }
.type-xrayabs { --t: var(--type-xrayabs); }

.pager { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.pager a, .pager span { padding: 0.25rem 0.65rem; border-radius: 6px; text-decoration: none; color: var(--ink); }
.pager a:hover { background: var(--sunken); }
.pager [aria-current] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

/* Spectrum */
.spectrum-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; }
.spectrum-head h1 { margin-bottom: 0.25rem; }
.head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.head-actions form { margin: 0; }
.sign-in-buttons { display: grid; gap: 0.5rem; max-width: 20rem; margin: 1rem 0 2rem; }
.sign-in-buttons .button { justify-content: center; }
.password-login { display: grid; gap: 0.35rem; max-width: 20rem; margin-bottom: 2rem; }
.password-login label { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-top: 0.4rem; }
.password-login .button { justify-self: start; margin-top: 0.75rem; }
input[type="password"] { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.6rem; }
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline-form input { flex: 1 1 16rem; }
input[type="email"] { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.6rem; min-width: 0; }
.badge-complete { white-space: nowrap; }
.cal-table input, .cal-table select { width: 100%; min-width: 5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.3rem 0.4rem; }
.cal-table select { min-width: 9rem; }
.byline { color: var(--muted); margin: 0; }
.byline .formula { color: var(--ink); }
.plot-panel { margin-top: 1.5rem; }
.plot { min-height: 360px; }
.plot-tools { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-size: 0.85rem; color: var(--muted); padding: 0.25rem 0.25rem 0; }
.plot-tools label { display: inline-flex; gap: 0.35rem; align-items: center; }
.plot-message { color: var(--muted); padding: 2rem; text-align: center; }
.uplot .u-legend { font-size: 0.8rem; color: var(--muted); }
.uplot .u-legend th { background: none; color: inherit; }
.uplot { font-family: var(--font); }
.spectrum-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; }
dl.meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.35rem 1.25rem; margin: 0; }
dl.meta dt { color: var(--muted); font-size: 0.875rem; padding-top: 0.1rem; }
dl.meta dd { margin: 0; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0; margin: 0; list-style: none; }

dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  width: min(42rem, 100% - 2rem);
  padding: 1.25rem 1.5rem 1.5rem;
}
dialog::backdrop { background: rgb(20 15 10 / 0.45); }
dialog h2 { margin-top: 0; }
.cite-block { position: relative; }
.cite-block pre { padding-right: 4.5rem; }
.copy { position: absolute; top: 0.4rem; right: 0.4rem; font-size: 0.75rem; padding: 0.15rem 0.5rem; }
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

.prose { max-width: 72ch; }
.snippet { margin-top: 1rem; max-width: 72ch; }
.snippet summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.notice { border: 1px solid var(--line); background: var(--sunken); border-radius: 8px; padding: 1rem 1.25rem; }

.endpoint { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.endpoint code.path { font-size: 1rem; font-weight: 600; }
.method { font-family: var(--mono); font-size: 0.75rem; font-weight: 700; color: var(--accent-ink); margin-right: 0.5rem; }

@media (max-width: 860px) {
  .browse, .home-intro, .home-cols, .spectrum-cols { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; border-top: 1px solid var(--line); padding-top: 1rem; }
  .browse > section { order: -1; }
  .jump-filters { display: inline !important; }
  .site-nav { margin-left: 0; width: 100%; }
  .plot { min-height: 280px; }
}

@media (max-width: 560px) {
  h1 { font-size: 1.5rem; }
  .home-intro h1 { font-size: 1.7rem; }
  .logo { width: 210px; }
  .site-nav { gap: 0.25rem 0.7rem; font-size: 0.95rem; }
  .theme-toggle { width: 1.8rem; height: 1.8rem; }
  .site-header .wrap { gap: 0.75rem; }
  td:has(> .type) { vertical-align: top; }
  td .type { font-size: 0; gap: 0; display: flex; padding-top: 0.4rem; }
  td .type::before { width: 0.6rem; height: 0.6rem; }
  th, td { padding: 0.45rem 0.5rem; }
  .hide-sm { display: none; }
}

@media (max-width: 1440px) {
  .hide-md { display: none; }
}

/* Submit form */
.submit-form { display: grid; gap: 0.5rem; max-width: 60rem; }
.form-section { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.form-section h2 { margin-top: 1rem; }
.field { display: grid; gap: 0.3rem; align-content: start; margin: 0 0 1rem; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend { font-size: 0.85rem; font-weight: 600; color: var(--ink); padding: 0; }
.field input[type="text"], .field input[type="number"], .field input[type="url"], .field select, .field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  color: inherit;
}
.field textarea { resize: vertical; }
.field input[type="file"] { font-size: 0.9rem; }
input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.8rem;
  margin-right: 0.75rem;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--muted); }
.hint { margin: 0; font-size: 0.8rem; color: var(--muted); }
.error { margin: 0; font-size: 0.85rem; color: var(--danger); font-weight: 600; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.error-summary { border-color: var(--danger); margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 0.75rem; }
.measured-row { display: flex; gap: 0.5rem 0.9rem; align-items: center; flex-wrap: wrap; }
.measured-row input[type="number"] { width: 7.5rem; }
.measured-uncertainty { display: flex; gap: 0.5rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.measured-uncertainty input { width: 6rem !important; }
.unit { color: var(--muted); font-size: 0.9rem; }
.inline-label { color: var(--muted); }
.choice-buttons { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.choice-buttons input { position: absolute; opacity: 0; }
.choice-buttons span {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.8rem;
  background: var(--surface);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.choice-buttons input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.choice-buttons input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.checks-row { display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem; margin-bottom: 0.5rem; }
.provenance { font-style: italic; }
.provenance.from-file { color: var(--note); font-style: normal; font-weight: 600; }
.agreement { display: block !important; font-weight: 500 !important; }
.checks { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.checks .plot { min-height: 0; }
.findings { margin: 0.5rem 0 0; padding-left: 1.2rem; font-size: 0.9rem; }
.findings .error { font-weight: 600; }
.findings .warning { color: var(--note); }
.findings .info { color: var(--muted); }

@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
