/* ==========================================================================
   Powerduck — Shared Site Styles
   Header, footer, navigation dropdown, theme toggle, and common utilities.
   Used by all pages: root index, legal pages, and opensource library pages.
   ========================================================================== */

:root {
  --page-max: 1320px;
  --content-max: 1180px;
  --reading-max: 980px;

  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-subtle: #fafbfc;
  --surface: #ffffff;
  --surface-raised: #ffffff;

  --ink: #0e1116;
  --ink-soft: #252c36;
  --muted: #657080;
  --muted-light: #9aa3b0;

  --line: #e4e7eb;
  --line-strong: #d6dbe2;

  --accent: #1c5cff;
  --accent-soft: #e9efff;
  --accent-border: #c3d2ff;

  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fef6e7;
  --danger: #b32020;
  --danger-soft: #feecec;

  --shadow-sm: 0 1px 2px rgba(14, 17, 22, 0.06);
  --shadow-md: 0 12px 32px -22px rgba(14, 17, 22, 0.22);
  --shadow-lg: 0 28px 70px -42px rgba(14, 17, 22, 0.36);

  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

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

  --nav-bg: rgba(255, 255, 255, 0.88);
  --dropdown-bg: #ffffff;
  --dropdown-border: #e4e7eb;
  --dropdown-item-hover: #f6f7f9;
}

html[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-soft: #111720;
  --bg-subtle: #0e141b;
  --surface: #121821;
  --surface-raised: #171e28;
  --ink: #edf2f7;
  --ink-soft: #d9e1eb;
  --muted: #98a4b4;
  --muted-light: #6f7b8b;
  --line: #252e39;
  --line-strong: #34404e;
  --accent: #6d96ff;
  --accent-soft: rgba(74, 119, 255, 0.14);
  --accent-border: rgba(109, 150, 255, 0.35);
  --ok: #5dd6a0;
  --ok-soft: rgba(34, 197, 94, 0.1);
  --warn: #e7a84b;
  --warn-soft: rgba(217, 144, 31, 0.11);
  --danger: #f08080;
  --danger-soft: rgba(240, 128, 128, 0.12);
  --nav-bg: rgba(11, 15, 20, 0.88);
  --dropdown-bg: #171e28;
  --dropdown-border: #252e39;
  --dropdown-item-hover: #1e2630;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

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

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

.container {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ==========================================================================
   Header / Navigation
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

header .nav-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.035em;
  flex-shrink: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
  color: var(--ink);
}

.brand-logo {
  width: 25px;
  height: 25px;
  flex: none;
}

.brand span.accent { color: var(--muted); font-weight: 500; }

/* Primary nav links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: 4px;
  font-size: 13.5px;
  color: var(--muted);
  list-style: none;
}

.nav-links a {
  transition: color 0.15s ease;
  color: var(--muted);
  text-decoration: none;
}

.nav-links a:hover { color: var(--ink);   text-decoration: none;
}

/* ==========================================================================
   Opensource Dropdown
   ========================================================================== */

.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  color: var(--muted);
  padding: 6px 2px;
  transition: color 0.15s ease;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-dropdown-trigger:hover { color: var(--ink); }

.nav-dropdown-trigger .chevron {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.nav-dropdown:hover .nav-dropdown-trigger .chevron,
.nav-dropdown.open .nav-dropdown-trigger .chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  min-width: 300px;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 200;
  overflow: hidden;
}

.nav-dropdown-menu::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--dropdown-bg);
  border-left: 1px solid var(--dropdown-border);
  border-top: 1px solid var(--dropdown-border);
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.dropdown-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-light);
  padding: 10px 12px 6px;
  background: var(--bg-soft);
  margin: -6px -6px 4px;
  border-bottom: 1px solid var(--line);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
}

.dropdown-item + .dropdown-item {
  margin-top: 2px;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background: var(--accent-soft);
  color: var(--ink);
  border-color: var(--accent-border);
  outline: none;
}

.dropdown-item:focus-visible {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px var(--accent-soft);
}

.dropdown-item .pkg-name {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.dropdown-item:hover .pkg-name {
  color: var(--accent);
}

.dropdown-item .pkg-desc {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.dropdown-item-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Compact grouped dropdown: one-line items, category headers */
.nav-dropdown-menu.compact {
  min-width: 260px;
}

.nav-dropdown-menu.compact .dropdown-item {
  padding: 5px 12px;
  font-size: 12.5px;
  gap: 8px;
  align-items: center;
}

.nav-dropdown-menu.compact .dropdown-item .pkg-badge {
  width: 68px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 3px;
}

.nav-dropdown-menu.compact .dropdown-item .pkg-name {
  font-size: 12px;
  white-space: nowrap;
}

.nav-dropdown-menu.compact .dropdown-section-title {
  padding: 8px 12px 4px;
  margin-top: 2px;
}

/* ==========================================================================
   Nav Actions (right side)
   ========================================================================== */

.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.nav-icon-btn:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.nav-icon-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.btn-github {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn-github:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.btn-github svg { width: 16px; height: 16px; }

.btn-docs {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  text-decoration: none;
}

.btn-docs:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-docs svg { width: 15px; height: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -6px var(--accent);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn-secondary:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-demo {
  background: linear-gradient(135deg, #E8A33D 0%, #d4922f 50%, #7FD1AE 100%);
  color: #0e1116;
  font-weight: 700;
  border: 1px solid rgba(232, 163, 61, 0.4);
  box-shadow: 0 1px 3px rgba(232, 163, 61, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-demo:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -6px rgba(232, 163, 61, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border-color: rgba(232, 163, 61, 0.6);
}

/* ==========================================================================
   Footer (unified across all pages)
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 56px 0 28px;
  margin-top: 96px;
}

.site-footer .footer-shell {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 24px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr 1fr 1fr;
  gap: 48px;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 24px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.footer-brand .brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.footer-brand .brand-logo {
  width: 28px;
  height: 28px;
}

.footer-brand p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.65;
  max-width: 300px;
}

.footer-column h6,
.footer-col h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-light);
  margin-bottom: 16px;
}

.footer-column ul,
.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-column a,
.footer-col a {
  font-size: 13.5px;
  color: var(--muted);
  transition: color 0.15s ease;
}

.footer-column a:hover,
.footer-col a:hover {
  color: var(--ink);
}

.footer-bottom {
  max-width: var(--page-max);
  margin: 40px auto 0;
  padding: 22px 24px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted-light);
}

.footer-bottom-links {
  display: flex;
  gap: 20px;
}

.footer-bottom-links a {
  color: var(--muted-light);
  transition: color 0.15s ease;
}

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

/* ==========================================================================
   Legal Pages (cookie, privacy, refunds, terms)
   ========================================================================== */

.legal-page {
  max-width: var(--reading-max);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.legal-page h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  color: var(--ink);
}

.legal-page .legal-meta {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 32px;
}

.legal-page h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 36px 0 14px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.legal-page h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--ink-soft);
}

.legal-page p {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

.legal-page ul, .legal-page ol {
  margin: 12px 0 16px 24px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.legal-page li { margin-bottom: 6px; }

.legal-page a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* Legal hero + content (used by cookie/privacy/refunds/terms pages) */

.legal-hero {
  padding: 64px 0 40px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

.legal-hero .legal-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 12px;
}

.legal-hero h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--ink);
  margin-bottom: 12px;
}

.legal-hero p {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 600px;
}

.legal-hero .legal-updated {
  font-size: 13px;
  color: var(--muted-light);
  margin-top: 16px;
}

.legal-content {
  max-width: var(--reading-max);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.legal-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 40px 0 16px;
  color: var(--ink);
  letter-spacing: -0.02em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.legal-content h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--ink-soft);
}

.legal-content p {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.legal-content ul, .legal-content ol {
  margin: 14px 0 20px 24px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.legal-content li { margin-bottom: 8px; }

.legal-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.legal-content a:hover {
  color: var(--ink);
  opacity: 0.85;
}

.legal-content strong { color: var(--ink); font-weight: 600; }

/* Table of Contents for legal pages */

.legal-toc {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 36px;
}

.legal-toc h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-light);
  margin-bottom: 12px;
}

.legal-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legal-toc li {
  margin: 0;
  padding: 0;
  counter-increment: toc-counter;
}

.legal-toc ol {
  counter-reset: toc-counter;
}

.legal-toc li::before {
  content: counter(toc-counter, decimal-leading-zero);
  display: inline-block;
  width: 28px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-light);
  font-weight: 600;
}

.legal-toc a {
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.15s ease;
}

.legal-toc a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Hamburger button — hidden on desktop */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 0;
}
.nav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 900px) {
  .nav-hamburger { display: flex; }
  header .nav-inner { position: relative; }
  header nav {
    position: fixed !important;
    top: 60px;
    left: 0;
    right: 0;
    background: #ffffff !important;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    padding: 8px 20px 20px;
    transform: translateY(-120%);
    transition: transform 0.25s ease;
    z-index: 9999 !important;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    display: block !important;
  }
  [data-theme="dark"] header nav {
    background: #0b0f14 !important;
  }
  header nav.open { transform: translateY(0) !important; }
  .nav-links {
    display: flex !important;
    flex-direction: column;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .nav-links > li > a,
  .nav-links > a,
  .nav-links .nav-dropdown-trigger {
    padding: 12px 0;
    font-size: 15px;
    border-bottom: 1px solid var(--line);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border-left: none;
    border-right: none;
    color: var(--ink-soft);
    text-decoration: none;
  }
  .nav-dropdown-menu {
    position: static;
    transform: none !important;
    box-shadow: none;
    border: none;
    padding: 0 0 8px 12px;
    min-width: auto;
    opacity: 0;
    visibility: hidden;
    display: none;
  }
  .nav-dropdown.open .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    display: block;
  }
  .nav-dropdown-menu::before { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; gap: 12px; text-align: center; }
  .btn-github .gh-text { display: none; }
}
