/* ==========================================================================
   BLOCK: DASHBOARD - traditional members landing (utility, not brochure)
   Welcome + quick search * KPI strip * feed panels (newsletter, members,
   documents, media) * congress CTA band * two featured items.
   All panels use the --panel-* theme tokens so light/dark come free.
   ========================================================================== */

@scope (.block-dashboard) {
    :scope {
        /* the full-bleed hero owns the top edge; section padding applies
           below it only */
        padding-block: 0 clamp(44px, 9cqw, 130px);
        container-type: inline-size;
        container-name: dash;
    }

    /* ------------------------------------------- WELCOME + QUICK SEARCH -- */
    /* Grid-stacked hero (same pattern as the section page-heads): a
       real <img> under an rgba(37,40,43,.8) tint, content on top. The
       media uses block-size: 0 + min-block-size: 100% so the banner's
       height stays content-driven (no intrinsic feedback loop). */
    .dash-head {
        display: grid;
        grid-template: 1fr / 1fr;
        overflow: clip;
        background: var(--bg-contrast);
        color: var(--text-inverse);
        margin-block-end: clamp(28px, 4cqw, 64px);
    }
    .dash-head > * { grid-area: 1 / 1; }
    .dash-head .head-media {
        inline-size: 100%;
        block-size: 0;
        min-block-size: 100%;
        object-fit: cover;
        display: block;
    }
    .dash-head .head-scrim { background: rgba(37, 40, 43, 0.8); }

    .dash-head-inner {
        z-index: 1;
        display: grid;
        gap: var(--space-xs);
        align-items: end;
        /* inline gutters come from .cms-block-inner; the hero only sets
           its own depth */
        padding-block: clamp(48px, 7cqw, 120px);
    }
    @container dash (width >= 900px) {
        .dash-head-inner { grid-template-columns: 1fr minmax(360px, 480px); }
    }

    /* Dark-surface recolour for the hero's content */
    .dash-head .kicker { color: var(--accent-lime); }
    .dash-head .dash-meta { color: rgba(255, 255, 255, 0.72); }
    .dash-head .search-group {
        border-color: rgba(255, 255, 255, 0.3);
        background: transparent;
    }
    .dash-head .search-group:has(input:focus-visible) { border-color: var(--accent-lime); }
    .dash-head .search-group input { color: #fff; }
    .dash-head .search-group input::placeholder { color: rgba(255, 255, 255, 0.55); }
    .dash-head .tag-row a {
        border-color: rgba(255, 255, 255, 0.28);
        color: rgba(255, 255, 255, 0.78);
    }
    .dash-head .tag-row a:hover {
        border-color: var(--accent-lime);
        color: var(--accent-lime);
    }

    .dash-welcome h1 {
        font-weight: 100;
        font-size: clamp(2.2rem, 5.5cqw, 4.4rem);
        line-height: 1;
        margin-block: 14px 12px;
    }
    .dash-welcome h1 strong { font-weight: 900; }
    .dash-meta {
        font-size: 0.85rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text-secondary);
    }

    .search-group {
        display: flex;
        align-items: stretch;
        border: 1px solid var(--panel-border);
        background: var(--panel-bg);
        transition: border-color 0.3s;
    }
    .search-group:has(input:focus-visible) { border-color: var(--accent-lime); }
    .search-group input {
        flex: 1;
        border: 0;
        outline: none;
        background: transparent;
        color: var(--panel-text);
        font: inherit;
        font-size: 1rem;
        font-weight: 300;
        padding: clamp(14px, 1.8cqw, 20px) clamp(16px, 2cqw, 24px);
        min-inline-size: 0;
        min-inline-size: 0;
    }
    .search-group input::placeholder { color: var(--panel-muted); }
    .search-group button {
        font-weight: 700;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.18em;
        padding-inline: 22px;
        background: var(--accent-lime);
        color: #000;
        transition: background 0.25s;
    }
    .search-group button:hover { background: var(--text-primary); color: var(--bg-default); }

    .tag-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-block-start: 12px;
    }
    .tag-row a {
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.14em;
        padding: clamp(7px, 1cqw, 10px) clamp(14px, 1.6cqw, 18px);
        border: 1px solid var(--panel-border);
        color: var(--text-secondary);
        transition: border-color 0.25s, color 0.25s, background 0.25s;
    }
    .tag-row a:hover {
        border-color: var(--accent-lime);
        color: var(--accent-ink);
    }

    /* ---------------------------------------------------------- KPI ROW -- */
    .kpi-grid {
        display: grid;
        /* two-up on phones; an odd final card spans the full row so the
           box is always filled (PHP renders five today - the odd-count
           rule generalises to any odd total in the 2-col layout) */
        grid-template-columns: repeat(2, 1fr);
        border: 1px solid var(--panel-border);
        background: var(--panel-bg);
        margin-block-end: clamp(28px, 4cqw, 64px);
    }
    .kpi-grid li:last-child:nth-child(odd) { grid-column: 1 / -1; }
    @container dash (width >= 1024px) {
        .kpi-grid { grid-template-columns: repeat(5, 1fr); }
        .kpi-grid li:last-child:nth-child(odd) { grid-column: auto; }
    }
    .kpi-grid li {
        min-inline-size: 0;               /* let tracks honour their minimum */
        padding: clamp(18px, 2.8cqw, 40px);
        border-inline-end: 1px solid var(--panel-border);
        border-block-end: 1px solid var(--panel-border);
        display: grid;
        align-content: start;
        gap: 4px;
    }
    .kpi-grid strong {
        font-size: clamp(1.9rem, 3.2cqw, 3.4rem);
        font-weight: 900;
        line-height: 1;
        color: var(--accent-ink);
    }
    .kpi-grid span {
        font-size: 0.74rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.18em;
        color: var(--panel-text);
    }
    .kpi-grid em {
        font-style: normal;
        font-size: 0.78rem;
        font-weight: 500;
        color: var(--panel-muted);
    }

    /* ------------------------------------------------------ FEED PANELS -- */
    .dash-grid {
        display: grid;
        gap: clamp(20px, 2.6cqw, 40px);
        margin-block-end: clamp(28px, 4cqw, 64px);
    }
    @container dash (width >= 720px)  { .dash-grid { grid-template-columns: repeat(2, 1fr); } }
    @container dash (width >= 1100px) {
        .dash-grid { grid-template-columns: repeat(12, 1fr); }
        .panel-newsletter { grid-column: span 7; }
        .panel-members    { grid-column: span 5; }
        .panel-docs       { grid-column: span 5; }
        .panel-media      { grid-column: span 7; }
    }

    .panel {
        border: 1px solid var(--panel-border);
        background: var(--panel-bg);
        color: var(--panel-text);
        display: grid;
        grid-template-rows: auto 1fr;
    }
    /* head / carousel / marker dots - the ::scroll-marker-group pseudo is
       laid out as a sibling of the scroller, so the panel reserves its row */
    .panel-media { grid-template-rows: auto 1fr auto; }
    .panel-head {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 20px;
        padding: clamp(18px, 2.4cqw, 32px) clamp(22px, 2.6cqw, 34px);
        border-block-end: 1px solid var(--panel-border);
    }
    .panel-head h2 {
        font-size: 0.84rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.24em;
    }
    .panel-more {
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.14em;
        color: var(--panel-muted);
        white-space: nowrap;
        transition: color 0.25s;
    }
    .panel-more:hover { color: var(--accent-ink); }

    .feed { display: grid; align-content: start; }
    .feed li {
        display: grid;
        gap: 8px;
        padding: clamp(16px, 2.2cqw, 30px) clamp(22px, 2.6cqw, 34px);
        border-block-end: 1px solid var(--panel-border);
    }
    .feed li:last-child { border-block-end: 0; }
    .feed a {
        font-weight: 600;
        font-size: 1.05rem;
        line-height: 1.5;
        transition: color 0.25s;
    }
    .feed a:hover { color: var(--accent-ink); }
    .feed-meta {
        font-size: 0.8rem;
        letter-spacing: 0.05em;
        color: var(--panel-muted);
    }
    .doc-type {
        font-size: 0.6rem;
        font-weight: 900;
        letter-spacing: 0.14em;
        padding: 2px 7px;
        border: 1px solid var(--accent-lime);
        color: var(--accent-ink);
        margin-inline-end: 4px;
    }

    /* ------------------------------------------------ MEDIA CAROUSEL --
       Base experience (baseline everywhere): a scroll-snap strip that
       fills the panel - swipe / trackpad / keyboard scroll all native.
       Enhancement (Chromium 135+): CSS carousel controls - scroll
       buttons + marker dots - generated entirely in CSS, no JS. */
    .media-scroller {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: min(360px, 100%);   /* narrow: one full slide,
                                                  no partial-slide sliver */
        grid-template-rows: 100%;              /* definite row: images can
                                                  resolve block-size 100% */
        gap: clamp(10px, 1.2cqw, 16px);
        padding-inline: 1px;                   /* keep panel border visible */
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
        scrollbar-color: var(--accent-lime) transparent;
    }
    .media-scroller li {
        scroll-snap-align: start;
        display: grid;
        grid-template: 1fr / 1fr;              /* definite cell for the stack */
        min-inline-size: 0;
    }
    .media-scroller a {
        display: grid;
        grid-template: 1fr / 1fr;
    }
    .media-scroller a > * { grid-area: 1 / 1; min-inline-size: 0; }
    .media-scroller img {
        inline-size: 100%;
        block-size: 100%;
        min-block-size: clamp(220px, 24cqw, 340px);
        object-fit: cover;
        display: block;
    }
    /* Caption overlaid on the image - slides are clean single cards, so
       the controls and dots have nothing to fight with */
    .media-scroller span {
        align-self: end;
        z-index: 1;
        font-size: 0.82rem;
        font-weight: 600;
        letter-spacing: 0.06em;
        color: #fff;
        padding: 44px 18px 14px;
        background: linear-gradient(to top, rgba(0,0,0,0.72), transparent);
        transition: color 0.25s;
    }
    .media-scroller a:hover span { color: var(--accent-lime); }

    /* CSS carousel enhancement - Chromium ships this today; other engines
       simply keep the plain snap strip until they catch up. */
    @supports (selector(::scroll-button(inline-start))) {
        .media-scroller {
            anchor-name: --dash-media;
            scroll-behavior: smooth;
            scroll-marker-group: after;
            scrollbar-width: none;             /* buttons + dots take over */
        }
        .media-scroller::scroll-marker-group {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            padding-block: 16px;
            background: var(--panel-bg);
            border-block-start: 1px solid var(--panel-border);
        }
        .media-scroller > li::scroll-marker {
            content: "" / "";
            inline-size: 9px;
            block-size: 9px;
            border-radius: 50%;
            border: 1px solid var(--panel-muted);
            cursor: pointer;
            transition: background 0.25s, border-color 0.25s;
        }
        .media-scroller > li::scroll-marker:hover { border-color: var(--accent-ink); }
        .media-scroller > li::scroll-marker:target-current {
            background: var(--accent-lime);
            border-color: var(--accent-lime);
        }
        .media-scroller::scroll-button(*) {
            position: absolute;                /* anchored overlay control */
            position-anchor: --dash-media;
            inset-block-start: anchor(center);
            translate: 0 -50%;
            z-index: 2;
            inline-size: 44px;
            block-size: 44px;
            border-radius: 50%;
            display: grid;
            place-items: center;
            background: rgba(0, 0, 0, 0.65);
            color: var(--accent-lime);
            font-size: 1.1rem;
            font-weight: 900;
            cursor: pointer;
            transition: background 0.25s, opacity 0.25s;
        }
        .media-scroller::scroll-button(*):hover { background: #000; }
        .media-scroller::scroll-button(*):disabled { opacity: 0.25; cursor: default; }
        .media-scroller::scroll-button(inline-start) {
            content: "\2190" / "Previous media";
            inset-inline-start: calc(anchor(start) + 12px);
        }
        .media-scroller::scroll-button(inline-end) {
            content: "\2192" / "Next media";
            inset-inline-end: calc(anchor(end) + 12px);
        }
    }

    /* ----------------------------------------------------- CONGRESS CTA -- */
    .congress-cta {
        display: grid;
        background: var(--bg-contrast);
        color: var(--text-inverse);
        margin-block-end: clamp(28px, 4cqw, 64px);
    }
    .congress-cta > * { grid-area: 1 / 1; }   /* grid-stacked, no absolute */
    .cta-media {
        background: url("https://www.worldooh.org/banners/london.jpg") center / cover no-repeat;
        filter: grayscale(25%);
        opacity: 0.35;
    }
    .cta-copy {
        padding: clamp(40px, 7cqw, 120px);
        max-inline-size: 720px;
        display: grid;
        gap: 14px;
        justify-items: start;
        z-index: 1;
    }
    .cta-copy .kicker { color: var(--accent-lime); }
    .cta-copy h2 {
        font-weight: 100;
        font-size: clamp(2.4rem, 5.5cqw, 4.2rem);
        line-height: 1.02;
    }
    .cta-copy h2 strong { font-weight: 900; display: block; }
    .cta-copy p { font-weight: 300; font-size: clamp(1.02rem, 1.3cqw, 1.2rem); line-height: 1.8; color: rgba(255,255,255,0.75); max-inline-size: 50ch; }
    .cta-copy .btn { margin-block-start: 8px; }

    /* --------------------------------------------------- FEATURED ITEMS -- */
    .feature-duo {
        display: grid;
        gap: clamp(24px, 2.6cqw, 40px);
    }
    @container dash (width >= 820px) { .feature-duo { grid-template-columns: 1fr 1fr; } }

    .feature-card {
        display: grid;
        grid-template-rows: auto 1fr;
        border: 1px solid var(--panel-border);
        background: var(--panel-bg);
        color: var(--panel-text);
        transition: border-color 0.3s;
    }
    .feature-card:hover { border-color: var(--accent-lime); }
    .feature-card figure { overflow: hidden; }
    .feature-card img {
        inline-size: 100%;
        aspect-ratio: 21 / 9;
        object-fit: cover;
        display: block;
        transition: scale 0.6s var(--ease-lux);
    }
    .feature-card:hover img { scale: 1.04; }

    .feature-copy {
        padding: clamp(22px, 3.4cqw, 52px);
        display: grid;
        gap: 14px;
        justify-items: start;
        align-content: start;
    }
    .feature-copy h3 {
        font-weight: 100;
        font-size: clamp(1.8rem, 3cqw, 2.6rem);
        line-height: 1.08;
    }
    .feature-copy h3 strong { font-weight: 900; display: block; }
    .feature-copy p { font-weight: 300; font-size: 1.02rem; line-height: 1.75; color: var(--panel-muted); max-inline-size: 46ch; }
    .feature-copy .btn-link { margin-block-start: 4px; }
}
