:root {
    --header-height: 40px       /* ini adalah variabel yang bisa dipanggil nanti di bagian lain */
}

/* Base text setting */
body {
    font-size: 16px; /* This makes 1rem = 16px */
    line-height: 1.6;
    color: #333;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;

    /*background-color: #f8fafc; /* A light grey so the white portal "pops" */
    background-color: #f8fafc; /* Soft light gray/blue background */
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 20px);
}


/*=========================================================================
========================== The Main Page Skeleton =========================
======= mengatur halaman utamam menjadi 3 baris (header, isi, footer) =====
===========================================================================*/
.container {
    display: grid;
    /* Define 3 rows: Header (auto height), Content (takes up remaining space), Footer (auto) */
    grid-template-rows: auto 1fr auto;
    /* Ensure the container takes at least the full height of the screen */
    min-height: 100vh;

    /* Limit the width */
    max-width: 1500px; 
    width: 98%; /* Ensures a small gap on mobile screens */

    /* Center it on the screen */
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 0 50px rgba(0,0,0,0.05);
    background-color: #ffffff;
}

/* 2. Styling the Header and Footer */
.main-header {
    position: sticky;
    top: 0;
    z-index: 5000;  /* keeps it above other content when scrolling */
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;  /* subtle separator line */
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--header-height)
}

.main-header img {
    height: 28px;
}

/* mengatur warna search box dan icon */
mark {
    background: #fff3b0;
    border-radius: 2px;
    padding: 0 2px;
    color: inherit;
}

mark.active-match {
    background: #f39c12;
    outline: 2px solid #f39c12;
    border-radius: 3px;
}

#prev-btn,
#next-btn {
    display: none;
}

.main-footer {
    background-color: #2c3e50; /* A professional dark blue */
    color: white;
    padding: 20px;
    text-align: center;
}

/* ======================================*/
/* The Middle Section (Nested Grid)      */
/* Halaman menjadi 2 kolom (TOC dan isi) */
/* ======================================*/
.konten-utama {
    display: grid;
    /* Create two columns: 
       Left (toc-sidebar): 300px width
       Right (law-content): 1fr (takes all remaining space) */
    grid-template-columns: 300px 1fr;
    gap: 20px; /* Adds space between the TOC and the Law content */
    padding: 15px;
    padding-right: 30px;
    align-items: start;
}

.pembukaan-grid {
    display: grid;
    grid-template-columns: 110px 1fr; /* Label column and Content column */
    gap: 10px 25px;
    align-items: start;
    padding: 30px 0;
}

.persetujuan-row {
    /* This tells the div to start at column line 1 and end at the very last line */
    grid-column: 1 / -1; 
    text-align: center;
}

.memutuskan-row {
    /* This tells the div to start at column line 1 and end at the very last line */
    grid-column: 1 / -1; 
    text-align: center;
    font-weight: bold;
    letter-spacing: 2px; /* Adds that formal legal look */
    
    /* Optional: making it uppercase as per standard practice */
    text-transform: uppercase;
}

.label {
    font-weight: bold;
}

.item-content p { /* ini untuk mengatur <p> di daerah pembukaan */
    margin-top: 0;
    margin-bottom: 0.5rem; /* Space between paragraphs if there are more than one */
    text-align: left;
    padding-left: 0
}

.item-content ol {
    margin-top: 0;
    padding-left: 1.2rem;
    list-style-position: outside;
    margin-left: 0;
}

.item-content li {
    margin-bottom: 0.5rem;
}

.item-content li:last-child {
    margin-bottom: 0;
}

/* 5. Main Law Content Styling */
.peraturan {
    line-height: 1.6; /* Improves readability for legal text */
    color: #333;
}

.legal-divider {
    position: relative; /* Acts as an anchor for the symbol */
    height: 1px;        /* The thickness of the line */
    background-color: #333; /* A dark gray for the line */
    margin: 25px auto;  /* Large vertical spacing for a "regal" breath */
    width: 75%;         /* Shorter width looks more centered and formal */
    border: none;
}

.legal-divider::before {
    content: "§";       /* The legal section symbol */
    position: absolute;
    top: 50%;           /* Move to middle of the line */
    left: 50%;          /* Move to middle of the page */
    transform: translate(-50%, -50%); /* Perfectly centers the symbol */
    background-color: #ffffff; /* Matches your background exactly */
    padding: 0 20px;    /* Creates the "gap" between the lines and symbol */
    color: #555;        /* A slightly lighter gray for the symbol */
    font-family: "Times New Roman", serif; /* Classic serif font */
    font-size: 1.5rem;  /* Makes it a clear focal point */
}

/* Class ini mengatur tampilan list agar bisa disisipi */
ol.legal-list {
    list-style: none;
    padding-left: 0;
}

ol.legal-list > li {
    position: relative;
    padding-left: 2rem;    /* creates space for the label */
    text-indent: 0;        /* no longer needed for the label trick */
}

ol.legal-list > li::before {
    content: attr(data-label) ".";
    position: absolute;
    left: 0;
    top: 0;
    min-width: 1.75rem;
    font-weight: normal;
}

ol.legal-list > li:has(> .riwayat-perubahan)::before {
    top: 0.4rem;    /* adjust this value to taste */
}

section + section {
    margin-top: 1.5rem;
}

article.blok-pasal {
    /*font-weight: 500;*/
}

article.blok-pasal + aside.penjelasan {
    margin-top: -0.35rem;
}

/* ================================= */
/* BAGIAN INI MENGATUR TAMPILAN AYAT */
/* ================================= */

/* 1. Standard Ayat Spacing */
.ayat {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 1rem; /* Adjust this to your preferred uniform gap */
    padding-bottom: 0;
}

/* 2. Neutralize the List's "Extra Air" */
.isi-ayat {
    flex: 1;
}
.isi-ayat ul {
    margin-top: 0.5rem;   /* Space between the text and the list */
    margin-bottom: 0;     /* KILL the bottom margin that pushes next ayat */
    padding-left: 2.5rem;
}

.isi-ayat ol {
    margin-top: 0.5rem;
    margin-bottom: 0;
    padding-left: 2.5rem; /* Increased padding to accommodate double letters */
    width: 100%;
    box-sizing: border-box;

}

/* 3. The "Safety Net" - No matter what the last element is, 
   it shouldn't have a bottom margin inside the ayat container */
.isi-ayat > *:last-child {
    margin-bottom: 0 !important;
}

/* 4. List Item Spacing */
.isi-ayat ol li {
    margin-bottom: 0.3rem;
    line-height: 1.5;
}

.isi-ayat ol li:last-child {
    margin-bottom: 0;
}

/* ================================= */
/* ARTICLE / PASAL BLOCK             */
/* ini nggak pakai titik di depannya */
/* jadi ini bukan class tapi tag     */
/* ================================= */

article {
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background-color: #ffffff;
}

article.peraturan {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

article.blok-pasal {
    padding: 0.5rem 1.25rem;
    margin-bottom: 1rem;
}

article h6 {
    border-bottom: 1px solid #93c5fd; /* blue-300 — a touch stronger under the title */
    padding-bottom: 0.4rem;
    margin-bottom: 0.75rem;
}

article .ayat + .ayat {
    border-top: 1px solid #dbeafe;    /* blue-100 — whisper-light separator */
    padding-top: 0.75rem;
}


/* ============================================== */
/* =========   HOME PAGE SETTING  =============== */
/* ============================================== */
/* 1. The Main Wrapper - Centers everything and limits width */
.home-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* 2. The Header Area */
.site-header {
    text-align: center;
    padding: 60px 20px;
}

.site-logo {
    max-width: 100%;
    height: auto;
    width: 664px;
}

/* 3. The Grid Parent */
.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
}

/* 4. The Individual Card */
.category-card {
    text-decoration: none;
    color: inherit;
    flex: 1 1 400px; /* Base width of 400px, but can grow */
    max-width: 450px;
}

/* The box inside the link */
.card-content {
    background-color: #f1f5f9; /* Your sidebar color */
    padding: 40px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    height: 100%;
    box-sizing: border-box;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Subtle "Hover" effect for better UX */
.card-content:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.card-title {
    margin-top: 0;
    color: #0f172a;
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 10px;
}

.card-description {
    color: #475569;
    line-height: 1.6;
}

.card-link-text {
    margin-top: 20px;
    color: #3b82f6;
    font-weight: 600;
}


/* ============================================== */
/* ========= MOBILE PHONE DISPLAY =============== */
/* ============================================== */
@media screen and (max-width: 600px) {
    body {
        line-height: normal;
    }

    .main-header {
        padding: 8px;
        height: 40px;
    }

    .main-header img {
        height: 24px;
    }

    header.search-open .main-header-logo {
        display: none;
    }

    header.search-open #search-input {
        width: 100%;
        max-width: 150px;
    }

    .pembukaan-grid {
        grid-template-columns: 1fr; /* Single column: label stacks above content */
        gap: 0;
        padding: 15px 0;
    }

    .pembukaan-grid .label {
        cursor: pointer;
        padding: 10px 8px;
        border-radius: 6px;
        background-color: #f1f5f9;
        border: 1px solid #e2e8f0;
        margin-top: 8px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        user-select: none;
    }

    /* The chevron indicator appended via CSS */
    .pembukaan-grid .label::after {
        content: "▶";
        font-size: 10px;
        color: #64748b;
        transition: transform 0.25s ease;
        flex-shrink: 0;
        margin-left: 8px;
    }

    .pembukaan-grid .label.is-open::after {
        transform: rotate(90deg);
    }

    /* Content hidden by default, revealed when label is toggled */
    .pembukaan-grid .item-content {
        display: none;
        padding: 10px 8px 4px 8px;
        margin-bottom: 4px;
    }

    .pembukaan-grid .label.is-open + .item-content {
        display: block;
    }

    .item-content ol {
        margin-top: 0;
        padding-left: 1rem;
        list-style-position: outside;
        margin-left: 0;
    }

    /* Remove side margins and shadow from container on mobile */
    .container {
        width: 100%;
        box-shadow: none;
    }
 
    /* Tighten konten-utama padding on all sides */
    .konten-utama {
        padding: 8px;
    }
 
    /* Tighten list indentation — legal-list (Pasal 1 definitions etc.) */
    ol.legal-list > li {
        padding-left: 1.5rem;
    }

    /* Tighten list indentation — ayat body lists */
    .isi-ayat ol {
        padding-left: 0rem;
    }
}