/* FlexGaze project page: one stylesheet, no build step. */

/* ----------------------------------------------------------------------------
 * Base
 * ------------------------------------------------------------------------- */

/* Palette: one light-dark() pair per color. The theme switch sets color-scheme:
 * "light dark" follows the system, a manual choice fixes one scheme. */
:root {
  color-scheme: light dark;

  --color-page:              light-dark(#fbfaf7, #141311);
  --color-surface:           light-dark(#ffffff, #1c1b18);
  --color-ink:               light-dark(#1d1c1a, #ece8e0);
  --color-ink-secondary:     light-dark(#46433e, #c7c1b6);
  --color-ink-muted:         light-dark(#6f6b64, #9d978c);
  --color-rule:              light-dark(#e3dfd7, #33302b);
  --color-rule-strong:       light-dark(#c9c3b8, #4a4640);
  --color-table-rule:        light-dark(#1d1c1a, #c7c1b6);
  --color-accent:            light-dark(#b14e1b, #ef9a62);
  --color-in-domain:         light-dark(#edeae3, #3a372f);
  --color-focus:             light-dark(#1f6feb, #79b8ff);
  --color-series-flexgaze:   light-dark(#d55e00, #f08a4b);
  --color-series-unigaze:    light-dark(#0072b2, #5aaee8);
  --color-series-gat:        light-dark(#009e73, #3cc39b);

  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --column-width: 60rem;
  --gutter: 16px;
}

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

/* Without light-dark() the page keeps the light palette in every theme. */
@supports not (color: light-dark(#000, #fff)) {
  :root,
  :root[data-theme] {
    color-scheme: light;

    --color-page: #fbfaf7;
    --color-surface: #ffffff;
    --color-ink: #1d1c1a;
    --color-ink-secondary: #46433e;
    --color-ink-muted: #6f6b64;
    --color-rule: #e3dfd7;
    --color-rule-strong: #c9c3b8;
    --color-table-rule: #1d1c1a;
    --color-accent: #b14e1b;
    --color-in-domain: #edeae3;
    --color-focus: #1f6feb;
    --color-series-flexgaze: #d55e00;
    --color-series-unigaze: #0072b2;
    --color-series-gat: #009e73;
  }

  :root .teaser-svg {
    --teaser-card: #f2f2f4;
    --teaser-card-pale: #f7f8f8;
    --teaser-card-border: #e7e8ea;
    --teaser-rule-light: #c4c7cb;
    --teaser-ink: #262a31;
    --teaser-ink-secondary: #7b828c;
    --teaser-white-on-card: #ffffff;
    --teaser-white-on-yaw-tint: #ffffff;
    --teaser-render-ground: #eceef1;
    --teaser-flexgaze-tint: #f7e2d1;
    --teaser-l2cs: #cc79a7;
    --teaser-frozen-mark: #1f5bc4;
    --teaser-gaze-arrow: #e69f00;
    --teaser-yaw: #2a8c6e;
    --teaser-yaw-tint: #aad1c5;
    --teaser-pitch: #7b5ea7;
    --teaser-pitch-tint: #cabfdc;
    --teaser-badge-disc: #ffffff;
    --teaser-badge-frozen: #2f73b5;
    --teaser-badge-trained: #d55e00;
    --teaser-badge-trained-core: #f6dcc7;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 0 var(--gutter);
  background: var(--color-page);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

@media (min-width: 640px) {
  :root {
    --gutter: 32px;
  }

  body {
    font-size: 1.125rem;
  }
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

figure {
  margin: 0;
}

figcaption {
  margin-top: 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-ink-secondary);
}

/* ----------------------------------------------------------------------------
 * Components
 * ------------------------------------------------------------------------- */

/* Every block sits in one content column; nothing is wider than it. */
.column {
  width: 100%;
  max-width: var(--column-width);
  margin: 0 auto;
}

.button {
  appearance: none;
  border: 1px solid var(--color-rule-strong);
  border-radius: 4px;
  background: var(--color-surface);
  font-family: var(--font-sans);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.button:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.button-small {
  color: var(--color-ink-secondary);
  font-size: 0.8125rem;
}

/* Controls that need a script stay hidden without one. */
:root:not(.js) .needs-script {
  display: none;
}

/* Figures and tables sit in the same framed panel, each with its caption below it. */
.panel {
  padding: 0.75rem clamp(0.5rem, 1.5vw, 1rem) 0.5rem;
  border: 1px solid var(--color-rule);
  border-radius: 6px;
  background: var(--color-surface);
}

/* Sideways scroll boxes keep a visible scrollbar. */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-rule-strong) transparent;
}

.scroll-x::-webkit-scrollbar {
  height: 8px;
}

.scroll-x::-webkit-scrollbar-thumb {
  background: var(--color-rule-strong);
  border-radius: 4px;
}

.caption-label {
  font-weight: 700;
  color: var(--color-ink);
}

/* Visible only while focused. */
.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-rule-strong);
  border-radius: 4px;
  background: var(--color-surface);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

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

/* ----------------------------------------------------------------------------
 * Page header
 * ------------------------------------------------------------------------- */

.page-header .column {
  padding: 2.25rem 0;
  border-bottom: 1px solid var(--color-rule);
}

.header-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-title {
  min-width: 0;
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2.6rem, 7vw, 4.25rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.header-subtitle {
  margin: 0.35rem 0 0;
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 3.2vw, 2rem);
  font-weight: 400;
  line-height: 1.15;
  color: var(--color-ink-secondary);
}

.theme-switch {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.125rem;
  padding: 0.35rem 0.7rem;
  line-height: 1;
}

/* The root's data-theme decides which icon and label show, so the first frame is right. */
.theme-switch-icon,
.theme-switch-label {
  display: none;
}

.theme-switch-icon {
  width: 16px;
  height: 16px;
}

:root:not([data-theme]) .theme-switch-icon[data-mode="system"],
:root[data-theme="light"] .theme-switch-icon[data-mode="light"],
:root[data-theme="dark"] .theme-switch-icon[data-mode="dark"] {
  display: block;
}

:root:not([data-theme]) .theme-switch-label[data-mode="system"],
:root[data-theme="light"] .theme-switch-label[data-mode="light"],
:root[data-theme="dark"] .theme-switch-label[data-mode="dark"] {
  display: inline;
}

/* Narrow screens: icon only; the state stays in the tooltip and the accessible name. */
@media (max-width: 520px) {
  .theme-switch {
    padding: 0.45rem;
  }

  :root .header-title-row .theme-switch .theme-switch-label[data-mode] {
    display: none;
  }
}

.header-byline {
  margin: 1.6rem 0 0;
}

.header-authors {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.5rem;
  font-weight: 600;
}

.header-affiliation {
  margin: 0.2rem 0 0;
  color: var(--color-ink-muted);
}

.header-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
}

.header-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.95rem 0.45rem 0.8rem;
  color: var(--color-ink);
  font-size: 0.9375rem;
}

.header-link svg {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--color-ink-muted);
  transition: color 0.15s ease;
}

.header-link:hover svg {
  color: var(--color-accent);
}

/* ----------------------------------------------------------------------------
 * Teaser
 * ------------------------------------------------------------------------- */

.teaser {
  padding: 2.25rem 0 0;
}

.teaser-plate {
  padding: clamp(8px, 1.6vw, 18px);
}

/* Marks drawn on photographs and renders keep the paper's colors in every theme;
 * marks on the figure's own ground use these roles. Light values are the paper's.
 * Method colors and the ground are the page's own. */
.teaser-svg {
  width: 100%;

  --teaser-ground:             var(--color-surface);
  --teaser-white-on-ground:    var(--teaser-ground);
  --teaser-flexgaze:           var(--color-series-flexgaze);
  --teaser-unigaze:            var(--color-series-unigaze);
  --teaser-gat:                var(--color-series-gat);
  --teaser-card:               light-dark(#f2f2f4, #2b2a26);
  --teaser-card-pale:          light-dark(#f7f8f8, #2b2a26);
  --teaser-card-border:        light-dark(#e7e8ea, #45423d);
  --teaser-rule-light:         light-dark(#c4c7cb, #5a5752);
  --teaser-ink:                light-dark(#262a31, #dcd7ce);
  --teaser-ink-secondary:      light-dark(#7b828c, #a29d94);
  --teaser-white-on-card:      light-dark(#ffffff, #2b2a26);
  --teaser-white-on-yaw-tint:  light-dark(#ffffff, #294a40);
  --teaser-render-ground:      light-dark(#eceef1, #2b2a26);
  --teaser-flexgaze-tint:      light-dark(#f7e2d1, #4a2e1b);
  --teaser-l2cs:               light-dark(#cc79a7, #e39dc4);
  --teaser-frozen-mark:        light-dark(#1f5bc4, #78a6f2);
  --teaser-gaze-arrow:         light-dark(#e69f00, #f2b632);
  --teaser-yaw:                light-dark(#2a8c6e, #62cfac);
  --teaser-yaw-tint:           light-dark(#aad1c5, #294a40);
  --teaser-pitch:              light-dark(#7b5ea7, #ad96d8);
  --teaser-pitch-tint:         light-dark(#cabfdc, #3d3352);
  --teaser-badge-disc:         light-dark(#ffffff, #36342f);
  --teaser-badge-frozen:       light-dark(#2f73b5, #86b6f2);
  --teaser-badge-trained:      light-dark(#d55e00, #f39a5a);
  --teaser-badge-trained-core: light-dark(#f6dcc7, #7a4a26);
}

/* ----------------------------------------------------------------------------
 * Sections
 * ------------------------------------------------------------------------- */

.section {
  padding: 2.5rem 0 2.75rem;
  border-top: 1px solid var(--color-rule);
}

.teaser + .section {
  margin-top: 2.5rem;
}

.section-title {
  margin: 0 0 0.9rem;
  font-family: var(--font-serif);
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1.25;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.section-header .section-title {
  margin: 0;
}

.section-subtitle {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.4;
}

.section-title + .section-subtitle {
  margin-top: 0.5rem;
}

.section-text {
  margin: 0;
}

.section-figure {
  margin-top: 0.25rem;
}

.section-subtitle + .section-figure {
  margin-top: 0;
}

.section-figure + .section-subtitle {
  margin-top: 2.75rem;
}

/* ----------------------------------------------------------------------------
 * Results table
 * ------------------------------------------------------------------------- */

/* Decimal points align as in the paper: results-table.js measures the widths
 * per column; the values below are fallbacks. */

.results-table {
  width: 100%;
  min-width: 54rem;
  border-collapse: collapse;
  font-size: 0.8125rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums lining-nums;
}

.results-table th,
.results-table td {
  padding: 0.34rem 0.25rem;
  text-align: center;
  white-space: nowrap;
}

.results-table th:first-child,
.results-table td:first-child {
  text-align: left;
  padding-left: 0.1rem;
}

.results-params .results-params-value {
  display: inline-block;
  min-width: 3.4em;
  text-align: right;
}

.results-table td.results-preproc {
  color: var(--color-ink-secondary);
}

.results-score .results-score-block {
  display: inline-block;
  text-align: left;
}

.results-score .results-mean {
  display: inline-block;
  min-width: 2.9em;
  text-align: right;
}

.results-score .results-mean-whole {
  display: inline-block;
  min-width: 1.3em;
  text-align: right;
}

.results-score .results-mean-fraction {
  display: inline-block;
  min-width: 1.6em;
  text-align: left;
}

.results-score .results-sd {
  display: inline-block;
  min-width: 2.7em;
  padding-left: 0.12em;
  position: relative;
  top: 0.2em;
  font-size: 0.6875rem;
  color: var(--color-ink-muted);
  text-align: left;
}

.results-table thead th {
  vertical-align: middle;
  font-weight: 600;
  border-top: 1.5px solid var(--color-table-rule);
  border-bottom: 1px solid var(--color-table-rule);
  padding-top: 0.55rem;
  padding-bottom: 0.45rem;
}

.results-score .results-head {
  display: inline-block;
  text-align: center;
}

.results-score .results-head-note {
  display: block;
  font-weight: 400;
  font-size: 0.6875rem;
  color: var(--color-ink-muted);
}

.results-table tbody th {
  font-weight: 500;
}

.results-table .results-group th {
  padding-top: 0.75rem;
  padding-bottom: 0.25rem;
  font-weight: 700;
  text-align: left;
}

.results-table tbody + tbody .results-group th {
  border-top: 1px solid var(--color-rule-strong);
}

.results-table tbody:last-child tr:last-child > * {
  border-bottom: 1.5px solid var(--color-table-rule);
}

/* Score cells hold their own visually hidden text. */
.results-table td.results-score {
  position: relative;
}

.results-table td.results-in-domain {
  background: var(--color-in-domain);
}

/* SD figures on the in-domain shade need the stronger ink for 4.5:1. */
.results-table td.results-in-domain .results-sd {
  color: var(--color-ink-secondary);
}

.results-table td b {
  font-weight: 700;
}

/* Method names stay in view while the table scrolls sideways. */
.results-table tbody tr:not(.results-group) > th:first-child,
.results-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--color-surface);
}

.results-notes {
  margin: 0.85rem 0 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-ink-secondary);
}

.results-notes > div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.75rem;
}

.results-notes > div + div {
  margin-top: 0.3rem;
}

.results-notes dt {
  font-weight: 600;
  color: var(--color-ink);
}

.results-notes dd {
  margin: 0;
}

.results-in-domain-swatch {
  display: inline-block;
  padding: 0 0.3rem;
  background: var(--color-in-domain);
  font-weight: 400;
}

/* ----------------------------------------------------------------------------
 * Sensitivity chart
 * ------------------------------------------------------------------------- */

/* Both layouts share the smallest panel width P = 210 px (gap 12 px):
 *   four in a row    from 4P + 3 gaps = 876 px
 *   two by two       432-472 px, panel at most 230 px, centered under the legend
 *   below 432 px     the panels scroll inside their box
 * Panel height follows from the plot's 1.7 aspect. */

.sensitivity-chart {
  container-type: inline-size;
}

.sensitivity-legend {
  max-width: 472px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.25rem;
  margin: 0 auto 0.25rem;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--color-ink-secondary);
}

.sensitivity-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.sensitivity-legend svg {
  width: 28px;
  height: 12px;
}

.sensitivity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 432px;
  max-width: 472px;
  margin: 0 auto;
  gap: 0.5rem 12px;
}

@container (min-width: 876px) {
  .sensitivity-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: none;
  }

  .sensitivity-legend {
    max-width: none;
  }
}

.sensitivity-panel {
  min-width: 0;
}

.sensitivity-panel svg {
  overflow: visible;
}

.sensitivity-line {
  fill: none;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

.sensitivity-line.series-flexgaze   { stroke: var(--color-series-flexgaze); }
.sensitivity-line.series-unigaze    { stroke: var(--color-series-unigaze); }
.sensitivity-line.series-gat        { stroke: var(--color-series-gat); }
.sensitivity-marker.series-flexgaze { fill: var(--color-series-flexgaze); }
.sensitivity-marker.series-unigaze  { fill: var(--color-series-unigaze); }
.sensitivity-marker.series-gat      { fill: var(--color-series-gat); }

.sensitivity-axis {
  stroke: var(--color-ink-muted);
  stroke-width: 1;
}

.sensitivity-gridline {
  stroke: var(--color-rule);
  stroke-width: 1;
}

.sensitivity-tick {
  fill: var(--color-ink-secondary);
  font: 12px var(--font-sans);
  font-variant-numeric: tabular-nums;
}

.sensitivity-axis-title {
  fill: var(--color-ink-secondary);
  font: 12px var(--font-sans);
}

.sensitivity-panel-title {
  fill: var(--color-ink);
  font: 600 12.5px var(--font-sans);
  paint-order: stroke;
  stroke: var(--color-surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.sensitivity-message {
  margin: 0.5rem 0;
  color: var(--color-ink-muted);
}

/* ----------------------------------------------------------------------------
 * Citation
 * ------------------------------------------------------------------------- */

.citation-copy {
  padding: 0.35rem 0.8rem;
}

/* BibTeX wraps on narrow screens instead of scrolling. */
.citation-bibtex {
  margin: 0;
  padding: 1rem 1.1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--color-ink);
  font: 0.8125rem/1.6 var(--font-mono);
}

/* ----------------------------------------------------------------------------
 * Page footer
 * ------------------------------------------------------------------------- */

.page-footer .column {
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--color-rule);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-ink-muted);
}

.page-footer p {
  margin: 0;
}

.page-footer a {
  color: inherit;
}

/* ----------------------------------------------------------------------------
 * Print and reduced motion
 * ------------------------------------------------------------------------- */

/* Paper is light: printing always uses the light palette. */
@media print {
  :root,
  :root[data-theme] {
    color-scheme: light;
  }

  .theme-switch,
  .citation-copy {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
