/* Chrome for the catalogue pages themselves — not part of the design system.
   Everything a reader is meant to copy is styled by ../css/DR.Simple_UI.css.
   This file may only style .cat-* and .ex-* selectors; a test enforces that, so
   the examples always render exactly as an app would get them.

   Every colour here is a library token, so the docs follow the theme toggles. */

/* ── Sidebar drawer ─────────────────────────────────────────────────────────
   display:contents keeps the .sidebar a direct flex child of .layout on the
   desktop, so the library's own frame layout applies untouched. */
.cat-drawer { display: contents; }

.cat-scrim { display: none; }

/* ── Topbar additions ─────────────────────────────────────────────────────── */
.cat-burger { display: none; }

.cat-topbrand {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 0 4px 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
    white-space: nowrap;
}
.cat-topbrand:hover { text-decoration: none; }
.cat-topbrand img { border-radius: 6px; }

.cat-toggle[aria-pressed="true"] {
    color: var(--brand-text);
    background: var(--brand-tint);
}

/* ── Content column ───────────────────────────────────────────────────────── */
.cat-main {
    max-width: 1100px;
    margin-inline: auto;
    padding-bottom: 64px;
}

.cat-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 6px; }
.cat-head h1 { flex: 1; min-width: 0; }

.cat-tier {
    flex-shrink: 0;
    margin-top: 4px;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    white-space: nowrap;
}

.cat-lede { color: var(--muted); margin: 0 0 8px; max-width: 80ch; line-height: 1.65; }

.cat-main h2 { scroll-margin-top: 16px; }

.cat-anchor {
    margin-left: 8px;
    font-size: 13px;
    color: var(--muted);
    opacity: 0;
    transition: opacity 0.12s;
}
.cat-main h2:hover .cat-anchor,
.cat-anchor:focus-visible { opacity: 1; text-decoration: none; }

/* Block layout, NOT flex. A note's content is ordinary inline prose containing
   <code> spans; as a flex container every one of those spans and every text run
   between them became its own column. A leading icon is floated instead, which
   gives the hanging indent without making the text a flex item. */
.cat-note {
    display: block;
    margin: 16px 0;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    font-size: 13px;
    color: var(--fg-soft);
    line-height: 1.65;
}
.cat-note::after { content: ""; display: block; clear: both; }
.cat-note > i:first-child {
    float: left;
    margin: 2px 10px 0 0;
    font-size: 16px;
    color: var(--muted);
}
.cat-note code { font-size: 12px; }
/* Element selector, not the library's .table class — a note is chrome, never an
   example, so spacing it here cannot change how an example renders. */
.cat-note table { margin-top: 6px; }

/* ── Hosted-site bar ──────────────────────────────────────────────────────────
   A slim strip directly under the header rather than a block inside the content
   column, so it reads as chrome about the site rather than as page content. */
.cat-hostedbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 20px;
    border-bottom: 1px solid var(--warn-border);
    background: var(--warn-bg);
    color: var(--fg-soft);
    font-size: 12.5px;
    line-height: 1.5;
}
.cat-hostedbar > i { flex-shrink: 0; font-size: 15px; color: var(--warn-fg); }
.cat-hostedbar strong { color: var(--warn-fg); font-weight: 600; }
.cat-hostedbar a { color: var(--warn-fg); text-decoration: underline; }
.cat-hostedbar code { font-size: 11.5px; }
.cat-hostedbar-long { color: var(--muted); }

/* Visible to screen readers only — used for the "opens in a new tab" hint. */
.cat-sr {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ── Hero (overview page) ─────────────────────────────────────────────────── */
.cat-hero {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 8px 0 4px;
    flex-wrap: wrap;
}
.cat-hero-logo {
    width: 76px; height: 76px;
    border-radius: 18px;
    flex-shrink: 0;
    box-shadow: var(--shadow-float);
}
.cat-hero-text { flex: 1; min-width: 260px; }
.cat-hero-text h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: -0.01em; }
.cat-hero-text p {
    margin: 0;
    font-size: 15px;
    color: var(--muted);
    line-height: 1.6;
}
.cat-hero-rule {
    height: 3px;
    width: 120px;
    margin: 18px 0 4px;
    border-radius: 999px;
    background: var(--brand);
}

.cat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 4px; }

.cat-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 26px 0 8px;
}
.cat-fact {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
}
.cat-fact strong {
    display: block;
    font-size: 20px;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
.cat-fact span { font-size: 12px; color: var(--muted); }

/* ── Overview tiles ───────────────────────────────────────────────────────── */
.cat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 26px;
}

/* .cat-tile sits on a library .card, so border, background and radius come from
   the design system; only the layout and the hover lift are added here. */
.cat-tile {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    color: inherit;
    transition: border-color 0.12s, transform 0.12s, background 0.12s;
}
.cat-tile:hover {
    text-decoration: none;
    transform: translateY(-2px);
    border-color: var(--brand);
    background: var(--bg-elevated);
}
.cat-tile:focus-visible {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-ring-soft);
}
.cat-tile-ic {
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    background: var(--brand-tint);
    color: var(--brand-text);
}
.cat-tile-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cat-tile-text strong { font-size: 14px; color: var(--fg); }
.cat-tile-text span { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.cat-tile-go {
    flex-shrink: 0;
    align-self: center;
    font-size: 17px;
    color: var(--muted);
    transition: transform 0.12s, color 0.12s;
}
.cat-tile:hover .cat-tile-go { transform: translateX(3px); color: var(--brand-text); }

/* ── Examples ─────────────────────────────────────────────────────────────── */
.cat-ex { margin: 0 0 32px; }
.cat-ex > h2 { margin: 0 0 4px; font-size: 16px; }
.cat-ex > p {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--muted);
    max-width: 84ch;
    line-height: 1.65;
}

.ex-demo {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    background: var(--bg);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
    overflow-x: auto;
}
.ex-demo--block { display: block; }
.ex-demo--pad { padding: 32px; }

.ex-codewrap { position: relative; }
.ex-codewrap--only .ex-code { border-top: 1px solid var(--border); border-radius: 8px; }

.ex-code {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: var(--bg-elevated);
}
.ex-code code {
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--fg-soft);
    white-space: pre;
}

.ex-copy {
    position: absolute;
    top: 8px; right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font: inherit;
    font-size: 11px;
    cursor: pointer;
    padding: 4px 9px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--muted);
    opacity: 0;
    transition: opacity 0.12s, color 0.12s, border-color 0.12s;
}
.ex-codewrap:hover .ex-copy,
.ex-copy:focus-visible { opacity: 1; }
.ex-copy:hover { color: var(--fg); border-color: var(--border-strong); }

/* ── Token swatches ──────────────────────────────────────────────────────── */
.cat-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
    margin-bottom: 26px;
}
.cat-swatch {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    font-size: 12px;
    min-width: 0;
}
.cat-chip {
    width: 30px; height: 30px;
    border-radius: 5px;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.cat-swatch-name { font-family: var(--font-mono); font-size: 11.5px; word-break: break-all; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.cat-footer {
    margin-top: 48px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.7;
}
.cat-footer p { margin: 0 0 4px; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .cat-burger { display: inline-flex; }
    .cat-collapse { display: none; }
    .cat-topbrand { display: flex; }

    /* The sidebar becomes an off-canvas drawer. z-index follows the shared
       chain: backdrop 500, drawer just above it. */
    .cat-drawer {
        display: block;
        position: fixed;
        top: 0; bottom: 0; left: 0;
        z-index: 510;
        transform: translateX(-100%);
        transition: transform 0.18s ease;
    }
    .cat-drawer > * { height: 100%; }
    body.cat-nav-open .cat-drawer { transform: none; }

    /* Shown only while the drawer is open. Driven by the state class rather than
       the `hidden` attribute: an author `display: block` outranks the UA
       [hidden] rule regardless of specificity, which would leave a full-viewport
       backdrop swallowing every click on the page. */
    body.cat-nav-open .cat-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 500;
        border: none;
        padding: 0;
        background: var(--backdrop);
        cursor: pointer;
    }

    .cat-hero-logo { width: 60px; height: 60px; border-radius: 14px; }
    .cat-hero-text h1 { font-size: 24px; }
    .cat-hero-text { min-width: 0; }
    .cat-tiles { grid-template-columns: 1fr; }
    .cat-main { padding-bottom: 48px; }
    .ex-demo { padding: 14px; }
    /* Touch has no hover, so the copy button has to be permanently visible. */
    .ex-copy { opacity: 1; }

    .cat-hostedbar { padding: 7px 14px; }
    .cat-hostedbar-long { display: none; }
}

@media (max-width: 560px) {
    .cat-head { flex-direction: column; gap: 6px; }
    .cat-tier { margin-top: 0; }
    .cat-facts { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .cat-drawer, .cat-tile, .cat-tile-go, .ex-copy, .cat-anchor { transition: none; }
    .cat-tile:hover { transform: none; }
}
