/* ==========================================================================
   Zonix Education — Global Stylesheet
   Production CSS for 300+ TDLR defensive-driving city landing pages & blog.
   Pure CSS. No JS, no build step. Works with existing markup unchanged.
   Markup contract (classes in use): .city-page .subtitle .cta-box .cta-button
   .tw .faq-section .faq-item  +  header>nav, main, section, h1-h3, p, ul/ol,
   table, footer, blockquote, pre/code, article.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens (CSS custom properties)
   -------------------------------------------------------------------------- */
:root {
  /* Brand palette */
  --color-primary: #00a844;        /* Zonix green */
  --color-primary-dark: #00812f;   /* green, hover/darker */
  --color-secondary: #1b3a5c;      /* corporate blue */
  --color-secondary-dark: #122a44;
  --color-accent: #ff6b35;         /* CTA orange */
  --color-accent-dark: #e4521d;

  /* Surfaces & text */
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-text: #333333;
  --color-muted: #6b7280;
  --color-border: #e2e6ea;
  --color-code-bg: #f1f3f5;

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --line-body: 1.7;

  /* Layout & shape */
  --maxw-content: 800px;
  --space: 2rem;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 8px rgba(27, 58, 92, .08);
  --shadow-lg: 0 8px 24px rgba(255, 107, 53, .35);

  /* Interaction */
  --focus-ring: 3px solid var(--color-accent);
  --transition: .2s ease;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: var(--line-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--color-primary-dark);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--color-accent); text-decoration: underline; }

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

/* --------------------------------------------------------------------------
   3. Header, nav & language switcher (sticky, hamburger on mobile)
   -------------------------------------------------------------------------- */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

header > nav {
  max-width: 1024px;
  margin: 0 auto;
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* First link = logo/brand, left-aligned */
header > nav > a:first-child {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-secondary);
  margin-right: auto;        /* pushes remaining links (language switcher) right */
}
header > nav > a:first-child:hover { color: var(--color-primary); text-decoration: none; }

/* Remaining links = language switcher, pill styled, right-aligned */
header > nav > a:not(:first-child) {
  padding: .4rem .85rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-secondary);
  white-space: nowrap;
}
header > nav > a:not(:first-child):hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  text-decoration: none;
}

/* CSS-only hamburger affordance for very small screens: the nav wraps
   gracefully, and the toggle (if markup provides #nav-toggle) collapses links.
   With the current markup the links simply wrap; this keeps it tidy. */
.nav-toggle { display: none; }

/* --------------------------------------------------------------------------
   4. Typography
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  color: var(--color-secondary);
  line-height: 1.25;
  margin: 0 0 .6em;
  font-weight: 700;
  text-wrap: balance;
}
h1 { font-size: 2.5rem; }
h2 { font-size: 1.8rem; margin-top: 1.4em; }
h3 { font-size: 1.4rem; }

p { margin: 0 0 1rem; }

.subtitle {
  color: var(--color-muted);
  font-size: 1.15rem;
  margin-top: -.3rem;
  margin-bottom: 1.5rem;
}

blockquote {
  margin: 1.5rem 0;
  padding: .85rem 1.25rem;
  border-left: 4px solid var(--color-primary);
  background: var(--color-surface);
  color: var(--color-text);
  font-style: italic;
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
}
blockquote p:last-child { margin-bottom: 0; }

strong { color: var(--color-secondary); }

/* --------------------------------------------------------------------------
   5. Layout
   -------------------------------------------------------------------------- */
main, .city-page, .container {
  max-width: var(--maxw-content);
  margin: 0 auto;
  padding: var(--space) 1.25rem;
}
.container { max-width: 960px; }

section { margin-bottom: var(--space); }

article {
  background: var(--color-surface);
  padding: var(--space);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
article > :first-child { margin-top: 0; }

/* --------------------------------------------------------------------------
   6. CTA components
   -------------------------------------------------------------------------- */
.cta-box {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  margin: var(--space) 0;
  text-align: center;
  box-shadow: var(--shadow);
}
.cta-box h2, .cta-box h3 { color: #fff; margin-top: 0; }
.cta-box p { color: rgba(255, 255, 255, .95); }
.cta-box a:not(.cta-button):not(.cta-btn) { color: #fff; text-decoration: underline; }

.cta-button, .cta-btn {
  display: inline-block;
  margin-top: 1rem;
  padding: .95rem 2rem;
  background: var(--color-accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}
.cta-button:hover, .cta-btn:hover,
.cta-button:focus-visible, .cta-btn:focus-visible {
  background: var(--color-accent-dark);
  color: #fff;
  text-decoration: none;
  transform: scale(1.05);
  animation: cta-pulse 1.2s ease-in-out infinite;
}
.cta-button:active, .cta-btn:active { transform: scale(.98); }

/* --------------------------------------------------------------------------
   7. Tables (.tw = scroll wrapper)
   -------------------------------------------------------------------------- */
.tw {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.25rem 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--color-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .97rem;
}
th, td {
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
thead th, table > tr > th:first-child {
  background: var(--color-secondary);
  color: #fff;
  font-weight: 600;
}
thead th { border-bottom: 0; }
/* Striped rows */
tbody tr:nth-child(even),
table > tr:nth-child(even) { background: var(--color-bg); }
tbody tr:hover,
table > tr:hover { background: rgba(0, 168, 68, .06); }
table tr:last-child td, table tr:last-child th { border-bottom: 0; }

/* --------------------------------------------------------------------------
   8. FAQ section
   -------------------------------------------------------------------------- */
.faq-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem var(--space);
  box-shadow: var(--shadow);
}
.faq-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
}
.faq-item:last-child { border-bottom: 0; padding-bottom: 0; }
.faq-item h3 {
  margin: 0 0 .5rem;
  font-size: 1.15rem;
  color: var(--color-secondary);
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.faq-item h3::before {
  content: "Q";
  flex: 0 0 auto;
  width: 1.5em;
  height: 1.5em;
  display: inline-grid;
  place-items: center;
  font-size: .8rem;
  color: #fff;
  background: var(--color-primary);
  border-radius: 50%;
}
.faq-item p { margin: 0; color: var(--color-text); }

/* Native accordion support if markup uses <details>/<summary> */
details.faq-item { cursor: pointer; }
details.faq-item > summary {
  list-style: none;
  font-weight: 700;
  color: var(--color-secondary);
}
details.faq-item > summary::-webkit-details-marker { display: none; }
details.faq-item > summary::after { content: "+"; float: right; color: var(--color-primary); }
details.faq-item[open] > summary::after { content: "–"; }

/* --------------------------------------------------------------------------
   9. Lists
   -------------------------------------------------------------------------- */
ul, ol { padding-left: 1.5rem; margin: 0 0 1.25rem; }
li { margin-bottom: .5rem; }
li > ul, li > ol { margin-top: .5rem; margin-bottom: 0; }

/* Custom marker for unordered lists (scoped to content, not nav) */
main ul:not(.plain) { list-style: none; padding-left: 1.5rem; }
main ul:not(.plain) > li { position: relative; }
main ul:not(.plain) > li::before {
  content: "";
  position: absolute;
  left: -1.3rem;
  top: .6em;
  width: .5rem;
  height: .5rem;
  background: var(--color-primary);
  border-radius: 50%;
}
main ol { list-style: none; counter-reset: step; padding-left: 2.25rem; }
main ol > li { position: relative; }
main ol > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -2.25rem;
  top: 0;
  width: 1.6rem;
  height: 1.6rem;
  display: inline-grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  background: var(--color-secondary);
  border-radius: 50%;
}

/* --------------------------------------------------------------------------
   10. Blog article: code blocks & readable flow
   -------------------------------------------------------------------------- */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: .9em;
  background: var(--color-code-bg);
  padding: .15em .4em;
  border-radius: 4px;
}
pre {
  background: var(--color-code-bg);
  color: var(--color-text);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  border: 1px solid var(--color-border);
  line-height: 1.5;
}
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: var(--space) 0; }

/* --------------------------------------------------------------------------
   11. Hero & highlight box (used by richer blog template)
   -------------------------------------------------------------------------- */
.hero {
  background: linear-gradient(135deg, var(--color-secondary), var(--color-secondary-dark));
  color: #fff;
  text-align: center;
  padding: 3rem 1.25rem;
}
.hero h1 { color: #fff; }
.hero p { color: rgba(255, 255, 255, .9); max-width: 42rem; margin: 0 auto 1.5rem; }
.hero .badge {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  padding: .35rem 1rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.badge {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  padding: .25rem .75rem;
  border-radius: 999px;
  font-size: .85rem;
}
.highlight-box {
  background: var(--color-surface);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  margin: 1.5rem 0;
}

/* --------------------------------------------------------------------------
   12. Footer
   -------------------------------------------------------------------------- */
footer {
  background: var(--color-secondary);
  color: #fff;
  text-align: center;
  padding: var(--space) 1.25rem;
  margin-top: var(--space);
  font-size: .95rem;
}
footer p { margin: .35rem 0; color: rgba(255, 255, 255, .85); }
footer a { color: #fff; text-decoration: underline; }
footer a:hover { color: var(--color-accent); }

/* --------------------------------------------------------------------------
   13. Utility classes
   -------------------------------------------------------------------------- */
.text-center { text-align: center; }
.text-muted { color: var(--color-muted); }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.hidden-mobile { }
.hidden-desktop { }

/* --------------------------------------------------------------------------
   14. Animations
   -------------------------------------------------------------------------- */
@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(255, 107, 53, .35); }
  50% { box-shadow: 0 8px 32px rgba(255, 107, 53, .6); }
}
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Fade sections in on load/scroll. Uses scroll-driven animation where
   supported; otherwise degrades to a simple entrance via the fallback. */
main > section, article, .cta-box { animation: fade-in-up .6s ease both; }

@supports (animation-timeline: view()) {
  main > section, article {
    animation: fade-in-up linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 18%;
  }
}

/* --------------------------------------------------------------------------
   15. Responsive — mobile-first refinements at 768px / 1024px
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  h1 { font-size: 1.9rem; }
  h2 { font-size: 1.45rem; }
  h3 { font-size: 1.2rem; }
  .hero { padding: 2rem 1rem; }
  .cta-box { padding: 1.25rem; }
  .cta-button, .cta-btn { display: block; width: 100%; text-align: center; }
  header > nav { padding: .7rem 1rem; }
  .hidden-mobile { display: none !important; }
}

@media (min-width: 768px) {
  main, .city-page { padding: var(--space) 1.5rem; }
  .hidden-desktop { display: none !important; }
}

@media (min-width: 1024px) {
  :root { --space: 2.5rem; }
  body { font-size: 1.05rem; }
}

/* --------------------------------------------------------------------------
   16. Print — clean, ink-friendly; drop nav/footer/CTAs
   -------------------------------------------------------------------------- */
@media print {
  header, footer, .cta-box, .cta-button, .cta-btn, .nav-toggle { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  main, .city-page, .container { max-width: none; padding: 0; }
  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; color: #555; }
  .tw, article, .faq-section, blockquote { box-shadow: none; border: 1px solid #ccc; }
  h1, h2, h3 { color: #000; }
  section, .faq-item { page-break-inside: avoid; }
}

/* --------------------------------------------------------------------------
   17. Dark mode — inverted surfaces; brand CTAs preserved for contrast
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f141a;
    --color-surface: #1a222c;
    --color-text: #e4e7eb;
    --color-muted: #9aa5b1;
    --color-border: #2c3744;
    --color-code-bg: #11181f;
    --color-primary-dark: #18c25a;
    --shadow: 0 2px 10px rgba(0, 0, 0, .5);
  }
  header { background: var(--color-surface); }
  header > nav > a:first-child,
  header > nav > a:not(:first-child) { color: var(--color-text); }
  h1, h2, h3, h4, strong { color: #ffffff; }
  .subtitle { color: var(--color-muted); }
  thead th, table > tr > th:first-child { background: var(--color-secondary-dark); }
  tbody tr:nth-child(even), table > tr:nth-child(even) { background: rgba(255, 255, 255, .04); }
  a { color: #4fd98a; }
  a:hover { color: var(--color-accent); }
  /* .cta-box (green) and footer (blue) intentionally keep brand colors —
     they already meet contrast on white CTA text. */
}
