/* Deep-dive layout (MAR-1174): the knowledge graph in a right rail, and
   "On this page" as a pill strip above the sections.

   functions/deep-dives/[[slug]].js rewrites each static deep dive into
     <main><div class="ddr-cols"><div class="ddr-main">header, strip, sections</div>
           <aside class="ddr-rail"><div id="guide-kg"></div></aside></div></main>
   js/location-knowledge-graph.js fills #guide-kg and leaves it hidden when
   the graph has nothing, so the rail only takes a column once it has cards.
   The rail styles mirror the right strip on /resources/<id>/ figure pages
   (resources/chart.html, html.is-kgrail). */

/* ── "On this page" pill strip (every width) ── */
main .guide-toc.ddr-strip {
    position: sticky; top: 64px; left: auto; z-index: 20;
    display: flex; align-items: center; gap: 0;
    width: auto; max-width: var(--content-max);
    margin: 0 auto; padding: 10px calc(var(--page-pad) + var(--inner-pad)) 0;
    background: var(--bg); border: 0; border-radius: 0; box-shadow: none;
    flex-direction: column; align-items: stretch;
}
main .guide-toc.ddr-strip.toc-hidden { opacity: 1; visibility: visible; pointer-events: auto; }
main .guide-toc.ddr-strip .guide-toc-label { display: none; }
main .guide-toc.ddr-strip .guide-toc-list {
    display: flex; flex-wrap: nowrap; gap: 6px;
    overflow-x: auto; overflow-y: hidden; padding: 0 0 10px;
    scrollbar-width: none;
}
main .guide-toc.ddr-strip .guide-toc-list::-webkit-scrollbar { display: none; }
/* More pills off to the right: fade the edge (js/deep-dive-rail.js sets .is-more). */
main .guide-toc.ddr-strip .guide-toc-list.is-more { -webkit-mask-image: linear-gradient(to right, black calc(100% - 48px), transparent); mask-image: linear-gradient(to right, black calc(100% - 48px), transparent); } /* theme-guardrail-allow: mask alpha, not a paint colour */
main .guide-toc.ddr-strip .guide-toc-list li { flex: 0 0 auto; }
main .guide-toc.ddr-strip .guide-toc-list a {
    display: inline-block; padding: 6px 13px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--card);
    font-size: 13px; line-height: 1.3; white-space: nowrap; color: var(--muted);
}
main .guide-toc.ddr-strip .guide-toc-list a:hover { color: var(--b-700); border-color: var(--b-100); background: var(--b-25); }
main .guide-toc.ddr-strip .guide-toc-list a.active { color: var(--b-700); border-color: var(--b-100); background: var(--b-25); font-weight: 600; }
main .guide-toc.ddr-strip .guide-toc-progress { margin: 0; border-radius: 0; height: 2px; }
body.capturing-png main .guide-toc.ddr-strip { display: none; }

/* ── Two columns once the graph has content ── */
@media (min-width: 1100px) {
    html:not(.is-embed) .ddr-cols:has(#kgSection:not([hidden])) {
        display: grid; grid-template-columns: minmax(0, 1fr) 320px; column-gap: 2.5rem;
        align-items: start;
        max-width: calc(var(--content-max) + 320px + 2.5rem); margin: 0 auto;
        padding: 0 var(--page-pad);
    }
    /* The page column already carries the outer gutter. */
    html:not(.is-embed) .ddr-cols:has(#kgSection:not([hidden])) .ddr-main { --page-pad: 0px; min-width: 0; }
    .ddr-rail { position: sticky; top: var(--ddr-top, 84px); padding-top: 40px; }

    .ddr-rail .kg-guide { max-width: none; margin: 0; padding: 0; border-top: 0; }
    .ddr-rail .kg-head { margin-bottom: 0.9rem; }
    .ddr-rail .kg-sub { display: none; }
    .ddr-rail .kg-lanes { border-left: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.9rem; }
    .ddr-rail .kg-lane { padding: 0.95rem 1rem 1rem; background: var(--surface-card); border: 1px solid var(--border-light); border-radius: 14px; }
    .ddr-rail .kg-lane:last-child { padding-bottom: 1rem; }
    .ddr-rail .kg-lane-head { margin-bottom: 0.7rem; align-items: baseline; flex-direction: row; }
    .ddr-rail .kg-lane-head::before { display: none; }
    .ddr-rail .kg-lane-head h3 { font-size: 0.95rem; font-weight: 700; letter-spacing: 0; }
    .ddr-rail .related-all { font-size: 0.78rem; }
    .ddr-rail .related-grid { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
    .ddr-rail .rc-card { border-radius: 10px; }
    .ddr-rail .rc-card:hover { transform: none; }
    .ddr-rail .rc-preview, .ddr-rail .rc-deals-list { height: 92px; }
    .ddr-rail .rc-preview iframe { width: 640%; height: 640%; transform: scale(0.15625); }
    .ddr-rail .rc-title { padding: 0.5rem 0.6rem 0; margin-bottom: 0.55rem; font-size: 0.78rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .ddr-rail .rc-preview .grr-list-preview { zoom: 0.66; }
    .ddr-rail .kg-more { margin-top: 0.7rem; font-size: 0.78rem; }
}
/* Narrow screens: the graph sits under the sections, as before. */
@media (max-width: 1099px) {
    .ddr-rail .kg-guide { margin: 0 auto; }
}
