:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --danger: #ef4444;
  --success: #10b981;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 56px;
}

.nav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  letter-spacing: -.3px;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: .25rem;
  list-style: none;
}

.nav-links a {
  padding: .4rem .85rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  transition: background .15s, color .15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: #eff6ff;
  color: var(--primary);
  text-decoration: none;
}

/* ── Layout ── */
.page-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #7c3aed 100%);
  color: #fff;
  padding: 4rem 1.5rem 3.5rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: .75rem;
}

.hero p {
  font-size: 1.1rem;
  opacity: .85;
  max-width: 600px;
  margin: 0 auto 1.5rem;
}

.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  padding: .3rem .9rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

/* ── Cards ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: .75rem;
}

.card h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.card p { font-size: .88rem; color: var(--muted); margin-bottom: 1rem; }
.card a.btn { font-size: .85rem; }

/* ── Sections ── */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.section h2 {
  font-size: 1.25rem;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.section p { color: var(--muted); font-size: .92rem; }

h2 { font-size: 1.5rem; margin-bottom: 1rem; }
h3 { font-size: 1.1rem; margin-bottom: .5rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.badge-hidden   { background: #fee2e2; color: #b91c1c; }
.badge-visible  { background: #dcfce7; color: #15803d; }
.badge-dynamic  { background: #dbeafe; color: #1d4ed8; }
.badge-partial  { background: #fef9c3; color: #92400e; }

/* ── Experiment blocks ── */
.experiment {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.experiment-header {
  background: #f1f5f9;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.experiment-header h3 {
  margin: 0;
  font-size: .95rem;
}

.experiment-body {
  padding: 1.25rem;
}

.experiment-body p { margin-bottom: .5rem; font-size: .9rem; }

/* ── Code block ── */
.code-block {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 6px;
  padding: .85rem 1rem;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: .8rem;
  overflow-x: auto;
  margin: .75rem 0;
}

.code-block .hl-tag   { color: #93c5fd; }
.code-block .hl-attr  { color: #fca5a5; }
.code-block .hl-val   { color: #86efac; }
.code-block .hl-comm  { color: #64748b; font-style: italic; }
.code-block .hl-js    { color: #fde68a; }
.code-block .hl-css   { color: #c4b5fd; }

/* ── CSS Experiment: the hidden elements themselves ── */
.hidden-display-none    { display: none; }
.hidden-visibility      { visibility: hidden; }
.hidden-opacity         { opacity: 0; pointer-events: none; }
.hidden-offscreen       { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.hidden-clip            { clip-path: inset(100%); width: 1px; height: 1px; overflow: hidden; position: absolute; }
.hidden-white-on-white  { color: #f8fafc; background: #f8fafc; user-select: none; }
.hidden-zero-height     { height: 0; overflow: hidden; transition: height .3s; }

.reveal-wrapper { position: relative; }

/* ── JS loading states ── */
.loading-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: .5rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.js-placeholder {
  background: #f1f5f9;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  color: var(--muted);
  font-size: .88rem;
  min-height: 60px;
  display: flex;
  align-items: center;
}

.js-loaded {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  font-size: .9rem;
}

.js-loaded h4 { color: #166534; margin-bottom: .35rem; font-size: .95rem; }
.js-loaded p  { color: #166534; margin: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: 7px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
}

.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

.btn-ghost {
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #e2e8f0; text-decoration: none; }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; }

/* ── Info box ── */
.info-box {
  background: #eff6ff;
  border-left: 4px solid var(--primary);
  padding: .9rem 1.1rem;
  border-radius: 0 6px 6px 0;
  font-size: .88rem;
  color: #1e40af;
  margin: 1rem 0;
}

.warn-box {
  background: #fffbeb;
  border-left: 4px solid var(--accent);
  padding: .9rem 1.1rem;
  border-radius: 0 6px 6px 0;
  font-size: .88rem;
  color: #78350f;
  margin: 1rem 0;
}

/* ── Table ── */
.table-wrap { overflow-x: auto; margin: 1rem 0; }

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

th {
  background: #f1f5f9;
  text-align: left;
  padding: .6rem .9rem;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

td {
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Footer ── */
footer {
  background: #1e293b;
  color: #94a3b8;
  text-align: center;
  padding: 1.75rem 1.5rem;
  font-size: .82rem;
}

footer a { color: #60a5fa; }

/* ── Page title ── */
.page-title {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-title h1 { font-size: 1.7rem; }
.page-title p  { color: var(--muted); margin-top: .3rem; }

/* ── Highlight overlay for toggle ── */
.revealed-highlight {
  outline: 2px dashed var(--success);
  background: #f0fdf4 !important;
  border-radius: 4px;
  color: var(--text) !important;
}
