/* ==========================================================================
   Educypedia modern.css — docs-site edition
   Global rules are minimal (topbar + body background only).
   All content styles are scoped under .ed-container.
   Uses !important where legacy inline styles / font tags fight us.
   ========================================================================== */

/* --- Global baseline ---------------------------------------------------- */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 64px;
}

body {
  margin: 0;
  background: #d8dde5;
}

/* --- Sticky top header --------------------------------------------------- */
.ed-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  height: 56px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .18);
}

.ed-topbar-inner {
  display: flex;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  gap: 0.75rem;
}

.ed-brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: #f8fafc;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.ed-brand:hover,
.ed-brand:focus {
  text-decoration: none;
  color: #7dd3fc;
}

.ed-tagline {
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 400;
}

@media (max-width: 600px) {
  .ed-tagline { display: none; }
}

/* --- Box model reset for the container tree ----------------------------- */
.ed-container *,
.ed-container *::before,
.ed-container *::after {
  box-sizing: border-box;
}

/* --- Neutralize dark legacy inline background colors --------------------- */
/* Pages have inline style="background-color: #363696" (dark blue) and
   #000000 (black) on spans and cells used as sidebar/section headers.
   Those made sense with the original white text, but clash with the new
   dark content color and become unreadable. Force them to transparent. */
.ed-container [style*="#363696"],
.ed-container [style*="#000000"],
.ed-container [style*="#000"][style*="background"] {
  background: transparent !important;
  background-color: transparent !important;
  color: inherit !important;
}

/* --- Force academic serif on ALL descendants (defeats <font face="…">) --- */
/* Emoji fallback fonts appended so glyphs like 🍺 render — serif fonts have
   no emoji glyphs and would otherwise show tofu (.notdef) boxes. */
.ed-container,
.ed-container * {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, "Times New Roman", serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", emoji !important;
}
/* Headings get a slightly tighter transitional serif */
.ed-container h1,
.ed-container h2,
.ed-container h3,
.ed-container h4,
.ed-container h5,
.ed-container h6 {
  font-family: "Iowan Old Style", Charter, Georgia, "Times New Roman", serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", emoji !important;
  font-feature-settings: "kern", "liga", "dlig";
}
/* Topbar stays sans-serif — it's chrome, not content */
.ed-topbar,
.ed-topbar * {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Content column — "docs site" card look ----------------------------- */
.ed-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  background: #ffffff;
  color: #1a2332;
  font-size: 17px;
  line-height: 1.7;
}

@media (min-width: 900px) {
  .ed-container {
    box-shadow: 0 0 0 1px #e8ecf1;
    border-radius: 8px;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
  }
}

/* --- Typography — docs-site headings ------------------------------------ */
.ed-container h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #0f172a !important;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e8ecf1;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.ed-container h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a !important;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #e8ecf1;
  line-height: 1.3;
}

.ed-container h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #0f172a !important;
  margin: 2rem 0 0.5rem;
  line-height: 1.35;
}

.ed-container h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a !important;
  margin: 1.5rem 0 0.5rem;
}

.ed-container h5,
.ed-container h6 {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a !important;
  margin: 1.25rem 0 0.4rem;
}

.ed-container p { margin: 0 0 1em; }

/* --- Links (accent color) ----------------------------------------------- */
.ed-container a {
  color: #0b5fa5 !important;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s;
}

.ed-container a:hover,
.ed-container a:focus-visible {
  color: #083f70 !important;
  border-bottom-color: #0b5fa5;
}

.ed-container a:visited {
  color: #6a3fa0 !important;
}

.ed-container a:focus-visible {
  outline: 2px solid #0b5fa5;
  outline-offset: 2px;
}

/* --- Archived links (auto-rewritten to Internet Archive snapshots) ----- */
/* Applied by tools/apply_link_updates.py — class="ed-archived" on any
   <a> whose original href is a dead URL with a verified Wayback snapshot.
   We keep the link readable but visibly distinct from live external links
   so readers know they're about to visit an archive copy. */
.ed-container a.ed-archived {
  color: #5d6b7a !important;              /* muted slate, less saturated than live links */
  border-bottom: 1px dashed #b3bcc7;      /* dashed instead of solid underline on hover */
}
.ed-container a.ed-archived:hover,
.ed-container a.ed-archived:focus-visible {
  color: #334155 !important;
  border-bottom: 1px dashed #64748b;
}
.ed-container a.ed-archived:visited {
  color: #6b5d7a !important;
}
.ed-container a.ed-archived::after {
  content: " \1F5C4\FE0E";                /* 🗄 file cabinet, text presentation */
  font-size: 0.8em;
  opacity: 0.75;
  margin-left: 0.2em;
  vertical-align: baseline;
}
/* On hover, show a small "(archive)" hint alongside the icon */
.ed-container a.ed-archived:hover::after {
  content: " \1F5C4\FE0E  archive";
  opacity: 1;
  font-style: italic;
}

/* --- Tables (wide legacy tables get horizontal scroll) ------------------ */
.ed-container table {
  max-width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  margin: 1.25em 0;
  font-size: 0.95em;
}

.ed-container td,
.ed-container th {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e8ecf1;
  vertical-align: top;
  text-align: left;
}

.ed-container th {
  background: #f7f8fa;
  font-weight: 600;
  color: #0f172a;
}

/* Kill legacy table width attrs */
.ed-container table[width],
.ed-container td[width],
.ed-container th[width] {
  width: auto !important;
}

/* Nested tables (layout tables) — no borders, tighter padding */
.ed-container table table {
  border: 0 !important;
  background: transparent !important;
  display: table;
  overflow-x: visible;
}

.ed-container table table td,
.ed-container table table th {
  border: 0 !important;
  background: transparent !important;
  padding: 0.2rem 0.4rem;
}

/* --- Neutralize legacy educypedia.css named classes --------------------- */
.ed-container .bovenbalk,
.ed-container td.bovenbalk,
.ed-container .rechtsstart1,
.ed-container td.rechtsstart1,
.ed-container .rechtsstart2,
.ed-container td.rechtsstart2 {
  background: transparent !important;
  color: inherit !important;
  font-size: inherit !important;
}

/* --- Code / pre --------------------------------------------------------- */
.ed-container code,
.ed-container pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important;
  font-size: 0.9em;
  background: #f4f6f8;
}

.ed-container pre {
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid #e8ecf1;
  line-height: 1.5;
}

.ed-container code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.ed-container pre code {
  background: transparent;
  padding: 0;
  border: 0;
}

/* --- Images ------------------------------------------------------------- */
.ed-container img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* --- Neutralize surviving legacy tags ----------------------------------- */
.ed-container font {
  color: inherit !important;
  font-size: inherit !important;
  font-family: inherit !important;
  font-weight: inherit !important;
}

.ed-container center {
  display: block;
  text-align: left;
}

/* --- Horizontal rule ---------------------------------------------------- */
.ed-container hr {
  border: 0;
  border-top: 1px solid #e8ecf1;
  margin: 2.5rem 0;
}

/* --- Lists -------------------------------------------------------------- */
.ed-container ul,
.ed-container ol {
  margin: 0 0 1em 0;
  padding-left: 1.5em;
}

.ed-container li { margin: 0.2em 0; }

/* --- Mobile ------------------------------------------------------------- */
@media (max-width: 600px) {
  .ed-container {
    padding: 1.25rem 1rem 3rem;
    font-size: 16px;
    box-shadow: none;
    border-radius: 0;
    margin-top: 0;
  }

  .ed-container h1 { font-size: 1.55rem; }
  .ed-container h2 { font-size: 1.25rem; }

  .ed-topbar-inner { padding: 0 1rem; }
}

/* --- Dynamic slots (ads, donation, page-meta) --------------------------- */
/* IMPORTANT: do NOT use `.ed-container .ed-X-slot` descendant selectors.
   Many legacy pages have malformed HTML (unbalanced <div>) that causes the
   browser to auto-close .ed-container early, ejecting the slot from the
   container in the parsed DOM. The slots must be styleable wherever they
   land. We use class-only selectors and rely on the system font stack as a
   fallback (since the slots may also fall outside the serif scope). */

/* Ad slot — above the container, full width up to the container width */
.ed-ad-slot {
  max-width: 860px;
  margin: 1rem auto 0.5rem;
  padding: 0 1.5rem;
  min-height: 0;
  text-align: center;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.ed-ad-slot:empty { display: none; }
.ed-ad-slot ins.adsbygoogle { display: block; min-height: 90px; }

/* Donation slot — its own card, stacks under the main content card */
.ed-donation-slot {
  max-width: 860px;
  margin: 1rem auto 2rem;
  padding: 1.5rem 1.5rem;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px #e8ecf1;
  text-align: center;
  color: #475569;
  font-size: 0.95em;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.ed-donation-slot:empty { display: none; }
@media (max-width: 600px) {
  .ed-donation-slot {
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    padding: 1.25rem 1rem;
    border-top: 1px solid #e8ecf1;
  }
}

.ed-donation-slot .ed-donate-msg {
  margin: 0 0 0.75rem !important;
  color: #475569 !important;
  font-size: 0.95em !important;
  font-style: italic;
  font-family: inherit !important;
}

.ed-donation-slot .ed-donate-btn {
  display: inline-block;
  padding: 0.55rem 1.4rem !important;
  background: #f0c14b !important;            /* warm amber, beer-ish */
  color: #1a2332 !important;
  border: 1px solid #d4a017 !important;
  border-radius: 6px;
  font-weight: 600 !important;
  font-size: 0.95em !important;
  text-decoration: none !important;
  font-style: normal;
  font-family: inherit !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: background 0.15s, transform 0.1s;
}
.ed-donation-slot .ed-donate-btn:hover,
.ed-donation-slot .ed-donate-btn:focus-visible {
  background: #f7cf68 !important;
  color: #0f172a !important;
  border-color: #b8860b !important;
  transform: translateY(-1px);
}
.ed-donation-slot .ed-donate-btn:visited {
  color: #1a2332 !important;
}

/* Page meta footer — its own slim card */
.ed-page-meta {
  max-width: 860px;
  margin: 1.5rem auto 0.5rem;
  padding: 0.6rem 1.5rem;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px #e8ecf1;
  font-size: 0.85em;
  color: #64748b;
  text-align: right;
  font-style: italic;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.ed-page-meta .ed-last-updated:empty { display: none; }
@media (max-width: 600px) {
  .ed-page-meta {
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    border-top: 1px solid #e8ecf1;
  }
}
