/* ═══════════════════════════════════════════════
   main.css — Global layout, typography, components
   ═══════════════════════════════════════════════ */

/* ── Fonts ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout wrapper ────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 3rem);
}

main {
  flex: 1;
  padding-top: var(--header-height);
}

/* ── Typography ─────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-ink-blue);
  font-weight: 700;
  line-height: 1.25;
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.35rem, 3vw, 2rem); margin: 2.5rem 0 1rem; }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); margin: 2rem 0 0.75rem; }
h4 { font-size: 1.125rem; margin: 1.5rem 0 0.5rem; }

p { margin-bottom: 1.25rem; }

a {
  color: var(--color-sky-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-sky-blue-dark); text-decoration: underline; }
a:focus-visible {
  outline: 3px solid var(--color-coral);
  outline-offset: 2px;
  border-radius: 3px;
}

strong { color: var(--color-ink-blue); }

ul, ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}
li { margin-bottom: 0.35rem; }

hr {
  border: none;
  border-top: 2px solid var(--color-border);
  margin: 2.5rem 0;
}

/* ── Inline code ─────────────────────────────────── */
:not(pre) > code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: none;
  color: inherit;
  border: none;
  padding: 0;
  border-radius: 0;
  /* Slightly heavier weight so it reads as "code" without a visible box */
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* ── Tables ──────────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead tr {
  background: var(--color-ink-blue);
  color: var(--color-white);
}

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

tbody tr:nth-child(even) { background: var(--color-yellow-light); }
tbody tr:nth-child(odd)  { background: var(--color-white); }
tbody tr:hover           { background: var(--color-bg-alt); }

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

/* ── Interactive Checkboxes ──────────────────────── */
li.task-item {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

li.task-item input[type="checkbox"] {
  margin-top: 0.25rem;
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-coral);
  flex-shrink: 0;
  cursor: pointer;
}

li.task-item label {
  cursor: pointer;
  transition: color var(--transition-fast);
}

li.task-item input[type="checkbox"]:checked + label {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

ul:has(li.task-item) { padding-left: 0; }

/* ── FAQ Accordions ──────────────────────────────── */
details.faq-item {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-coral);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  overflow: hidden;
  background: var(--color-white);
}

details.faq-item summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-ink-blue);
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  user-select: none;
  transition: background var(--transition-fast);
}

details.faq-item summary::-webkit-details-marker { display: none; }

details.faq-item summary::after {
  content: '▸';
  font-size: 0.85rem;
  color: var(--color-coral);
  transition: transform var(--transition-normal);
  flex-shrink: 0;
  margin-left: 1rem;
}

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

details.faq-item summary:hover { background: var(--color-coral-light); }

.faq-body {
  padding: 0 1.25rem 1.25rem;
}

/* ── Breadcrumbs ─────────────────────────────────── */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
  list-style: none;
  counter-reset: none;
}

.breadcrumbs li {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  counter-increment: none;
  margin-bottom: 0;
  padding: 0;
}

.breadcrumbs li::before,
.breadcrumbs li::marker {
  content: none;
  display: none;
}

.breadcrumbs a {
  color: var(--color-sky-blue);
  transition: color var(--transition-fast);
}

.breadcrumbs a:hover { color: var(--color-coral); text-decoration: underline; }

.breadcrumb-sep {
  color: var(--color-border);
  font-size: 0.7rem;
  margin: 0 0.1rem;
}

.breadcrumbs span[aria-current] {
  color: var(--color-ink-blue);
  font-weight: 500;
}

/* ── Anchor link hover icon ──────────────────────── */
/* ariaHidden mode: .header-anchor is a separate '#' symbol after heading text */
.header-anchor {
  display: inline-block;
  margin-left: 0.45rem;
  font-size: 0.75em;
  font-weight: 400;
  color: var(--color-sky-blue);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  vertical-align: middle;
}

h2:hover > .header-anchor,
h3:hover > .header-anchor,
h4:hover > .header-anchor,
h2:focus-within > .header-anchor,
h3:focus-within > .header-anchor { opacity: 0.6; }

.header-anchor:hover { opacity: 1 !important; }

/* ── Article content area ────────────────────────── */
.content-article {
  max-width: 100%;
}

.content-article > h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  color: var(--color-ink-blue);
  margin-bottom: 0.5rem;
}

/* The anchor '#' inside h1 should not inherit gradient */
.content-article > h1 > .header-anchor {
  font-size: 0.55em;
  color: var(--color-sky-blue);
  vertical-align: middle;
}

/* ── Content-page lists ───────────────────────────── */

/* Reset the global padding/list-style inside content so we can fully control it */
.content-article ul:not(:has(> li.task-item)),
.content-article ol:not(.breadcrumbs) {
  list-style: none;
  padding-left: 0;
  margin: 0.25rem 0 1.5rem;
}

/* ── Unordered list — coral dot bullets ──────────── */
.content-article ul:not(:has(> li.task-item)) > li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.55rem;
  line-height: 1.7;
}

.content-article ul:not(:has(> li.task-item)) > li::before {
  content: '';
  position: absolute;
  left: 0.1rem;
  top: 0.6em;
  width: 6px;
  height: 6px;
  background: var(--color-coral);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Nested ul: smaller, sky-blue hollow circles */
.content-article ul:not(:has(> li.task-item)) ul > li::before {
  background: transparent;
  border: 1.5px solid var(--color-sky-blue);
  top: 0.62em;
  width: 5px;
  height: 5px;
}

/* ── Ordered list — numbered ink-blue badges ─────── */
.content-article ol:not(.breadcrumbs) {
  counter-reset: content-ol;
}

.content-article ol:not(.breadcrumbs) > li {
  counter-increment: content-ol;
  position: relative;
  padding-left: 2.25rem;
  margin-bottom: 0.65rem;
  line-height: 1.7;
}

.content-article ol:not(.breadcrumbs) > li::before {
  content: counter(content-ol);
  position: absolute;
  left: 0;
  top: 0.1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  background: var(--color-ink-blue);
  color: var(--color-white);
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'Inter', system-ui, sans-serif;
  border-radius: 50%;
  line-height: 1;
}

/* Follow-on paragraphs or code blocks inside list items */
.content-article li > p { margin-bottom: 0.5rem; }
.content-article li > pre { margin: 0.75rem 0; }

.reading-time {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ── Page nav (prev/next) ─────────────────────────── */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--color-border);
}

.page-nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-ink-blue);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all var(--transition-fast);
  max-width: 50%;
}

.page-nav a:hover {
  border-color: var(--color-sky-blue);
  background: var(--color-bg-alt);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.page-nav .prev::before { content: '←'; }
.page-nav .next::after  { content: '→'; }

/* ── Mermaid wrapper ─────────────────────────────── */
.mermaid {
  background: var(--color-code-bg);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  border: 1px solid var(--color-border);
}

/* ── Tag / badge ─────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2em 0.6em;
  border-radius: 99px;
  background: var(--color-yellow-light);
  color: var(--color-ink-blue);
  border: 1px solid var(--color-yellow-sunny);
}

/* ── Skip link ───────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--color-coral);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600;
  z-index: 9999;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: 0; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  main { padding-top: calc(var(--header-height) + 0.5rem); }
  h2 { margin: 1.75rem 0 0.75rem; }
  .page-nav { flex-direction: column; }
  .page-nav a { max-width: 100%; }
}

