/* ═══════════════════════════════════════════════
   CodyMaster — Global Design Tokens & Base Styles
   Shared across ALL pages (index + 5W1H suite)
   ═══════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  /* Color Palette */
  --bg: oklch(97% 0.018 70);
  --bg-warm: oklch(95.5% 0.022 65);
  --surface: oklch(99% 0.008 70);
  --fg: oklch(22% 0.02 50);
  --fg-soft: oklch(38% 0.018 50);
  --muted: oklch(50% 0.018 50);
  --border: oklch(90% 0.014 70);
  --border-strong: oklch(82% 0.016 60);
  --accent: oklch(64% 0.13 28);
  --accent-soft: oklch(64% 0.13 28 / 0.1);
  --accent-hover: oklch(58% 0.14 28);
  --green: oklch(62% 0.14 155);
  --green-soft: oklch(62% 0.14 155 / 0.1);
  --red-soft: oklch(60% 0.14 20 / 0.08);

  /* Typography */
  --font-display: 'Newsreader', Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Layout */
  --radius: 14px;
  --radius-sm: 8px;
  --max-w: 1120px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Layout Utility ── */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 28px; }

/* ── Unified Header ── */
.cm-header {
  position: sticky; top: 0; z-index: 100;
  background: oklch(97% 0.018 70 / 0.88);
  backdrop-filter: blur(16px) saturate(120%);
  border-bottom: 1px solid var(--border);
}
.cm-header-inner {
  max-width: var(--max-w); margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; gap: 8px;
}
.cm-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.cm-logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), oklch(72% 0.12 45));
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  box-shadow: 0 2px 8px oklch(64% 0.13 28 / 0.3);
}
.cm-logo-text {
  font-family: var(--font-display); font-weight: 600; font-size: 18px;
  letter-spacing: -0.01em; color: var(--fg);
}

.cm-nav { display: flex; align-items: center; gap: 2px; }
.cm-nav > a,
.cm-nav > .cm-dropdown > a {
  font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: 8px;
  color: var(--fg-soft);
  text-decoration: none; transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.cm-nav > a:hover,
.cm-nav > .cm-dropdown > a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.cm-nav > a.active,
.cm-nav > .cm-dropdown > a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ── Dropdown Menu ── */
.cm-dropdown { position: relative; }
.cm-dropdown-trigger {
  display: flex; align-items: center; gap: 4px;
  cursor: pointer; user-select: none;
}
.cm-dropdown-arrow {
  font-size: 10px; line-height: 1;
  transition: transform 0.15s ease;
  display: inline-block;
}
.cm-dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) translateY(-4px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px oklch(22% 0.02 50 / 0.1);
  padding: 6px 0;
  z-index: 200;
}
.cm-dropdown:hover .cm-dropdown-menu,
.cm-dropdown:focus-within .cm-dropdown-menu {
  opacity: 1; visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.cm-dropdown:hover .cm-dropdown-arrow,
.cm-dropdown:focus-within .cm-dropdown-arrow {
  transform: rotate(180deg);
}
.cm-dropdown-menu a {
  display: block; padding: 8px 16px;
  font-size: 13px; font-weight: 500; color: var(--fg-soft);
  border-radius: 4px; margin: 0 6px;
  transition: background 0.12s, color 0.12s;
}
.cm-dropdown-menu a:hover {
  background: var(--accent-soft); color: var(--accent); text-decoration: none;
}
.cm-dropdown-menu a.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

/* Parent active state when child page is active */
.cm-dropdown:has(.cm-dropdown-menu .active) > .cm-dropdown-trigger {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

.cm-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cm-btn-gh {
  font-size: 12px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px;
  color: var(--fg-soft) !important; border: 1px solid var(--border);
  text-decoration: none; transition: border-color 0.15s, color 0.15s;
}
.cm-btn-gh:hover { border-color: var(--fg-soft); color: var(--fg) !important; text-decoration: none; }
.cm-btn-free {
  background: var(--accent) !important; color: white !important;
  padding: 7px 16px !important; border-radius: 8px !important;
  font-size: 12px !important; font-weight: 600 !important;
  text-decoration: none; transition: opacity 0.15s;
}
.cm-btn-free:hover { opacity: 0.85; text-decoration: none; }

.cm-hamburger {
  display: none; background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 8px;
  align-items: center; justify-content: center;
  color: var(--fg-soft); font-size: 18px;
  transition: background 0.15s;
}
.cm-hamburger:hover { background: var(--accent-soft); }
.cm-mobile-menu {
  display: none;
  position: fixed; top: 56px; left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px 16px;
  box-shadow: 0 8px 32px oklch(22% 0.02 50 / 0.08);
  z-index: 99;
}
.cm-mobile-menu.open { display: block; }
.cm-mobile-menu a {
  display: block; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--fg-soft);
  text-decoration: none; transition: background 0.12s;
}
.cm-mobile-menu a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.cm-mobile-menu a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cm-mobile-menu .ext-links { display: flex; gap: 8px; flex-wrap: wrap; }
.cm-mobile-menu .ext-links a { font-size: 13px; color: var(--muted); }
.cm-mobile-menu .divider { height: 1px; background: var(--border); margin: 8px 0; }

/* ── Mobile Accordion ── */
.cm-mobile-group { margin-bottom: 2px; }
.cm-mobile-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 10px 12px;
  background: none; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--fg-soft);
  cursor: pointer; transition: background 0.12s, color 0.12s;
  font-family: inherit;
}
.cm-mobile-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.cm-mobile-toggle::after {
  content: '▾'; font-size: 10px;
  transition: transform 0.2s ease;
}
.cm-mobile-toggle.open::after { transform: rotate(180deg); }
.cm-mobile-sub {
  display: none; padding-left: 12px;
}
.cm-mobile-sub.open { display: block; }
.cm-mobile-sub a {
  font-size: 13px; padding: 8px 12px; color: var(--muted);
}

@media (max-width: 900px) {
  .cm-nav > a:not(.active) { padding: 6px 8px; font-size: 12px; }
}
@media (max-width: 768px) {
  .cm-right { display: none; }
  .cm-nav { display: none; }
  .cm-hamburger { display: flex; }
}

/* ── Scroll Progress Bar ── */
.cm-progress-bar {
  position: fixed; top: 56px; left: 0;
  height: 2px; width: 0%;
  background: var(--accent);
  z-index: 101;
  transition: width 0.1s linear;
}
