/* =============================================================================
   Tesla David — design system
   Original tokens (not the competitor's). System fonts only = no render-blocking
   font fetch, no CLS. Light + dark via prefers-color-scheme.
   ============================================================================= */

:root {
  /* palette — deep "ink" base + electric teal→blue accent + warm signal */
  --ink: #0b1220;
  --ink-2: #111a2e;
  --paper: #ffffff;
  --paper-2: #f5f7fb;
  --line: #e4e8f0;
  --text: #16202e;
  --text-2: #55607a;
  --accent: #0fb5a6;      /* teal */
  --accent-2: #1f8fff;    /* blue */
  --accent-ink: #04121a;
  --signal: #f5a623;      /* amber highlight */
  --good: #12885f;
  --bad: #d1425b;

  --grad: linear-gradient(135deg, #3ef0d0 0%, #1fb6ff 100%);
  --shadow-sm: 0 1px 2px rgba(16,32,60,.06), 0 2px 8px rgba(16,32,60,.05);
  --shadow-md: 0 8px 30px rgba(16,32,60,.10);

  --radius: 14px;
  --radius-sm: 10px;
  --wrap: 1120px;
  --space: clamp(1rem, 2.5vw, 1.5rem);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
          "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --bg: var(--paper);
  --bg-2: var(--paper-2);
  --card: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--ink);
    --bg-2: var(--ink-2);
    --card: #131d33;
    --line: #26324b;
    --text: #eaf0fb;
    --text-2: #a3afc7;
    --paper-2: #131d33;
    --shadow-md: 0 8px 30px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  }
}

/* ── base ─────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); color: var(--text); background: var(--bg);
  line-height: 1.65; font-size: 1.02rem; text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
img, svg { max-width: 100%; height: auto; vertical-align: middle; }
a { color: var(--accent-2); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5.5vw, 3.25rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); font-weight: 750; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1rem; }
.lead { font-size: 1.16rem; color: var(--text-2); max-width: 62ch; }
.muted { color: var(--text-2); }
.small { font-size: .9rem; } .xsmall { font-size: .8rem; }
.wrap { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }
.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section.tint { background: var(--bg-2); }
.section > .wrap > h2 { margin-bottom: .35em; }
/* centered reading column for article pages (kills dead space on wide screens) */
.section.narrow > .wrap { max-width: 820px; }
.section.narrow .prose { max-width: none; }

.skip-link {
  position: absolute; left: -999px; top: .5rem; z-index: 100;
  background: var(--card); padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow-md);
}
.skip-link:focus { left: .5rem; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }

/* ── header ───────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 1rem; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800;
  color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.brand-name { font-size: 1.16rem; }
.brand-name b { color: var(--accent); font-weight: 800; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: .3rem; }
.site-nav a { color: var(--text-2); text-decoration: none; padding: .5rem .7rem; border-radius: 8px;
  font-weight: 600; font-size: .96rem; }
.site-nav a:hover { color: var(--text); background: var(--bg-2); }
.site-nav a[aria-current="page"] { color: var(--text); }
.nav-toggle { display: none; }

/* ── buttons ──────────────────────────────────────────────────────────────── */
.btn {
  --b: var(--accent-2);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  padding: .7rem 1.15rem; border-radius: 999px; border: 1px solid transparent;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { box-shadow: var(--shadow-md); }
.btn-sm { padding: .5rem 1rem; background: var(--grad); color: var(--accent-ink);
  font-size: .9rem; box-shadow: var(--shadow-sm); }
.btn-sm:hover { box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-block { display: flex; width: 100%; margin-top: .8rem; }
.btn-copy { background: var(--text); color: var(--bg); padding: .55rem 1rem; border-radius: 10px; }
.btn-copy.copied { background: var(--good); color: #fff; }

/* ── hero ─────────────────────────────────────────────────────────────────── */
.hero { position: relative; overflow: clip;
  background: radial-gradient(1200px 500px at 80% -10%, rgba(31,182,255,.16), transparent 60%),
              radial-gradient(900px 500px at 0% 0%, rgba(15,181,166,.14), transparent 55%); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(1.5rem,4vw,3rem);
  align-items: center; padding: clamp(2.5rem,6vw,4.5rem) 0; }
.eyebrow { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700;
  font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); padding: .35rem .7rem;
  border-radius: 999px; }
.hero h1 .hl { background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; }

/* ── pills ────────────────────────────────────────────────────────────────── */
.pills { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 1.1rem 0; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: .4rem .85rem; font-size: .88rem; font-weight: 600; box-shadow: var(--shadow-sm); }
.pill-accent { border-color: transparent; background: var(--grad); color: var(--accent-ink); }

/* ── slim trust line (replaces the busy trust-pill row in the hero) ─────────── */
.trust-line { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; margin: 1.25rem 0 0;
  padding: 0; list-style: none; color: var(--text-2); font-size: .9rem; font-weight: 600; }
.trust-line li { display: inline-flex; align-items: center; gap: .4rem; }
.trust-line svg { flex: none; }

/* ── feature icon (clean square, replaces mixed emoji/text circles) ─────────── */
.feature-ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  font-size: 1.35rem; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: .7rem; }
.feature-ico.grad { background: var(--grad); border-color: transparent; }

/* ── code card ────────────────────────────────────────────────────────────── */
.code-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow-md); position: relative; }
.code-card::before { content: ""; position: absolute; inset: 0; border-radius: var(--radius);
  padding: 1px; background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; opacity: .5; pointer-events: none; }
.code-card-label { font-weight: 700; margin: 0 0 .55rem; }
.code-row { display: flex; gap: .5rem; align-items: stretch; }
.code-value { flex: 1; font-family: var(--mono); font-size: 1.15rem; font-weight: 600;
  background: var(--bg-2); border: 1px dashed var(--line); border-radius: 10px;
  padding: .6rem .85rem; display: flex; align-items: center; letter-spacing: .02em;
  overflow-x: auto; white-space: nowrap; }

/* ── generic cards / grids ────────────────────────────────────────────────── */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow-sm); }
.card h3 { margin-top: 0; }
a.card { text-decoration: none; color: inherit; display: block; transition: transform .12s, box-shadow .12s; }
a.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card .tag { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tag.ok { color: var(--good); } .tag.no { color: var(--bad); }
.step-num { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 999px;
  background: var(--grad); color: var(--accent-ink); font-weight: 800; margin-bottom: .5rem; }

/* ── tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); }
table { border-collapse: collapse; width: 100%; min-width: 520px; background: var(--card); }
th, td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--line); font-size: .96rem; }
thead th { background: var(--bg-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-2); }
tbody tr:last-child td { border-bottom: 0; }
.yes { color: var(--good); font-weight: 700; } .noo { color: var(--bad); font-weight: 700; }

/* ── FAQ ──────────────────────────────────────────────────────────────────── */
.faq { display: grid; gap: .6rem; max-width: 820px; }
.faq-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; }
.faq-item summary { cursor: pointer; list-style: none; padding: 1rem 1.15rem; font-weight: 700;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.4rem; color: var(--accent); line-height: 1; }
.faq-item[open] summary::after { content: "–"; }
.faq-a { padding: 0 1.15rem 1.15rem; color: var(--text-2); }
.faq-a :is(p):last-child { margin-bottom: 0; }

/* ── callouts ─────────────────────────────────────────────────────────────── */
.note { border-left: 4px solid var(--accent); background: var(--bg-2); padding: 1rem 1.15rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 1.2rem 0; }
.note.warn { border-color: var(--signal); }
.note strong { color: var(--text); }

/* ── post figure (news images) ───────────────────────────────────────────── */
.post-figure { margin: 1.4rem 0; }
.post-figure img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); }
.post-figure figcaption { margin-top: .5rem; }
.post-figure figcaption a { color: inherit; }
.news-tag { display: inline-block; background: var(--bg-2); color: var(--text-2); font-size: .78rem;
  font-weight: 700; letter-spacing: .02em; text-transform: uppercase; padding: .2rem .55rem;
  border-radius: 999px; margin-bottom: .6rem; }

/* ── breadcrumb ───────────────────────────────────────────────────────────── */
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0;
  margin: 0 0 1rem; font-size: .88rem; color: var(--text-2); }
.breadcrumb li + li::before { content: "/"; margin-right: .4rem; color: var(--line); }
.breadcrumb a { color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

/* ── prose (article body) ─────────────────────────────────────────────────── */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 2.2rem; } .prose h3 { margin-top: 1.6rem; }
.prose ul, .prose ol { padding-left: 1.25rem; } .prose li { margin: .35rem 0; }
.prose table { margin: 1rem 0; }

/* ── footer ───────────────────────────────────────────────────────────────── */
.site-footer { background: var(--bg-2); border-top: 1px solid var(--line); margin-top: 2rem;
  padding-top: 2.5rem; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 1.5rem; }
.footer-grid nav { display: flex; flex-direction: column; gap: .35rem; }
.footer-grid nav a { color: var(--text-2); text-decoration: none; font-size: .93rem; }
.footer-grid nav a:hover { color: var(--text); }
.foot-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text);
  margin: 0 0 .3rem; }
.foot-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  border-top: 1px solid var(--line); margin-top: 2rem; padding: 1.2rem 0; }

/* ── utilities ────────────────────────────────────────────────────────────── */
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 1rem; }
.hero-cta { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.2rem; }

/* ── responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; flex-direction: column; gap: 4px; margin-left: auto;
    background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 9px 8px; cursor: pointer; }
  .nav-toggle span { width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: .2s; }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .site-nav { position: fixed; inset: 64px 0 auto 0; flex-direction: column; align-items: stretch;
    background: var(--bg); border-bottom: 1px solid var(--line); padding: .75rem 1rem 1.25rem;
    gap: .25rem; transform: translateY(-120%); transition: transform .22s ease; box-shadow: var(--shadow-md); }
  .site-nav.open { transform: translateY(0); }
  .site-nav a { padding: .75rem .5rem; }
  .site-nav .btn-sm { margin-top: .4rem; }
}
@media (max-width: 480px) {
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .foot-bottom { flex-direction: column; }
}
