/* gde.ee shared document shell — trust pages + gdePedia.
   Tokens only; loads after shared.css / trust.css / theme.css. The bridge
   below maps trust.css's legacy hardcoded surfaces onto semantic tokens, so
   the components follow the light/dark switch instead of staying dark. */

.doc-wrap { max-width: 1000px; margin: 0 auto; padding: 112px var(--gutter) 72px; }
.doc-head { margin: 0 0 26px; }
.doc-head .hero-badge { margin-bottom: 14px; }

.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.doc-body { min-width: 0; }
.doc-body [id] { scroll-margin-top: 96px; }

.doc-toc { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 14px; padding: 10px 12px; }
.doc-toc-title {
  min-height: 44px; margin: 0; padding: 0 4px; display: flex; align-items: center;
  justify-content: space-between; gap: 8px; font: 800 11px/1.3 var(--font-outfit, system-ui);
  letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); list-style: none;
}
.doc-toc summary.doc-toc-title { cursor: pointer; }
.doc-toc summary.doc-toc-title::-webkit-details-marker { display: none; }
.doc-toc summary.doc-toc-title::after { content: '+'; font-size: 16px; color: var(--accent-text); }
.doc-toc[open] > summary.doc-toc-title::after { content: '–'; }
.doc-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.doc-toc a {
  display: flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 9px;
  color: var(--text-secondary); font-size: 13px; line-height: 1.35; text-decoration: none;
}
.doc-toc a:hover { color: var(--text-primary); background: var(--bg-surface-muted); }
.doc-toc a[aria-current] {
  color: var(--accent-text); background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent-text);
}
.doc-toc--mobile { margin-bottom: 4px; }
.doc-toc--mobile ol { padding: 2px 0 8px; }

.doc-top {
  position: fixed; right: max(var(--gutter), env(safe-area-inset-right, 0px));
  bottom: calc(var(--gutter) + env(safe-area-inset-bottom, 0px)); z-index: 900;
  display: inline-flex; align-items: center; gap: 8px; min-width: 44px; min-height: 44px;
  padding: 0 16px; border: 1px solid var(--border-subtle); border-radius: 999px;
  background: var(--bg-surface); color: var(--text-secondary); text-decoration: none;
  font: 800 12px/1 var(--font-outfit, system-ui); box-shadow: var(--shadow-md);
}
.doc-top:hover { color: var(--text-primary); border-color: var(--border-strong); }
.doc-top .ph-duotone { font-size: 16px; }

.doc-empty {
  display: grid; justify-items: center; gap: 10px; text-align: center;
  margin: 4px 0 30px; padding: 42px 24px; border: 1px dashed var(--border-strong);
  border-radius: 18px; background: var(--bg-surface-muted);
}
.doc-empty .ph-duotone { font-size: 44px; line-height: 1; color: var(--accent); }
.doc-empty p { max-width: 44ch; margin: 0; color: var(--text-secondary); }
.doc-body .trust-card > .ph-duotone { display: block; margin-bottom: 8px; font-size: 22px; color: var(--accent); }

@media (max-width: 767px) {
  .doc-wrap { padding: 88px var(--gutter-sm) 56px; }
  .doc-top {
    right: max(var(--gutter-sm), env(safe-area-inset-right, 0px));
    bottom: calc(var(--gutter-sm) + env(safe-area-inset-bottom, 0px));
  }
}
@media (max-width: 1023px) {
  .doc-rail { display: none; }
  .doc-toc--mobile { display: block; }
}
@media (min-width: 1024px) {
  .doc-layout--rail { grid-template-columns: 232px minmax(0, 1fr); gap: 44px; }
  .doc-rail {
    position: sticky; top: 100px; max-height: calc(100vh - 124px);
    overflow-y: auto; overscroll-behavior: contain;
  }
  .doc-toc--mobile { display: none; }
}

/* ── token bridge for the sealed trust.css component set ───────────────────
   Screen only: trust.css owns the print palette, and a later unlayered bridge
   would otherwise repaint print headings with the dark-theme token. */
@media screen {
body.doc-page .trust-nav { border-bottom-color: var(--border-subtle); }
body.doc-page .trust-nav .trust-home,
body.doc-page .trust-nav a[aria-current="page"] { color: var(--text-primary); }
body.doc-page .trust-nav a { color: var(--text-muted); }
body.doc-page .trust-nav a:hover { color: var(--accent-text); }
body.doc-page .trust-card,
body.doc-page .trust-flow-row,
body.doc-page .trust-status-row,
body.doc-page .trust-timeline-item,
body.doc-page .trust-step,
body.doc-page .trust-price-card,
body.doc-page .trust-faq details { background: var(--bg-surface); border-color: var(--border-subtle); }
body.doc-page .trust-card--accent { background: var(--accent-soft); border-color: var(--border-accent); }
body.doc-page .trust-card--warn { background: var(--warning-soft); border-color: var(--warning); }
body.doc-page .trust-card--good { background: var(--success-soft); border-color: var(--success); }
body.doc-page .trust-timeline-item { border-left: 2px solid var(--border-accent); }
body.doc-page .trust-price-card--featured { border-color: var(--border-accent); }
body.doc-page .trust-faq details[open] { background: var(--bg-surface-muted); }
body.doc-page .trust-h1,
body.doc-page .trust-h2,
body.doc-page .trust-h3,
body.doc-page .trust-table strong,
body.doc-page .trust-flow-node,
body.doc-page .trust-status-name,
body.doc-page .trust-price-name,
body.doc-page .trust-price-value,
body.doc-page .trust-kpi-value,
body.doc-page .trust-faq summary { color: var(--text-primary); }
body.doc-page .trust-table th,
body.doc-page .trust-table td { border-color: var(--border-subtle); }
body.doc-page .trust-table a,
body.doc-page .trust-step-day { color: var(--accent-text); }
body.doc-page .trust-meta span { background: var(--bg-surface-muted); border-color: var(--border-subtle); }
body.doc-page .trust-label--promise { color: var(--success); background: var(--success-soft); }
body.doc-page .trust-label--limit { color: var(--warning); background: var(--warning-soft); }
body.doc-page .trust-label--note,
body.doc-page .trust-timeline-kind { color: var(--accent-text); background: var(--accent-soft); }
/* Primary CTA: the old indigo→purple gradient held white text at 3.96–4.47:1.
   Solid --accent-strong with the inverse label clears AA in both themes. */
body.doc-page .trust-btn--primary { color: var(--text-inverse); background: var(--accent-strong); }
body.doc-page .trust-btn--ghost { color: var(--text-secondary); border-color: var(--border-subtle); background: var(--bg-surface-muted); }
body.doc-page .trust-note { color: var(--text-muted); border-left-color: var(--border-strong); }
body.doc-page .trust-table-wrap:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
}

/* ── live background layer ──────────────────────────────────────────────────
   The band lives at the top of the document, not the viewport: the canvas and
   the grid are absolute (900px tall) and fade out by 760px. The master's
   glows resolve near the header on a long page, so pin them to the band. */
body.doc-page {
  --doc-bg-band: 900px;
  padding-bottom: 0; /* no fixed bottom CTA on document pages */
}
body.doc-page #particle-canvas,
body.doc-page .grid-bg-overlay {
  position: absolute;
  inset: 0 0 auto 0;
  width: 100%;
  height: var(--doc-bg-band);
  -webkit-mask-image: linear-gradient(to bottom, #000 0 240px, transparent 760px);
  mask-image: linear-gradient(to bottom, #000 0 240px, transparent 760px);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  pointer-events: none;
}
body.doc-page #particle-canvas { z-index: -2; }
body.doc-page .grid-bg-overlay { z-index: -1; }
body.doc-page .ambient-glow {
  bottom: auto;
  z-index: -1;
  pointer-events: none;
}
body.doc-page .ambient-indigo { top: -120px; right: auto; left: 0; }
body.doc-page .ambient-purple { top: 40px; right: 0; left: auto; }

@media screen {
  /* 1. Document switcher: an opaque-ish bar over the field. --bg-glass is
        86% (light) / 70% (dark), so the worst-case dot is muted by the bar. */
  body.doc-page .trust-nav {
    margin: 0 0 14px;
    padding: 10px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  body.doc-page .trust-nav a { color: var(--text-muted); }
  body.doc-page .trust-nav a[aria-current="page"] { color: var(--text-primary); }

  /* 2. Eyebrow badge: same tint, but opaque over the canvas. */
  body.doc-page .doc-head .hero-badge.indigo {
    color: var(--accent-text);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-surface));
    border-color: var(--border-accent);
  }

  /* 3. Tinted cards: keep the tint, remove the translucency. */
  body.doc-page .trust-card--accent {
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-surface));
    border-color: var(--border-accent);
  }
  body.doc-page .trust-card--good {
    background: color-mix(in srgb, var(--success) 12%, var(--bg-surface));
    border-color: var(--success);
  }
  body.doc-page .trust-card--warn {
    background: color-mix(in srgb, var(--warning) 16%, var(--bg-surface));
    border-color: var(--warning);
  }

  /* 4. Tables get their own opaque surface; th moves off the subtle token. */
  body.doc-page .trust-table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 12px 16px;
  }
  body.doc-page .trust-table th { color: var(--text-secondary); }

  /* 5. Meta chips: 12px text needs --text-muted on the muted surface. */
  body.doc-page .trust-meta span { color: var(--text-muted); background: var(--bg-surface-muted); }

  /* 6. Promise/limit labels: one opaque background, coloured border only. */
  body.doc-page .trust-label--promise,
  body.doc-page .trust-label--limit {
    background: var(--bg-surface);
    border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
  }
  body.doc-page .trust-label--promise { color: var(--success); }
  body.doc-page .trust-label--limit { color: var(--warning); }

  /* 7. Footer document links sit on the near-black footer, not the canvas. */
  body.doc-page footer .qw-footer-docs a {
    color: var(--footer-muted);
    border-bottom-color: color-mix(in srgb, var(--footer-text) 25%, transparent);
  }
  body.doc-page footer .qw-footer-docs a:hover {
    color: var(--footer-text);
    border-bottom-color: var(--footer-text);
  }

  /* 8. Beta pill: opaque surface, amber stays only on the text/border. */
  body.doc-page .beta-pill {
    color: var(--warning);
    background: var(--bg-surface);
    border-color: color-mix(in srgb, var(--warning) 35%, transparent);
  }

  /* 9. Focus: keep the outline, put a canvas halo under it so the ring is
        never directly against a particle. Footer links get a light ring. */
  body.doc-page :focus-visible {
    outline-color: var(--focus-ring) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 2px var(--bg-canvas);
  }
  body.doc-page footer :focus-visible { outline-color: var(--text-subtle) !important; }

  /* 10. Body links: token colour plus an underline (not colour alone). */
  body.doc-page .doc-body a:not(.trust-btn) {
    color: var(--accent-text);
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
  }
  body.doc-page .doc-body a:not(.trust-btn):hover {
    color: var(--accent-strong);
    text-decoration-thickness: 2px;
  }
}

/* <=900px with JS the hamburger panel already lists the four locales, so the
   inline duplicate row is the no-JS fallback only. */
@media screen and (max-width: 900px) {
  html.doc-js body.doc-page .trust-nav .trust-langs { display: none; }
}

/* Mobile chrome: a closed contents disclosure is a 46px bar (44px summary),
   and the first heading no longer needs a full section gap. */
@media screen and (max-width: 1023px) {
  body.doc-page .trust-nav { margin-bottom: 12px; }
  body.doc-page .doc-toc--mobile { padding: 0 12px; margin-bottom: 0; }
  body.doc-page .doc-toc--mobile ol { padding: 4px 0 10px; }
  body.doc-page .doc-layout { gap: 16px; }
  body.doc-page .doc-body h2:first-of-type { margin-top: 24px; }
}

/* A long TOC scrolls inside the rail; the fade signals that there is more. */
@media screen and (min-width: 1024px) {
  body.doc-page .doc-rail { scroll-padding-bottom: 24px; }
  body.doc-page .doc-rail.is-scrollable:not(.is-at-end)::after {
    content: "";
    position: sticky;
    bottom: 0;
    display: block;
    height: 20px;
    margin-top: -20px;
    background: linear-gradient(to bottom, transparent, var(--bg-surface));
    pointer-events: none;
  }
}

@media print {
  #particle-canvas, .grid-bg-overlay, .ambient-glow { display: none !important; }
  .hud-navigation, .mobile-nav-overlay, .mobile-nav-panel, .skip-link,
  .trust-nav, .doc-rail, .doc-toc--mobile, .doc-top, .site-footer { display: none !important; }
  .doc-wrap { max-width: none; padding: 0; }
  .doc-layout, .doc-layout--rail { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  html[data-native-scroll] { scroll-behavior: auto; }
}

/* Back-to-top is a scroll affordance, not chrome: it must not cover the H1 and
   the first bullets at the top of the page (it did on a 390px screen).
   Without JS the anchor stays visible, so the fallback is the old behaviour. */
.doc-top {
  visibility: hidden; opacity: 0; transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
html:not(.doc-js) .doc-top,
.doc-top.is-visible { visibility: visible; opacity: 1; transform: none; }

/* Below 900px shared.css hides the header language pills and the sign-in link,
   so the inline language row in the document switcher is the no-JS fallback.
   Above 900px the header already carries the same four locales. */
@media (min-width: 901px) {
  body.doc-page .trust-nav .trust-langs { display: none; }
}

/* Phones: a six-column subprocessor table cannot be read in a 358px column —
   it scrolled sideways with a third of the vendor list off-screen and no hint
   that it scrolls. Below 640px each row becomes a labelled block instead.
   data-label is emitted by table() in scripts/gen-trust-pages.mjs. */
@media (max-width: 640px) {
  body.doc-page .trust-table-wrap { overflow: visible; }
  body.doc-page .trust-table { display: block; width: 100%; border-collapse: collapse; }
  body.doc-page .trust-table thead {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  body.doc-page .trust-table tbody { display: block; }
  body.doc-page .trust-table tr {
    display: block; padding: 14px 0; border: 0;
    border-top: 1px solid var(--border-subtle);
  }
  body.doc-page .trust-table tr:first-child { border-top: 0; }
  body.doc-page .trust-table td {
    display: block; width: auto; padding: 0 0 6px; border: 0;
    white-space: normal; overflow-wrap: anywhere;
  }
  body.doc-page .trust-table td:last-child { padding-bottom: 0; }
  body.doc-page .trust-table td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    font: 800 10.5px/1.4 var(--font-outfit, system-ui); letter-spacing: .06em;
    text-transform: uppercase; color: var(--text-muted);
  }
}

/* ── product updates archive (/<lang>/updates/) ─────────────────────────────
   Moved out of the four hand-maintained inline <style> blocks and tokenised,
   so the changelog follows the theme switch instead of pinning dark colours.
   `.update-tag` stays in shared.css (sealed) — the shell only sizes it. */
.trust-updates { margin: 24px 0 0; border-top: 1px solid var(--border-subtle); }
.trust-update {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 22px;
  padding: 18px 0; border-bottom: 1px solid var(--border-subtle);
}
.trust-update-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.trust-update-date { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.trust-update p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.65; }
.trust-update .update-tag { flex: 0 0 auto; }
@media (max-width: 640px) {
  .trust-update { grid-template-columns: 1fr; gap: 7px; padding: 16px 0; }
}

/* shared.css owns `.update-tag`; those colours were tuned for the old dark-only
   archive (amber #fbbf24 on the light card is ~1.7:1). Re-point the four tag
   colours at semantic tokens on document pages only — the landing timeline
   keeps shared.css untouched. */
body.doc-page .update-tag { background: var(--bg-surface); }
body.doc-page .update-tag.feat { color: var(--accent-text); border-color: var(--border-accent); }
body.doc-page .update-tag.fix { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
body.doc-page .update-tag.perf { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
body.doc-page .update-tag.security { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }

/* Long single-word titles (RU "Политика конфиденциальности") dropped the last
   letter onto its own line at 360–390. Hyphenate where the locale allows it and
   let the type scale down on very narrow screens instead of breaking a word. */
body.doc-page .trust-h1 { overflow-wrap: break-word; hyphens: auto; }
@media (max-width: 430px) {
  body.doc-page .trust-h1 { font-size: clamp(24px, 7.6vw, 32px); letter-spacing: -0.01em; }
}

/* ── gdePedia instant search — suggestion listbox (landing/pedia-search.js) ──
   trust.css owns the input and the status line (sealed); this file owns the
   popup, the options and the jump highlight. The popup is absolutely positioned
   inside .pedia-search so it overlays the article instead of pushing it down,
   and it is created only when there are suggestions — an empty page never shows
   an empty box. Tokens only, so light and dark come for free. */
body.doc-page .pedia-search { position: relative; }
body.doc-page .pedia-suggest[hidden],
body.doc-page .pedia-suggest-foot[hidden] { display: none; }
body.doc-page .pedia-suggest {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(58vh, 400px); overflow-y: auto; overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--border-strong); border-radius: 16px;
  background: var(--bg-surface); box-shadow: 0 18px 40px color-mix(in srgb, #000 24%, transparent);
}
body.doc-page .pedia-suggest-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
body.doc-page .pedia-option {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: center;
  gap: 1px 10px; min-height: 44px; padding: 8px 10px; border-radius: 11px;
  color: var(--text-primary); cursor: pointer;
}
body.doc-page .pedia-option-kind {
  grid-column: 1; font: 800 10.5px/1.3 var(--font-outfit, system-ui);
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted);
}
body.doc-page .pedia-option-title {
  grid-column: 1; font-size: 13.5px; font-weight: 700; line-height: 1.35;
  overflow-wrap: anywhere;
}
body.doc-page .pedia-option-snippet {
  grid-column: 1; font-size: 12px; line-height: 1.45; color: var(--text-muted);
  overflow-wrap: anywhere;
}
body.doc-page .pedia-option-badge {
  grid-column: 2; grid-row: 1 / span 3; align-self: center;
  padding: 2px 7px; border-radius: 999px;
  background: var(--bg-surface-muted); color: var(--text-subtle);
  font-size: 10.5px; font-weight: 800;
}
body.doc-page .pedia-option[aria-selected="true"] {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent-text);
}
body.doc-page .pedia-option[aria-selected="true"] .pedia-option-title { color: var(--accent-text); }
body.doc-page .pedia-option:hover { background: var(--bg-surface-muted); }
body.doc-page .pedia-option[aria-selected="true"]:hover { background: var(--accent-soft); }
/* Sticky, so "show all" never hides below the list's own scroll area (the
   popup caps at 400px while 8 options can be taller). */
body.doc-page .pedia-suggest-foot {
  position: sticky; bottom: 0; z-index: 1;
  padding: 6px 2px 2px; border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}
body.doc-page .pedia-suggest-more {
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--border-subtle); border-radius: 11px;
  background: var(--bg-surface-muted); color: var(--text-secondary);
  font: 700 12.5px/1 var(--font-outfit, system-ui); cursor: pointer;
}
body.doc-page .pedia-suggest-more:hover { color: var(--text-primary); border-color: var(--border-strong); }

/* Jump highlight: a ring that stays long enough to be seen, then fades. Motion
   is decoration only — with reduced motion the ring is static while the class
   is present, so the target is still marked. */
body.doc-page .is-pedia-hit { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
@media (prefers-reduced-motion: no-preference) {
  body.doc-page .is-pedia-hit { animation: pedia-hit 2.4s ease-out both; }
}
@keyframes pedia-hit {
  0%, 55% { outline-color: var(--accent); }
  100% { outline-color: transparent; }
}
/* The search bar is sticky on <=1023px (trust.css: top 60px, ~97px tall), so an
   anchor that a suggestion switches to must clear it. doc.css gives every [id]
   96px and trust.css gives the answer rows 150px — both still land under the
   bar's bottom edge (~157px). Measured in scripts/e2e/pedia-search-geometry.mjs. */
@media (max-width: 1023px) {
  body.doc-page .doc-body:has(.pedia-search-sticky) [id] { scroll-margin-top: 168px; }
}

@media print {
  body.doc-page .pedia-suggest { display: none !important; }
}

/* No JS: pedia-search.js never adds .pedia-js, so the inert search shell and
   toolbar are hidden instead of shipping controls that silently do nothing.
   The topics grid, the section anchors and the TOC carry navigation. */
html:not(.pedia-js) .pedia-search-sticky,
html:not(.pedia-js) .pedia-toolbar { display: none; }

/* The global `outline: 2px solid var(--primary) !important` (shared.css) lands
   inside the search pill and draws a second rectangle around the input. The pill
   already shows focus via :focus-within (accent border + 4px soft ring), so the
   inner ring is only noise — keep the indicator, drop the duplicate. */
body.doc-page .pedia-search input:focus-visible { outline: none !important; }
