/* ==========================================================================
   Engineering product pages (package G): SwapLayer, GeoCanon, SessionArmor,
   Database Service, AZ UI Kit and its component pages.

   Page CSS sets layout only. Type comes from the roles in system.css
   (.hero-title, .section-title, .card-title, .lead ...); colours come from tokens and
   the page accent (var(--pillar-engineering), set by page_accent on <body>).
   This file loads before system.css, so every rule is scoped under `main` to win
   over equal-specificity base rules.
   ========================================================================== */

/* ---------- Package hero: copy on the left, the generated code window on the right from 1280px ---------- */
main .package-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
}
@media (min-width: 1280px) {
    main .package-hero-grid {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
        column-gap: clamp(2.5rem, 4vw, 4rem);
        align-items: start;
    }
}
main .package-hero-copy { min-width: 0; }
main .package-hero-copy .hero-actions { margin-bottom: 1.5rem; }
main .package-install { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem; margin-bottom: 2rem; }
main .package-install .install-chip { min-width: 0; }
main .package-hero-copy .hero-meta .eyebrow { margin-bottom: 0.75rem; }
main .package-hero-run { position: relative; min-width: 0; }

/* With JavaScript, only the panel of the selected tab shows from the first paint, so nothing shifts when
   effects.js later hides the other panels. The selected tab drives the panel, so this keeps holding after the
   tabs initialise. Without JavaScript (or without :has) every panel shows, one after another. */
@supports selector(:has(*)) {
    html.js main .package-hero-run .code-tabs-panel { display: none; }
    html.js main .package-hero-run .code-tabs:has(> .code-tabs-list > :nth-child(1)[aria-selected="true"]) > .code-tabs-panel:nth-child(2),
    html.js main .package-hero-run .code-tabs:has(> .code-tabs-list > :nth-child(2)[aria-selected="true"]) > .code-tabs-panel:nth-child(3),
    html.js main .package-hero-run .code-tabs:has(> .code-tabs-list > :nth-child(3)[aria-selected="true"]) > .code-tabs-panel:nth-child(4) { display: block; }
}

/* From 1280px (with JavaScript, so only one panel shows) the run column takes exactly the height of the
   row: it contributes no height of its own (contain: size) and stretches to it. The row is the copy
   column's height, with a floor so a short copy column cannot starve the window (the floor sits on the
   row, not on the run item, so the window never overflows the hero). The source part of the window
   scrolls inside it and always keeps room for about a dozen lines; a long output scrolls in its own
   bounded pane; the caption and the note stay whole. Tabs never move anything, and both columns start
   and end together. */
@media (min-width: 1280px) {
    html.js main .package-hero-grid { align-items: stretch; grid-template-rows: minmax(46rem, auto); }
    html.js main .package-hero-run { display: flex; flex-direction: column; contain: size; }
    html.js main .package-hero-run .code-tabs { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
    html.js main .package-hero-run .code-tabs-list { flex: none; align-self: flex-start; }
    html.js main .package-hero-run .code-tabs-panel { flex: 1 1 auto; flex-direction: column; min-height: 0; }
    @supports not selector(:has(*)) {
        html.js main .package-hero-run .code-tabs-panel:not([hidden]) { display: flex; }
    }
    @supports selector(:has(*)) {
        html.js main .package-hero-run .code-tabs:has(> .code-tabs-list > :nth-child(1)[aria-selected="true"]) > .code-tabs-panel:nth-child(2),
        html.js main .package-hero-run .code-tabs:has(> .code-tabs-list > :nth-child(2)[aria-selected="true"]) > .code-tabs-panel:nth-child(3),
        html.js main .package-hero-run .code-tabs:has(> .code-tabs-list > :nth-child(3)[aria-selected="true"]) > .code-tabs-panel:nth-child(4) { display: flex; }
    }
    html.js main .package-hero-run .code-tabs-panel > .code-window { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
    html.js main .package-hero-run .code-window > :not(.code-window-code) { flex: none; }
    html.js main .package-hero-run .code-window > .code-window-code {
        flex: 1 1 auto;
        min-height: 15rem;
        overflow: auto;
        /* Scroll shadow: a soft edge at the bottom while more source is below; the cover scrolls with the
           content and hides it at the end. Backgrounds only, nothing animates. */
        background:
            linear-gradient(to top, var(--surface-3) 45%, rgba(23, 24, 27, 0)) center bottom / 100% 1.75rem no-repeat local,
            linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0)) center bottom / 100% 1rem no-repeat scroll,
            var(--surface-3);
    }
    /* A long output (the audit event JSON) scrolls in its own pane instead of taking the source's room.
       The pre is already focusable (tabindex="0", role="region"), so it stays keyboard-scrollable; same
       scroll shadow as the source, on the well colour. */
    html.js main .package-hero-run .code-window-output {
        max-height: 12rem;
        overflow: auto;
        background:
            linear-gradient(to top, var(--well) 45%, rgba(6, 6, 7, 0)) center bottom / 100% 1.75rem no-repeat local,
            linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0)) center bottom / 100% 1rem no-repeat scroll,
            var(--well);
    }
    html.js main .package-hero-run .package-run-note { flex: none; }
}

main .package-run-note {
    max-width: 60ch;
    margin: 0.875rem 0 0;
    font: 400 var(--fs-meta)/1.5 var(--font-sans);
    color: var(--ink-4);
}

/* Status line under a lead (planned or pre-release products). */
main .package-status-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin: -0.75rem 0 2rem;
    font: 400 var(--fs-small)/1.5 var(--font-sans);
    color: var(--ink-3);
}
main .package-status-line a { color: var(--ink-1); text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 0.25em; }
main .package-status-line a:hover { text-decoration-color: currentColor; }

/* ---------- Chapters ---------- */
main .pkg-head { max-width: var(--measure-head); margin-bottom: var(--space-head); }
main .pkg-head > .lead { margin-bottom: 0; }
main .pkg-head > .eyebrow + .section-title { margin-top: 0; }
main .pkg-nowrap { white-space: nowrap; }

/* Descriptive copy inside cards and columns. */
main .package-copy {
    font-size: var(--fs-small);
    line-height: 1.6;
    color: var(--ink-3);
}
main .package-copy + .package-copy { margin-top: 0.75rem; }
main .package-copy--muted { color: var(--ink-4); }

/* Grids. */
main .pkg-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--grid-gap);
}
main .pkg-grid + .pkg-grid,
main .pkg-grid + .pkg-panel,
main .pkg-compare + .pkg-grid { margin-top: var(--grid-gap); }
@media (min-width: 768px) {
    main :is(.pkg-grid--2, .pkg-grid--3, .pkg-grid--4) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    main .pkg-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    main .pkg-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Static cards on the surface ladder. Link cards get their edge and lift from effects.css. */
main .pkg-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: clamp(1.25rem, 1rem + 1vw, 1.75rem);
}
main .pkg-card > .card-title:last-child,
main .pkg-card > p:last-child { margin-bottom: 0; }
main .pkg-card .eyebrow { margin-bottom: 0.625rem; }
main .pkg-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
main .pkg-card-head .pkg-icon { margin-bottom: 0; }
main .pkg-card-foot { margin-top: auto; padding-top: 1.25rem; }
main .pkg-card-foot .text-link { min-height: 0; }
main a.pkg-card { color: inherit; text-decoration: none; }

/* Icon tile: the accent chip with the icon in the page accent. */
main .pkg-icon {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-sm);
    color: var(--accent);
}
main .pkg-icon svg { width: 1.375rem; height: 1.375rem; }

/* Bulleted points under a card's copy. */
main .pkg-points {
    display: grid;
    gap: 0.625rem;
    margin: 1.25rem 0 0;
    padding: 1.25rem 0 0;
    border-top: 1px solid var(--line-1);
    list-style: none;
}
main .pkg-points li {
    position: relative;
    padding-left: 1.125rem;
    font: 400 var(--fs-ui)/1.55 var(--font-sans);
    color: var(--ink-3);
}
main .pkg-points li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.62em;
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 80%, transparent);
}
main .pkg-points--plain { margin-top: 0; padding-top: 0; border-top: 0; }
@media (min-width: 768px) {
    main .pkg-points--2col { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; }
}

/* Wide summary panel under a grid. */
main .pkg-panel { padding: clamp(1.5rem, 1rem + 2vw, 2.25rem); }
main .pkg-panel > .card-title { margin-bottom: 1rem; }

/* ---------- Before / after comparisons (illustrative code) ---------- */
main .pkg-compare {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem var(--grid-gap);
}
@media (min-width: 1024px) {
    main .pkg-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
main .pkg-compare-col { display: flex; flex-direction: column; min-width: 0; }
main .pkg-compare-col--before { --tone: #f87171; }
main .pkg-compare-col--after { --tone: #4ade80; }
main .pkg-compare-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
main .pkg-compare-head .card-title { margin: 0; color: var(--tone); }
main .pkg-verdict-icon {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent);
    border-radius: 50%;
    background: color-mix(in srgb, var(--tone) 10%, transparent);
    color: var(--tone);
}
main .pkg-verdict-icon svg { width: 1.125rem; height: 1.125rem; }
main .pkg-compare-col > .package-copy { margin: 0 0 1.25rem; }
main .pkg-compare-col > .code-window { flex: 1 1 auto; }

/* ---------- Developer experience: features beside an example window ---------- */
main .pkg-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem;
}
@media (min-width: 1024px) {
    main .pkg-split {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
        column-gap: clamp(2.5rem, 5vw, 4.5rem);
        align-items: start;
    }
}
main .pkg-split > * { min-width: 0; }
main .pkg-features { display: grid; gap: 1.5rem; margin: 0; padding: 0; list-style: none; }
main .pkg-feature { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem; align-items: start; }
main .pkg-feature .pkg-icon { margin: 0; }
main .pkg-feature .card-title { margin-bottom: 0.375rem; }
main .pkg-feature .package-copy { margin: 0; }

/* ---------- Head beside content (installation steps, component examples): the head stays in view from 1024px ---------- */
@media (min-width: 1024px) {
    main .pkg-aside-layout {
        display: grid;
        grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
        column-gap: clamp(2.5rem, 5vw, 4.5rem);
        align-items: start;
    }
    main .pkg-aside-layout > .pkg-head { position: sticky; top: calc(var(--anchor-offset) + 1.5rem); margin-bottom: 0; }
    main .pkg-aside-layout > .pkg-steps { max-width: none; }
}
main .pkg-steps {
    display: grid;
    gap: 2.5rem;
    max-width: 56rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
main .pkg-step { min-width: 0; }
main .pkg-step > .card-title { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 1rem; }
main .pkg-step > .install-chip { margin: 0; }

/* Example windows that were not run: a file name and an "Example" label, no traffic-light dots. */
main .code-window-meta--example { color: var(--ink-3); }

/* ---------- Small code snippets inside cards (wells, scroll sideways when long) ---------- */
main .pkg-code {
    margin: 1.25rem 0 0;
    padding: 0.875rem 1rem;
    overflow-x: auto;
    border: 1px solid var(--line-1);
    border-radius: var(--radius-sm);
    background: var(--well);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
    font: 400 var(--fs-code)/var(--lh-code) var(--font-mono);
    color: #e4e4e7;
    white-space: pre;
    tab-size: 4;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
    font-variant-ligatures: none;
    font-feature-settings: 'calt' 0;
}
main .pkg-code--wrap { white-space: pre-wrap; overflow-wrap: break-word; }
main .pkg-code code { font: inherit; padding: 0; background: none; border-radius: 0; }
main .pkg-code:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
main .pkg-code .pkg-attr { color: color-mix(in srgb, var(--accent) 70%, #fff); }
main .pkg-code .pg-c { color: #8b8b95; font-style: italic; }
main .pkg-code .pg-s { color: #86efac; }
main .pkg-code .pg-k { color: #c4b5fd; }
main .pkg-code .pg-nf { color: #7dd3fc; }
@media (max-width: 639px) {
    main .pkg-code { font-size: 0.78125rem; }
}
/* Attribute names in example markup inside code windows. */
main .code-window .pkg-attr { color: color-mix(in srgb, var(--accent) 70%, #fff); }

/* ---------- Database Service ---------- */
main .pkg-plain-list { margin: 0; padding: 0; list-style: none; }
main .pkg-card .eyebrow .index { margin-right: 0.125rem; }

/* Short lists with a leading icon in the page accent. */
main .pkg-icon-list { display: grid; gap: 0.625rem; margin: 1.25rem 0 0; padding: 0; list-style: none; }
main .pkg-icon-list li { display: flex; align-items: flex-start; gap: 0.75rem; font: 400 var(--fs-ui)/1.5 var(--font-sans); color: var(--ink-3); }
main .pkg-icon-list svg { flex: none; width: 1.125rem; height: 1.125rem; margin-top: 0.125rem; color: var(--accent); }
main .pkg-icon-list strong { font-weight: 600; color: var(--ink-1); }

/* An illustrative window at the foot of a card. */
main .pkg-card-code { margin-top: 1.5rem; box-shadow: none; }
main .pkg-card-code .code-window-code { padding: 1rem 1.125rem; }

/* "Designed to replace": a neutral ruled list, not red crosses. */
main .pkg-minus-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: var(--grid-gap);
    margin: 0;
    padding: 0;
    list-style: none;
}
@media (min-width: 768px) {
    main .pkg-minus-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
main .pkg-minus-list li {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr);
    gap: 0.5rem;
    padding: 1.125rem 0;
    border-top: 1px solid var(--line-2);
}
main .pkg-minus { font: 500 1.125rem/1.35 var(--font-sans); color: var(--ink-4); }
main .pkg-minus-list strong { display: block; margin-bottom: 0.25rem; font: 600 var(--fs-body)/1.4 var(--font-sans); color: var(--ink-2); }
main .pkg-minus-list p { margin: 0; font: 400 var(--fs-small)/1.6 var(--font-sans); color: var(--ink-3); }

/* tenant_abc ≠ tenant_xyz */
main .pkg-tenants { display: flex; flex-wrap: wrap; align-items: center; gap: 0.625rem; margin: 1.25rem 0 0; color: var(--ink-4); }
main .pkg-tenants code { padding: 0.25rem 0.5rem; color: var(--ink-2); }

/* Request path through the planned security layers. */
main .pkg-panel-text { margin: 0 0 1rem; }
main .pkg-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 0.625rem 2rem; margin: 0; padding: 0; list-style: none; counter-reset: pkg-flow; }
main .pkg-flow li {
    position: relative;
    counter-increment: pkg-flow;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.25rem;
    padding: 0 0.875rem 0 0.75rem;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line-2));
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    font: 500 var(--fs-ui)/1.2 var(--font-sans);
    color: var(--ink-1);
}
main .pkg-flow li::before {
    content: counter(pkg-flow, decimal-leading-zero);
    font: 500 0.6875rem/1 var(--font-mono);
    letter-spacing: var(--tr-mono);
    color: var(--accent);
}
/* The arrow sits in the gap between two steps (decorative; the list order carries the sequence). */
main .pkg-flow li:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -1.5rem;
    width: 1rem;
    height: 1rem;
    margin-top: -0.5rem;
    background: var(--ink-4);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14m-5-5 5 5-5 5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14m-5-5 5 5-5 5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* CTA panel footnote tags. */
main .pkg-cta-tags { justify-content: center; margin-top: 2rem; }

/* ---------- AZ UI Kit ---------- */
/* Group labels inside the component library: documented, in development, planned. */
main .pkg-group-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1rem;
    font: 500 var(--fs-ui)/1.4 var(--font-sans);
    color: var(--ink-2);
}
main * + .pkg-group-label { margin-top: clamp(2.5rem, 2rem + 2vw, 3.5rem); }

/* Snippets and tags inside documented component cards. */
main .pkg-card > .package-copy + .pkg-code { margin-top: 1rem; }
main .pkg-card-tags { margin-top: 1rem; }
main .pkg-code--flush { margin-top: 0; }

/* Components in development: a plain three-column list, ruled, no cards. */
main .pkg-planned {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: var(--grid-gap);
    margin: 0;
    padding: 0;
    list-style: none;
}
@media (min-width: 768px) {
    main .pkg-planned { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    main .pkg-planned { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
main .pkg-planned li { display: grid; align-content: start; gap: 0.25rem; padding: 1rem 0 1.125rem; border-top: 1px solid var(--line-2); }
main .pkg-planned strong { font: 600 var(--fs-body)/1.4 var(--font-sans); color: var(--ink-1); }
main .pkg-planned span { font: 400 var(--fs-ui)/1.55 var(--font-sans); color: var(--ink-3); }
main .pkg-also { max-width: var(--measure); margin: 0; }

/* A code token shown as a hero stat (the attribute API): mono, no tabular spacing, no chip. */
main .hero-stat .pkg-stat-code {
    padding: 0;
    border-radius: 0;
    background: none;
    font: 500 0.8em/1.1 var(--font-mono);
    letter-spacing: -0.02em;
    font-variant-numeric: normal;
    color: inherit;
}
