/* ==========================================================================
   1. VARIABEL TEMA (LIGHT & DARK MODE)
   ========================================================================== */
:root {
    --bg-color: #ffffff;
    --bg-alt: #f8fafc;
    --bg-soft: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #0a0f1e;
    --text-muted: #64748b;
    --text-soft: #94a3b8;

    --primary: #dc2626;
    --primary-hover: #b91c1c;
    --primary-soft: rgba(220, 38, 38, 0.08);
    --primary-glow: rgba(220, 38, 38, 0.25);

    --border-color: #e2e8f0;
    --border-soft: #f1f5f9;

    --shadow-sm: 0 1px 2px rgba(10, 15, 30, 0.04);
    --shadow: 0 4px 24px rgba(10, 15, 30, 0.08);
    --shadow-lg: 0 24px 48px -16px rgba(10, 15, 30, 0.15);

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 24px;
    --r-full: 999px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0a0f1e;
        --bg-alt: #111827;
        --bg-soft: #1a2234;
        --card-bg: #151b2d;
        --text-color: #f8fafc;
        --text-muted: #94a3b8;
        --text-soft: #64748b;
        --border-color: #1e293b;
        --border-soft: #1e293b;
        --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.6);
    }
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    scroll-behavior: smooth;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#content-router { flex: 1 0 auto; }
.main-footer { flex-shrink: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ==========================================================================
   3. HEADER (z-index 1000)
   ========================================================================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 76px;
    background-color: rgba(255, 255, 255, 0.75);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-soft);
    z-index: 1000;
    transition: all 0.3s ease;
}

@media (prefers-color-scheme: dark) {
    .main-header { background-color: rgba(10, 15, 30, 0.75); }
}

.main-header:hover {
    background-color: var(--primary);
    border-color: var(--primary);
}

.main-header:hover .nama-sekolah,
.main-header:hover .brand-tagline,
.main-header:hover .bi,
.main-header:hover #global-search-bar { color: #ffffff; }

.main-header:hover .brand-tagline { opacity: 0.85; }

.main-header:hover #global-search-bar {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.main-header:hover .hamburger-menu span { background-color: #ffffff; }

.header-inner {
    height: 100%;
    max-width: 100%;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

/* Brand */
.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex-shrink: 0;
}

.logo-circle {
    width: 44px;
    height: 44px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-circle img { width: 100%; height: 100%; object-fit: contain; }

.brand-info { display: flex; flex-direction: column; line-height: 1.2; }

.nama-sekolah {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--text-color);
    transition: color 0.3s ease;
    white-space: nowrap;
}

.brand-tagline {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: color 0.3s ease, opacity 0.3s ease;
}

/* Search */
.search-center-wrapper { flex: 1; max-width: 520px; margin: 0 auto; }

.search-input-box { position: relative; width: 100%; display: flex; align-items: center; }

.icon-search {
    position: absolute;
    left: 18px;
    font-size: 0.95rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s ease;
    z-index: 2;
}

#global-search-bar {
    width: 100%;
    padding: 11px 44px 11px 44px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text-color);
    background-color: var(--bg-alt);
    border: 1.5px solid transparent;
    border-radius: var(--r-full);
    outline: none;
    transition: all 0.3s ease;
}

#global-search-bar:focus {
    background-color: var(--card-bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.btn-clear {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    z-index: 2;
}

.btn-clear:hover { color: var(--text-color); }

.fake-placeholder {
    position: absolute;
    left: 44px;
    right: 44px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.92rem;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.4s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fake-placeholder.hidden { opacity: 0; visibility: hidden; }

/* Hamburger */
.hamburger-menu {
    width: 28px;
    height: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1100;
    flex-shrink: 0;
    padding: 0;
}

.hamburger-menu span {
    width: 100%;
    height: 2.5px;
    background-color: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center;
}

.hamburger-menu.active span:nth-child(1) { transform: rotate(45deg) translateY(-1px); }
.hamburger-menu.active span:nth-child(2) { width: 0%; opacity: 0; }
.hamburger-menu.active span:nth-child(3) { transform: rotate(-45deg) translateY(1px); }

/* ==========================================================================
   4. SIDEBAR (z-index 999 — DI BAWAH HEADER, biar hamburger × terlihat)
   ========================================================================== */
.sidebar-nav {
    position: fixed;
    top: 0;
    right: -340px;
    width: 340px;
    height: 100vh;
    background-color: var(--card-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding-top: 76px;
}

.sidebar-nav.open { transform: translateX(-340px); }

.sidebar-header {
    padding: 8px 24px 24px 24px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-header-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background-color: var(--bg-alt);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.sidebar-header-text { display: flex; flex-direction: column; line-height: 1.3; }

.sidebar-header-title { font-size: 0.95rem; font-weight: 700; color: var(--text-color); }
.sidebar-header-sub { font-size: 0.75rem; color: var(--text-muted); }

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 16px;
    overflow-y: auto;
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-muted);
    transition: all 0.25s ease;
    position: relative;
}

.menu-item i { font-size: 1.1rem; width: 20px; text-align: center; }

.menu-item:hover {
    color: var(--primary);
    background-color: var(--bg-alt);
}

.menu-item.active-menu {
    color: var(--primary);
    background-color: var(--bg-alt);
    font-weight: 600;
}

.menu-item.active-menu::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background-color: var(--primary);
    border-radius: 0 4px 4px 0;
}

/* ==========================================================================
   5. KONTAINER UTAMA
   ========================================================================== */
#content-router {
    margin-top: 76px;
    min-height: calc(100vh - 156px);
    width: 100%;
    max-width: 100%;
    padding: 0;
}

.section-block {
    padding: 64px 48px;
    width: 100%;
}

.section-block:nth-of-type(even) { background-color: var(--bg-alt); }

.container { width: 100%; max-width: 100%; padding: 0; margin: 0; }

/* Loading */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 120px 24px;
    color: var(--text-muted);
    gap: 20px;
}

.loading-screen p { font-size: 0.9rem; font-weight: 500; }

.crescent-spinner {
    width: 56px;
    height: 56px;
    color: var(--primary);
    animation: spinCrescent 1.1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
    display: block;
}

.crescent-spinner circle { filter: drop-shadow(0 0 8px var(--primary-glow)); }

@keyframes spinCrescent { to { transform: rotate(360deg); } }

/* ==========================================================================
   6. TIPOGRAFI
   ========================================================================== */
h1, h2, h3, h4, h5 {
    line-height: 1.2;
    letter-spacing: -0.025em;
    color: var(--text-color);
    font-weight: 800;
}

.section-label {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--primary);
    margin-bottom: 12px;
}

.section-title {
    font-size: 2.25rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.03em !important;
    color: var(--text-color);
    margin: 0 0 16px 0 !important;
    text-align: left;
}

.sub-section-title {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: var(--text-color);
    margin: 32px 0 16px 0 !important;
    padding: 0 !important;
    border: none !important;
    text-align: left;
}

/* ==========================================================================
   7. FOOTER
   ========================================================================== */
.main-footer {
    height: 80px;
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.35s ease;
}

.main-footer:hover {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.main-footer:hover span { color: #ffffff; }

/* ==========================================================================
   8. REVEAL ANIMATION — ENHANCED
   Slide Kiri/Kanan + Naik dari Bawah + Scale + Blur
   ========================================================================== */
.reveal-init {
    opacity: 0;
    transform: 
        translateX(var(--reveal-dir, -60px)) 
        translateY(24px) 
        scale(0.96);
    filter: blur(6px);
    transition: 
        opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1),
        transform 1.05s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.85s ease;
    will-change: opacity, transform, filter;
}

.reveal-init.revealed {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
    filter: blur(0);
}

.reveal-left { --reveal-dir: -60px; }
.reveal-right { --reveal-dir: 60px; }

/* ==========================================================================
   8B. STAGGER — Item dalam list muncul bertingkat
   ========================================================================== */

/* Artikel list */
#google-grid-artikel .grid-card:nth-child(1) { transition-delay: 0s; }
#google-grid-artikel .grid-card:nth-child(2) { transition-delay: 0.05s; }
#google-grid-artikel .grid-card:nth-child(3) { transition-delay: 0.1s; }
#google-grid-artikel .grid-card:nth-child(4) { transition-delay: 0.15s; }
#google-grid-artikel .grid-card:nth-child(5) { transition-delay: 0.2s; }

/* Highlight artikel beranda */
.highlight-list .highlight-artikel-item:nth-child(1) { transition-delay: 0s; }
.highlight-list .highlight-artikel-item:nth-child(2) { transition-delay: 0.08s; }
.highlight-list .highlight-artikel-item:nth-child(3) { transition-delay: 0.16s; }

/* Grid guru */
.guru-grid-layout .card-guru:nth-child(1) { transition-delay: 0s; }
.guru-grid-layout .card-guru:nth-child(2) { transition-delay: 0.05s; }
.guru-grid-layout .card-guru:nth-child(3) { transition-delay: 0.1s; }
.guru-grid-layout .card-guru:nth-child(4) { transition-delay: 0.15s; }
.guru-grid-layout .card-guru:nth-child(5) { transition-delay: 0.2s; }
.guru-grid-layout .card-guru:nth-child(6) { transition-delay: 0.25s; }
.guru-grid-layout .card-guru:nth-child(7) { transition-delay: 0.3s; }
.guru-grid-layout .card-guru:nth-child(8) { transition-delay: 0.35s; }

/* Sosmed circles */
.sosmed-flex-row .sosmed-item-circle:nth-child(1) { transition-delay: 0s; }
.sosmed-flex-row .sosmed-item-circle:nth-child(2) { transition-delay: 0.08s; }
.sosmed-flex-row .sosmed-item-circle:nth-child(3) { transition-delay: 0.16s; }
.sosmed-flex-row .sosmed-item-circle:nth-child(4) { transition-delay: 0.24s; }
.sosmed-flex-row .sosmed-item-circle:nth-child(5) { transition-delay: 0.32s; }

/* Statistik */
.stat-grid .stat-item:nth-child(1) { transition-delay: 0s; }
.stat-grid .stat-item:nth-child(2) { transition-delay: 0.1s; }
.stat-grid .stat-item:nth-child(3) { transition-delay: 0.2s; }

/* Fasilitas grid */
.grid-fasilitas-mini .kartu-fasilitas-premium:nth-child(1) { transition-delay: 0s; }
.grid-fasilitas-mini .kartu-fasilitas-premium:nth-child(2) { transition-delay: 0.05s; }
.grid-fasilitas-mini .kartu-fasilitas-premium:nth-child(3) { transition-delay: 0.1s; }
.grid-fasilitas-mini .kartu-fasilitas-premium:nth-child(4) { transition-delay: 0.15s; }

/* Galeri album */
.galeri-grid-responsive .box-galeri-item:nth-child(1) { transition-delay: 0s; }
.galeri-grid-responsive .box-galeri-item:nth-child(2) { transition-delay: 0.06s; }
.galeri-grid-responsive .box-galeri-item:nth-child(3) { transition-delay: 0.12s; }
.galeri-grid-responsive .box-galeri-item:nth-child(4) { transition-delay: 0.18s; }

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .reveal-init {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        transition: none !important;
    }
}

/* ==========================================================================
   9. RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
    .main-header { height: 64px; }
    .header-inner { padding: 0 16px; gap: 12px; }
    .brand-info { display: none; }
    .search-center-wrapper { max-width: 100%; }
    #global-search-bar { padding: 9px 36px 9px 36px; font-size: 0.88rem; }
    .icon-search { left: 14px; }
    .btn-clear { right: 12px; }
    .fake-placeholder { left: 36px; right: 36px; font-size: 0.88rem; }
    .logo-circle { width: 38px; height: 38px; }

    #content-router {
        margin-top: 64px;
        min-height: calc(100vh - 128px);
        padding: 0;
    }

    .section-block { padding: 40px 16px; }
    .section-title { font-size: 1.65rem !important; }
    .sub-section-title { font-size: 1.1rem !important; }

    .sidebar-nav {
        width: 300px;
        right: -300px;
        padding-top: 64px;
    }

    .sidebar-nav.open { transform: translateX(-300px); }
    .sidebar-header { padding: 8px 20px 20px 20px; }
}