/* ==========================================================================
   Statistical Modelling — v2 theme
   A print-inspired academic style: ivory paper, serif prose, hairline rules,
   booktabs-style tables. Light-mode only, by design.
   ========================================================================== */

:root {
  /* Surfaces */
  --paper: #fdfcf8;
  --surface: #ffffff;
  --surface-sunken: #f5f3ec;

  /* Ink */
  --ink: #1c1b17;
  --ink-muted: #63615a;
  --ink-faint: #8b887f;

  /* Rules */
  --rule: #ded9cc;
  --rule-strong: #2b2a25;

  /* Accent — slate blue, used sparingly */
  --accent: #2d4f63;
  --accent-hover: #1d3a4c;
  --accent-wash: #eef2f5;

  /* Feedback */
  --warning-ink: #7a4510;
  --warning-wash: #fdf3e6;
  --warning-rule: #e0bd8c;

  /* Type */
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Rhythm — the measure has to hold displayed mathematics, not just prose */
  --measure: 50rem;
  --sidebar-width: 17rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.875rem;
  --space-4: 1.25rem;
  --space-5: 2rem;
  --space-6: 3rem;
}

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

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.65;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--accent-hover);
}

/* --------------------------------------------------------------------------
   Layout — fixed sidebar, flowing main column
   -------------------------------------------------------------------------- */

.layout {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--rule);
  background: var(--surface-sunken);
  font-family: var(--font-sans);
  font-size: 0.875rem;
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  /* Pad symmetrically so the reading column sits centred in whatever space is
     left beside the sidebar, rather than stranded against it on wide screens. */
  padding: var(--space-6) max(var(--space-5), calc((100% - var(--measure)) / 2));
}

.content > * {
  max-width: var(--measure);
}

/* --------------------------------------------------------------------------
   Sidebar navigation
   -------------------------------------------------------------------------- */

.sidebar__brand {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.3;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule);
}

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

.sidebar__brand em {
  display: block;
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: var(--space-1);
}

.sidebar__section {
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sidebar__group {
  margin-bottom: var(--space-1);
}

.sidebar__law {
  display: block;
  padding: 0.2rem 0;
  color: var(--ink);
  text-decoration: none;
}

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

.sidebar__law[aria-current="true"] {
  color: var(--accent);
  font-weight: 600;
}

.sidebar__links {
  display: flex;
  gap: var(--space-3);
  padding: 0 0 0.3rem 0;
  font-size: 0.75rem;
}

.sidebar__links a {
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.sidebar__links a:hover {
  color: var(--accent);
  border-bottom-color: var(--rule);
}

.sidebar__links a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sidebar__foot {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
  font-size: 0.75rem;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

.page-kicker {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 var(--space-2);
}

h1 {
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 600;
  margin: 0 0 var(--space-3);
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.375rem;
  line-height: 1.3;
  font-weight: 600;
  margin: var(--space-6) 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--rule);
}

h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: var(--space-5) 0 var(--space-2);
}

p {
  margin: 0 0 var(--space-3);
}

.lede {
  font-size: 1.0625rem;
  color: var(--ink-muted);
  margin-bottom: var(--space-5);
}

.note {
  font-size: 0.9375rem;
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   Version banner — marks this as a 2026 revision of a 2023 project
   -------------------------------------------------------------------------- */

.revision-note {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink-muted);
  background: var(--accent-wash);
  border-left: 2px solid var(--accent);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-5);
}

.revision-note strong {
  color: var(--ink);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Section switcher — links between a distribution's three pages
   -------------------------------------------------------------------------- */

.sections {
  display: flex;
  gap: var(--space-4);
  margin: var(--space-4) 0 var(--space-5);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: 0.875rem;
}

.sections__link {
  display: block;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: var(--space-2) 0;
  color: var(--ink-muted);
  text-decoration: none;
}

.sections__link:hover {
  color: var(--ink);
}

.sections__link[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Definition block — the distribution's formulae
   -------------------------------------------------------------------------- */

.definition {
  border-top: 2px solid var(--rule-strong);
  border-bottom: 2px solid var(--rule-strong);
  margin: var(--space-4) 0 var(--space-5);
}

.definition__row {
  display: grid;
  grid-template-columns: minmax(6rem, 10rem) 1fr;
  gap: var(--space-4);
  align-items: baseline;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--rule);
}

.definition__row:last-child {
  border-bottom: none;
}

.definition__term {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.definition__value {
  min-width: 0;
  overflow-x: auto;
}

/* --------------------------------------------------------------------------
   Forms — parameter entry
   -------------------------------------------------------------------------- */

.controls {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: var(--space-4);
  margin: var(--space-4) 0 var(--space-5);
}

.controls__legend {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: var(--space-3);
}

.field {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-3);
}

.field__label {
  color: var(--ink-muted);
}

.field input[type="text"],
.field input[type="number"],
.field input[type="file"] {
  width: 100%;
  max-width: 18rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.4rem 0.55rem;
}

.field input[type="text"]:focus,
.field input[type="number"]:focus,
.field input[type="file"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field input[type="file"] {
  font-family: var(--font-sans);
  padding: 0.3rem;
}

.button {
  appearance: none;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--surface);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
}

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

.button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Tables — booktabs style: horizontal rules only
   -------------------------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-4) 0 var(--space-5);
  font-size: 0.9375rem;
}

.table caption {
  caption-side: top;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: var(--space-2);
}

.table th,
.table td {
  text-align: left;
  padding: 0.5rem var(--space-3) 0.5rem 0;
  vertical-align: baseline;
}

.table thead th {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  border-top: 2px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.table tbody tr {
  border-bottom: 1px solid var(--rule);
}

.table tbody tr:last-child {
  border-bottom: 2px solid var(--rule-strong);
}

.table__formula {
  width: 45%;
}

.table__value {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  padding-right: 0;
}

.table__value--empty {
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   Chart
   -------------------------------------------------------------------------- */

.chart {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: var(--space-4);
  margin: var(--space-4) 0 var(--space-5);
}

.chart__canvas-wrap {
  position: relative;
  height: 22rem;
}

/* --------------------------------------------------------------------------
   Empty / warning states
   -------------------------------------------------------------------------- */

.empty-state {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink-muted);
  background: var(--surface-sunken);
  border: 1px dashed var(--rule);
  padding: var(--space-4);
  margin: var(--space-4) 0;
}

.alert {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--warning-ink);
  background: var(--warning-wash);
  border-left: 2px solid var(--warning-rule);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-3) 0;
}

/* --------------------------------------------------------------------------
   Home page specifics
   -------------------------------------------------------------------------- */

.masthead {
  border-bottom: 2px solid var(--rule-strong);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-5);
}

.masthead h1 {
  margin-bottom: var(--space-2);
}

.masthead__byline {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink-muted);
  margin: 0;
}

.meta-list {
  border-top: 1px solid var(--rule);
  margin: var(--space-4) 0 var(--space-5);
  padding: 0;
}

.meta-list div {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) 1fr;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9375rem;
}

.meta-list dt {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.meta-list dd {
  margin: 0;
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: var(--space-4);
  margin: var(--space-4) 0 var(--space-5);
  padding: 0;
  list-style: none;
}

.index-grid li {
  border-top: 1px solid var(--rule);
  padding-top: var(--space-2);
}

.index-grid a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  font-size: 1rem;
}

.index-grid a:hover {
  color: var(--accent);
}

.index-grid span {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 60rem) {
  .layout {
    display: block;
  }

  .sidebar {
    width: auto;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }

  .content {
    padding: var(--space-5) var(--space-4);
  }

  .field {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .definition__row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
}

/* --------------------------------------------------------------------------
   Print — the layout this design is really for
   -------------------------------------------------------------------------- */

@media print {
  .sidebar,
  .tabs,
  .controls {
    display: none;
  }

  .content {
    padding: 0;
  }

  .tabs__panel[hidden] {
    display: block;
  }

  body {
    background: #fff;
  }
}
