/* Shared components. The page stylesheet sets these variables:
   --bg --surface --fg --muted --line --accent --accent-2 --radius
   --font-body --font-head --font-mono */

/* Lightbox */
html.lightbox-open { overflow: hidden; }
.lightbox {
    position: fixed; inset: 0; z-index: 1000;
    display: grid; grid-template-columns: 64px 1fr 64px; align-items: center;
    background: rgba(2, 3, 8, 0.94);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; max-height: 100vh; padding: 24px 0; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 4px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.lightbox figcaption { color: #d8dcef; font: 15px/1.5 var(--font-body, system-ui); text-align: center; max-width: 70ch; }
.lightbox-title { display: block; font-family: var(--font-head, inherit); font-weight: 600; color: #fff; margin-bottom: 2px; }
.lightbox button {
    background: none; border: 0; color: #fff; font-size: 44px; line-height: 1; cursor: pointer;
    opacity: 0.7; padding: 12px; transition: opacity 0.2s;
}
.lightbox button:hover, .lightbox button:focus-visible { opacity: 1; }
.lightbox-close { position: absolute; top: 12px; right: 16px; }
@media (max-width: 640px) {
    .lightbox { grid-template-columns: 0 1fr 0; }
    .lightbox-prev, .lightbox-next { position: absolute; bottom: 18px; }
    .lightbox-prev { left: 12px; }
    .lightbox-next { right: 12px; }
}

/* YouTube placeholder, the player loads only on click */
.yt-facade { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #000; border-radius: var(--radius, 12px); }
.yt-facade img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s ease, filter 0.6s ease; filter: saturate(0.9) brightness(0.85); }
.yt-facade:hover img { transform: scale(1.03); filter: saturate(1.05) brightness(0.95); }
.yt-facade iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-play { position: absolute; inset: 0; margin: auto; width: 76px; height: 54px; border: 0; background: none; cursor: pointer; }
.yt-play svg { width: 100%; height: 100%; }
.yt-play path:first-child { fill: rgba(10, 10, 16, 0.75); transition: fill 0.2s; }
.yt-facade:hover .yt-play path:first-child, .yt-play:focus-visible path:first-child { fill: #f00; }
.yt-play .yt-arrow { fill: #fff; }
.yt-consent {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px;
    font: 12px/1.4 var(--font-body, system-ui); color: rgba(255, 255, 255, 0.75);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    opacity: 0; transition: opacity 0.2s;
}
.yt-facade:hover .yt-consent, .yt-facade:focus-within .yt-consent { opacity: 1; }
.yt-playing .yt-consent { display: none; }

/* Documentation content */
.docs-content { font-family: var(--font-body); color: var(--fg); line-height: 1.7; font-size: 17px; }
.docs-content > *:first-child { margin-top: 0; }
.docs-content h1 { font-family: var(--font-head); font-size: clamp(32px, 4vw, 46px); line-height: 1.1; margin: 0 0 24px; letter-spacing: -0.02em; }
.docs-content h2 { font-family: var(--font-head); font-size: 26px; line-height: 1.25; margin: 56px 0 14px; letter-spacing: -0.01em; scroll-margin-top: 96px; }
.docs-content h3 { font-family: var(--font-head); font-size: 20px; margin: 36px 0 10px; scroll-margin-top: 96px; }
.docs-content h4 { font-size: 17px; margin: 28px 0 8px; scroll-margin-top: 96px; }
.docs-content p, .docs-content ul, .docs-content ol { margin: 0 0 16px; }
.docs-content li { margin: 4px 0; }
.docs-content li > ul, .docs-content li > ol { margin: 6px 0; }
.docs-content a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.docs-content a:hover { text-decoration-thickness: 2px; }
.docs-content a.docs-external::after { content: "↗"; font-size: 0.75em; margin-left: 2px; text-decoration: none; display: inline-block; }
.docs-content em { color: var(--fg-strong, var(--fg)); }
.docs-content strong { color: var(--fg-strong, var(--fg)); font-weight: 650; }
.docs-content code { font-family: var(--font-mono); font-size: 0.88em; background: var(--surface); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; }
.docs-content pre { background: var(--code-bg, var(--surface)); border: 1px solid var(--line); border-radius: var(--radius, 10px); padding: 16px 18px; overflow-x: auto; margin: 0 0 20px; }
.docs-content pre code { background: none; border: 0; padding: 0; font-size: 14px; line-height: 1.6; }
.docs-content hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.docs-anchor { margin-left: 10px; font-size: 0.7em; color: var(--muted) !important; text-decoration: none !important; opacity: 0; transition: opacity 0.15s; }
.docs-content h2:hover .docs-anchor, .docs-content h3:hover .docs-anchor, .docs-content h4:hover .docs-anchor { opacity: 1; }
.docs-figure { margin: 28px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.docs-figure img { max-width: 100%; height: auto; border-radius: 8px; }
.docs-figure figcaption { font-size: 14px; color: var(--muted); text-align: center; max-width: 60ch; }
.docs-note { margin: 22px 0; padding: 14px 18px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius, 10px) var(--radius, 10px) 0; }
.docs-note p:last-child { margin-bottom: 0; }
.docs-note--tip { border-left-color: var(--accent-2, var(--accent)); }
.docs-note--warning, .docs-note--important { border-left-color: #e8a33a; }
.docs-table { overflow-x: auto; margin: 0 0 22px; border: 1px solid var(--line); border-radius: var(--radius, 10px); }
.docs-table table { border-collapse: collapse; width: 100%; font-size: 15px; }
.docs-table th, .docs-table td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.docs-table th { font-weight: 600; background: var(--surface); }
.docs-table tr:last-child td { border-bottom: 0; }
.docs-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.docs-loading { opacity: 0.45; transition: opacity 0.2s; }
.docs-error h1 { font-size: 28px; }

/* Documentation navigation */
.docs-part { margin-bottom: 22px; }
.docs-part-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.docs-part-index { color: var(--accent); margin-right: 4px; }
.docs-part ol { list-style: none; margin: 0; padding: 0; }
.docs-part li > a { display: block; padding: 6px 10px; border-radius: 7px; color: var(--fg); text-decoration: none; font-size: 15px; }
.docs-part li > a:hover { background: var(--surface); }
.docs-part li.active > a { background: var(--surface); color: var(--accent); font-weight: 600; }
.docs-subnav { list-style: none; margin: 4px 0 8px 10px; padding: 0 0 0 10px; border-left: 1px solid var(--line); }
.docs-subnav a { display: block; padding: 3px 6px; font-size: 13.5px; color: var(--muted); text-decoration: none; }
.docs-subnav a:hover { color: var(--fg); }

/* Documentation search */
.docs-search { position: relative; }
.docs-search input {
    width: 100%; box-sizing: border-box; padding: 10px 14px 10px 36px; font: 15px var(--font-body);
    color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.docs-search input:focus { border-color: var(--accent); }
.docs-search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; stroke: var(--muted); }
.docs-search kbd { position: absolute; right: 10px; top: 50%; translate: 0 -50%; font: 11px var(--font-mono); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.docs-results {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50; max-height: min(70vh, 560px); overflow-y: auto;
    background: var(--popover, var(--bg)); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.docs-results[hidden] { display: none; }
.docs-hit { display: block; padding: 10px 14px; text-decoration: none; border-bottom: 1px solid var(--line); color: var(--fg); }
.docs-hit:last-child { border-bottom: 0; }
.docs-hit:hover, .docs-hit:focus { background: var(--surface); }
.docs-hit-where { display: block; font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.docs-hit-text { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.docs-hit mark { background: none; color: var(--fg); font-weight: 650; }
.docs-search-status { padding: 12px 14px; color: var(--muted); font-size: 14px; }

/* Previous / next */
.docs-pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); }
.docs-pager a { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius, 10px); text-decoration: none; color: var(--fg); min-width: 0; flex: 0 1 46%; }
.docs-pager a:hover { border-color: var(--accent); }
.docs-pager .docs-next { text-align: right; margin-left: auto; }
.docs-pager-label { font: 12px var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.docs-pager-title { font-weight: 600; }

/* Reveal on scroll. Hidden only once the script runs, so the content stays visible if a script fails to load */
[data-reveal] { transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }
.reveal-on [data-reveal]:not(.is-visible) { opacity: 0; transform: translateY(24px); }
@media (prefers-reduced-motion: reduce) {
    [data-reveal] { transition: none; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
