/*
 * Kipside — kipside.site
 *
 * Design language is the extension's own (§79). Tokens below are lifted verbatim from
 * src/ui/tokens.css so the site and the product cannot drift.
 *
 * §48's anti-pattern list is binding here too, and it is most of what keeps this from
 * looking like every other extension landing page: no gradients, no glassmorphism, no glow,
 * no floating blobs, no 24px radius on everything, no sparkle icons, no stock illustration.
 *
 * Hierarchy comes from type, spacing and hairlines. There is exactly one shadow in the
 * entire stylesheet and it belongs to a popover.
 *
 * Typeface: the system stack, deliberately. It renders SF Pro on macOS and Segoe UI on
 * Windows — both excellent — costs no network request, and cannot flash. Adding a fashionable
 * display face would be the single fastest way to make this look like a template.
 */

/* ============================================================ tokens */

:root {
  --canvas: #f4f2ec;
  --panel: #fbfaf6;
  --surface: #ffffff;
  --raised: #eeece5;
  --border: #d8d6cf;
  --border-strong: #c7c5bd;
  --ink-primary: #1c1d1a;
  --ink-secondary: #5f625b;
  --ink-muted: #8b8e85; /* non-text only — fails AA at body sizes */
  --accent: #3e684f;
  --accent-hover: #31553f;
  --accent-subtle: #e2ebe4;
  --warning: #986721;
  --destructive: #a5453f;

  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 48px; --s9: 64px; --s10: 96px; --s11: 128px;

  --r-thumb: 6px; --r-control: 7px; --r-inset: 8px; --r-overlay: 12px;

  --measure: 60ch;
  --shell: 1120px;
  --ease: cubic-bezier(0.2, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #181a17;
    --panel: #1d1f1b;
    --surface: #20221e;
    --raised: #272a25;
    --border: #373a34;
    --border-strong: #464a42;
    --ink-primary: #f1f0ea;
    --ink-secondary: #abaea5;
    --ink-muted: #777b72;
    --accent: #78a887;
    --accent-hover: #8fbc9b;
    --accent-subtle: #273a2c;
    --warning: #d1a55c;
    --destructive: #d2766f;
  }
}

/* ============================================================ base */

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

html {
  scroll-behavior: smooth;
  /* Sticky header is 60px; give anchored sections room to breathe above them. */
  scroll-padding-top: 84px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.6;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

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

::selection { background: var(--accent-subtle); color: var(--ink-primary); }

.skip {
  position: absolute;
  left: -9999px;
  top: var(--s2);
  padding: var(--s2) var(--s4);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-control);
  z-index: 100;
}
.skip:focus { left: var(--s4); }

.wrap { max-width: var(--shell); margin: 0 auto; padding: 0 var(--s6); }

@media (max-width: 600px) { .wrap { padding: 0 var(--s5); } }

/* ============================================================ type */

h1, h2, h3 {
  margin: 0;
  font-weight: 500;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.6rem, 6.4vw, 4.25rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
}

h2 {
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.028em;
}

h3 {
  font-size: 1.0625rem;
  line-height: 1.35;
  letter-spacing: -0.012em;
}

p { margin: 0; max-width: var(--measure); text-wrap: pretty; }

a { color: inherit; }

/* Editorial eyebrow. Mono + tracking is what gives the page its technical register —
   it is doing the job a decorative typeface would otherwise be hired for. */
.eyebrow {
  display: block;
  margin-bottom: var(--s4);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
  line-height: 1.5;
  color: var(--ink-secondary);
  max-width: 46ch;
}

.muted { color: var(--ink-secondary); }
.small { font-size: 0.875rem; line-height: 1.55; }

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--panel);
  font-family: var(--font-ui);
  font-size: 0.8125em;
  line-height: 1.5;
  color: var(--ink-secondary);
  white-space: nowrap;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--raised);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ============================================================ header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  /* Solid, with a hairline. Not a blurred glass bar (§48). */
  background: var(--canvas);
  border-bottom: 1px solid transparent;
  transition: border-color 140ms var(--ease);
}

.site-header[data-stuck] { border-bottom-color: var(--border); }

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--s5);
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  text-decoration: none;
}

.site-nav { display: flex; align-items: center; gap: var(--s6); margin-left: auto; }

/*
 * :not(.btn) matters. `.site-nav a` has specificity (0,1,1) and would otherwise beat
 * `.btn--primary` at (0,1,0), forcing secondary ink onto the accent-filled CTA — invisible
 * in light mode, and readable in dark only by accident of secondary ink being light there.
 */
.site-nav a:not(.btn) {
  font-size: 0.9375rem;
  color: var(--ink-secondary);
  text-decoration: none;
  transition: color 110ms var(--ease);
}

.site-nav a:not(.btn):hover { color: var(--ink-primary); }

@media (max-width: 780px) {
  .site-nav a:not(.btn) { display: none; }
  .site-nav { margin-left: auto; }
}

/* ============================================================ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 42px;
  padding: 0 var(--s5);
  border-radius: var(--r-control);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-primary);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 110ms var(--ease), border-color 110ms var(--ease);
}

.btn:hover { background: var(--raised); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--panel);
}

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

.btn--sm { min-height: 34px; padding: 0 var(--s4); font-size: 0.875rem; }

.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--raised); }

/* ============================================================ sections */

section { padding: var(--s10) 0; }

@media (max-width: 780px) { section { padding: var(--s9) 0; } }

.rule { height: 1px; background: var(--border); border: 0; margin: 0; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(var(--s7), 6vw, var(--s10));
  align-items: center;
}

.row--reverse > :first-child { order: 2; }

@media (max-width: 900px) {
  .row { grid-template-columns: minmax(0, 1fr); gap: var(--s7); }
  .row--reverse > :first-child { order: 0; }
}

.stack > * + * { margin-top: var(--s4); }
.stack-lg > * + * { margin-top: var(--s6); }

/* Quiet scroll reveal. Nothing moves more than 8px; nothing animates off-screen. */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 420ms var(--ease), transform 420ms var(--ease);
}

.reveal[data-shown] { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ============================================================ hero */

.hero { padding-top: var(--s9); padding-bottom: var(--s10); }

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 404px;
  gap: clamp(var(--s7), 6vw, var(--s10));
  align-items: center;
}

@media (max-width: 980px) {
  .hero__grid { grid-template-columns: minmax(0, 1fr); }
  .hero__panel { justify-self: start; width: 100%; max-width: 404px; }
}

.hero h1 { margin-bottom: var(--s5); }

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  margin-top: var(--s7);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  margin-top: var(--s5);
  font-size: 0.875rem;
  color: var(--ink-secondary);
}

.hero__meta span { display: inline-flex; align-items: center; gap: 7px; }

.tick { width: 9px; height: 5px; border-left: 1.75px solid var(--accent); border-bottom: 1.75px solid var(--accent); transform: rotate(-45deg) translate(1px, -2px); flex: none; }

/* ============================================================ panel mock */

.mock {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-overlay);
  background: var(--panel);
  overflow: hidden;
  font-size: 13px;
  line-height: 1.45;
}

.mock__header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 44px;
  padding: 0 var(--s3);
  border-bottom: 1px solid var(--border);
}

.mock__wordmark { font-weight: 500; letter-spacing: -0.01em; }

.mock__status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-secondary);
}

.mock__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

.mock__tabs {
  display: flex;
  gap: var(--s4);
  padding: 0 var(--s3);
  border-bottom: 1px solid var(--border);
}

.mock__tab { position: relative; padding: var(--s2) 0; color: var(--ink-secondary); }

.mock__tab[data-active] { color: var(--ink-primary); font-weight: 500; }

.mock__tab[data-active]::after {
  content: '';
  position: absolute;
  inset: auto 0 -1px 0;
  height: 2px;
  background: var(--accent);
}

.mock__group {
  padding: var(--s4) var(--s3) var(--s2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.mock__search {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
}

.mock__field {
  flex: 1;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 var(--s2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink-primary);
}

.caret {
  display: inline-block;
  width: 1px;
  height: 15px;
  margin-left: 1px;
  background: var(--ink-primary);
  animation: blink 1.06s steps(1) infinite;
  vertical-align: -3px;
}

@keyframes blink { 50% { opacity: 0; } }

.clip { position: relative; padding: var(--s3); border-bottom: 1px solid var(--border); }

.clip:last-child { border-bottom: 0; }

.clip__body { color: var(--ink-primary); }

.clip__body--code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--raised);
  border-radius: var(--r-inset);
  padding: var(--s2);
}

.clip__meta {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: 7px;
  font-size: 12px;
  color: var(--ink-secondary);
}

.clip__age { margin-left: auto; font-variant-numeric: tabular-nums; }

.clip__shot {
  height: 118px;
  border-radius: var(--r-thumb);
  border: 1px solid var(--border);
  background:
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 100% 26px,
    var(--raised);
  /* A flat placeholder that reads as "a screenshot" without pretending to be a real one.
     Ruled lines, like a page — not a fake UI screenshot (§79). */
}

.clip__color { display: flex; align-items: center; gap: var(--s2); }

.clip__swatch {
  width: 20px; height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: #3e684f;
  flex: none;
}

.clip__mono { font-family: var(--font-mono); }

.clip[data-arriving] { animation: arrive 180ms var(--ease) both; }

@keyframes arrive {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.clip[data-hit] { background: var(--accent-subtle); }

/* ============================================================ the loop */

.loop {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s5);
  counter-reset: loop;
}

@media (max-width: 780px) { .loop { grid-template-columns: minmax(0, 1fr); } }

.loop__step {
  padding: var(--s6);
  border: 1px solid var(--border);
  border-radius: var(--r-inset);
  background: var(--panel);
}

.loop__step::before {
  counter-increment: loop;
  content: '0' counter(loop);
  display: block;
  margin-bottom: var(--s4);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.loop__step p { margin-top: var(--s2); font-size: 0.9375rem; color: var(--ink-secondary); }

/* ============================================================ callout */

.callout {
  margin-top: var(--s7);
  padding: var(--s5) var(--s6);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-inset);
  background: var(--panel);
  max-width: 72ch;
}

.callout p { font-size: 0.9375rem; color: var(--ink-secondary); max-width: none; }
.callout strong { color: var(--ink-primary); font-weight: 500; }

/* ============================================================ architecture */

.arch {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: var(--s4);
  max-width: 760px;
}

@media (max-width: 720px) { .arch { grid-template-columns: 1fr; } }

.arch__node {
  padding: var(--s6);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-inset);
  background: var(--panel);
}

.arch__node b { display: block; font-weight: 500; margin-bottom: var(--s1); }
.arch__node span { font-size: 0.875rem; color: var(--ink-secondary); }

.arch__node--absent {
  border-style: dashed;
  background: transparent;
}

.arch__gap {
  display: grid;
  place-items: center;
  padding: 0 var(--s2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  text-align: center;
}

/* ============================================================ facts grid */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--s6) var(--s7);
  margin-top: var(--s8);
}

.fact h3 { margin-bottom: var(--s2); }
.fact p { font-size: 0.9375rem; color: var(--ink-secondary); }

/* ============================================================ faq */

.faq { max-width: 74ch; margin-top: var(--s8); }

.faq details { border-bottom: 1px solid var(--border); }

.faq summary {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
  padding: var(--s5) 0;
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  transition: color 110ms var(--ease);
}

.faq summary::-webkit-details-marker { display: none; }

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

.faq summary::after {
  content: '';
  flex: none;
  margin-left: auto;
  width: 9px;
  height: 9px;
  border-right: 1.75px solid var(--ink-secondary);
  border-bottom: 1.75px solid var(--ink-secondary);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 140ms var(--ease);
}

.faq details[open] summary::after { transform: rotate(225deg) translate(-3px, -3px); }

.faq__answer { padding: 0 0 var(--s5); }
.faq__answer p { font-size: 0.9375rem; color: var(--ink-secondary); max-width: 68ch; }
.faq__answer p + p { margin-top: var(--s3); }

/* ============================================================ cta band */

.cta { padding: var(--s10) 0; text-align: center; }
.cta h2 { margin-bottom: var(--s4); }
.cta p { margin: 0 auto; }
.cta .hero__actions { justify-content: center; }

/* ============================================================ footer */

.site-footer { border-top: 1px solid var(--border); padding: var(--s8) 0 var(--s9); }

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s6);
  align-items: flex-start;
  justify-content: space-between;
}

.site-footer a { color: var(--ink-secondary); text-decoration: none; }
.site-footer a:hover { color: var(--ink-primary); text-decoration: underline; }

.footer-links { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s6); font-size: 0.9375rem; }

.footer-note { margin-top: var(--s6); font-size: 0.8125rem; color: var(--ink-secondary); }

/* ============================================================ legal pages */

.doc { padding: var(--s9) 0 var(--s10); }
.doc__inner { max-width: 72ch; }
.doc h1 { font-size: clamp(2rem, 4vw, 2.75rem); margin-bottom: var(--s3); }
.doc h2 { font-size: 1.375rem; margin-top: var(--s8); margin-bottom: var(--s4); }
.doc h3 { margin-top: var(--s6); margin-bottom: var(--s2); }
.doc p, .doc li { color: var(--ink-secondary); font-size: 0.9375rem; }
.doc p + p, .doc ul + p, .doc p + ul { margin-top: var(--s4); }
.doc ul { padding-left: var(--s5); }
.doc li + li { margin-top: var(--s2); }
.doc strong { color: var(--ink-primary); font-weight: 500; }
.doc table { width: 100%; border-collapse: collapse; margin-top: var(--s4); font-size: 0.875rem; }
.doc th, .doc td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; }
.doc th { color: var(--ink-primary); font-weight: 500; }
.doc td { color: var(--ink-secondary); }
.doc__updated { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-secondary); }

/* Attribution line. The house link is the one thing in the footer that should read as a
   link rather than a note, so it carries the accent and an underline on hover. */
.footer-note__by {
  color: var(--accent) !important;
  font-weight: 500;
  text-decoration: none;
}

.footer-note__by:hover { text-decoration: underline; }

.footer-note__sep { margin: 0 var(--s2); color: var(--ink-muted); }
