/*
 * theirside.dev styles, after the designer's landing draft (design/landing-draft.html).
 * Colours, fonts, type, spacing, radii and sizes come only from the design-system snapshot
 * in /assets/design/tokens.css (npm run sync-design). Headline sizes the type scale doesn't
 * have (the draft's 36/40 section titles and figures) are derived from tokens with calc().
 *
 * Draft colours that aren't tokens yet use stand-ins (see README, "Design tokens pending"):
 *   brand wash -> --color-surface-alt, yellow accent -> --color-accent,
 *   icon tile fills -> --color-surface + border, icon in a status colour.
 */

:root {
  --h2-size: calc(var(--text-2xl) * 1.5);                  /* 36 */
  --h2-leading: calc(var(--leading-2xl) + var(--space-2)); /* 40 */
  --gutter: var(--space-4);
  --sec-y: calc(var(--space-12) * 1.5);
}

@media (min-width: 640px) {
  :root {
    --gutter: var(--space-6);
    --sec-y: calc(var(--space-12) * 2);
  }
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-6);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-thickness: 2px; }

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

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(var(--space-12) * -2);
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  --focus-color: var(--color-text);
}
.skip-link:focus { top: var(--space-4); }

/* ---------- Layout ---------- */

.wrap {
  width: 100%;
  max-width: var(--size-page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sec { padding-block: var(--sec-y); }
.rule { border-top: 1px solid var(--color-border); }

.intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: calc(var(--size-page-narrow) - var(--space-12) * 2 - var(--space-6)); /* 640 */
  margin-bottom: var(--space-12);
}

.grid { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 900px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.grid + .card { margin-top: var(--space-6); }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}
.row--nowrap { flex-wrap: nowrap; }
.row--between { justify-content: space-between; }
.row__end { margin-left: auto; }

/* ---------- Type ---------- */

.display {
  font-size: var(--text-display);
  line-height: var(--leading-display);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.03em;
}
.h2 {
  font-size: var(--h2-size);
  line-height: var(--h2-leading);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.h3 {
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
  font-weight: var(--weight-semibold);
}
.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
  color: var(--color-text-muted);
}
.label {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
}
.label--link { color: var(--color-link); }
.muted { color: var(--color-text-muted); }
.big {
  font-size: var(--text-xl);
  line-height: var(--leading-xl);
  font-weight: var(--weight-semibold);
}
.fig {
  font-size: var(--h2-size);
  line-height: var(--h2-leading);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.code {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  line-height: var(--leading-md);
  overflow-wrap: anywhere;
}
.code--link { color: var(--color-link); font-size: var(--text-lg); font-weight: var(--weight-regular); }
.code--text { color: var(--color-text); }
.code--pre { white-space: pre; overflow-x: auto; overflow-wrap: normal; tab-size: 2; }
.code--card {
  white-space: pre;
  overflow-x: auto;
  overflow-wrap: normal;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.inline-code {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  padding: 0 var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
}

.tok-c { color: var(--color-text-muted); }
.tok-k { color: var(--color-link); }
.tok-s { color: var(--color-healthy); }
.tok-del { color: var(--color-danger); text-decoration: line-through; }

/* ---------- Brand, header, footer ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
  font-weight: var(--weight-semibold);
}
.brand__mark {
  position: relative;
  flex: none;
  width: var(--space-6);
  height: var(--space-6);
  border-radius: var(--radius-md);
  background: var(--color-accent);
}
.brand__mark::after {
  content: "";
  position: absolute;
  right: calc(var(--space-1) + 1px);
  top: calc(var(--space-1) + 1px);
  width: calc(var(--space-1) + var(--space-0_5));
  height: calc(var(--space-1) + var(--space-0_5));
  border-radius: var(--radius-full);
  background: var(--color-on-accent);
}
.brand--small { font-size: var(--text-base); line-height: var(--leading-base); }
.brand--small .brand__mark { width: var(--space-5); height: var(--space-5); }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-12);
  padding-block: var(--space-6);
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  order: 3;
  width: 100%;
}
.site-nav a { color: var(--color-text-muted); text-decoration: none; padding-block: var(--space-1); }
.site-nav a:hover { color: var(--color-link); }
.site-header__actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--space-2); }

@media (min-width: 860px) {
  .site-nav { order: 0; width: auto; }
}
@media (max-width: 420px) {
  .site-nav { gap: var(--space-1) var(--space-4); }
  .site-header__actions .btn { padding-inline: var(--space-3); }
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-6);
  padding-block: var(--space-6) var(--space-12);
  color: var(--color-text-muted);
}
.site-footer a { color: var(--color-text-muted); }
.site-footer a:hover { color: var(--color-link); }
.site-footer__legal { margin-left: auto; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--size-touch);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-base);
  line-height: var(--leading-base);
  font-weight: var(--weight-semibold);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn--primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn--primary:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.btn--secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn--secondary:hover { background: var(--color-surface-alt); }
.btn--inverse { background: var(--color-on-accent); color: var(--color-accent); }
.btn--inverse:hover { text-decoration: underline; text-underline-offset: 0.2em; }

/* ---------- Bits ---------- */

.dot {
  display: inline-block;
  flex: none;
  width: var(--size-dot);
  height: var(--size-dot);
  border-radius: var(--radius-full);
  background: var(--color-neutral);
}
.dot--danger { background: var(--color-danger); }
.dot--healthy { background: var(--color-healthy); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--space-1) + var(--space-0_5));
  padding: var(--space-0_5) var(--space-2);
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: calc(var(--space-1) + var(--space-0_5));
  height: calc(var(--space-1) + var(--space-0_5));
  border-radius: var(--radius-full);
  background: currentColor;
}
.badge--danger { color: var(--color-danger); }
.badge--warning { color: var(--color-warning); }
.badge--healthy { color: var(--color-healthy); }

.num {
  width: var(--size-control);
  height: var(--size-control);
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: var(--color-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-semibold);
}

/* ---------- Cards and panels ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.card__foot { margin-top: auto; }
.card--answer { background: var(--color-surface-alt); border-color: var(--color-accent); }
.card--brand { border-color: var(--color-accent); }

.panel {
  background: var(--color-surface-alt);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.log { display: flex; flex-direction: column; gap: var(--space-2); }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-12);
  align-items: stretch;
  padding-block: var(--space-12) var(--sec-y);
}
.hero > * { min-width: 0; }
@media (min-width: 900px) {
  .hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.hero__copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-6);
}

/* Brand panel: the accent fill, as on the sign-in page */
.hero-panel {
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.hero-panel__label {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-semibold);
}
.hero-alert, .hero-ids {
  background: var(--color-background);
  color: var(--color-text);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
}
.hero-alert { padding: var(--space-6); gap: var(--space-2); }
.hero-ids { padding: var(--space-4) var(--space-6); gap: var(--space-1); }
.hero-alert__fig { margin-top: var(--space-2); }

.spark { display: block; width: 100%; height: calc(var(--space-12) * 2); margin-block: var(--space-2); }
.spark__threshold, .chart__threshold {
  stroke: var(--color-danger);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.spark__line, .chart__line {
  fill: none;
  stroke: var(--color-danger);
  stroke-width: 2;
  stroke-linejoin: round;
}

/* ---------- Features ---------- */

.features { margin-top: var(--space-12); row-gap: var(--space-12); }
.feat { display: flex; gap: var(--space-4); align-items: flex-start; }
.feat .muted { margin-top: var(--space-1); }
.tile {
  width: var(--space-10);
  height: var(--space-10);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.tile svg {
  width: var(--space-5);
  height: var(--space-5);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tile--blue { color: var(--color-link); }
.tile--green { color: var(--color-healthy); }
.tile--red { color: var(--color-danger); }

/* ---------- Incident ---------- */

.incident { gap: var(--space-6); }
.incident > * + * { border-top: 1px solid var(--color-border); padding-top: var(--space-6); }
.incident__head { display: flex; flex-direction: column; gap: var(--space-2); }
.incident__endpoint { font-size: var(--text-lg); line-height: var(--leading-lg); }

.incident__stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4) var(--space-6);
}
@media (min-width: 640px) {
  .incident__stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.incident__stats > div { display: flex; flex-direction: column-reverse; justify-content: flex-end; }

.incident__body { display: grid; gap: var(--space-8); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .incident__body { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}
.incident__chart, .incident__endpoints, .incident__summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.chart { display: block; width: 100%; height: calc(var(--space-10) * 4); }
.chart__grid { stroke: var(--color-grid); stroke-width: 1; }
.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  color: var(--color-text-muted);
}
.legend { display: inline-flex; align-items: center; gap: var(--space-2); }
.legend::before { content: ""; width: var(--space-4); border-top: 2px solid var(--color-danger); }
.legend--threshold::before { border-top: 1px dashed var(--color-danger); }

.endpoints { width: 100%; border-collapse: collapse; }
.endpoints th {
  text-align: left;
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3) var(--space-2) 0;
}
.endpoints td {
  padding: var(--space-2) var(--space-3) var(--space-2) 0;
  border-top: 1px solid var(--color-border);
  vertical-align: middle;
}
.endpoints td:last-child, .endpoints th:last-child { padding-right: 0; text-align: right; }

.incident__summary .code--pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Privacy ---------- */

.never { display: flex; flex-direction: column; gap: var(--space-2); }
.never li { position: relative; padding-left: var(--space-6); }
.never li::before,
.never li::after {
  content: "";
  position: absolute;
  left: var(--space-0_5);
  top: calc(var(--leading-base) / 2 - 1px);
  width: calc(var(--space-3) - var(--space-0_5));
  height: 2px;
  border-radius: var(--radius-full);
  background: var(--color-danger);
  transform: rotate(45deg);
}
.never li::after { transform: rotate(-45deg); }

.privacy { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8) var(--space-12); }
@media (min-width: 900px) {
  .privacy { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.privacy__copy, .privacy__list { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }

/* ---------- Quick start ---------- */

.quickstart { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
.quickstart > li { min-width: 0; }

/* ---------- Copy-to-clipboard (added by site.js) ---------- */

.copy-wrap { position: relative; min-width: 0; }
.copy-wrap .code--pre { padding-right: calc(var(--space-12) + var(--space-6)); }
.copy-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  min-height: var(--size-control);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.copy-btn:hover { background: var(--color-surface-alt); }
@media (max-width: 640px), (pointer: coarse) {
  .copy-btn { min-height: var(--size-touch); }
  .copy-wrap .code--pre { padding-top: calc(var(--size-touch) + var(--space-3)); padding-right: var(--space-4); }
}

/* ---------- CTA ---------- */

.cta-sec { padding-bottom: var(--sec-y); }
.cta {
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius-2xl);
  padding: clamp(var(--space-6), 5vw, var(--space-12));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-6) var(--space-12);
  --focus-color: var(--color-on-accent);
}
.cta__copy { flex: 1 1 22rem; display: flex; flex-direction: column; gap: var(--space-2); }
.cta .lead { color: var(--color-on-accent); }

/* ---------- 404 ---------- */

.notfound {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-6);
  padding-block: var(--sec-y);
}
