/* =========================================================
   kaos-control.io — site.css
   Tokens → Reset → Base → Layout → Components → Utilities
   ========================================================= */

/* ---------------------------------------------------------
   1. Colour tokens (light theme defaults)
   --------------------------------------------------------- */
:root {
  --bg:              #f7f8fa;
  --surface:         #ffffff;
  --surface-2:       #eef0f4;
  --text:            #0f1a26;
  --muted:           #54627a;
  --accent:          #ee7a2b;
  --accent-dark:     #c85f18;
  --accent-contrast: #ffffff;
  --border:          #d5dae3;

  --nav-h:           64px;
  --content-w:       1100px;
  --gutter:          clamp(1rem, 4vw, 2rem);
  --radius:          6px;
  --section-gap:     clamp(4rem, 8vw, 7rem);
}

/* Dark-theme via OS preference */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #101822;
    --surface:   #17202c;
    --surface-2: #1e2a39;
    --text:      #e8edf3;
    --muted:     #a4b1c4;
    --border:    #2a3a50;
  }
}

/* Dark-theme via JS toggle ([data-theme="dark"] on <html>) */
[data-theme="dark"] {
  --bg:        #101822;
  --surface:   #17202c;
  --surface-2: #1e2a39;
  --text:      #e8edf3;
  --muted:     #a4b1c4;
  --border:    #2a3a50;
}

/* Light-theme override — used by JS toggle */
[data-theme="light"] {
  --bg:        #f7f8fa;
  --surface:   #ffffff;
  --surface-2: #eef0f4;
  --text:      #0f1a26;
  --muted:     #54627a;
  --border:    #d5dae3;
}

/* ---------------------------------------------------------
   2. Reset & box model
   --------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  min-width: 320px;
  overflow-x: hidden;
}

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

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-dark);
}

code, pre, kbd, samp {
  font-family: "JetBrains Mono", "Cascadia Code", "Fira Code", ui-monospace,
               "Courier New", monospace;
}

ul, ol {
  list-style: none;
}

/* ---------------------------------------------------------
   3. Focus styles (WCAG AA)
   --------------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------------------------------------------------------
   4. Skip-to-content link
   --------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
  transition: top 0.1s;
}

.skip-link:focus {
  top: 0;
}

/* ---------------------------------------------------------
   5. Layout helpers
   --------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--content-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------------------------------------------------------
   6. Navigation / header
   --------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  transition: padding 0.2s, box-shadow 0.2s;
}

.site-header.is-condensed {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: var(--content-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.nav-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.nav-logo span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  transition: background 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}

/* Hamburger */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background 0.15s;
}

.nav-hamburger:hover {
  background: var(--surface-2);
}

/* Mobile nav */
@media (max-width: 767px) {
  .nav-hamburger {
    display: inline-flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem var(--gutter) 1rem;
    gap: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 99;
  }

  .nav-links.is-open {
    display: flex;
  }

  .nav-links a {
    width: 100%;
    padding: 0.75rem 0.5rem;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
  }

  .nav-links a:last-child {
    border-bottom: none;
  }
}

/* Fallback: with JS disabled, always show nav links */
@media (max-width: 767px) {
  .no-js .nav-hamburger {
    display: none;
  }
  .no-js .nav-links {
    display: flex;
  }
}

/* ---------------------------------------------------------
   7. Sections — shared layout
   --------------------------------------------------------- */
section {
  scroll-margin-top: calc(var(--nav-h) + 1rem);
  padding-block: var(--section-gap);
}

section:nth-child(even) {
  background: var(--surface);
}

section h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

section p {
  max-width: 68ch;
  color: var(--text);
  margin-bottom: 1rem;
}

section p:last-child {
  margin-bottom: 0;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

/* ---------------------------------------------------------
   8. Hero (#top)
   --------------------------------------------------------- */
.hero {
  padding-block: clamp(4rem, 10vw, 8rem);
  background: var(--surface);
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin-bottom: 1rem;
}

.hero h1 .accent {
  color: var(--accent);
}

.hero-value {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  font-weight: 600;
  line-height: 1.4;
  max-width: 52ch;
  margin-inline: auto;
  margin-bottom: 1rem;
  color: var(--text);
}

.hero-sub {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  max-width: 62ch;
  margin-inline: auto;
  margin-bottom: 2.5rem;
  color: var(--muted);
}

.hero-ctas {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

.hero-image {
  max-width: min(900px, 100%);
  margin-inline: auto;
  border-radius: calc(var(--radius) * 2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* ---------------------------------------------------------
   9. Buttons
   --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 2px solid var(--accent);
}

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

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}

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

/* ---------------------------------------------------------
   10. Features grid
   --------------------------------------------------------- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 2);
  padding: 1.5rem;
  transition: box-shadow 0.2s;
}

.feature-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

section:nth-child(even) .feature-card {
  background: var(--surface-2);
}

.feature-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  display: block;
}

.feature-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.feature-card p {
  font-size: 0.925rem;
  color: var(--muted);
  max-width: none;
  margin-bottom: 0;
}

/* ---------------------------------------------------------
   11. Two-column text + image layout (≥ 768 px)
   --------------------------------------------------------- */
.two-col {
  display: grid;
  gap: 3rem;
  align-items: center;
}

@media (min-width: 768px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }

  .two-col.img-first {
    direction: rtl;
  }

  .two-col.img-first > * {
    direction: ltr;
  }
}

.diagram {
  border-radius: calc(var(--radius) * 2);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  width: 100%;
}

.steps + picture {
  display: block;
  margin-top: 2.5rem;
}

.video-embed {
  aspect-ratio: 16 / 9;
  width: 100%;
  margin-top: 2.5rem;
  border-radius: calc(var(--radius) * 2);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  background: #000;
}

.video-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------------------------------------------------------
   12. Audience grid
   --------------------------------------------------------- */
.audience-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.audience-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem;
}

section:nth-child(even) .audience-card {
  background: var(--surface-2);
}

.audience-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.audience-card p {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: none;
  margin-bottom: 0;
}

/* ---------------------------------------------------------
   13. Roadmap section
   --------------------------------------------------------- */
.roadmap-images {
  display: grid;
  gap: 2rem;
  margin-top: 2rem;
}

@media (min-width: 768px) {
  .roadmap-images {
    grid-template-columns: 1fr 1fr;
  }
}

.roadmap-images figure {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.roadmap-images figcaption {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
}

/* ---------------------------------------------------------
   14. Code block (install snippet)
   --------------------------------------------------------- */
.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin-block: 1.5rem;
}

.code-block pre {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre;
}

/* ---------------------------------------------------------
   15. Footer
   --------------------------------------------------------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-block: 2.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.footer-inner {
  max-width: var(--content-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--accent);
}

/* ---------------------------------------------------------
   16. How-it-works steps
   --------------------------------------------------------- */
.steps {
  display: grid;
  gap: 1.5rem;
  margin-top: 2rem;
  counter-reset: step-counter;
}

@media (min-width: 768px) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

.step {
  position: relative;
  padding: 1.25rem 1.25rem 1.25rem 3.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 2);
  counter-increment: step-counter;
}

section:nth-child(even) .step {
  background: var(--surface-2);
}

.step::before {
  content: counter(step-counter);
  position: absolute;
  left: 1rem;
  top: 1.2rem;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.step h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.step p {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: none;
  margin-bottom: 0;
}

/* ---------------------------------------------------------
   17. Get-started section
   --------------------------------------------------------- */
.get-started-ctas {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.licence-note {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 1.5rem;
}

/* ---------------------------------------------------------
   18. Responsive guard — no horizontal scroll
   --------------------------------------------------------- */
@media (max-width: 767px) {
  .two-col {
    grid-template-columns: 1fr;
  }

  .hero-ctas {
    flex-direction: column;
    align-items: center;
  }

  .roadmap-images {
    grid-template-columns: 1fr;
  }
}
