/*
 * Theme "workbench" (draft A, Werkbank) (ADR-196). Self-contained and portable: fonts relative to
 * ../fonts/, every token of the contract (tests/test_theme_css.py), the
 * chrome of the header/footer markup contract. No external URL, no @import.
 * Dark mode follows the system; data-scheme on <html> is reserved for a
 * future manual toggle.
 */

/* 1. Fonts (vendored OFL fonts, see ../fonts/SOURCES.toml) */
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/public-sans-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/public-sans-latin-400-normal.woff2") format("woff2");
  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: "Public Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/public-sans-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/public-sans-latin-500-normal.woff2") format("woff2");
  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: "Public Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/public-sans-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/public-sans-latin-600-normal.woff2") format("woff2");
  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;
}

/* 2. Tokens */
:root {
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-panel: #f2f5f7;
  --color-fg: #18212b;
  --color-muted: #5c6b7a;
  --color-line: #d6dde4;
  --color-control-border: #7d8a97;
  --color-accent: #1f5f8b;
  --color-accent-fg: #ffffff;
  --color-accent-soft: #e3edf5;
  --color-focus: #1f5f8b;
  --color-band-bg: #2a3138;
  --color-band-fg: #eef2f5;
  --color-band-muted: #b9c4ce;
  --color-viewer-bg: #2a3138;
  --color-viewer-fg: #eef2f5;
  --color-danger: #b00020;
  --color-warning-bg: #fff4e5;
  --color-warning-line: #b26b00;
  --color-success: #2e7d32;
  --color-row-selected: #e3edf5;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ui: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 4px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2.5rem;
  --measure: 46rem;
  --page-max: 76rem;
  --sidebar-w: 13rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --color-bg: #161b20;
    --color-surface: #1d242b;
    --color-panel: #1d242b;
    --color-fg: #e3e9ef;
    --color-muted: #98a7b5;
    --color-line: #2c363f;
    --color-control-border: #6f7d8b;
    --color-accent: #7db7e0;
    --color-accent-fg: #161b20;
    --color-accent-soft: #1e3446;
    --color-focus: #7db7e0;
    --color-band-bg: #0e1114;
    --color-band-fg: #e3e9ef;
    --color-band-muted: #98a7b5;
    --color-viewer-bg: #0e1114;
    --color-viewer-fg: #e3e9ef;
    --color-danger: #ff8a8a;
    --color-warning-bg: #33280f;
    --color-warning-line: #c98f2a;
    --color-success: #7cc48a;
    --color-row-selected: #1e3446;
    color-scheme: dark;
  }
}
:root[data-scheme="dark"] {
  --color-bg: #161b20;
  --color-surface: #1d242b;
  --color-panel: #1d242b;
  --color-fg: #e3e9ef;
  --color-muted: #98a7b5;
  --color-line: #2c363f;
  --color-control-border: #6f7d8b;
  --color-accent: #7db7e0;
  --color-accent-fg: #161b20;
  --color-accent-soft: #1e3446;
  --color-focus: #7db7e0;
  --color-band-bg: #0e1114;
  --color-band-fg: #e3e9ef;
  --color-band-muted: #98a7b5;
  --color-viewer-bg: #0e1114;
  --color-viewer-fg: #e3e9ef;
  --color-danger: #ff8a8a;
  --color-warning-bg: #33280f;
  --color-warning-line: #c98f2a;
  --color-success: #7cc48a;
  --color-row-selected: #1e3446;
  color-scheme: dark;
}

/* 3. Base typography */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  margin: 0;
  overflow-wrap: break-word;
}
h1,
h2,
h3 {
  line-height: 1.2;
  text-wrap: balance;
}
a {
  color: var(--color-accent);
  text-underline-offset: 0.15em;
}
a:hover {
  text-decoration-thickness: 2px;
}
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
::selection {
  background: var(--color-accent);
  color: var(--color-accent-fg);
}
code,
pre,
kbd {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* 4. Chrome: header, tools, footer, skip link, kicker, band, buttons, controls */
.skip-link {
  background: var(--color-accent);
  color: var(--color-accent-fg);
  font-family: var(--font-ui);
  font-weight: 600;
  left: var(--space-2);
  padding: var(--space-2) var(--space-3);
  position: absolute;
  top: -100vh;
  z-index: 10;
}
.skip-link:focus {
  top: var(--space-2);
}
.site-header {
  align-items: center;
  border-bottom: 1px solid var(--color-line);
  display: flex;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  gap: var(--space-3) var(--space-5);
  padding-block: var(--space-3);
  padding-inline: max(var(--space-4), calc((100% - var(--page-max)) / 2));
}
.site-brand {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-2);
}
.site-name {
  color: var(--color-fg);
  font-weight: 600;
  text-decoration: none;
}
.site-sub {
  color: var(--color-muted);
  font-size: 0.85rem;
}
.site-tools,
.service-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  gap: var(--space-1) var(--space-4);
}
.site-tools {
  margin-inline-start: auto;
}
.site-tools a,
.service-nav a,
.btn-link {
  align-items: center;
  display: inline-flex;
  min-height: 24px;
  padding-block: var(--space-1);
}
.site-tools a,
.btn-link {
  color: var(--color-accent);
  text-decoration: none;
}
.site-tools a:hover,
.btn-link:hover {
  text-decoration: underline;
}
.site-tools a[aria-current] {
  color: var(--color-fg);
  font-weight: 600;
}
.signed-in {
  color: var(--color-muted);
}
.btn-link {
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  min-height: 24px;
  padding-inline: 0;
}
.lang-switch:empty {
  display: none;
}
.site-footer {
  border-top: 1px solid var(--color-line);
  color: var(--color-muted);
  display: flex;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  gap: var(--space-2) var(--space-5);
  margin-top: var(--space-6);
  padding-block: var(--space-4);
  padding-inline: max(var(--space-4), calc((100% - var(--page-max)) / 2));
}
.site-footer a {
  color: var(--color-muted);
}
.site-footer a:hover {
  color: var(--color-fg);
}
.kicker {
  color: var(--color-accent);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  margin: 0;
  text-transform: uppercase;
}
.band {
  background: var(--color-band-bg);
  color: var(--color-band-fg);
}
/* Focus ring on the dark surfaces: 3:1 against the band (WCAG 1.4.11). */
.band {
  --color-focus: var(--color-band-fg);
}
.object-stage {
  --color-focus: var(--color-viewer-fg);
}
input,
select,
textarea {
  background: var(--color-surface);
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius);
  color: var(--color-fg);
  font-family: var(--font-ui);
  font-size: 1rem;
  max-width: 100%;
  min-height: 2.25rem;
  padding: 0.4rem 0.6rem;
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--color-accent);
  height: 1.1rem;
  min-height: 0;
  width: 1.1rem;
}
button,
.btn {
  background: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  color: var(--color-accent-fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 600;
  min-height: 2.25rem;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
}
button.btn-link {
  background: none;
  border: 0;
  color: var(--color-accent);
  font-weight: 400;
  min-height: 24px;
  padding: var(--space-1) 0;
}
.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-control-border);
  color: var(--color-fg);
}
@media (max-width: 760px) {
  .site-tools {
    margin-inline-start: 0;
  }
}

/* 5. Workbench only: compact header with a search box, two-column object page */
.site-search {
  display: flex;
  flex: 1 1 14rem;
  max-width: 34rem;
}
.site-search input {
  background: var(--color-panel);
  border-radius: var(--radius) 0 0 var(--radius);
  flex: 1;
  min-width: 0;
}
.site-search button {
  border-radius: 0 var(--radius) var(--radius) 0;
}
@media (max-width: 760px) {
  .site-search {
    flex-basis: 100%;
    max-width: none;
    order: 3;
  }
}
h1 {
  font-size: 1.6rem;
  font-weight: 600;
}
h2 {
  font-size: 1.15rem;
  font-weight: 600;
}
.object-head .kicker {
  display: none;
}
.hero {
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: calc(var(--radius) * 2);
  margin-block: var(--space-5);
  padding: var(--space-4) var(--space-5);
}
.hero h1 {
  margin-top: var(--space-2);
}
/* Object page: head, metadata and citation first, then files and versions,
   in reading order on every width. From 900px metadata and citation sit
   side by side. With a viewer (phase 2) the stage takes the wide left
   column and the description moves to the right, as in draft A. */
@media (min-width: 900px) {
  .object-aside {
    align-items: start;
    display: grid;
    gap: 0 var(--space-6);
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  }
  .object-head {
    grid-column: 1 / -1;
  }
  .object-layout:has(.object-stage) {
    align-items: start;
    display: grid;
    gap: 0 var(--space-6);
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  }
  .object-layout:has(.object-stage) .object-aside {
    border-inline-start: 1px solid var(--color-line);
    display: block;
    grid-column: 2;
    grid-row: 1;
    padding-inline-start: var(--space-5);
  }
  .object-layout:has(.object-stage) .object-main {
    grid-column: 1;
    grid-row: 1;
  }
}
.landing section.citation {
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: calc(var(--radius) * 1.5);
  padding: var(--space-3) var(--space-4);
}
.landing section.citation h2 {
  margin-top: 0;
}
