/*!
 * OPD pejabat hierarchy — unscoped (works outside .home--nexus).
 * Fixes acak-acakan whitespace / misaligned Bupati-Wakil / Kepala Dinas tiers.
 * Palette tokens from indexBaru.php: --tg-kuning #FCA416, --tg-merah #900000.
 */

:root {
    --tg-kuning: #FCA416;
    --tg-kuning-light: #EFBD6C;
    --tg-merah: #900000;
    --tg-coklat: #422400;
    --tg-kuning-gradient: linear-gradient(135deg, #f7b500, #FFDBA0, #f7b500);
    --tg-merah-gradient: linear-gradient(135deg, #900000, #BE4A4A, #900000);
    --tg-light: #f8f9fa;
    --tg-text: #495057;
}

/* Induk brand (tanggamus/default) — indexBaru DNA */
body.skin-magz[data-opd-theme="tanggamus"],
body.skin-magz[data-opd-theme="default"] {
    --idds-primary: var(--tg-merah) !important;
    --idds-accent: var(--tg-kuning) !important;
    --idds-a-primary: var(--tg-merah) !important;
    --idds-a-accent: var(--tg-kuning) !important;
    --hz-primary: var(--tg-merah) !important;
    --hz-accent: var(--tg-kuning) !important;
    --hz-surface: #f8f5f0 !important;
    --color-primary: var(--tg-merah);
    --color-secondary: var(--tg-kuning);
    --color-accent: var(--tg-kuning);
}

/* ===== Pejabat shell — tight, centered ===== */
.opd-layout .arch-pejabat,
.arch-shell .arch-pejabat {
    padding: 1.25rem clamp(1rem, 3vw, 2rem) 1.5rem !important;
    background: #fff !important;
    border-block: 1px solid #e8ecf1;
    max-width: 1200px;
    margin-inline: auto;
    width: 100%;
}

.opd-layout .hz-leaders,
.arch-shell .hz-leaders,
.opd-layout .arch-pejabat .hz-leaders {
    max-width: 1100px;
    margin: 0 auto;
}

.opd-layout .hz-leaders__head,
.arch-shell .hz-leaders__head {
    margin-bottom: .75rem !important;
    gap: .65rem !important;
}

.opd-layout .hz-leaders__section,
.arch-shell .hz-leaders__section {
    margin: 0 !important;
    padding: 0 !important;
}

.opd-layout .hz-leaders__section--bordered,
.arch-shell .hz-leaders__section--bordered {
    margin-top: 1rem !important;
    padding-top: 1rem !important;
    border-top: 1px solid #e8ecf1;
}

.opd-layout .hz-leaders__hint,
.arch-shell .hz-leaders__hint {
    display: none !important; /* reduce clutter */
}

/* Regional stage — ALWAYS grid (not dependent on .home--nexus) */
.hz-leaders__stage {
    position: relative;
    isolation: isolate;
    padding: 1.15rem 1rem 1.25rem;
    border-radius: 1rem;
    overflow: hidden;
    background:
        radial-gradient(520px 220px at 50% 0%, color-mix(in srgb, var(--hz-accent, var(--tg-kuning)) 14%, transparent), transparent 70%),
        linear-gradient(160deg, #fff, color-mix(in srgb, var(--hz-primary, var(--tg-merah)) 5%, #fff));
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .05);
}

.hz-leaders__regional {
    display: grid !important;
    gap: 1rem !important;
    justify-content: center !important;
    justify-items: stretch;
    margin: 0 auto;
    width: 100%;
    max-width: 640px;
}
.hz-leaders__regional--count-1 { grid-template-columns: minmax(220px, 280px) !important; }
.hz-leaders__regional--count-2 { grid-template-columns: repeat(2, minmax(200px, 280px)) !important; }
.hz-leaders__regional--count-3 { grid-template-columns: repeat(3, minmax(180px, 240px)) !important; }

.hz-leaders__label {
    text-align: center;
    margin: 0 0 .75rem;
    font-size: .95rem;
    font-weight: 800;
    color: var(--hz-primary, var(--tg-merah));
}
.hz-leaders__stage-note {
    text-align: center;
    margin: -.35rem 0 .85rem;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: rgba(255, 255, 255, .82);
}

/* Agency mid-tier — fixed count columns, never stretch to full width */
.hz-agency {
    padding: .85rem .5rem 0 !important;
    max-width: 720px;
    margin: 0 auto;
}
.hz-agency__bar { margin-bottom: .75rem !important; text-align: center; }
.hz-agency__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--hz-primary, var(--tg-merah));
}
.hz-agency__subtitle {
    margin: .2rem 0 0;
    color: #64748b;
    font-size: .85rem;
}
.hz-agency__grid {
    display: grid !important;
    gap: 1rem !important;
    justify-content: center !important;
    margin: 0 auto;
}
.hz-agency__grid--count-1 { grid-template-columns: minmax(220px, 300px) !important; }
.hz-agency__grid--count-2 { grid-template-columns: repeat(2, minmax(200px, 280px)) !important; }
.hz-agency__grid--count-3,
.hz-agency__grid--count-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 260px)) !important; justify-content: center; }

.hz-agency__card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .05);
    border-top: 4px solid var(--hz-accent, var(--tg-kuning));
}
.hz-agency__photo img {
    width: 120px !important;
    height: 120px !important;
    object-fit: cover;
    border-radius: 999px;
    border: 3px solid color-mix(in srgb, var(--hz-primary, var(--tg-merah)) 30%, #fff);
    margin: 0 auto .65rem;
    display: block;
    background: #f1f5f9;
}

/* Officers marquee — contained */
.opd-layout .hz-officers,
.arch-shell .hz-officers {
    padding: .5rem 0 0 !important;
}
.opd-layout .hz-officers__bar,
.arch-shell .hz-officers__bar {
    margin-bottom: .65rem !important;
}

/*
 * CRITICAL: horizontal slider for pejabat struktural.
 * Magz marquee CSS was scoped to .home--nexus only — OPD layouts stacked vertically.
 * These rules apply to ALL pejabat sections (opd-layout, arch-shell, nexus).
 */
.hz-officers--marquee {
    position: relative;
    padding: .75rem 0 .25rem;
    width: 100%;
}
.hz-officers--marquee .hz-officers__bar {
    display: flex !important;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
    flex-wrap: wrap;
}
.hz-officers--marquee .hz-officers__controls {
    display: flex !important;
    gap: .45rem;
    flex: 0 0 auto;
}
.hz-officers--marquee .hz-officers__viewport {
    display: block !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    width: 100% !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
    padding: .5rem 0 1rem;
}
.hz-officers--marquee .hz-officers__track {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 1rem !important;
    width: max-content !important;
    min-width: 100%;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}
.hz-officers--marquee .hz-officer {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    flex: 0 0 220px !important;
    flex-shrink: 0 !important;
    min-width: 220px !important;
    max-width: 220px !important;
    width: 220px !important;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid color-mix(in srgb, var(--idds-primary, var(--hz-primary, #1a365d)) 12%, #e2e8f0);
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .07);
    padding: 1.05rem .85rem 1.1rem;
    text-align: center;
    min-height: 280px;
    box-sizing: border-box;
    float: none !important;
    clear: none !important;
}
.hz-officers--marquee .hz-officer__photo {
    width: 96px;
    height: 96px;
    margin: 0 auto .75rem;
    position: relative;
}
.hz-officers--marquee .hz-officer__photo img {
    width: 96px !important;
    height: 96px !important;
    object-fit: cover;
    border-radius: 999px;
    display: block;
    margin: 0 auto;
    background: #f1f5f9;
}
.hz-officers--marquee .hz-officer__body {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 auto;
}
.hz-officers--marquee .hz-officer__role {
    display: inline-flex;
    padding: .22rem .55rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--idds-primary, var(--hz-primary, #166534)) 12%, #fff);
    color: var(--idds-primary, var(--hz-primary, #166534));
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.hz-officers--marquee .hz-officer__name {
    margin: .45rem 0 .25rem;
    font-size: .95rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
    min-height: calc(1.25em * 2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.hz-officers--marquee .hz-officer__position {
    margin: 0;
    font-size: .8rem;
    color: #64748b;
    line-height: 1.35;
    min-height: calc(1.35em * 2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1 1 auto;
}
.hz-officers--marquee .hz-officer__nip {
    margin-top: auto !important;
    font-size: .65rem;
    color: #94a3b8;
    width: 100%;
}

/* Fill mode when few cards — center them in a row, not a column */
.hz-officers--marquee.hz-officers--fill .hz-officers__viewport {
    overflow: visible !important;
    mask-image: none;
    -webkit-mask-image: none;
}
.hz-officers--marquee.hz-officers--fill .hz-officers__track {
    width: 100% !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
}
.hz-officers--marquee.hz-officers--fill .hz-officer {
    flex: 0 0 220px !important;
}

/* Split hero — full-bleed banner (cinema) or columns+illustration */
.opd-layout--split .opd-split-hero {
    position: relative;
    z-index: 1;
    isolation: isolate;
}
.opd-layout--split .opd-split-hero-media {
    position: relative;
    overflow: hidden !important;
    isolation: isolate;
}
.opd-layout--split .opd-split-hero-media--full {
    width: 100%;
    /* Keep decorative body ornaments from painting over the slider */
    z-index: 2;
    background: #0f172a;
}
.opd-layout--split .opd-split-hero-media__banner {
    z-index: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center center !important;
    transform: none !important;
}
.opd-layout--split .opd-split-hero-media x-opd-illustration,
.opd-layout--split .opd-split-hero-media svg {
    max-width: 100%;
    max-height: 100%;
}
/* Ornaments must never cover OPD layout heroes */
body.skin-magz:has(.opd-layout--split) .nx-orn,
body.skin-magz .opd-layout--split ~ .nx-orn,
body.skin-magz .opd-layout .nx-orn {
    pointer-events: none;
}
body.skin-magz:has(.opd-layout--split) .nx-orn__stage,
body.skin-magz:has(.opd-layout--split) .nx-orn__glow {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* ===== OPD layout container polish ===== */
.opd-layout {
    --opd-max: 1200px;
}
.opd-layout > section {
    box-sizing: border-box;
}
.opd-layout .tg-tags {
    max-width: var(--opd-max);
    margin-left: auto;
    margin-right: auto;
}

/* Service layout: prevent hero + pejabat collision */
.opd-layout--service > section:first-child {
    margin-bottom: 0;
}
.opd-layout--service .arch-pejabat {
    margin-top: 0;
}

@media (max-width: 720px) {
    .hz-leaders__regional--count-2,
    .hz-leaders__regional--count-3 {
        grid-template-columns: 1fr !important;
        max-width: 320px;
    }
    .hz-agency__grid--count-2,
    .hz-agency__grid--count-3,
    .hz-agency__grid--count-4 {
        grid-template-columns: 1fr !important;
        max-width: 300px;
    }
    .hz-officers--marquee .hz-officer {
        flex: 0 0 min(200px, 72vw) !important;
        min-width: min(200px, 72vw) !important;
        max-width: min(200px, 72vw) !important;
        width: min(200px, 72vw) !important;
    }
}
