/* ============================================================================
   PP-Pedia — a Wikipedia (Vector 2022)-inspired stylesheet
   Hand-built for the "History of Microsoft Power Platform" reference site.
   Light + dark themes, responsive, print-friendly. No external assets.
   ========================================================================== */

:root {
  /* Palette (light) */
  --page-bg: #f8f9fa;
  --content-bg: #ffffff;
  --text: #202122;
  --text-muted: #54595d;
  --text-faint: #72777d;

  --link: #3366cc;
  --link-hover: #2a4b8d;
  --link-visited: #6a60b0;
  --link-red: #d33;

  --border: #a2a9b1;
  --border-soft: #c8ccd1;
  --border-faint: #eaecf0;

  --box-bg: #f8f9fa;
  --header-bg: #eaecf0;
  --accent: #4b2e83;          /* Power Platform-ish plum for wordmark */
  --accent-2: #742774;

  --note-bg: #f8f9fa;
  --note-border: #c8ccd1;

  --serif: "Georgia", "Linux Libertine", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --content-max: 60rem;
  --sidebar-w: 11.5rem;
}

/* Dark theme. Applied via [data-theme="dark"] (set by the inline head script from
   localStorage or the OS preference, and flipped by the header toggle), with a
   no-JS system fallback below. */
:root[data-theme="dark"] {
  --page-bg: #101418;
  --content-bg: #1b1f24;
  --text: #e6e6e6;
  --text-muted: #a7adb4;
  --text-faint: #8b9096;

  --link: #88a9f0;
  --link-hover: #aec3f7;
  --link-visited: #b7a4e6;
  --link-red: #f27a7a;

  --border: #4a5158;
  --border-soft: #3a4046;
  --border-faint: #2a2f35;

  --box-bg: #23282e;
  --header-bg: #2a2f35;
  --accent: #c9b6f0;
  --accent-2: #e0a6df;

  --note-bg: #23282e;
  --note-border: #3a4046;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --page-bg: #101418;
    --content-bg: #1b1f24;
    --text: #e6e6e6;
    --text-muted: #a7adb4;
    --text-faint: #8b9096;

    --link: #88a9f0;
    --link-hover: #aec3f7;
    --link-visited: #b7a4e6;
    --link-red: #f27a7a;

    --border: #4a5158;
    --border-soft: #3a4046;
    --border-faint: #2a2f35;

    --box-bg: #23282e;
    --header-bg: #2a2f35;
    --accent: #c9b6f0;
    --accent-2: #e0a6df;

    --note-bg: #23282e;
    --note-border: #3a4046;
  }
}

/* ---------------------------------------------------------------- reset */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.6;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
a:visited { color: var(--link-visited); }
a.new, a.redlink { color: var(--link-red); }
a.ext::after { content: " ↗"; font-size: 0.75em; color: var(--text-faint); }

/* ---------------------------------------------------------------- header */
.wiki-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1.25rem;
  background: var(--content-bg);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 30;
}
.wiki-brand { display: flex; align-items: baseline; gap: 0.5rem; text-decoration: none; }
.wiki-brand:hover { text-decoration: none; }
.wiki-logo {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent-2), var(--accent));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--serif); font-weight: 700; font-size: 1.1rem;
  flex: 0 0 auto;
}
.wiki-wordmark { font-family: var(--serif); font-size: 1.35rem; color: var(--text); line-height: 1; }
.wiki-wordmark small { display: block; font-family: var(--sans); font-size: 0.62rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); margin-top: 2px; }
.wiki-search { margin-left: auto; flex: 0 1 20rem; min-width: 0; position: relative; }
.wiki-search[hidden] { display: none; }
.wiki-search[hidden] + .theme-toggle { margin-left: auto; }
.wiki-search input {
  width: 100%; font: inherit; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: 2px;
  background: var(--content-bg); color: var(--text);
  padding: 0.4rem 0.6rem;
}
.wiki-search input::placeholder { color: var(--text-faint); opacity: 1; }
.wiki-search input:focus-visible { outline: 2px solid var(--link); outline-offset: 0; border-color: var(--link); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.search-results {
  position: absolute; top: calc(100% + 4px); right: 0;
  width: min(30rem, calc(100vw - 2rem));
  max-height: min(28rem, 70vh); overflow-y: auto;
  margin: 0; padding: 0.25rem; list-style: none;
  background: var(--content-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  z-index: 40;
}
.search-results[hidden] { display: none; }
.search-results [role="option"] { border-radius: 3px; }
.search-results [role="option"] a {
  display: block; padding: 0.4rem 0.6rem; color: var(--text); text-decoration: none;
}
.search-results [role="option"]:hover,
.search-results [role="option"][aria-selected="true"] { background: var(--header-bg); }
.search-results [role="option"][aria-selected="true"] { outline: 2px solid var(--link); outline-offset: -2px; }
.search-results .sr-title { display: block; font-weight: 600; font-size: 0.85rem; }
.search-results .sr-sub { display: block; color: var(--accent-2); font-size: 0.75rem; font-weight: 600; }
.search-results .sr-snip { display: block; color: var(--text-muted); font-size: 0.78rem; line-height: 1.4; }
.search-results .sr-empty { padding: 0.6rem; color: var(--text-muted); font-size: 0.85rem; }
.theme-toggle {
  flex: 0 0 auto;
  width: 2.2rem; height: 2.2rem;
  border: 1px solid var(--border-soft); border-radius: 4px;
  background: var(--content-bg); color: var(--text);
  font-size: 1.05rem; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--header-bg); }

/* ---------------------------------------------------------------- layout */
.wiki-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  max-width: 78rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 4rem;
}

.wiki-sidebar {
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 4rem;
  font-size: 0.8125rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
}
.nav-disclosure > summary { display: none; }
.wiki-sidebar h3 {
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 700;
  margin: 1rem 0 0.35rem;
  border: 0;
}
.wiki-sidebar ul { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.wiki-sidebar li { margin: 0.15rem 0; }
.wiki-sidebar a { display: block; padding: 0.12rem 0.45rem; border-radius: 3px; color: var(--link); }
.wiki-sidebar a:hover { background: var(--border-faint); text-decoration: none; }
.wiki-sidebar a[aria-current="page"] { background: var(--header-bg); color: var(--text); font-weight: 600; }

.wiki-content {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--content-bg);
  border: 1px solid var(--border-soft);
  border-radius: 2px;
  padding: 1.25rem 1.75rem 2.5rem;
}
.mw-body { max-width: var(--content-max); }

/* ---------------------------------------------------------------- titles */
.firstHeading {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.85rem;
  line-height: 1.25;
  margin: 0 0 0.15rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}
.tagline {
  color: var(--text-faint);
  font-size: 0.8rem;
  font-style: italic;
  margin: 0 0 1rem;
}

h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; scroll-margin-top: 4.5rem; }
.wiki-content h2 {
  font-size: 1.4rem;
  font-weight: 400;
  margin: 1.6rem 0 0.6rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border-faint);
}
.wiki-content h3 { font-size: 1.12rem; margin: 1.2rem 0 0.4rem; }
.wiki-content h4 { font-size: 1rem; margin: 1rem 0 0.3rem; }

.wiki-content p { margin: 0.6rem 0; }
.wiki-content ul, .wiki-content ol { margin: 0.6rem 0; padding-left: 1.6rem; }
.wiki-content li { margin: 0.2rem 0; }

/* section edit link mimicry */
.mw-editsection { font-size: 0.72rem; font-family: var(--sans); font-weight: 400; color: var(--text-faint); margin-left: 0.5rem; }
.mw-editsection a { color: var(--link); }

/* ---------------------------------------------------------------- hatnote */
.hatnote {
  font-style: italic;
  color: var(--text-muted);
  padding: 0.15rem 0 0.15rem 1.6rem;
  margin: 0.3rem 0;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- notices */
.mbox {
  display: flex; gap: 0.75rem; align-items: flex-start;
  border: 1px solid var(--note-border);
  border-left-width: 4px;
  background: var(--note-bg);
  padding: 0.6rem 0.9rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  border-radius: 2px;
}
.mbox .mbox-icon { font-size: 1.1rem; line-height: 1.4; }
.mbox.info { border-left-color: #3366cc; }
.mbox.note { border-left-color: #4b2e83; }

/* ---------------------------------------------------------------- infobox */
.infobox {
  float: right;
  clear: right;
  width: 22.5rem;
  max-width: 100%;
  margin: 0.2rem 0 1rem 1.5rem;
  border: 1px solid var(--border-soft);
  background: var(--box-bg);
  font-size: 0.82rem;
  line-height: 1.5;
  border-radius: 2px;
  border-collapse: collapse;
}
.infobox caption, .infobox .infobox-title {
  background: var(--header-bg);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.02rem;
  text-align: center;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-soft);
}
.infobox .infobox-subheader {
  background: var(--header-bg);
  text-align: center;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
}
.infobox th, .infobox td {
  text-align: left;
  vertical-align: top;
  padding: 0.35rem 0.6rem;
  border-top: 1px solid var(--border-faint);
}
.infobox th[scope="row"] { width: 38%; color: var(--text-muted); font-weight: 600; }
.infobox .infobox-full { text-align: center; color: var(--text-muted); }

/* ---------------------------------------------------------------- TOC */
.toc {
  display: inline-block;
  min-width: 16rem;
  max-width: 100%;
  border: 1px solid var(--border-soft);
  background: var(--box-bg);
  padding: 0.6rem 1rem 0.8rem;
  margin: 0.5rem 0 1rem;
  font-size: 0.875rem;
  border-radius: 2px;
}
.toc .toctitle { font-weight: 700; text-align: center; margin-bottom: 0.4rem; font-family: var(--sans); }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc > ol > li { counter-increment: toc; }
.toc > ol > li > a::before { content: counter(toc) "\00a0\00a0"; color: var(--text-muted); }
.toc ol ol { padding-left: 1.4rem; counter-reset: toc2; }
.toc ol ol li { counter-increment: toc2; }
.toc ol ol li > a::before { content: counter(toc) "." counter(toc2) "\00a0\00a0"; color: var(--text-muted); }
.toc a { color: var(--link); }

/* ---------------------------------------------------------------- figures / era bands */
.era-band {
  border-left: 4px solid var(--accent);
  background: var(--box-bg);
  padding: 0.5rem 0.9rem;
  margin: 1rem 0;
  border-radius: 0 2px 2px 0;
}
.era-band .era-years { font-family: var(--mono); font-size: 0.78rem; color: var(--accent-2); font-weight: 700; }

/* ---------------------------------------------------------------- tables */
.table-scroll { overflow-x: auto; max-width: 100%; }
.wikitable {
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.86rem;
  width: 100%;
  background: var(--content-bg);
}
.wikitable caption { font-weight: 700; padding: 0.3rem; text-align: left; }
.wikitable th, .wikitable td {
  border: 1px solid var(--border-soft);
  padding: 0.4rem 0.55rem;
  vertical-align: top;
  text-align: left;
}
.wikitable th { background: var(--header-bg); font-weight: 600; }
.wikitable tr:nth-child(even) td { background: color-mix(in srgb, var(--box-bg) 55%, transparent); }

/* ---------------------------------------------------------------- timeline */
.timeline { list-style: none; margin: 1.2rem 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 6.5rem; top: 0; bottom: 0;
  width: 2px; background: var(--border-soft);
}
.timeline li {
  position: relative;
  padding: 0.35rem 0 0.65rem 8rem;
  margin: 0;
}
.timeline li::before {
  content: ""; position: absolute; left: 5.9rem; top: 0.7rem;
  width: 0.7rem; height: 0.7rem; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--content-bg);
}
.timeline .tl-date {
  position: absolute; left: 0; top: 0.35rem; width: 5.5rem;
  text-align: right; font-family: var(--mono); font-size: 0.74rem;
  color: var(--accent-2); font-weight: 700; line-height: 1.5;
}
.timeline .tl-event { font-weight: 600; }
.timeline .tl-note { color: var(--text-muted); font-size: 0.9em; font-weight: 400; }
.tl-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.02rem 0.45rem;
  margin-left: 0.15rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--box-bg);
  color: var(--text-muted);
  white-space: nowrap;
  vertical-align: middle;
}
a.tl-tag:hover { background: var(--header-bg); color: var(--link); text-decoration: none; }

/* wide date column for merged timelines (dates like "September 30, 2019" stay on one line) */
.timeline.tl-wide::before { left: 9.5rem; }
.timeline.tl-wide li { padding-left: 11.25rem; }
.timeline.tl-wide li::before { left: 8.9rem; }
.timeline.tl-wide .tl-date { width: 8.5rem; overflow-wrap: break-word; }
.timeline li[id] { scroll-margin-top: 4.5rem; }
.timeline li[hidden], h3[hidden] { display: none; }

.year-jump { display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; margin: 0.4rem 0 0.8rem; font-family: var(--mono); font-size: 0.8rem; }
.year-jump a { padding: 0.05rem 0.3rem; border-radius: 3px; }
.year-jump a:hover { background: var(--header-bg); text-decoration: none; }
.tl-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0 0 1rem; }
.tl-filter[hidden] { display: none; }
.tl-chip {
  font: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border-soft); background: var(--box-bg); color: var(--text-muted);
}
.tl-chip:hover { background: var(--header-bg); }
.tl-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--content-bg); }
.tl-chip:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.tl-chip-all { background: transparent; border-style: dashed; }
.tl-count { margin-left: 0.4rem; }

/* ---------------------------------------------------------------- references */
sup.reference { font-size: 0.75em; line-height: 1; vertical-align: super; white-space: nowrap; }
sup.reference a { padding: 0 1px; }
.references {
  font-size: 0.82rem;
  line-height: 1.5;
  padding-left: 2.2rem;
  margin: 0.6rem 0;
  color: var(--text-muted);
}
.references li { margin: 0.28rem 0; }
.references li:target { background: color-mix(in srgb, #ffce7b 40%, transparent); }
.references .cite-cite { font-style: italic; }
.references .cite-pub { }
.references cite { font-style: normal; }
.reflist-2col { column-width: 24rem; column-gap: 2rem; }

.citation-backlink { font-weight: 700; }

.src-tag {
  display: inline-block;
  font-size: 0.68rem;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.02rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text-faint);
  background: var(--content-bg);
  vertical-align: middle;
  white-space: nowrap;
}
.src-tag.src-official { border-color: #3366cc55; color: var(--link); }
.src-tag.src-press { border-color: #74277455; color: var(--accent-2); }
.src-tag.src-analyst { border-color: #2e7d3255; color: #2e7d32; }
.src-tag.src-community { border-color: #b7791f55; color: #b7791f; }
.src-tag.src-primaryarchive { border-color: #4b2e8355; color: var(--accent); }
.src-tag.src-conference { border-color: #c2185b55; color: #c2185b; }
:root[data-theme="dark"] .src-tag.src-analyst { color: #7bc47f; }
:root[data-theme="dark"] .src-tag.src-community { color: #e0b055; }
:root[data-theme="dark"] .src-tag.src-conference { color: #f48fb1; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .src-tag.src-analyst { color: #7bc47f; }
  :root:not([data-theme]) .src-tag.src-community { color: #e0b055; }
  :root:not([data-theme]) .src-tag.src-conference { color: #f48fb1; }
}

/* ---------------------------------------------------------------- misc */
.mw-content-subtitle { color: var(--text-faint); font-size: 0.85rem; margin: -0.4rem 0 1rem; }
blockquote { border-left: 3px solid var(--border-soft); margin: 1rem 0; padding: 0.2rem 1rem; color: var(--text-muted); font-style: italic; }
code { font-family: var(--mono); font-size: 0.86em; background: var(--box-bg); padding: 0.05rem 0.3rem; border-radius: 2px; }
hr { border: 0; border-top: 1px solid var(--border-faint); margin: 1.5rem 0; }
.nowrap { white-space: nowrap; }
.small { font-size: 0.85em; color: var(--text-muted); }

/* "See also" / category chips */
.catlinks {
  border: 1px solid var(--border-soft);
  background: var(--box-bg);
  padding: 0.5rem 0.75rem;
  margin-top: 2rem;
  font-size: 0.82rem;
  border-radius: 2px;
}
.catlinks .cat-chip {
  display: inline-block; padding: 0.1rem 0.5rem; margin: 0.15rem 0.2rem;
  border: 1px solid var(--border-soft); border-radius: 999px; background: var(--content-bg);
}

/* ---------------------------------------------------------------- footer */
.wiki-footer {
  max-width: 78rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem;
  color: var(--text-faint); font-size: 0.78rem; line-height: 1.6;
  border-top: 1px solid var(--border-soft);
}
.wiki-footer a { color: var(--link); }
.wiki-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: 1rem; padding: 0; margin: 0.4rem 0; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 60rem) {
  .infobox { float: none; width: 100%; margin: 1rem 0; table-layout: fixed; }
  .infobox th, .infobox td { overflow-wrap: anywhere; }
  .wiki-layout { flex-direction: column; align-items: stretch; gap: 1rem; }
  .wiki-sidebar {
    position: static; flex-basis: auto; max-height: none; width: 100%;
    border-bottom: 1px solid var(--border-soft); padding-bottom: 0.5rem;
  }
  .wiki-sidebar ul { columns: 2; }
  .nav-disclosure > summary {
    display: block; cursor: pointer; list-style: none;
    padding: 0.5rem 0.75rem; font-weight: 600; font-size: 0.9rem;
    border: 1px solid var(--border-soft); border-radius: 3px;
    background: var(--content-bg); color: var(--text);
  }
  .nav-disclosure > summary::-webkit-details-marker { display: none; }
  .nav-disclosure > summary::before { content: "\25B8"; display: inline-block; width: 1.1em; transition: transform 0.15s; }
  .nav-disclosure[open] > summary::before { transform: rotate(90deg); }
  .nav-disclosure > summary:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
  .wiki-sidebar { padding-bottom: 0; border-bottom: 0; }
  .nav-disclosure[open] > summary { margin-bottom: 0.25rem; }
  .timeline::before { left: 0.35rem; }
  .timeline li { padding-left: 1.6rem; }
  .timeline li::before { left: 0; }
  .timeline .tl-date { position: static; width: auto; text-align: left; display: block; }
  .timeline.tl-wide::before { left: 0.35rem; }
  .timeline.tl-wide li { padding-left: 1.6rem; }
  .timeline.tl-wide li::before { left: 0; }
  .timeline.tl-wide .tl-date { position: static; width: auto; text-align: left; }
}

@media (max-width: 40rem) {
  .wiki-layout { padding: 0.5rem 0.5rem 3rem; gap: 0.5rem; }
  .wiki-content { padding: 0.9rem 0.85rem 1.75rem; border-left: 0; border-right: 0; margin: 0 -0.5rem; }
  .wiki-header { padding: 0.45rem 0.75rem; gap: 0.6rem; }
  .wiki-footer { padding: 1.25rem 0.85rem 2.5rem; }
  .wiki-search { position: static; }
  .search-results { left: 0.5rem; right: 0.5rem; width: auto; top: 100%; }
}

@media print {
  .wiki-header, .wiki-sidebar, .wiki-search, .wiki-footer, .mw-editsection { display: none !important; }
  .wiki-content { border: 0; }
  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: none; }
  sup.reference a::after { content: ""; }
}
