/* =========================================================
   PortalCMS — Content theme  (Blog at /updates + Docs at /docs)

   One small layer on top of docs.css. It is switched on by the
   attributes ContentPages::themeAttrs() prints on the .docs-scope /
   .posts-scope wrappers, set from Design > Blog & Docs Pages > Theme:

       data-pcms-theme    clean | soft | outline | bold
       data-pcms-mode     light | dark          (absent = follow the site)
       data-pcms-radius   sharp | rounded | round   (absent = theme's own)
       data-pcms-font     sans | serif | mono       (absent = site font)
       data-pcms-spacing  compact | roomy           (absent = normal)
       data-pcms-tint     cool | warm | accent      (absent = neutral greys)
       data-pcms-hero     grid | mesh | plain       (absent = glow + dots)
       data-pcms-cards    bordered | raised | glass | tinted  (absent = theme)
       data-pcms-hover    glow | border | none      (absent = lift)
       data-pcms-icon     circle | gradient | plain (absent = tile; docs)
       data-pcms-cols     2 | 3 | 4                 (absent = auto; docs home)
       --pcms-theme-accent                          (absent = brand colour)

   No attribute, no effect: the "Legacy" choice in the admin leaves the
   wrapper bare and the old looks in docs.css take over exactly as before.

   ---- Making your own theme ----
   A theme is nothing but the --t-* variables in section 2. Copy one
   block, give it a new name, change the values, and add the name to
   ContentPages::THEMES. Everything in section 5 reads these variables,
   so a new theme needs no component rules at all.

   A colour picked under "Fine-tune colours" always beats the theme:
   every mapping in section 4 reads the admin's --pcms-* value first and
   only falls back to the theme's.
   ========================================================= */


/* ---------------------------------------------------------
   1. Defaults every theme starts from — "follow the site"
   --------------------------------------------------------- */
[data-pcms-theme] {
    --t-accent:   var(--pcms-theme-accent, var(--brand-color, #3B82F6));
    --t-bg:       transparent;
    --t-surface:  var(--bg-card, #1e1e32);
    --t-raised:   color-mix(in srgb, var(--bg-card, #1e1e32) 94%, var(--text-light, #e2e2ef));
    --t-code:     var(--bg-darker, #12121f);
    --t-code-ink: #e6e8ef;
    --t-line:     var(--border-color, #2d2d44);
    --t-ink:      var(--text-light, #e2e2ef);
    --t-ink-2:    color-mix(in srgb, var(--text-light, #e2e2ef) 82%, var(--text-muted, #9595aa));
    --t-ink-3:    var(--text-muted, #9595aa);
    --t-shadow:   0 0 0;
    --t-shadow-a: 0.32;

    --t-heading-weight: 700;
    --t-tracking: -0.022em;
    --t-hero-size: clamp(2.3rem, 5vw, 3.5rem);
}


/* ---------------------------------------------------------
   2. Themes — the character: corners, depth, weight
   --------------------------------------------------------- */

/* Clean — hairline borders, quiet surfaces, soft lift on hover. */
[data-pcms-theme="clean"] {
    --doc-r-xs: 6px; --doc-r-sm: 8px; --doc-r-md: 12px; --doc-r-lg: 14px;
}

/* Soft — filled cards with no outline, big friendly corners. */
[data-pcms-theme="soft"] {
    --doc-r-xs: 10px; --doc-r-sm: 12px; --doc-r-md: 18px; --doc-r-lg: 22px;
    --t-shadow-a: 0.22;
    --t-card-line: transparent;
}

/* Outline — nothing filled, nothing floating. Pure structure. */
[data-pcms-theme="outline"] {
    --doc-r-xs: 4px; --doc-r-sm: 6px; --doc-r-md: 8px; --doc-r-lg: 10px;
    --t-card: transparent;
    --t-shadow-a: 0;
    --t-heading-weight: 650;
}

/* Bold — big display type, an accent-lit header, heavier weight. */
[data-pcms-theme="bold"] {
    --doc-r-xs: 8px; --doc-r-sm: 10px; --doc-r-md: 14px; --doc-r-lg: 18px;
    --t-heading-weight: 800;
    --t-tracking: -0.035em;
    --t-hero-size: clamp(2.8rem, 7vw, 4.6rem);
}


/* ---------------------------------------------------------
   3. Modes — light and dark palettes
   Literal values only: these also remap the SITE variables inside the
   wrapper, so anything in there that reads --text-light or --bg-card
   (galleries, embeds, builder blocks) flips with the section.
   --------------------------------------------------------- */
[data-pcms-theme][data-pcms-mode="light"] {
    color-scheme: light;
    --t-bg:       #ffffff;
    --t-surface:  #ffffff;
    --t-raised:   #f6f7f9;
    --t-code:     #0f1219;
    --t-line:     #e3e6eb;
    --t-ink:      #0d1220;
    --t-ink-2:    #374151;
    --t-ink-3:    #6b7280;
    --t-shadow:   16 24 40;
    --t-shadow-a: 0.08;

    --text-light: #0d1220;
    --text-muted: #6b7280;
    --bg-card:    #ffffff;
    --bg-dark:    #ffffff;
    --bg-darker:  #f6f7f9;
    --border-color: #e3e6eb;
}

[data-pcms-theme][data-pcms-mode="dark"] {
    color-scheme: dark;
    --t-bg:       #0b0d12;
    --t-surface:  #12151c;
    --t-raised:   #181c25;
    --t-code:     #0d1016;
    --t-line:     #232834;
    --t-ink:      #f3f4f6;
    --t-ink-2:    #c5c9d3;
    --t-ink-3:    #8a909e;
    --t-shadow:   0 0 0;
    --t-shadow-a: 0.45;

    --text-light: #f3f4f6;
    --text-muted: #8a909e;
    --bg-card:    #12151c;
    --bg-dark:    #0b0d12;
    --bg-darker:  #0d1016;
    --border-color: #232834;
}

/* Outline has no surfaces in any mode, and Soft keeps no card borders. */
[data-pcms-theme="outline"][data-pcms-mode] { --t-card: transparent; }
[data-pcms-theme="soft"][data-pcms-mode="light"] { --t-card: #f4f5f8; --t-shadow-a: 0.06; }


/* ---------------------------------------------------------
   4. Map the theme onto the docs.css design tokens
   --------------------------------------------------------- */
[data-pcms-theme] {
    --doc-radius: var(--doc-r-md);
    --doc-heading-weight: var(--t-heading-weight);
    --doc-heading-tracking: var(--t-tracking);
    --doc-shadow-sm: 0 1px 2px rgb(var(--t-shadow) / calc(var(--t-shadow-a) * 0.6));
    --doc-shadow-md: 0 1px 2px rgb(var(--t-shadow) / calc(var(--t-shadow-a) * 0.5)),
                     0 8px 24px -8px rgb(var(--t-shadow) / var(--t-shadow-a));
    --doc-shadow-lg: 0 2px 4px rgb(var(--t-shadow) / calc(var(--t-shadow-a) * 0.5)),
                     0 22px 48px -16px rgb(var(--t-shadow) / calc(var(--t-shadow-a) * 1.4));
    color: var(--doc-ink-2);
}

.docs-scope[data-pcms-theme] {
    --doc-accent:      var(--pcms-doc-accent, var(--t-accent));
    --doc-surface:     var(--pcms-doc-surface, var(--t-card, var(--t-surface)));
    --doc-surface-2:   var(--t-raised);
    --doc-surface-3:   var(--pcms-doc-code-bg, var(--t-code));
    --doc-line-strong: var(--pcms-doc-line, var(--t-line));
    --doc-line:        color-mix(in srgb, var(--doc-line-strong) 78%, transparent);
    --doc-ink:         var(--pcms-doc-heading, var(--t-ink));
    --doc-ink-2:       var(--pcms-doc-text, var(--t-ink-2));
    --doc-ink-3:       var(--pcms-doc-muted, var(--t-ink-3));
    --doc-code-ink:    var(--pcms-doc-code-text, var(--t-code-ink));
    --doc-icon-bg:     var(--pcms-doc-icon-bg, color-mix(in srgb, var(--doc-accent) 13%, transparent));
    background: var(--pcms-doc-bg, var(--t-bg));
}

.posts-scope[data-pcms-theme] {
    --doc-accent:      var(--pcms-post-accent, var(--t-accent));
    --doc-surface:     var(--pcms-post-surface, var(--t-card, var(--t-surface)));
    --doc-surface-2:   var(--t-raised);
    --doc-surface-3:   var(--pcms-doc-code-bg, var(--t-code));
    --doc-line-strong: var(--pcms-post-line, var(--t-line));
    --doc-line:        color-mix(in srgb, var(--doc-line-strong) 78%, transparent);
    --doc-ink:         var(--pcms-post-heading, var(--t-ink));
    --doc-ink-2:       var(--pcms-post-text, var(--t-ink-2));
    --doc-ink-3:       var(--pcms-post-muted, var(--t-ink-3));
    --doc-link:        var(--pcms-post-link, var(--doc-accent));
    --doc-code-ink:    var(--pcms-doc-code-text, var(--t-code-ink));
    --doc-accent-ink:  var(--doc-accent);
    --doc-accent-weak: color-mix(in srgb, var(--doc-accent) 10%, transparent);
    --doc-ring:        0 0 0 3px color-mix(in srgb, var(--doc-accent) 34%, transparent);
    background: var(--pcms-post-bg, var(--t-bg));
}


/* ---------------------------------------------------------
   Options that apply on top of any theme
   --------------------------------------------------------- */
[data-pcms-theme][data-pcms-radius="sharp"]   { --doc-r-xs: 2px;  --doc-r-sm: 3px;  --doc-r-md: 4px;  --doc-r-lg: 6px; }
[data-pcms-theme][data-pcms-radius="rounded"] { --doc-r-xs: 6px;  --doc-r-sm: 8px;  --doc-r-md: 12px; --doc-r-lg: 16px; }
[data-pcms-theme][data-pcms-radius="round"]   { --doc-r-xs: 10px; --doc-r-sm: 14px; --doc-r-md: 20px; --doc-r-lg: 26px; }

[data-pcms-theme][data-pcms-font="sans"] {
    --doc-heading-font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
[data-pcms-theme][data-pcms-font="serif"] {
    --doc-heading-font: 'Fraunces', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
    --t-heading-weight: 600;
    --t-tracking: -0.012em;
}
[data-pcms-theme][data-pcms-font="mono"] {
    --doc-heading-font: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --t-heading-weight: 650;
    --t-tracking: -0.03em;
}

[data-pcms-theme][data-pcms-spacing="compact"] { --doc-pad: 0.8; --doc-body-leading: 1.65; }
[data-pcms-theme][data-pcms-spacing="roomy"]   { --doc-pad: 1.25; --doc-body-leading: 1.85; }


/* ---------------------------------------------------------
   5. Components — shared by every theme
   --------------------------------------------------------- */

/* ---- Page headers: solid, confident type over a quiet glow ---- */
[data-pcms-theme] .docs-hero,
[data-pcms-theme] .blog-hero,
[data-pcms-theme] .doc-cat-header,
[data-pcms-theme] .post-hero { isolation: isolate; }

[data-pcms-theme] .docs-hero h1,
[data-pcms-theme] .blog-hero-title {
    font-size: var(--t-hero-size);
    line-height: 1.04;
    letter-spacing: var(--t-tracking);
    font-weight: var(--t-heading-weight);
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--doc-ink);
    text-wrap: balance;
}

[data-pcms-theme] .docs-hero .page-subtitle,
[data-pcms-theme] .blog-hero-sub {
    font-size: clamp(1rem, 1.6vw, 1.15rem);
    color: var(--doc-ink-3);
}

/* The glow plus a faint dot grid that fades out downwards. Both are one
   pseudo-element each and sit inside the header, so nothing overflows. */
[data-pcms-theme] .docs-hero::before,
[data-pcms-theme] .blog-hero::before,
[data-pcms-theme] .post-hero::before {
    inset: 0;
    background: radial-gradient(60% 80% at 50% 0%,
        color-mix(in srgb, var(--doc-accent) 16%, transparent) 0%,
        transparent 70%);
    z-index: -1;
}

[data-pcms-theme] .docs-hero::after,
[data-pcms-theme] .blog-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: radial-gradient(color-mix(in srgb, var(--doc-ink) 14%, transparent) 1px, transparent 1.2px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(70% 90% at 50% 0%, #000 0%, transparent 75%);
    mask-image: radial-gradient(70% 90% at 50% 0%, #000 0%, transparent 75%);
    opacity: 0.6;
}

[data-pcms-theme="outline"] .docs-hero::before,
[data-pcms-theme="outline"] .blog-hero::before,
[data-pcms-theme="outline"] .post-hero::before { opacity: 0.45; }

[data-pcms-theme] .docs-hero { padding-top: calc(76px * var(--doc-pad)); padding-bottom: calc(12px * var(--doc-pad)); }
[data-pcms-theme] .blog-hero { padding-top: calc(72px * var(--doc-pad)); padding-bottom: calc(18px * var(--doc-pad)); }

/* Bold: the accent lights the header from below as well, and the title
   picks up a gradient that runs into the accent. */
[data-pcms-theme="bold"] .docs-hero::before,
[data-pcms-theme="bold"] .blog-hero::before {
    background:
        radial-gradient(50% 70% at 20% 0%, color-mix(in srgb, var(--doc-accent) 26%, transparent) 0%, transparent 70%),
        radial-gradient(45% 70% at 85% 10%, color-mix(in srgb, var(--doc-accent) 18%, var(--doc-note) 12%) 0%, transparent 70%);
}

[data-pcms-theme="bold"] .docs-hero h1,
[data-pcms-theme="bold"] .blog-hero-title,
[data-pcms-theme="bold"] .post-title {
    background: linear-gradient(100deg, var(--doc-ink) 30%, color-mix(in srgb, var(--doc-accent) 75%, var(--doc-ink)) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---- Search ---- */
[data-pcms-theme] .docs-search { max-width: 640px; }

[data-pcms-theme] .docs-search input {
    padding-top: 16px;
    padding-bottom: 16px;
    border-radius: var(--doc-r-lg);
    border-color: var(--doc-line-strong);
    background: var(--doc-surface);
    box-shadow: var(--doc-shadow-md);
    font-size: 15.5px;
}

[data-pcms-theme="outline"] .docs-search input { box-shadow: none; }
[data-pcms-theme][data-pcms-radius="round"] .docs-search input { border-radius: var(--doc-r-pill); }

[data-pcms-theme] .docs-search input:hover { background: var(--doc-surface); border-color: color-mix(in srgb, var(--doc-accent) 30%, var(--doc-line-strong)); }

/* ---- Cards (category cards, blog cards, sub-categories, prev/next) ---- */
[data-pcms-theme] .doc-category-card,
[data-pcms-theme] .pcms-post-card,
[data-pcms-theme] .doc-subcat-card,
[data-pcms-theme] .doc-prevnext-link,
[data-pcms-theme] .related-doc-card {
    background: var(--doc-surface);
    border-color: var(--t-card-line, var(--doc-line));
    box-shadow: var(--doc-shadow-sm);
}

[data-pcms-theme="soft"] .doc-category-card,
[data-pcms-theme="soft"] .pcms-post-card,
[data-pcms-theme="soft"] .doc-subcat-card,
[data-pcms-theme="soft"] .doc-prevnext-link,
[data-pcms-theme="soft"] .related-doc-card { box-shadow: var(--doc-shadow-md); }

[data-pcms-theme="outline"] .doc-category-card,
[data-pcms-theme="outline"] .pcms-post-card,
[data-pcms-theme="outline"] .doc-subcat-card,
[data-pcms-theme="outline"] .doc-prevnext-link,
[data-pcms-theme="outline"] .related-doc-card { box-shadow: none; border-color: var(--doc-line-strong); }

[data-pcms-theme] .doc-category-card:hover,
[data-pcms-theme] .pcms-post-card:hover,
[data-pcms-theme] .doc-subcat-card:hover,
[data-pcms-theme] .doc-prevnext-link:hover {
    border-color: color-mix(in srgb, var(--doc-accent) 45%, var(--doc-line-strong));
    box-shadow: var(--doc-shadow-lg), 0 0 0 1px color-mix(in srgb, var(--doc-accent) 18%, transparent);
    transform: translateY(-3px);
}

[data-pcms-theme="outline"] .doc-category-card:hover,
[data-pcms-theme="outline"] .pcms-post-card:hover,
[data-pcms-theme="outline"] .doc-subcat-card:hover,
[data-pcms-theme="outline"] .doc-prevnext-link:hover { box-shadow: none; transform: none; border-color: var(--doc-accent); }

/* Bold cards wear a thicker accent edge on hover rather than a glow. */
[data-pcms-theme="bold"] .doc-category-card:hover,
[data-pcms-theme="bold"] .pcms-post-card:hover {
    box-shadow: var(--doc-shadow-lg), 0 0 0 2px var(--doc-accent);
}

/* ---- Docs home: category cards ---- */
[data-pcms-theme] .docs-categories { gap: calc(22px * var(--doc-pad)); padding-top: calc(40px * var(--doc-pad)); }


[data-pcms-theme] .doc-category-icon {
    border-radius: var(--doc-r-md);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--doc-accent) 22%, transparent);
}

[data-pcms-theme] .doc-category-card h3 { font-size: 1.12rem; }

[data-pcms-theme] .doc-category-card .doc-count {
    padding: 2px 8px;
    border-radius: var(--doc-r-pill);
    background: var(--doc-surface-2);
    border: 1px solid var(--doc-line);
}

/* Article rows in a card: read as links, with an arrow that slides in. */
[data-pcms-theme] .doc-category-card .doc-list a { color: var(--doc-ink-2); }
[data-pcms-theme] .doc-category-card .doc-list li:not(.doc-list-more) a::after {
    content: '→';
    margin-left: auto;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity var(--doc-fast), transform var(--doc-fast);
    color: var(--doc-accent);
}
[data-pcms-theme] .doc-category-card .doc-list a:hover::after { opacity: 1; transform: none; }
[data-pcms-theme] .doc-category-card .doc-list a:hover { padding-left: 9px; }

/* The badge on a doc in a category card only had a style inside the
   sidebar, so on the docs home it printed as loose text. */
.doc-category-card .doc-list .sidebar-doc-badge,
[data-pcms-theme] .doc-category-card .doc-list .sidebar-doc-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: var(--doc-r-pill);
    background: var(--doc-badge);
    color: var(--doc-badge-ink);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.6;
}

/* ---- Category page ---- */
[data-pcms-theme] .doc-cat-header { padding-top: calc(64px * var(--doc-pad)); }
[data-pcms-theme] .doc-cat-header h1 {
    font-size: clamp(2rem, 4vw, 2.8rem);
    letter-spacing: var(--t-tracking);
    font-weight: var(--t-heading-weight);
    color: var(--doc-ink);
}

[data-pcms-theme] .doc-index-item {
    border-radius: var(--doc-r-md);
    transition: background var(--doc-fast), border-color var(--doc-fast), transform var(--doc-fast);
}
[data-pcms-theme] .doc-index-item:hover { transform: translateX(3px); }
[data-pcms-theme] .doc-index-icon { border-radius: var(--doc-r-sm); }

/* ---- Blog list: cards ---- */
[data-pcms-theme] .pcms-post-card { overflow: hidden; }

[data-pcms-theme] .pcms-post-card-body { display: flex; flex-direction: column; }
[data-pcms-theme] .pcms-post-card-more { margin-top: auto; padding-top: 6px; }

/* Thumbnails fill their frame edge to edge at one fixed shape, so a row of
   cards lines up and no band of card colour shows above or below the image.
   Showcase lays the words over the picture and keeps its own rules. */
[data-pcms-theme]:not([data-blog-layout="showcase"]) .pcms-post-card-thumb {
    position: relative;
    display: block;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--doc-surface-2);
}
[data-pcms-theme]:not([data-blog-layout="showcase"]) .pcms-post-card-thumb img {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    border-radius: 0;
    object-fit: cover;
    transition: transform 0.6s var(--doc-ease);
}
[data-pcms-theme] .pcms-post-card:hover .pcms-post-card-thumb img { transform: scale(1.04); }

[data-pcms-theme] .pcms-post-list.is-grid .pcms-post-card-thumb,
[data-pcms-theme][data-blog-layout="feature"] .pcms-post-card:first-child .pcms-post-card-thumb {
    aspect-ratio: 16 / 9;
}
[data-pcms-theme] .pcms-post-list.is-grid .pcms-post-card-thumb img { height: 100%; }

[data-pcms-theme] .pcms-post-list.is-grid .pcms-post-card { display: flex; flex-direction: column; }
[data-pcms-theme] .pcms-post-list.is-grid .pcms-post-card-body { flex: 1; }

/* List layout: the image column runs the full height of the card. */
[data-pcms-theme][data-blog-layout="list"] .pcms-post-card.has-thumb { grid-template-columns: 300px minmax(0, 1fr); }
[data-pcms-theme][data-blog-layout="list"] .pcms-post-card-thumb { min-height: 200px; }
[data-pcms-theme][data-blog-layout="list"] .pcms-post-card-thumb img { position: absolute; inset: 0; }

@media (max-width: 768px) {
    [data-pcms-theme][data-blog-layout="list"] .pcms-post-card.has-thumb { grid-template-columns: minmax(0, 1fr); }
    [data-pcms-theme][data-blog-layout="list"] .pcms-post-card-thumb { min-height: 0; aspect-ratio: 16 / 9; }
}

[data-pcms-theme] .pcms-post-card .pcms-post-card-title {
    margin: 10px 0 8px;
    font-size: 1.32rem;
    line-height: 1.25;
    letter-spacing: var(--t-tracking);
    text-wrap: pretty;
}
[data-pcms-theme] .pcms-post-card .pcms-post-card-title a { font-weight: var(--t-heading-weight); }

[data-pcms-theme] .pcms-post-card-more {
    color: var(--doc-accent);
    font-weight: 600;
    font-size: 13.5px;
    text-decoration: none;
}
[data-pcms-theme] .pcms-post-card-more span { display: inline-block; transition: transform var(--doc-fast); }
[data-pcms-theme] .pcms-post-card:hover .pcms-post-card-more span { transform: translateX(3px); }

/* Minimal layout stays a ruled index: no card chrome to lift. */
[data-pcms-theme][data-blog-layout="minimal"] .pcms-post-card,
[data-pcms-theme][data-blog-layout="minimal"] .pcms-post-card:hover {
    background: none;
    box-shadow: none;
    transform: none;
    border-width: 0 0 1px;
    border-color: var(--doc-line);
    border-radius: 0;
}

/* ---- Pills: categories, filters ---- */
[data-pcms-theme] .pcms-term-pill {
    border-radius: var(--doc-r-pill);
    background: var(--doc-surface);
    border: 1px solid var(--doc-line-strong);
    color: var(--doc-ink-2);
    font-weight: 550;
    transition: background var(--doc-fast), border-color var(--doc-fast), color var(--doc-fast);
}
[data-pcms-theme] .pcms-term-pill:hover {
    border-color: color-mix(in srgb, var(--doc-accent) 50%, var(--doc-line-strong));
    color: var(--doc-ink);
}
[data-pcms-theme] .pcms-term-pill.is-active {
    background: var(--doc-accent);
    border-color: var(--doc-accent);
    color: #fff;
    box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--doc-accent) 60%, transparent);
}
[data-pcms-theme] .pcms-term-pill.is-active .pcms-term-pill-count { color: rgb(255 255 255 / 0.8); }

/* Small pills on a card are labels, not buttons: tinted, borderless. */
[data-pcms-theme] .pcms-post-card-terms .pcms-term-pill {
    background: var(--doc-accent-weak);
    border-color: transparent;
    color: var(--doc-accent);
    font-size: 11.5px;
    padding: 3px 10px;
}

/* ---- Pagination ---- */
[data-pcms-theme] .pcms-post-pagination a,
[data-pcms-theme] .pcms-post-pagination .is-current {
    border-radius: var(--doc-r-sm);
    border: 1px solid var(--doc-line-strong);
    background: var(--doc-surface);
    color: var(--doc-ink-2);
}
[data-pcms-theme] .pcms-post-pagination a:hover { border-color: var(--doc-accent); color: var(--doc-ink); }
[data-pcms-theme] .pcms-post-pagination .is-current { background: var(--doc-accent); border-color: var(--doc-accent); color: #fff; }

/* ---- Single post ---- */
[data-pcms-theme] .post-hero { padding-top: calc(64px * var(--doc-pad)); }
[data-pcms-theme] .post-title {
    font-size: clamp(2.1rem, 4.6vw, 3.2rem);
    line-height: 1.08;
    letter-spacing: var(--t-tracking);
    font-weight: var(--t-heading-weight);
}
[data-pcms-theme] .post-featured img,
[data-pcms-theme] .pcms-post-featured img {
    border-radius: var(--doc-r-lg);
    border: 1px solid var(--doc-line);
    box-shadow: var(--doc-shadow-lg);
}
[data-pcms-theme="outline"] .post-featured img { box-shadow: none; }

/* ---- Article (docs and posts share it) ---- */
[data-pcms-theme] .doc-title {
    font-weight: var(--t-heading-weight);
    letter-spacing: var(--t-tracking);
}

[data-pcms-theme] .doc-body h2,
[data-pcms-theme] .doc-body h3 { letter-spacing: var(--t-tracking); }
[data-pcms-theme="bold"] .doc-body h2,
[data-pcms-theme="bold"] .doc-body h3 { font-weight: 750; }

[data-pcms-theme] .doc-body pre,
[data-pcms-theme] .doc-code-wrap pre {
    background: var(--doc-surface-3);
    color: var(--doc-code-ink);
    border: 1px solid color-mix(in srgb, var(--doc-line-strong) 60%, transparent);
    border-radius: var(--doc-r-md);
}
[data-pcms-theme] .doc-body pre code { color: inherit; background: none; }

/* Light mode keeps code blocks dark — the convention readers expect, and
   it lets syntax highlighters keep their dark palettes. Inline code gets
   a light chip instead. */
[data-pcms-theme][data-pcms-mode="light"] .doc-body :not(pre) > code {
    background: color-mix(in srgb, var(--doc-accent) 9%, #f3f4f6);
    color: color-mix(in srgb, var(--doc-accent) 70%, #111827);
    border-color: transparent;
}
[data-pcms-theme][data-pcms-mode="light"] .doc-copy-btn {
    background: rgb(255 255 255 / 0.08);
    color: #e6e8ef;
    border-color: rgb(255 255 255 / 0.14);
}

[data-pcms-theme] .doc-callout { border-radius: var(--doc-r-md); }

[data-pcms-theme] .doc-body table { border-radius: var(--doc-r-md); }

[data-pcms-theme] .doc-body blockquote:not(.doc-callout) {
    border-left: 3px solid var(--doc-accent);
    border-radius: 0 var(--doc-r-md) var(--doc-r-md) 0;
}

/* ---- Sidebar + contents rail ---- */
[data-pcms-theme] .doc-sidebar a.active,
[data-pcms-theme] .doc-sidebar a[aria-current="page"] { border-radius: var(--doc-r-sm); }

[data-pcms-theme] .doc-nav-filter input,
[data-pcms-theme] .doc-nav-toggle { border-radius: var(--doc-r-sm); }

/* docs.css paints these with the code-block colour, which the theme keeps
   dark even in light mode — so give them the raised surface instead. */
[data-pcms-theme] .doc-nav-filter input,
[data-pcms-theme] .reaction-btn,
[data-pcms-theme] .sidebar-cat-count { background: var(--doc-surface-2); }

/* ---- Feedback buttons ---- */
[data-pcms-theme] .reaction-btn { border-radius: var(--doc-r-pill); }

/* Light-mode fixes for the few docs.css rules that assume a dark page. */
[data-pcms-theme][data-pcms-mode="light"] .doc-category-icon { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--doc-accent) 20%, transparent); }
[data-pcms-theme][data-pcms-mode="light"] kbd {
    background: #fff;
    color: var(--doc-ink);
    border-color: var(--doc-line-strong);
    box-shadow: 0 1px 0 var(--doc-line-strong);
}

@media (prefers-reduced-motion: reduce) {
    [data-pcms-theme] .doc-category-card:hover,
    [data-pcms-theme] .pcms-post-card:hover,
    [data-pcms-theme] .doc-subcat-card:hover,
    [data-pcms-theme] .doc-prevnext-link:hover,
    [data-pcms-theme] .doc-index-item:hover,
    [data-pcms-theme] .pcms-post-card:hover .pcms-post-card-thumb img { transform: none; }
}

/* Feature layout: the lead image fills its 16:9 frame (docs.css gives it a
   fixed pixel height, which left a band of card colour underneath). */
[data-pcms-theme][data-blog-layout="feature"] .pcms-post-card:first-child .pcms-post-card-thumb img { height: 100%; }
[data-pcms-theme][data-blog-layout="minimal"] .pcms-post-card-thumb { display: none; }
[data-pcms-theme][data-blog-layout="minimal"] .pcms-post-card.has-thumb { grid-template-columns: minmax(0, 1fr); }


/* =========================================================
   6. Look options — work on top of any theme
   Set from the Theme tab; each is an attribute on the wrapper and
   absent means "the theme's own choice".
   ========================================================= */

/* ---- Surface tint: the hue the greys lean towards ---- */
[data-pcms-theme][data-pcms-tint="cool"]:not([data-pcms-mode]) {
    --t-surface: color-mix(in srgb, var(--bg-card, #1e1e32) 93%, #3b82f6);
    --t-raised:  color-mix(in srgb, var(--bg-card, #1e1e32) 88%, #3b82f6);
}
[data-pcms-theme][data-pcms-tint="warm"]:not([data-pcms-mode]) {
    --t-surface: color-mix(in srgb, var(--bg-card, #1e1e32) 93%, #f59e0b);
    --t-raised:  color-mix(in srgb, var(--bg-card, #1e1e32) 88%, #f59e0b);
}
[data-pcms-theme][data-pcms-tint="accent"]:not([data-pcms-mode]) {
    --t-surface: color-mix(in srgb, var(--bg-card, #1e1e32) 90%, var(--t-accent));
    --t-raised:  color-mix(in srgb, var(--bg-card, #1e1e32) 84%, var(--t-accent));
    --t-line:    color-mix(in srgb, var(--border-color, #2d2d44) 75%, var(--t-accent));
}

[data-pcms-theme][data-pcms-mode="light"][data-pcms-tint="cool"] {
    --t-bg: #f8fafc; --t-surface: #ffffff; --t-raised: #f1f5f9; --t-line: #e2e8f0;
    --t-ink: #0f172a; --t-ink-2: #334155; --t-ink-3: #64748b;
    --bg-dark: #f8fafc; --bg-darker: #f1f5f9; --border-color: #e2e8f0;
}
[data-pcms-theme][data-pcms-mode="light"][data-pcms-tint="warm"] {
    --t-bg: #fbfaf8; --t-surface: #ffffff; --t-raised: #f5f3ef; --t-line: #e8e4dc;
    --t-ink: #1c1917; --t-ink-2: #44403c; --t-ink-3: #78716c;
    --bg-dark: #fbfaf8; --bg-darker: #f5f3ef; --border-color: #e8e4dc;
}
[data-pcms-theme][data-pcms-mode="light"][data-pcms-tint="accent"] {
    --t-bg: color-mix(in srgb, var(--t-accent) 4%, #ffffff);
    --t-surface: #ffffff;
    --t-raised: color-mix(in srgb, var(--t-accent) 7%, #ffffff);
    --t-line: color-mix(in srgb, var(--t-accent) 16%, #e5e7eb);
}

[data-pcms-theme][data-pcms-mode="dark"][data-pcms-tint="cool"] {
    --t-bg: #0a0f1c; --t-surface: #0f172a; --t-raised: #142038; --t-line: #1e293b;
    --t-ink: #f1f5f9; --t-ink-2: #cbd5e1; --t-ink-3: #8391a7;
    --bg-dark: #0a0f1c; --bg-card: #0f172a; --bg-darker: #0b1222; --border-color: #1e293b;
}
[data-pcms-theme][data-pcms-mode="dark"][data-pcms-tint="warm"] {
    --t-bg: #0e0c0a; --t-surface: #171412; --t-raised: #1e1a17; --t-line: #2b2622;
    --t-ink: #f5f2ee; --t-ink-2: #d6cfc7; --t-ink-3: #9c9188;
    --bg-dark: #0e0c0a; --bg-card: #171412; --bg-darker: #120f0d; --border-color: #2b2622;
}
[data-pcms-theme][data-pcms-mode="dark"][data-pcms-tint="accent"] {
    --t-bg: color-mix(in srgb, var(--t-accent) 5%, #09090c);
    --t-surface: color-mix(in srgb, var(--t-accent) 8%, #111216);
    --t-raised: color-mix(in srgb, var(--t-accent) 11%, #15161b);
    --t-line: color-mix(in srgb, var(--t-accent) 18%, #22242c);
}

/* ---- Header backdrop ---- */
[data-pcms-theme] .doc-cat-header { position: relative; isolation: isolate; }
[data-pcms-theme] .doc-cat-header::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(55% 80% at 50% 0%, color-mix(in srgb, var(--doc-accent) 14%, transparent), transparent 70%);
}

/* Grid: a fine line grid that fades out downwards. */
[data-pcms-theme][data-pcms-hero="grid"] .docs-hero::after,
[data-pcms-theme][data-pcms-hero="grid"] .blog-hero::after {
    background-image:
        linear-gradient(color-mix(in srgb, var(--doc-ink) 9%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--doc-ink) 9%, transparent) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center top;
    opacity: 1;
}

/* Mesh: three soft colour fields — the accent and the two callout hues. */
[data-pcms-theme][data-pcms-hero="mesh"] .docs-hero::before,
[data-pcms-theme][data-pcms-hero="mesh"] .blog-hero::before,
[data-pcms-theme][data-pcms-hero="mesh"] .post-hero::before,
[data-pcms-theme][data-pcms-hero="mesh"] .doc-cat-header::before {
    background:
        radial-gradient(40% 70% at 18% 10%, color-mix(in srgb, var(--doc-accent) 30%, transparent) 0%, transparent 70%),
        radial-gradient(35% 60% at 82% 0%, color-mix(in srgb, var(--doc-note) 24%, transparent) 0%, transparent 70%),
        radial-gradient(40% 60% at 55% 95%, color-mix(in srgb, var(--doc-tip) 14%, transparent) 0%, transparent 70%);
    filter: blur(8px);
}
[data-pcms-theme][data-pcms-hero="mesh"] .docs-hero::after,
[data-pcms-theme][data-pcms-hero="mesh"] .blog-hero::after { display: none; }

/* Plain: just the words. */
[data-pcms-theme][data-pcms-hero="plain"] .docs-hero::before,
[data-pcms-theme][data-pcms-hero="plain"] .docs-hero::after,
[data-pcms-theme][data-pcms-hero="plain"] .blog-hero::before,
[data-pcms-theme][data-pcms-hero="plain"] .blog-hero::after,
[data-pcms-theme][data-pcms-hero="plain"] .post-hero::before,
[data-pcms-theme][data-pcms-hero="plain"] .doc-cat-header::before { display: none; }

/* ---- Card style ---- */
[data-pcms-theme][data-pcms-cards="bordered"] :is(.doc-category-card, .pcms-post-card, .doc-subcat-card, .doc-prevnext-link, .related-doc-card, .doc-index-item) {
    background: var(--doc-surface);
    border: 1px solid var(--doc-line-strong);
    box-shadow: none;
}
[data-pcms-theme][data-pcms-cards="raised"] :is(.doc-category-card, .pcms-post-card, .doc-subcat-card, .doc-prevnext-link, .related-doc-card, .doc-index-item) {
    background: var(--doc-surface);
    border: 1px solid color-mix(in srgb, var(--doc-line-strong) 45%, transparent);
    box-shadow: var(--doc-shadow-md);
}
[data-pcms-theme][data-pcms-cards="glass"] :is(.doc-category-card, .pcms-post-card, .doc-subcat-card, .doc-prevnext-link, .related-doc-card, .doc-index-item) {
    background: color-mix(in srgb, var(--doc-surface) 55%, transparent);
    border: 1px solid color-mix(in srgb, var(--doc-ink) 10%, transparent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--doc-ink) 6%, transparent), var(--doc-shadow-sm);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    backdrop-filter: blur(14px) saturate(1.3);
}
[data-pcms-theme][data-pcms-cards="tinted"] :is(.doc-category-card, .pcms-post-card, .doc-subcat-card, .doc-prevnext-link, .related-doc-card, .doc-index-item) {
    background: color-mix(in srgb, var(--doc-accent) 7%, var(--doc-surface));
    border: 1px solid color-mix(in srgb, var(--doc-accent) 22%, transparent);
    box-shadow: none;
}

/* ---- Card hover ---- */
[data-pcms-theme][data-pcms-hover="glow"] :is(.doc-category-card, .pcms-post-card, .doc-subcat-card, .doc-prevnext-link, .doc-index-item):hover {
    transform: none;
    border-color: color-mix(in srgb, var(--doc-accent) 55%, var(--doc-line-strong));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--doc-accent) 30%, transparent),
                0 10px 40px -10px color-mix(in srgb, var(--doc-accent) 45%, transparent);
}
[data-pcms-theme][data-pcms-hover="border"] :is(.doc-category-card, .pcms-post-card, .doc-subcat-card, .doc-prevnext-link, .doc-index-item):hover {
    transform: none;
    border-color: var(--doc-accent);
    box-shadow: none;
}
[data-pcms-theme][data-pcms-hover="none"] :is(.doc-category-card, .pcms-post-card, .doc-subcat-card, .doc-prevnext-link, .doc-index-item):hover {
    transform: none;
}

/* Minimal blog layout is a ruled index whatever the card style says. */
[data-pcms-theme][data-blog-layout="minimal"][data-pcms-cards] .pcms-post-card,
[data-pcms-theme][data-blog-layout="minimal"][data-pcms-hover] .pcms-post-card:hover {
    background: none;
    box-shadow: none;
    transform: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-width: 0 0 1px;
    border-color: var(--doc-line);
    border-radius: 0;
}

/* ---- Docs icons ---- */
[data-pcms-theme][data-pcms-icon="circle"] :is(.doc-category-icon, .doc-cat-icon, .doc-index-icon, .doc-subcat-icon) {
    border-radius: 50%;
}
[data-pcms-theme][data-pcms-icon="gradient"] :is(.doc-category-icon, .doc-cat-icon, .doc-index-icon) {
    background-image: linear-gradient(135deg,
        color-mix(in srgb, var(--doc-accent) 85%, #ffffff),
        color-mix(in srgb, var(--doc-accent) 70%, var(--doc-note)));
    box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--doc-accent) 70%, transparent),
                inset 0 1px 0 rgb(255 255 255 / 0.25);
}
[data-pcms-theme][data-pcms-icon="plain"] :is(.doc-category-icon, .doc-cat-icon, .doc-index-icon) {
    background-color: transparent;
    box-shadow: none;
}
/* Bigger glyph only where the tile size setting applies; the small icons on
   a category's article list keep their own size. */
[data-pcms-theme][data-pcms-icon="plain"] :is(.doc-category-icon, .doc-cat-icon) {
    font-size: calc(var(--doc-card-icon-size, 44px) * 0.62);
}
/* An uploaded category image always shows, whatever the icon style. */
[data-pcms-theme][data-pcms-icon] .has-image { background-color: transparent; }

/* ---- Docs home columns ---- */
[data-pcms-theme][data-pcms-cols]:is([data-docs-layout="cards"], [data-docs-layout="compact"], [data-docs-layout="tiles"], [data-docs-layout="search"]) .docs-categories {
    grid-template-columns: repeat(var(--t-cols), minmax(0, 1fr));
}
[data-pcms-theme][data-pcms-cols="2"] { --t-cols: 2; }
[data-pcms-theme][data-pcms-cols="3"] { --t-cols: 3; }
[data-pcms-theme][data-pcms-cols="4"] { --t-cols: 4; }
@media (max-width: 1000px) { [data-pcms-theme][data-pcms-cols="4"] { --t-cols: 3; } }
@media (max-width: 860px)  { [data-pcms-theme][data-pcms-cols] { --t-cols: 2; } }
@media (max-width: 600px)  { [data-pcms-theme][data-pcms-cols] { --t-cols: 1; } }


/* =========================================================
   7. Docs polish — every theme
   ========================================================= */

/* The whole category card is the link to the category, with an arrow that
   slides in. The article links inside it sit above the stretched link. */
[data-pcms-theme] .doc-category-card h3 a::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: 0;
}
[data-pcms-theme] .doc-category-card .doc-list,
[data-pcms-theme] .doc-category-card .doc-list a { position: relative; z-index: 1; }
[data-pcms-theme] .doc-category-card { cursor: pointer; }
[data-pcms-theme] .doc-category-card .doc-category-header::after {
    content: '';
    width: 18px;
    height: 18px;
    margin-left: auto;
    flex-shrink: 0;
    background: var(--doc-accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%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='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity var(--doc-fast), transform var(--doc-fast);
}
[data-pcms-theme] .doc-category-card:hover .doc-category-header::after,
[data-pcms-theme] .doc-category-card:focus-within .doc-category-header::after { opacity: 1; transform: none; }

/* Callouts get an icon beside their label. */
[data-pcms-theme] .doc-body [data-callout] {
    border-left-width: 1px;
    border-radius: var(--doc-r-md);
    padding-left: calc(46px * var(--doc-pad));
    background: color-mix(in srgb, var(--doc-callout-tint) 7%, var(--doc-surface));
}
[data-pcms-theme] .doc-body [data-callout]::after {
    content: '';
    position: absolute;
    left: calc(16px * var(--doc-pad));
    top: calc(15px * var(--doc-pad));
    width: 18px;
    height: 18px;
    background: var(--doc-callout-tint);
    -webkit-mask: var(--t-callout-icon) center / contain no-repeat;
    mask: var(--t-callout-icon) center / contain no-repeat;
}
[data-pcms-theme] .doc-body [data-callout] {
    --t-callout-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M12 11v6M12 7.5v.5'/%3E%3C/svg%3E");
}
[data-pcms-theme] .doc-body .doc-callout.is-tip {
    --t-callout-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 21h4M12 3a6 6 0 0 0-3.5 10.9c.6.5 1 1.2 1 2.1h5c0-.9.4-1.6 1-2.1A6 6 0 0 0 12 3z'/%3E%3C/svg%3E");
}
[data-pcms-theme] .doc-body .doc-callout.is-warning {
    --t-callout-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20L12 3z'/%3E%3Cpath d='M12 10v4M12 17v.5'/%3E%3C/svg%3E");
}
[data-pcms-theme] .doc-body .doc-callout.is-danger {
    --t-callout-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M9 9l6 6M15 9l-6 6'/%3E%3C/svg%3E");
}

/* Search: a keyboard hint, filled in by docs.js (Ctrl K, or the Mac glyph). */
[data-pcms-theme] .docs-search[data-kbd]::after {
    content: attr(data-kbd);
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    padding: 3px 8px;
    border: 1px solid var(--doc-line-strong);
    border-radius: 6px;
    background: var(--doc-surface-2);
    color: var(--doc-ink-3);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    pointer-events: none;
    transition: opacity var(--doc-fast);
}
[data-pcms-theme] .docs-search:focus-within::after { opacity: 0; }
[data-pcms-theme] .docs-search[data-kbd] input { padding-right: 84px; }

/* Sidebar: the current page carries an accent bar as well as the tint. */
[data-pcms-theme] .doc-sidebar li a.active,
[data-pcms-theme] .doc-sidebar li a[aria-current="page"] {
    color: var(--doc-nav-active);
    font-weight: 600;
    background: color-mix(in srgb, var(--doc-nav-active) 11%, transparent);
}

/* Article header: a little more presence for the title and meta. */
[data-pcms-theme] .doc-title { font-size: clamp(2rem, 3.6vw, 2.75rem); line-height: 1.1; }
[data-pcms-theme] .doc-subtitle { font-size: 1.15rem; color: var(--doc-ink-3); }

/* Prev / next: direction label small and muted, title strong. */
[data-pcms-theme] .doc-prevnext-dir {
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--doc-ink-3);
}
[data-pcms-theme] .doc-prevnext-title { color: var(--doc-ink); font-weight: 650; }
[data-pcms-theme] .doc-prevnext-link:hover .doc-prevnext-title { color: var(--doc-accent); }

/* Tiles stack the header vertically, so the slide-in arrow would hang under
   the title; the whole tile already lifts on hover. */
[data-pcms-theme][data-docs-layout="tiles"] .doc-category-card .doc-category-header::after { display: none; }

/* No keyboard, no keyboard hint. */
@media (hover: none), (max-width: 640px) {
    [data-pcms-theme] .docs-search[data-kbd]::after { display: none; }
    [data-pcms-theme] .docs-search[data-kbd] input { padding-right: 18px; }
}
