/* Simault website. One stylesheet, system fonts, no dependencies. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #1c1d1f;
  --muted: #5b5f66;
  --border: #dfdcd4;
  --accent: #1f5f5b;
  --accent-text: #ffffff;
  --link: #1a5a56;
  --code-bg: #f1efe9;
  --note-bg: #f6f1e3;
  --note-border: #c9a548;
  --focus: #1f5f5b;
  --logo-ring: #ffffff;
  --logo-dot: #8ad8d1;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --measure: 68ch;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131516;
    --surface: #1a1d1f;
    --surface-2: #202426;
    --text: #e9e7e2;
    --muted: #a3a8ae;
    --border: #2f3438;
    --accent: #7fcfc8;
    --accent-text: #0e1b1a;
    --link: #8ad8d1;
    --code-bg: #1e2224;
    --note-bg: #2a2619;
    --note-border: #b7953f;
    --focus: #8ad8d1;
    --logo-ring: #123b38;
    --logo-dot: #123b38;
  }
}

:root[data-theme="dark"] {
  --bg: #131516;
  --surface: #1a1d1f;
  --surface-2: #202426;
  --text: #e9e7e2;
  --muted: #a3a8ae;
  --border: #2f3438;
  --accent: #7fcfc8;
  --accent-text: #0e1b1a;
  --link: #8ad8d1;
  --code-bg: #1e2224;
  --note-bg: #2a2619;
  --note-border: #b7953f;
  --focus: #8ad8d1;
  --logo-ring: #123b38;
  --logo-dot: #123b38;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- Text ---------- */

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 1rem;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  margin: 0 0 0.75rem;
}

h3 {
  font-size: 1.125rem;
  margin: 0 0 0.4rem;
}

p,
ul,
ol {
  margin: 0 0 1rem;
}

p,
li {
  max-width: var(--measure);
}

a {
  color: var(--link);
  text-underline-offset: 0.18em;
}

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

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

.lead {
  font-size: 1.2rem;
  color: var(--muted);
}

.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.6rem 1rem;
  z-index: 10;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
}

.logo {
  display: block;
  height: 26px;
  width: auto;
}

.logo-tile {
  fill: var(--accent);
}

.logo-ring {
  stroke: var(--logo-ring);
}

.logo-dot {
  fill: var(--logo-dot);
}

.logo-word {
  stroke: currentColor;
}

.logo-word-dot {
  fill: currentColor;
}

.site-nav {
  flex: 1 1 auto;
}

.site-nav ul,
.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.15rem;
}

.site-nav li {
  max-width: none;
}

.site-nav a,
.header-link {
  display: inline-block;
  padding: 0.35rem 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.975rem;
}

.site-nav a:hover,
.header-link:hover {
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-left: auto;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* Small screens: wordmark and actions share the first row, links go below */
@media (max-width: 719px) {
  .site-nav {
    order: 3;
    flex-basis: 100%;
  }
}

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

.hero {
  padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(2rem, 5vw, 3.5rem);
}

.hero-grid {
  display: grid;
  gap: 2rem;
  align-items: center;
}

@media (min-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 3rem;
  }
}

.hero-grid > * {
  min-width: 0;
}

.section {
  padding: clamp(2rem, 5vw, 3.5rem) 0;
  border-top: 1px solid var(--border);
}

/* Top and bottom only: the side padding comes from .wrap */
.page-head {
  padding-top: clamp(2rem, 6vw, 3.5rem);
  padding-bottom: 1rem;
}

.prose > * + h2 {
  margin-top: 2.5rem;
}

.prose > * + h3 {
  margin-top: 1.75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0 0;
}

.button {
  display: inline-block;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}

.button:hover {
  filter: brightness(1.08);
}

.button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.button.secondary:hover {
  border-color: var(--text);
  filter: none;
}

/* ---------- Grids and cards ---------- */

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15.5rem), 1fr));
  margin: 1.5rem 0 1.5rem;
  padding: 0;
  list-style: none;
}

.grid > * {
  max-width: none;
  min-width: 0;
}

/* Wider cards: three across on desktop, for sets of three or six */
.grid.wide {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}

.card p:last-child,
.card ul:last-child {
  margin-bottom: 0;
}

.card p,
.card li {
  color: var(--muted);
  font-size: 0.975rem;
}

a.card {
  display: block;
  color: inherit;
  text-decoration: none;
}

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

a.card h3 {
  color: var(--link);
}

.steps {
  counter-reset: step;
}

.steps > li {
  counter-increment: step;
}

.steps > li h3::before {
  content: counter(step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 0.55rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.85rem;
  font-weight: 700;
}

/* ---------- Code ---------- */

code,
pre,
kbd {
  font-family: var(--mono);
  font-size: 0.9em;
}

:not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.08em 0.35em;
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.55;
  font-size: 0.875rem;
  tab-size: 2;
}

.code-block {
  position: relative;
  margin: 0 0 1.25rem;
}

/* Room for the copy button, so it never covers the first line */
.code-block pre {
  padding-top: 2.4rem;
}

pre + .caption,
.code-block + .caption {
  margin-top: -0.75rem;
}

.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.55rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

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

.caption {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Notes, tables, diagram ---------- */

.note {
  background: var(--note-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--note-border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 0 0 1.25rem;
}

.note > :last-child {
  margin-bottom: 0;
}

.note h2,
.note h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.table-scroll {
  overflow-x: auto;
  margin: 0 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: var(--surface);
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-2);
  font-weight: 600;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

/* Identifiers stay on one line; the table scrolls inside its container instead */
td code,
th code {
  white-space: nowrap;
  overflow-wrap: normal;
}

.diagram {
  margin: 1.5rem 0 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.diagram svg {
  display: block;
  width: 100%;
  min-width: 34rem;
  height: auto;
}

.diagram .box {
  fill: var(--surface-2);
  stroke: var(--border);
  stroke-width: 1.5;
}

.diagram .box-accent {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.diagram .line {
  stroke: var(--muted);
  stroke-width: 1.5;
  fill: none;
}

.diagram .head {
  fill: var(--muted);
}

.diagram text {
  fill: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

.diagram .label {
  fill: var(--muted);
  font-size: 12.5px;
}

.diagram .title {
  font-weight: 600;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 1.75rem 0 2.5rem;
  font-size: 0.925rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
}

.footer-inner p {
  margin: 0;
}

/* ---------- Analytics consent ---------- */

.consent {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  font-size: 0.95rem;
}

.consent[hidden] {
  display: none;
}

.consent p {
  margin: 0 0 0.85rem;
  max-width: none;
}

.consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.consent .button {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  .button,
  .card,
  .copy-button {
    transition: border-color 0.15s ease, filter 0.15s ease, color 0.15s ease;
  }
}
