/*
 * shared/styles.css
 * Site-wide design system for the Cryptoeconomics-Blockchain GitHub Pages site.
 * Direction A ("Scholarly"). Reference:
 * docs/superpowers/specs/2026-05-22-website-layout-unification-design.md
 *
 * Section 1: Tokens and base styles
 */

:root {
  /* Surfaces and text (light) */
  --color-bg: #f6f6fb;
  --color-surface: #ffffff;
  --color-surface-2: #edecf4;
  --color-border: #e3e3ee;
  --color-text: #1a1a2e;
  --color-text-muted: #5a5a72;

  /* Brand */
  --color-primary: #3333b2;
  --color-primary-hover: #2a2a93;
  --color-on-primary: #ffffff;
  --color-nav-bg: #2d2d8f;
  --color-link: #3333b2;
  --hero-gradient: linear-gradient(135deg, #3333b2, #0066cc);

  /* Quiz feedback */
  --color-correct: #2ca02c;
  --color-wrong: #d62728;

  /* Module accents A through H */
  --mod-a: #3333b2;
  --mod-b: #0066cc;
  --mod-c: #ff7f0e;
  --mod-d: #2ca02c;
  --mod-e: #d62728;
  --mod-f: #008080;
  --mod-g: #7a3fb8;
  --mod-h: #c7991e;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", Consolas, monospace;
  --fs-h1: 2rem;
  --fs-h2: 1.5rem;
  --fs-h3: 1.25rem;
  --fs-h4: 1.05rem;
  --fs-body: 1rem;
  --fs-small: 0.875rem;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radius and shadow */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow: 0 3px 12px rgba(0, 0, 0, .10);

  /* Layout widths */
  --width: 1120px;
  --width-wide: 1400px;
}

[data-theme="dark"] {
  --color-bg: #13131f;
  --color-surface: #1e1e2e;
  --color-surface-2: #26263a;
  --color-border: #34344a;
  --color-text: #e8e8f0;
  --color-text-muted: #a0a0b8;

  --color-primary: #6d6de6;
  --color-primary-hover: #8585ec;
  --color-on-primary: #ffffff;
  --color-nav-bg: #1a1a30;
  --color-link: #9a9ae8;
  --hero-gradient: linear-gradient(135deg, #26264f, #173a63);

  --color-correct: #4cc24c;
  --color-wrong: #ef5f5f;

  --mod-a: #6d6de6;
  --mod-b: #3b9bff;
  --mod-c: #ff9e42;
  --mod-d: #4cc24c;
  --mod-e: #ef5f5f;
  --mod-f: #2eb8b8;
  --mod-g: #a875e0;
  --mod-h: #e0b94a;
}

/* Base and reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  transition: background-color .2s ease, color .2s ease;
}

h1,
h2,
h3,
h4 {
  color: var(--color-text);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 var(--space-3);
}

h1 {
  font-size: var(--fs-h1);
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--fs-h2);
  letter-spacing: -0.005em;
}

h3 {
  font-size: var(--fs-h3);
}

h4 {
  font-size: var(--fs-h4);
}

p {
  margin: 0 0 var(--space-4);
}

a {
  color: var(--color-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

code,
pre {
  font-family: var(--font-mono);
}

small {
  font-size: var(--fs-small);
}

/* Layout containers */
.container {
  max-width: var(--width);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-wide {
  max-width: var(--width-wide);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/*
 * Section 2: Navbar and footer
 */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--color-nav-bg);
  color: #fff;
}

.site-nav__brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav__brand:hover {
  text-decoration: none;
}

.site-nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-right: auto;
}

.site-nav__link {
  color: #fff;
  opacity: .82;
  text-decoration: none;
  font-size: .95rem;
}

.site-nav__link:hover {
  opacity: 1;
  text-decoration: none;
}

.site-nav__search,
.site-nav__lang,
.site-nav__theme {
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-3);
  color: #fff;
  font: inherit;
  font-size: .9rem;
}

.site-nav__lang,
.site-nav__theme {
  cursor: pointer;
}

.site-nav__lang:hover,
.site-nav__theme:hover {
  background: rgba(255, 255, 255, .25);
}

.site-nav__search::placeholder {
  color: rgba(255, 255, 255, .65);
}

@media (max-width: 720px) {
  .site-nav {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .site-nav__links {
    order: 3;
    width: 100%;
    margin-right: 0;
    gap: var(--space-3);
  }
}

.site-footer {
  margin-top: var(--space-8);
  border-top: 1px solid var(--color-border);
  padding: var(--space-5) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
  text-align: center;
}

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

/*
 * Section 3: Content components
 */

/* Hero */
.hero {
  background: var(--hero-gradient);
  color: #fff;
  padding: var(--space-8) var(--space-5);
}

.hero h1 {
  color: #fff;
  margin-bottom: var(--space-2);
}

.hero p {
  margin-bottom: var(--space-4);
  color: rgba(255, 255, 255, .9);
  font-size: 1.1rem;
}

/* Cards */
.card {
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .15s ease;
}

.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.card__stripe {
  height: 5px;
  background: var(--accent, var(--color-primary));
}

.card__body {
  padding: var(--space-4);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: var(--space-2) var(--space-5);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
}

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

.btn--secondary:hover {
  background: var(--color-surface-2);
}

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

.btn--light:hover {
  background: rgba(255, 255, 255, .88);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
  font-weight: 600;
}

.badge--accent {
  background: var(--color-surface-2);
  background: color-mix(in srgb, var(--accent, var(--color-primary)) 15%, var(--color-surface));
  color: var(--accent, var(--color-primary));
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}

.data-table th,
.data-table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background: var(--color-surface-2);
  font-weight: 700;
}

/* Code */
.code-block,
pre {
  overflow-x: auto;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: .9rem;
}

code {
  padding: 1px 5px;
  background: var(--color-surface-2);
  border-radius: 4px;
  font-size: .9em;
}

.code-block code,
pre code {
  padding: 0;
  background: none;
}

/* Module accent helpers */
.mod-a { --accent: var(--mod-a); }
.mod-b { --accent: var(--mod-b); }
.mod-c { --accent: var(--mod-c); }
.mod-d { --accent: var(--mod-d); }
.mod-e { --accent: var(--mod-e); }
.mod-f { --accent: var(--mod-f); }
.mod-g { --accent: var(--mod-g); }
.mod-h { --accent: var(--mod-h); }

/*
 * Section 4: Sidebar layouts
 */

/* Docs portal layout: fixed sidebar plus constrained content */
.docs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--space-6);
  max-width: var(--width-wide);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}

.docs-sidebar {
  position: sticky;
  top: 70px;
  align-self: start;
}

.docs-sidebar a {
  display: block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: .95rem;
}

.docs-sidebar a:hover {
  background: var(--color-surface-2);
  text-decoration: none;
}

.docs-sidebar a[aria-current="page"],
.docs-sidebar a.active {
  color: var(--color-primary);
  font-weight: 700;
}

/* Docs sidebar: grouped sections with headings and module dots */
.docs-sidebar__section {
  margin-bottom: var(--space-4);
}

.docs-sidebar__title {
  margin: 0 0 var(--space-1);
  padding: 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.docs-sidebar__nav {
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-sidebar__nav li {
  margin: 0;
}

.docs-sidebar__nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.docs-sidebar__dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, var(--color-primary));
}

.docs-main {
  min-width: 0;
  max-width: var(--width);
}

/* Docs content helpers: stat grid, callout, card grid (docs index page) */
.docs-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.docs-stat {
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-align: center;
}

.docs-stat__value {
  font-size: var(--fs-h1);
  font-weight: 700;
  color: var(--color-primary);
}

.docs-stat__label {
  color: var(--color-text-muted);
  font-size: var(--fs-small);
}

.docs-callout {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.docs-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

@media (max-width: 600px) {
  .docs-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.docs-breadcrumb {
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
}

.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

/* Table-of-contents layout (tag curriculum pages) */
.toc-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--space-6);
  max-width: var(--width-wide);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}

.toc-sidebar {
  position: sticky;
  top: 70px;
  align-self: start;
  font-size: .95rem;
}

.toc-sidebar a {
  display: block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}

.toc-sidebar a:hover {
  background: var(--color-surface-2);
  text-decoration: none;
}

.toc-content {
  min-width: 0;
}

/* Both sidebar layouts collapse to one column on narrow screens */
@media (max-width: 860px) {
  .docs-layout,
  .toc-layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .docs-sidebar,
  .toc-sidebar {
    position: static;
  }
}
