/* Plot45 — shared design system.
   "Broadsheet": Swiss-editorial, achromatic. Chrome is ink on cool paper, ordered
   by hairline rules + whitespace, never a decorative accent — colour belongs to the
   data. No gradients, no shadows, near-square corners, system grotesk. */

:root {
  --bg: #fafbfb;
  --bg-subtle: #eef0f1;
  --panel: #ffffff;
  --panel-hover: #f4f5f6;
  --text: #15171a;
  --muted: #5b6166;
  --line: rgba(20, 24, 28, 0.12);
  --line-strong: #d4d8da;
  --accent: #15171a;
  --accent-soft: rgba(20, 24, 28, 0.07);
  --accent-2: #15171a;
  --success: #1f7a3a;
  --success-soft: rgba(31, 122, 58, 0.12);
  --warning: #9a6b00;
  --warning-soft: rgba(154, 107, 0, 0.13);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.1);
  --shadow: none;
  /* Radius contract: --radius for all controls/chips/badges/tabs/inputs/buttons,
     --radius-lg for large cards/panels only, --radius-full for true dots/circles. */
  --radius: 3px;
  --radius-lg: 4px;
  --radius-full: 50%;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  /* Type scale: one grotesk, hierarchy from weight + size (tabular figures for data). */
  --fs-title: 1rem;       /* 16px / 700 — panel titles, wordmark */
  --fs-eyebrow: 0.6875rem;/* 11px / 600 / uppercase — section labels */
  --fs-body: 0.8125rem;   /* 13px / 400 — controls, body */
  --fs-chip: 0.75rem;     /* 12px / 600 — fit chips */
  --fs-data: 0.84rem;     /* ~13.5px — data table figures (mono) */
  --fs-caption: 0.75rem;  /* 12px — hints, captions, notes */
  --nav-height: 56px;
  --focus: 0 0 0 2px var(--panel), 0 0 0 3px var(--accent);
  --page-gradient: none;
  --header-bg: rgba(250, 251, 251, 0.85);
}

:root[data-theme="dark"] {
  --bg: #131417;
  --bg-subtle: #191c20;
  --panel: #1b1e22;
  --panel-hover: #23272c;
  --text: #eef0f2;
  --muted: #9ba2a8;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.17);
  --accent: #eceef0;
  --accent-soft: rgba(255, 255, 255, 0.09);
  --accent-2: #eceef0;
  --success: #3abf75;
  --success-soft: rgba(58, 191, 117, 0.16);
  --warning: #d9a441;
  --warning-soft: rgba(217, 164, 65, 0.16);
  --danger: #e8675a;
  --danger-soft: rgba(232, 103, 90, 0.16);
  --shadow: none;
  --focus: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent);
  --page-gradient: none;
  --header-bg: rgba(19, 20, 23, 0.85);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: var(--page-gradient);
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius);
}

/* Shell */

.site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-inner {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.site-header__cluster {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Logo: flex items default to min-width:auto, which uses the image’s intrinsic width and can blow up the layout */
.site-logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 1;
  min-width: 0;
  max-width: min(220px, 55vw);
  text-decoration: none;
  line-height: 0;
}

.site-logo img {
  display: block;
  height: 34px;
  max-height: 34px;
  width: auto;
  max-width: 100%;
  min-width: 0;
  flex-shrink: 1;
  object-fit: contain;
  object-position: left center;
}

/* Exam Timer: alternate header logo when dark theme is active */
.site-logo--theme .site-logo__brand--dark {
  display: none;
}

:root[data-theme="dark"] .site-logo--theme .site-logo__brand--light {
  display: none;
}

:root[data-theme="dark"] .site-logo--theme .site-logo__brand--dark {
  display: block;
}

.site-logo:hover {
  opacity: 0.9;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  font-size: 0.94rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.site-main {
  flex: 1;
  padding-top: 40px;
  padding-bottom: 56px;
}

/* Typography */

.page-title {
  margin: 0 0 6px;
  font-size: clamp(1.65rem, 2.5vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-lead {
  margin: 0 0 18px;
  max-width: 46ch;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.45;
}

.page-lead--home {
  max-width: 58ch;
  margin-bottom: 24px;
  font-size: 1rem;
  line-height: 1.5;
}

/* Cards / panels */

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel h2,
.card h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
  font-weight: 600;
}

/* Forms */

.field {
  margin-bottom: 14px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-subtle);
  color: var(--text);
}

input::placeholder {
  color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Buttons */

button,
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

button:hover:enabled,
.btn:hover:enabled {
  transform: translateY(-1px);
}

button:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Semantic buttons — flat token fills, no gradients/shadows (achromatic primary
   = ink). The app uses .ghost/.secondary today; the rest are codified for later
   (e.g. an Export primary). */
.primary,
button.primary {
  background: var(--accent);
  color: var(--bg);
}

.secondary,
button.secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.success,
button.success {
  background: var(--success);
  color: #fff;
}

.warning,
button.warning {
  background: var(--warning);
  color: #fff;
}

.danger,
button.danger {
  background: var(--danger);
  color: #fff;
}

:root[data-theme="dark"] .success,
:root[data-theme="dark"] button.success,
:root[data-theme="dark"] .warning,
:root[data-theme="dark"] button.warning,
:root[data-theme="dark"] .danger,
:root[data-theme="dark"] button.danger {
  color: var(--bg);
}

.ghost,
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.ghost:hover:enabled,
button.ghost:hover:enabled {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--panel-hover);
}

.site-footer {
  margin-top: auto;
  padding: 24px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .site-header__inner {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .site-header__cluster {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .site-header {
    height: auto;
  }

  .site-main {
    padding-top: 28px;
  }
}

/* ---------- Broadsheet: theme toggle + wordmark ---------- */

/* Theme toggle: hairline segmented control with sun/moon glyphs; the active
   side is a raised panel-on-subtle (ink text), no shadow. */
.theme-segment {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 2px;
  background: var(--bg-subtle);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.theme-segment__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
}
.theme-segment__btn:hover:enabled { transform: none; color: var(--text); }
.theme-segment__btn[aria-pressed="true"] {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line-strong);
}
.theme-segment__icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Monospace ONLY for the data-table figures (tabular alignment + instrument
   feel). Chips, graph, and the rest stay in the grotesk. */
input.plotlab-cell { font-family: var(--mono); }

/* Header text wordmark (no logo image yet). */
.plot45-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  line-height: 1;
}
.plot45-logo:hover { text-decoration: none; opacity: 0.85; }
.plot45-logo__img {
  height: 30px;
  width: auto;
  display: block;
}
.plot45-logo__img--dark { display: none; }
[data-theme="dark"] .plot45-logo__img--light { display: none; }
[data-theme="dark"] .plot45-logo__img--dark { display: block; }
.plot45-logo__beta {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1.5px solid var(--line-strong);
  padding: 2px 5px;
  line-height: 1;
}
