/* ==========================================================================
   RESULT PILLAR PAGES – 3-COLUMN LAYOUT
   Left TOC · Center content · Right "Other Lotteries"
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Base grid (desktop)
   -------------------------------------------------------------------------- */
.datochai-pillar-wrapper {
    display: grid;
    grid-template-columns: 250px 1fr 280px;
    gap: 30px;
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
    align-items: start;
}

/* --------------------------------------------------------------------------
   2. Sticky sidebars
   The !important flags fight a parent overflow/transform rule elsewhere.
   -------------------------------------------------------------------------- */
.pillar-sidebar {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 120px !important;
    align-self: start;
    height: fit-content;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    z-index: 10;
    min-height: 0;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   3. Sidebar widget base
   -------------------------------------------------------------------------- */
.pillar-widget {
    background: var(--color-surface-primary);
    border: 1px solid var(--color-border-secondary);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.widget-title {
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: 10px;
    margin: 0 0 15px 0;
}

/* --------------------------------------------------------------------------
   4. TOC toggle – desktop is always open
   -------------------------------------------------------------------------- */
.toc-toggle-btn          { display: none; }
.toc-collapsible-area    { display: block; }

/* --------------------------------------------------------------------------
   5. Auto-generated Table of Contents
   -------------------------------------------------------------------------- */
.datochai-auto-toc {
    list-style: none;
    padding: 0;
    margin: 0;
}

.datochai-auto-toc li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.datochai-auto-toc a {
    display: block;
    text-decoration: none;
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.datochai-auto-toc a:hover {
    color: var(--color-accent);
    padding-left: 5px;
}

/* Hierarchy indentation */
.toc-item-h2 {
    margin-left: 0;
    margin-top: 15px;
}
.toc-item-h2 a {
    font-weight: 700;
    color: var(--color-text-primary);
}

.toc-item-h3 {
    margin-left: 15px;
}
.toc-item-h3 a {
    font-size: 13px;
    font-weight: 500;
}

.toc-item-h4 {
    margin-left: 30px;
}
.toc-item-h4 a {
    font-size: 12px;
    font-weight: normal;
    color: var(--color-text-secondary);
}

/* --------------------------------------------------------------------------
   6. Right sidebar – other lotteries buttons
   -------------------------------------------------------------------------- */
.other-lotteries-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lottery-sidebar-btn {
    display: block;
    background: var(--color-surface-tertiary);
    color: var(--color-text-primary);
    padding: 10px 15px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    border-left: 4px solid var(--color-accent);
    transition: all 0.2s ease;
}

.lottery-sidebar-btn:hover {
    background: var(--color-accent);
    color: var(--color-text-inverse);
    transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   7. Center column
   -------------------------------------------------------------------------- */
.pillar-main-content {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    width: 100%;
}

.datochai-title {
    text-align: center;
}

/* --------------------------------------------------------------------------
   8. Tablet breakpoint (≤1024px)
   3-column collapses to 2-column: center on left, right sidebar on right.
   Left TOC moves above the article and becomes collapsible.
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .datochai-pillar-wrapper {
        grid-template-columns: 1fr 250px;
    }

    .left-sidebar {
        grid-column: 1;
        grid-row: 1;
        position: relative;
        top: 0;
        margin-bottom: -10px;
    }

    .pillar-main-content {
        grid-column: 1;
        grid-row: 2;
    }

    .right-sidebar {
        grid-column: 2;
        grid-row: 1 / span 2;
        position: sticky;
        top: 100px;
    }

    .left-sidebar .pillar-widget {
        padding: 15px 20px;
    }

    /* TOC title becomes a tap-target */
    .widget-title.toc-title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
        margin-bottom: 0;
        border-bottom: none;
    }

    .toc-toggle-btn {
        display: block;
        font-size: 16px;
        color: var(--color-accent);
        transition: transform 0.3s ease;
    }

    .toc-collapsible-area {
        display: none;
        padding-top: 15px;
        margin-top: 10px;
        border-top: 1px solid var(--color-border-secondary);
    }

    .toc-collapsible-area.active {
        display: block;
    }

    .widget-title.toc-title.active .toc-toggle-btn {
        transform: rotate(180deg);
    }
}

/* --------------------------------------------------------------------------
   9. Mobile breakpoint (≤768px)
   Everything stacks vertically.
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .datochai-pillar-wrapper {
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr; /* kept for old browsers, ignored because of flex */
    }

    .left-sidebar {
        order: 1;
        width: 100%;
        margin-bottom: 20px;
    }

    .pillar-main-content {
        order: 2;
        width: 100%;
    }

    .right-sidebar {
        order: 3;
        position: relative;
        top: 0;
        width: 100%;
        margin-top: 30px;
    }

    .other-lotteries-grid {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .lottery-sidebar-btn {
        flex: 1 1 45%;
        text-align: center;
        padding: 12px 10px;
    }
}

/* --------------------------------------------------------------------------
   10. Sticky workaround
   Ensures the pillar layout doesn't clip the sticky sidebars.
   -------------------------------------------------------------------------- */
.datochai-pillar-wrapper,
.layout-wrapper {
    overflow: visible !important;
}

/* --------------------------------------------------------------------------
   11. Large-screen scaling
   Proportional container growth on wide monitors.
   -------------------------------------------------------------------------- */
@media (min-width: 1280px) {
    .datochai-pillar-wrapper {
        grid-template-columns: 280px minmax(0, 1fr) 280px;
        gap: 50px;
        max-width: 1400px;
    }
}

@media (min-width: 1600px) {
    .datochai-pillar-wrapper {
        grid-template-columns: 300px minmax(0, 1fr) 300px;
        gap: 60px;
        max-width: 1550px;
    }
}

@media (min-width: 2000px) {
    .datochai-pillar-wrapper {
        grid-template-columns: 320px minmax(0, 1fr) 320px;
        max-width: 1750px;
    }
}

/* ==========================================================================
   RESULT HUB DISCLOSURE, COMPLIANCE & ACTIONS (Theme Variable Compliant)
   ========================================================================== */
.crc-timestamp-disclosure {
    font-size: 13.5px;
    color: var(--color-text-secondary);
    font-style: italic;
    margin-top: 14px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.crc-timestamp-disclosure strong {
    color: var(--color-text-primary);
    font-style: normal;
}

.datochai-compliance-callout {
    background: var(--color-surface-tertiary);
    border: 1px solid var(--color-border-secondary);
    border-left: 4px solid var(--color-warning);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--color-text-primary);
    margin: 28px 0;
    line-height: 1.6;
}

.datochai-compliance-callout a {
    color: var(--color-accent);
    font-weight: 700;
    text-decoration: underline;
}

/* Quick Guide / Panduan Pantas Callout */
.datochai-result-quicklinks {
    background: var(--card-bg, var(--color-surface-primary));
    color: var(--text-color, var(--color-text-primary));
    border: 1px solid var(--border-color, var(--color-border-secondary));
    border-left: 4px solid var(--color-primary, #2563eb);
    padding: 14px 18px;
    margin: 20px 0;
    border-radius: var(--radius-sm, 6px);
    line-height: 1.6;
}

.datochai-result-quicklinks strong {
    color: var(--text-color, var(--color-text-primary));
}

.datochai-result-quicklinks a {
    color: var(--color-accent);
    font-weight: 700;
}

body.dark-mode .datochai-result-quicklinks,
[data-theme="dark"] .datochai-result-quicklinks {
    background: var(--card-bg, #1a1a1a) !important;
    color: var(--text-color, #f0f0f0) !important;
    border-color: var(--border-color, #333333) !important;
    border-left-color: var(--color-primary, #3b82f6) !important;
}

.crc-hub-card-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 15px;
}

.crc-hub-card-actions .crc-btn-primary,
.crc-hub-card-actions .crc-btn-secondary,
.crc-hub-card-actions .crc-btn-prediction {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.crc-hub-card-actions .crc-btn-primary {
    background: var(--color-accent);
    color: #ffffff !important;
    border: 1px solid var(--color-accent);
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.2);
}

.crc-hub-card-actions .crc-btn-primary:hover {
    background: var(--color-accent-dark);
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(204, 0, 0, 0.35);
    transform: translateY(-2px);
}

.crc-hub-card-actions .crc-btn-secondary,
.crc-hub-card-actions .crc-btn-prediction {
    background: var(--color-primary, #2563eb);
    color: #ffffff !important;
    border: 1px solid var(--color-primary, #2563eb);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.crc-hub-card-actions .crc-btn-secondary:hover,
.crc-hub-card-actions .crc-btn-prediction:hover {
    background: var(--color-primary-dark, #1d4ed8);
    border-color: var(--color-primary-dark, #1d4ed8);
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
    transform: translateY(-2px);
}

/* ==========================================================================
   RESULT HUB (/result/) – 3-COLUMN AD-ISOLATED GRID LAYOUT
   ========================================================================== */
.datochai-pillar-wrapper--full {
    display: block;
    width: 95%;
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Default: rails hidden */
.datochai-side-ad { display: none; }

/* Desktop grid: content and rails share the row — no overlap */
@media (min-width: 1400px) {

    .datochai-pillar-wrapper--full {
        display: grid;
        grid-template-columns: 160px minmax(0, 1fr) 160px;
        column-gap: 20px;
        width: 95%;
        max-width: 1500px;
        margin: 40px auto;
        padding: 0 20px;
    }

    .datochai-side-ad {
        display: block;
        width: 160px;
        height: 600px;
        position: sticky;
        top: 150px;
        align-self: start;
    }

    .datochai-side-ad--left  { grid-column: 1; grid-row: 1; }
    .datochai-side-ad--right { grid-column: 3; grid-row: 1; }

    .datochai-main-content {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
    }
}

@media (max-width: 768px) {
    .datochai-pillar-wrapper--full {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
        padding: 0 10px;
        display: block;
    }
}

.datochai-pillar-wrapper--full .pillar-main-content {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.datochai-pillar-wrapper.datochai-pillar-wrapper--full .datochai-page-header,
body.page-id-386 .datochai-page-header {
    text-align: center;
}

.datochai-pillar-wrapper.datochai-pillar-wrapper--full .datochai-breadcrumbs,
body.page-id-386 .datochai-breadcrumbs {
    justify-content: center;
}

/* 10 Result Boards - Responsive 3-Column Grid spanning full width */
.datochai-pillar-wrapper.datochai-pillar-wrapper--full .crc-hub-grid,
body.page-id-386 .crc-hub-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 30px !important;
    align-items: start !important;
    width: 100% !important;
}

.datochai-pillar-wrapper.datochai-pillar-wrapper--full .crc-hub-grid .crc-hub-item,
body.page-id-386 .crc-hub-grid .crc-hub-item {
    width: 100% !important;
    min-width: 0 !important;
}

.datochai-pillar-wrapper.datochai-pillar-wrapper--full .crc-hub-grid .crc-ui-wrapper,
body.page-id-386 .crc-hub-grid .crc-ui-wrapper {
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
}

@media (max-width: 1100px) {
    .datochai-pillar-wrapper.datochai-pillar-wrapper--full .crc-hub-grid,
    body.page-id-386 .crc-hub-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .datochai-pillar-wrapper.datochai-pillar-wrapper--full .crc-hub-grid,
    body.page-id-386 .crc-hub-grid {
        grid-template-columns: 1fr !important;
    }
}
