/* ============================================================
   POO²L portal — design tokens
   Identity: a technical reference built around the @@@ sigil.
   Warm greige paper, ink chrome, a single teal signal color.
   ============================================================ */
:root {
  --ink:        #16181d;
  --ink-soft:   #21242b;
  --page:       #f3f2ee;
  --paper:      #ffffff;
  --line:       #e4e2db;
  --line-soft:  #efeee9;
  --text:       #22252b;
  --muted:      #6a6e75;
  --muted-2:    #8b8f96;
  --accent:     #0e7c7b;
  --accent-ink: #0a5a59;
  --accent-soft:#e2f0ef;
  --code-bg:    #f6f8f8;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 264px;
  --toc-w: 232px;
  --read-w: 760px;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must win over component display rules.
   Without this, `.loading { display: flex }` overrides the user-agent
   `[hidden] { display: none }`, so the loader never disappears. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font: 500 13px/1 var(--mono);
}
.skip-link:focus { left: 12px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  height: 100vh;
  overflow: hidden; /* only the inner .scroll column scrolls; never the page */
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--ink);
  color: #d8dade;
  display: flex;
  flex-direction: column;
  padding: 26px 20px 18px;
  overflow: hidden; /* the sidebar itself doesn't scroll — only .nav does */
  min-height: 0;
  border-right: 1px solid #000;
}

.brand {
  display: block;
  text-decoration: none;
  margin-bottom: 30px;
}
.brand__sigil {
  display: block;
  font: 700 26px/1 var(--mono);
  letter-spacing: 1px;
  color: var(--accent);
}
.brand__name {
  display: block;
  font: 700 19px/1.2 var(--mono);
  color: #fff;
  margin-top: 8px;
}
.brand__sub {
  display: block;
  font-size: 11.5px;
  color: var(--muted-2);
  margin-top: 5px;
  letter-spacing: .2px;
}

/* Only the menu scrolls; brand stays at top and credit (foot) stays pinned. */
.nav { flex: 1; overflow-y: auto; min-height: 0; }
.nav__group {
  font: 500 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted-2);
  margin: 22px 0 10px;
  padding-left: 12px;
  position: relative;
}
.nav__group::before {
  content: "@@@";
  position: absolute;
  left: -2px;
  top: 0;
  display: none;
}
.nav__group:first-child { margin-top: 0; }

/* Accordion: one block per document, expanding to its H1/H2 "files". */
.acc { margin-bottom: 2px; }

.acc__head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
  color: #cdd0d5;
  font: inherit;
  padding: 9px 12px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.acc__head:hover { background: var(--ink-soft); color: #fff; }
.acc.is-open > .acc__head {
  background: var(--ink-soft);
  border-left-color: var(--accent);
  color: #fff;
}
.acc__titles { flex: 1; min-width: 0; }
.acc__title {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
.acc__meta {
  display: block;
  font-size: 11.5px;
  color: var(--muted-2);
  margin-top: 2px;
}
.acc__caret {
  flex: none;
  color: var(--muted-2);
  transition: transform .18s ease;
}
.acc.is-open > .acc__head .acc__caret { transform: rotate(90deg); }

/* Collapsible panel — animated via the grid-rows 0fr→1fr technique. */
.acc__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .2s ease;
}
.acc.is-open > .acc__panel { grid-template-rows: 1fr; }
.acc__inner {
  overflow: hidden;
  padding-left: 14px;
}
.acc.is-open > .acc__panel > .acc__inner { padding-top: 4px; padding-bottom: 6px; }

.acc__page {
  display: block;
  text-decoration: none;
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.35;
  padding: 6px 10px;
  border-radius: 5px;
  border-left: 2px solid transparent;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.acc__page:hover { color: #fff; background: var(--ink-soft); }
.acc__page.is-active {
  color: #fff;
  border-left-color: var(--accent);
  background: var(--ink-soft);
}

/* Nested accordion: the "Standard" group holding its part accordions. */
.acc--group > .acc__panel > .acc__inner { padding-left: 8px; }
.acc--group .acc { margin-bottom: 0; }
.acc--group .acc__head { padding: 7px 10px; }
.acc--group .acc__title { font-size: 13px; font-weight: 600; }
.acc--group .acc__meta { font-size: 10.5px; }
.acc--group .acc__page { font-size: 12.5px; padding-left: 12px; }

.sidebar__foot {
  font: 400 11px/1 var(--mono);
  color: var(--muted-2);
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid #2a2d34;
}
.sidebar__foot-row {
  display: flex;
  justify-content: space-between;
}
.sidebar__credit {
  margin: 10px 0 0;
  color: var(--muted-2);
}
.sidebar__credit-line {
  display: block;
  line-height: 1.6;
  white-space: nowrap;
}
.sidebar__credit a {
  color: #cdd0d5;
  text-decoration: none;
  font-weight: 600;
}
.sidebar__credit a:hover { color: #fff; text-decoration: underline; }

/* ---------- Main column ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0; /* let .scroll scroll instead of growing the column */
  background: var(--page);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  flex: 0 0 56px;
  padding: 0 28px;
  background: rgba(243, 242, 238, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__crumb {
  font: 500 13.5px/1 var(--mono);
  color: var(--muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumb__link { color: inherit; text-decoration: none; }
.crumb__link:hover { color: var(--accent-ink); text-decoration: underline; }
.crumb__sep { color: var(--muted-2); }

.topbar__menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 8px 7px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}
.topbar__menu span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* Back-one-level arrow (top-left of the main column). */
.topbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .14s ease, color .14s ease;
}
.topbar__back:hover { border-color: var(--accent); color: var(--accent-ink); }

/* Contextual sidebar menu items. */
.menu__item {
  display: block;
  text-decoration: none;
  color: #cdd0d5;
  padding: 9px 12px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.menu__item:hover { background: var(--ink-soft); color: #fff; }
.menu__item.is-active {
  background: var(--ink-soft);
  border-left-color: var(--accent);
  color: #fff;
}
.menu__title { display: block; font-size: 14px; font-weight: 600; }
.menu__meta { display: block; font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }

/* "Go to §…" jump box in the topbar. */
.secjump {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: border-color .14s ease;
}
.secjump:focus-within { border-color: var(--accent); }
.secjump__sigil {
  font: 700 13px/1 var(--mono);
  color: var(--accent);
}
.secjump__input {
  width: 92px;
  border: 0;
  outline: 0;
  background: none;
  font: 500 13px/1 var(--mono);
  color: var(--text);
}
.secjump__input::placeholder { color: var(--muted-2); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 600 13px/1 var(--sans);
  text-decoration: none;
  border-radius: 7px;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.btn--download {
  background: var(--accent);
  color: #fff;
}
.btn--download:hover { background: var(--accent-ink); }
.btn--ghost {
  background: var(--paper);
  color: var(--text);
  border-color: var(--line);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Scroll region ---------- */
.scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ---------- Home ---------- */
.home {
  max-width: 880px;
  margin: 0 auto;
  padding: 64px 28px 80px;
}
.hero { margin-bottom: 48px; }
.hero__sigil {
  font: 700 64px/1 var(--mono);
  letter-spacing: 2px;
  color: var(--accent);
}
.hero__title {
  font: 700 38px/1 var(--mono);
  margin: 14px 0 0;
  color: var(--ink);
}
.hero__lede {
  font-size: 17px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 60ch;
  margin: 18px 0 0;
}
.hero__lede code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 1px 6px;
  border-radius: 5px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px -14px rgba(14, 124, 123, .5);
}
.card__tag {
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent-soft);
  align-self: flex-start;
  padding: 4px 8px;
  border-radius: 5px;
}
.card__title {
  font: 700 19px/1.2 var(--sans);
  margin: 14px 0 6px;
  color: var(--ink);
}
.card__file {
  font: 400 12px/1 var(--mono);
  color: var(--muted-2);
}
.card__desc {
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  margin: 12px 0 18px;
  flex: 1;
}
.card__actions {
  display: flex;
  gap: 10px;
}
.card__file a { color: var(--accent-ink); text-decoration: none; }
.card__file a:hover { text-decoration: underline; }

/* Reference-implementation badge: filled accent so it stands out. */
.card__tag--ref { color: #fff; background: var(--accent); }

/* Whole-tile click affordance (inner buttons still work). */
.card[data-href] { cursor: pointer; }
.card[data-href]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Kind badges for conformance tests. */
.kind--render  { color: #0a5a59; background: #e2f0ef; }
.kind--error   { color: #9a2a2a; background: #fbe7e7; }
.kind--warning { color: #8a5a00; background: #fbf0d8; }

/* Tile view (standard parts, conformance tests, levels). */
.tiles { max-width: 980px; margin: 0 auto; padding: 48px 28px 80px; }
.tiles__title { font: 700 26px/1.2 var(--mono); color: var(--ink); margin: 0 0 8px; }
.tiles__sub { font-size: 15px; line-height: 1.6; color: var(--muted); max-width: 70ch; margin: 0 0 26px; }

/* Single conformance-test page: all files of one test, clearly labelled. */
.test__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.test__id { font: 700 20px/1 var(--mono); color: var(--ink); }
.test__level { font: 500 12px/1 var(--mono); color: var(--muted-2); }
.test__title { font-size: 16px; color: var(--muted); margin: 10px 0 18px; max-width: 70ch; }
.test__nav { display: flex; justify-content: space-between; gap: 10px; margin: 0 0 24px; }
.btn.is-disabled { opacity: .4; pointer-events: none; }
.filecard {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 16px;
}
.filecard__name {
  font: 600 12.5px/1 var(--mono);
  color: var(--muted-2);
  background: var(--code-bg);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.filecard pre { margin: 0; border: 0; border-radius: 0; }
.filecard--render  { border-color: #bfe0dd; }
.filecard--render  .filecard__name { color: #0a5a59; background: #e2f0ef; border-bottom-color: #bfe0dd; }
.filecard--error   { border-color: #f0c9c9; }
.filecard--error   .filecard__name { color: #9a2a2a; background: #fbe7e7; border-bottom-color: #f0c9c9; }
.filecard--warning { border-color: #ecd9a8; }
.filecard--warning .filecard__name { color: #8a5a00; background: #fbf0d8; border-bottom-color: #ecd9a8; }

/* Secondary home section (e.g. Implementations). */
.home__section { margin-top: 56px; }
.home__h2 {
  font: 700 22px/1.2 var(--sans);
  color: var(--ink);
  margin: 0 0 6px;
}
.home__sub {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 60ch;
  margin: 0 0 22px;
}
.home__downloads {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 28px;
}
.home__downloads-label {
  font-size: 14px;
  color: var(--muted);
  margin-right: 2px;
}

/* ---------- Document ---------- */
.doc {
  max-width: var(--read-w);
  margin: 0 auto;
  padding: 48px 28px 120px;
  animation: fade .25s ease;
}
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.doc__body { color: var(--text); font-size: 16px; line-height: 1.7; }
.doc__body > *:first-child { margin-top: 0; }

.doc__body h1 {
  font: 700 30px/1.25 var(--sans);
  color: var(--ink);
  margin: 0 0 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
  scroll-margin-top: 72px;
}
.doc__body h2 {
  font: 700 23px/1.3 var(--sans);
  color: var(--ink);
  margin: 48px 0 14px;
  padding-top: 8px;
  scroll-margin-top: 72px;
}
.doc__body h3 {
  font: 600 18px/1.35 var(--sans);
  color: var(--ink-soft);
  margin: 34px 0 10px;
  scroll-margin-top: 72px;
}
.doc__body h4 {
  font: 600 15px/1.4 var(--sans);
  color: var(--ink-soft);
  margin: 26px 0 8px;
  scroll-margin-top: 72px;
}
.doc__body p { margin: 0 0 16px; }
.doc__body a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.doc__body a:hover { text-decoration-thickness: 2px; }

.doc__body ul, .doc__body ol { margin: 0 0 16px; padding-left: 26px; }
.doc__body li { margin: 5px 0; }
.doc__body li > ul, .doc__body li > ol { margin: 5px 0; }

.doc__body blockquote {
  margin: 20px 0;
  padding: 14px 18px;
  background: var(--paper);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  color: var(--ink-soft);
}
.doc__body blockquote p:last-child { margin-bottom: 0; }

.doc__body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 36px 0;
}

.doc__body code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-soft);
}
.doc__body pre {
  background: var(--ink);
  color: #e6e8ec;
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0 0 20px;
  border: 1px solid #000;
}
.doc__body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: inherit;
}
/* The signature: @@@ tokens highlighted in code */
.doc__body .sigil { color: #5fd6d3; font-weight: 500; }

/* Clickable cross-references to other sections of the suite, e.g. (5.4). */
.secref {
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
.secref:hover { background: var(--accent-soft); border-bottom-style: solid; }

.doc__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 22px;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}
.doc__body thead { background: var(--paper); }
.doc__body th {
  text-align: left;
  font-weight: 700;
  color: var(--ink);
  padding: 9px 12px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.doc__body td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.doc__body tr:hover td { background: rgba(14,124,123,.03); }

/* ---------- TOC ---------- */
.toc {
  border-left: 1px solid var(--line);
  padding: 60px 22px 40px;
  overflow-y: auto;
  min-height: 0; /* scroll within the 100vh track, don't push the page */
}
.toc__label {
  font: 500 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted-2);
  margin: 0 0 14px;
}
.toc__list { display: flex; flex-direction: column; gap: 2px; }
.toc__link {
  display: block;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  padding: 4px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.toc__link:hover { color: var(--accent-ink); }
.toc__link.is-current {
  color: var(--accent-ink);
  border-left-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
/* Indentation is relative to each document's split level, so the top-level
   in-page entries always sit flush regardless of their actual H-tag. */
.toc__link--lvl0 { font-weight: 600; color: var(--ink-soft); }
.toc__link--lvl1 { padding-left: 24px; font-size: 12.5px; color: var(--muted-2); }

/* ---------- States ---------- */
.loading, .error {
  max-width: var(--read-w);
  margin: 0 auto;
  padding: 80px 28px;
  text-align: center;
  color: var(--muted);
}
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; }
.loading__sigil {
  font: 700 20px/1 var(--mono);
  color: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
.error__hint { font-size: 14px; max-width: 46ch; margin: 8px auto 0; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 40;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0,1fr); }
  .toc { display: none; }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 80%;
    max-width: 300px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .sidebar.is-open { transform: none; }
  .topbar__menu { display: flex; }
  .secjump { display: none; } /* too cramped on phones; refs stay clickable */
  .cards { grid-template-columns: 1fr; }
  .hero__sigil { font-size: 48px; }
  .hero__title { font-size: 30px; }
  .doc, .home { padding-left: 20px; padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Focus visibility */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
