/* ════════════════════════════════════════════════════════════════════════
   COMPONENTS — Ocean Sunset
   ════════════════════════════════════════════════════════════════════════ */

/* ── HEADER ─────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--color-chrome);
  box-shadow: 0 2px 12px rgba(13, 27, 42, 0.5);
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--content-pad);
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  flex-shrink: 0;
}

.site-logo svg { width: 2rem; height: 2rem; }

.site-logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-gold);
  letter-spacing: -0.02em;
  transition: color var(--transition);
}

.site-logo:hover .site-logo-text { color: var(--color-dawn); }

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

/* Keep nav links readable regardless of visited state */
.nav-link:visited {
  color: rgba(255, 255, 255, 0.88);
}

.nav-link:hover,
.nav-link[aria-current="page"] {
  background: rgba(240, 165, 0, 0.15);
  color: var(--color-gold);
  text-decoration: none;
}

.nav-link[aria-current="page"] {
  border-bottom: 2px solid var(--color-gold);
}

.nav-icon { font-size: 1em; }

/* Hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
  color: var(--color-gold);
  font-size: 1.5rem;
  margin-left: auto;
}

@media (max-width: 768px) {
  .nav-toggle { display: flex; align-items: center; }

  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--color-chrome);
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-md);
    border-top: 1px solid var(--color-chrome-edge);
    gap: var(--space-xs);
    box-shadow: var(--shadow-lg);
  }

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

  .nav-link { padding: 0.65rem var(--space-md); font-size: 1rem; }
}

/* ── FOOTER ─────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--color-chrome);
  color: rgba(255, 255, 255, 0.7);
  padding: var(--space-2xl) var(--content-pad);
  margin-top: auto;
}

.footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-xl);
}

.footer-section h3 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-gold);
  margin-bottom: var(--space-md);
  margin-top: 0;
  border-bottom: none;
}

.footer-section ul { list-style: none; padding: 0; margin: 0; }

.footer-section li { margin-bottom: var(--space-sm); }

.footer-section a {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  text-decoration: none;
  transition: color var(--transition);
}

.footer-section a:hover { color: var(--color-gold); text-decoration: none; }

.footer-bottom {
  max-width: var(--content-max);
  margin: var(--space-xl) auto 0;
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55); /* raised from 0.4 to meet 4.5:1 contrast on midnight bg */
}

/* ── BREADCRUMBS ────────────────────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25em;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xl);
  padding: var(--space-sm) 0;
}

.breadcrumbs a {
  color: var(--color-wave);
  text-decoration: none;
  transition: color var(--transition);
}

.breadcrumbs a:hover { color: var(--color-sunset); }

.breadcrumb-sep {
  color: var(--color-border);
  user-select: none;
  margin: 0 0.15em;
}

.breadcrumb-current { color: var(--color-text-muted); font-weight: 500; }

/* ── CODE BLOCKS ────────────────────────────────────────────────────────── */
.code-block-wrapper {
  position: relative;
  margin: var(--space-lg) 0;
  width: 100%;
  display: block;
}

pre[class*="language-"],
pre:not([class]) {
  background: var(--color-sand) !important;
  border: 1px solid var(--color-dawn);
  border-radius: var(--radius-md);
  padding: var(--space-lg) !important;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--color-text) !important;
  width: 100%;
  display: block;
  box-sizing: border-box;
}

code[class*="language-"] {
  font-family: var(--font-mono) !important;
  background: none !important;
  border: none !important;
  padding: 0 !important;
}

/* Prism token overrides for Ocean Sunset light theme */
/* All colours verified >= 4.5:1 against the sand code-block background (#fdf3e3) */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--syntax-comment); font-style: italic; }
.token.keyword, .token.tag, .token.boolean { color: var(--color-ocean); font-weight: 600; }
.token.selector, .token.attr-name, .token.string, .token.char { color: var(--syntax-string); }
.token.number, .token.constant { color: var(--syntax-number); }
.token.property, .token.attr-value, .token.rule { color: var(--color-wave); }
.token.function { color: var(--syntax-func); }
.token.operator, .token.punctuation { color: var(--color-text-muted); }
.token.url { color: var(--color-wave); text-decoration: underline; }

.copy-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--color-fill-strong);
  color: var(--color-on-strong);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}

.code-block-wrapper:hover .copy-btn { opacity: 1; }

.copy-btn:hover { background: var(--color-sunset); }
.copy-btn.copied { background: #2a7d4f; }

/* ── CHECKBOXES ─────────────────────────────────────────────────────────── */

/* Remove indent & bullet from the parent <ul> of checkbox lists */
ul:has(> li > input[type="checkbox"]) {
  padding-left: 0.25rem;
  list-style: none;
}

/* Remove bullet, set flex layout for each checkbox row */
li:has(> input[type="checkbox"]) {
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  padding-left: 0;
}

li:has(> input[type="checkbox"]) input[type="checkbox"] {
  accent-color: var(--color-wave);
  cursor: pointer;
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  margin-top: 0.2em;
}

/* Strikethrough ALL child content (label, code, etc.) except the checkbox itself */
li.is-checked > *:not(input[type="checkbox"]) {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* Legacy class support (GitHub-flavored markdown / other plugins) */
.task-list-item {
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.task-list-item.is-checked > label,
.task-list-item.is-checked > span {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* ── MERMAID ────────────────────────────────────────────────────────────── */
.mermaid {
  background: var(--color-sand);
  border: 1px solid var(--color-dawn);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  overflow-x: auto;
  text-align: center;
}

/* ── TABLES ─────────────────────────────────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  margin: var(--space-lg) 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--color-surface);
}

thead tr { background: var(--color-fill-strong); color: var(--color-on-strong); }

thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:nth-child(odd) { background: var(--color-sand); }
tbody tr:nth-child(even) { background: var(--color-surface); }

tbody tr:hover { background: var(--color-row-hover); }

tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

/* ── FAQ ACCORDIONS ─────────────────────────────────────────────────────── */
.faq-item {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-gold);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  overflow: hidden;
  background: var(--color-surface);
}

.faq-item summary,
details.faq-item summary {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  font-weight: 600;
  /* Body colour, not the heading tint: the weight and the chevron already mark this as a
     control, and the tint sits close enough to the link colour in dark mode that inline
     <code> in a question reads as a link. */
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  gap: var(--space-md);
  transition: background var(--transition);
}

.faq-item summary:hover { background: var(--color-sand); }

.faq-item summary::after {
  content: "▸";
  font-size: 0.85em;
  color: var(--color-gold);
  transition: transform var(--transition);
  flex-shrink: 0;
}

details[open].faq-item summary::after,
.faq-item[open] summary::after {
  transform: rotate(90deg);
}

details[open].faq-item summary,
.faq-item[open] summary {
  border-bottom: 1px solid var(--color-border);
}

.faq-item .faq-body,
details.faq-item > *:not(summary) {
  padding: var(--space-md) var(--space-lg);
}

/* ── CARDS (section cards on homepage) ──────────────────────────────────── */
.section-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: var(--space-xl);
  margin: var(--space-2xl) 0;
}

.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-gold);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

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

.section-card-icon { font-size: 2.5rem; line-height: 1; }

.section-card h3 {
  font-size: 1.2rem;
  color: var(--color-ocean);
  margin: 0;
}

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

.section-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.section-card ul a {
  font-size: 0.875rem;
  color: var(--color-wave);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  transition: color var(--transition), gap var(--transition);
}

.section-card ul a::before { content: "→"; color: var(--color-gold); }

.section-card ul a:hover {
  color: var(--color-sunset);
  gap: var(--space-sm);
  text-decoration: none;
}

/* ── HERO ───────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--color-chrome) 0%, var(--color-chrome-edge) 60%, var(--color-hero-far) 100%);
  color: white;
  padding: clamp(3rem, 8vw, 6rem) var(--content-pad);
  /* The hero is a direct child of the full-width, unpadded .site-wrapper, so it
     is already edge-to-edge. Negative horizontal margins here would overshoot
     the viewport and force a horizontal scrollbar — keep only the bottom gap. */
  margin: 0 0 var(--space-2xl);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 50%, rgba(240, 165, 0, 0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(232, 98, 26, 0.10) 0%, transparent 50%);
}

.hero-inner {
  position: relative;
  max-width: var(--content-max);
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  background: linear-gradient(135deg, #ffffff 0%, var(--color-dawn-hero, #f5d87a) 60%, var(--color-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-md);
  max-width: 18ch;
}

.hero-tagline {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: var(--space-2xl);
  max-width: 55ch;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  cursor: pointer;
  border: none;
}

.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }

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

.btn-secondary { background: rgba(255,255,255,0.12); color: white; border: 1px solid rgba(255,255,255,0.3); }
.btn-secondary:hover { background: rgba(255,255,255,0.2); color: white; }

.btn-tertiary { background: var(--color-sunset); color: white; }
.btn-tertiary:hover { background: #d4551a; color: white; }

/* ── INTRO SECTION ──────────────────────────────────────────────────────── */
.intro-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: var(--space-xl);
  margin-bottom: var(--space-2xl);
}

.intro-section p {
  max-width: none;
  color: var(--color-text-muted);
  line-height: 1.8;
}

/* ── ARTICLE NAVIGATION (prev/next) ─────────────────────────────────────── */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: var(--space-3xl);
  padding-top: var(--space-xl);
  border-top: 2px solid var(--color-border);
  flex-wrap: wrap;
}

.page-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-wave);
  transition: background var(--transition), transform var(--transition);
  text-decoration: none;
}

.page-nav a:hover {
  background: var(--color-sand);
  transform: translateY(-2px);
  text-decoration: none;
}

/* ── CONTENT SECTION HEADER ─────────────────────────────────────────────── */
.section-header {
  margin-bottom: var(--space-2xl);
}

.section-header h1 { margin-bottom: var(--space-sm); }

.section-header .lead {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  line-height: 1.8;
}

/* ── TOPIC LIST ─────────────────────────────────────────────────────────── */
.topic-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
  list-style: none;
  padding: 0;
}

.topic-list li a {
  display: block;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-wave);
  font-weight: 500;
  text-decoration: none;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.topic-list li a:hover {
  border-color: var(--color-gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  color: var(--color-sunset);
  text-decoration: none;
}


/* ── THEME TOGGLE ───────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-left: auto;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  background: rgba(240, 165, 0, 0.18);
  border-color: var(--color-gold);
  color: var(--color-gold);
}

/* Keyboard focus must stay visible against the dark header in both themes. */
.theme-toggle:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

/* Sun in light mode (click = go dark), moon in dark mode (click = go light). */
.theme-toggle-icon::before { content: "\1F319"; }            /* 🌙 */
.theme-toggle[aria-pressed="true"] .theme-toggle-icon::before { content: "\2600\FE0F"; } /* ☀️ */

@media (max-width: 768px) {
  /* The hamburger owns the right edge on mobile; the toggle sits just before it. */
  .theme-toggle { margin-left: auto; }
  .theme-toggle-text { display: none; }
  .nav-toggle { margin-left: var(--space-sm); }
}

/* ── DARK THEME — targeted fixes ────────────────────────────────────────── */

/* The h2 rule underlines with --color-dawn, which is a border colour in dark mode. */
:root[data-theme="dark"] h2 { border-bottom-color: var(--color-dawn); }

/* Prose links carry an underline already; lift hover off pure orange for contrast. */
:root[data-theme="dark"] a:hover { color: var(--color-gold); }

/* Code blocks: the light theme's 1px dawn border becomes the dark border token. */
:root[data-theme="dark"] pre[class*="language-"],
:root[data-theme="dark"] pre:not([class]) { border-color: var(--color-border); }

/* Inline-SVG interiors. Diagrams paint with currentColor and follow --color-text,
   but a handful of authored status fills are baked light-mode hexes; remap them on
   EXACT hex value so nothing stays light-on-dark. Keep saturated data marks as-is. */
:root[data-theme="dark"] .page-content svg [fill="#fff"],
:root[data-theme="dark"] .page-content svg [fill="#ffffff"],
:root[data-theme="dark"] .page-content svg [fill="#fdf3e3"] { fill: #16202b; }

:root[data-theme="dark"] .page-content svg [fill="#fee2e2"] { fill: #3a1d1d; }
:root[data-theme="dark"] .page-content svg [fill="#dcfce7"] { fill: #14301f; }

/* Dark-on-dark label text — lighten the deep status hues used for <text>. */
:root[data-theme="dark"] .page-content svg [fill="#15803d"] { fill: #6ee7a0; }
:root[data-theme="dark"] .page-content svg [fill="#b91c1c"] { fill: #ff9b9b; }
:root[data-theme="dark"] .page-content svg [fill="#c0392b"] { fill: #ff9b9b; }
:root[data-theme="dark"] .page-content svg [fill="#27ae60"] { fill: #6ee7a0; }
:root[data-theme="dark"] .page-content svg [fill="#52a852"] { fill: #7fd694; }
:root[data-theme="dark"] .page-content svg [fill="#d4a017"] { fill: #f0c65a; }
:root[data-theme="dark"] .page-content svg [fill="#94a3b8"] { fill: #b6c4d4; }
:root[data-theme="dark"] .page-content svg [fill="#6a9fb5"] { fill: #92c4d8; }
:root[data-theme="dark"] .page-content svg [fill="#4a90d9"] { fill: #7cb8ee; }
:root[data-theme="dark"] .page-content svg [fill="#4f86f7"] { fill: #8caeff; }
:root[data-theme="dark"] .page-content svg [fill="#e05252"] { fill: #ff9b9b; }
:root[data-theme="dark"] .page-content svg [fill="#e07b54"] { fill: #ffa787; }
:root[data-theme="dark"] .page-content svg [fill="#e09a52"] { fill: #f5bd7e; }
:root[data-theme="dark"] .page-content svg [fill="#a78bfa"] { fill: #c4b0ff; }

:root[data-theme="dark"] .page-content svg [stroke="#c0392b"],
:root[data-theme="dark"] .page-content svg [stroke="#e05252"],
:root[data-theme="dark"] .page-content svg [stroke="#e55"] { stroke: #ff9b9b; }
:root[data-theme="dark"] .page-content svg [stroke="#27ae60"],
:root[data-theme="dark"] .page-content svg [stroke="#52a852"],
:root[data-theme="dark"] .page-content svg [stroke="#4a4"] { stroke: #6ee7a0; }
