/* ===== DETAIL HEADER ===== */
.detail-header {
    padding: 9rem 0 2rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}
.detail-header .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 0.75rem;
    color: var(--gray-500);
    font-size: 0.9rem;
}
.detail-header .meta i {
    color: var(--primary);
    width: 18px;
}
.detail-header .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.detail-header .tags span {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.2rem 1rem;
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: 100px;
}

/* ===== CAROUSEL ===== */
.carousel-section {
    background: var(--white);
    padding: 2rem 0 3rem;
}
.carousel-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    background: var(--gray-100);
}
.carousel-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}
.carousel-slide {
    min-width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--gray-100);
}
.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid var(--gray-200);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--gray-700);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    z-index: 10;
}
.carousel-btn:hover {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-md);
}
.carousel-btn.prev { left: 1rem; }
.carousel-btn.next { right: 1rem; }

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1.25rem;
}
.carousel-dots button {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: var(--gray-200);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}
.carousel-dots button.active {
    background: var(--gradient);
    width: 28px;
    border-radius: 8px;
}
.carousel-dots button:hover:not(.active) {
    background: var(--gray-400);
}

/* ===== TABS ===== */
.tabs-section {
    background: var(--bg-light);
    padding: 3rem 0 5rem;
}

.tab-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 2.5rem;
    background: var(--white);
    padding: 0.5rem 1rem 0.4rem;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    /* Visible, styled scrollbar — the fix for inaccessible last tabs */
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}

.tab-nav::-webkit-scrollbar {
    height: 6px;
}
.tab-nav::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 100px;
    margin: 0 0.5rem;
}
.tab-nav::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 100px;
    transition: background 0.2s ease;
}
.tab-nav::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    border-radius: 0;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    flex-shrink: 0;
    scroll-snap-align: start;
}
.tab-btn:hover {
    color: var(--gray-900);
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panels {
    background: var(--white);
    padding: 2rem 2.5rem;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    border-top: none;
    /* Contain any accidental wide content inside the panel */
    overflow-wrap: anywhere;
    min-width: 0;
}
.tab-panel {
    display: none;
    animation: fadeUp 0.3s ease;
}
.tab-panel.active {
    display: block;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   TAB CONTENT — rich text from the Django admin
   ============================================================ */

/* --- Headings --- */
.tab-panel h1,
.tab-panel h2,
.tab-panel h3,
.tab-panel h4,
.tab-panel h5,
.tab-panel h6 {
    color: var(--gray-900);
    font-weight: 700;
    line-height: 1.3;
    margin: 1.75rem 0 0.75rem;
    letter-spacing: -0.01em;
}
.tab-panel h1 { font-size: 1.6rem; }
.tab-panel h2 { font-size: 1.4rem; }
.tab-panel h3 { font-size: 1.2rem; }
.tab-panel h4 { font-size: 1.05rem; }
.tab-panel h5 { font-size: 0.98rem; }
.tab-panel h6 {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--gray-500);
}

.tab-panel h1:first-child,
.tab-panel h2:first-child,
.tab-panel h3:first-child,
.tab-panel h4:first-child,
.tab-panel h5:first-child,
.tab-panel h6:first-child {
    margin-top: 0;
}

/* Thin gradient underline under h2 for a bit of polish */
.tab-panel h2 {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

/* --- Paragraphs --- */
.tab-panel p {
    color: var(--gray-600);
    margin-bottom: 1rem;
    line-height: 1.8;
    font-size: 0.98rem;
    overflow-wrap: anywhere;
}

/* --- Lists --- */
.tab-panel ul,
.tab-panel ol {
    padding-left: 1.5rem;
    color: var(--gray-600);
    margin-bottom: 1.25rem;
}
.tab-panel ul { list-style: disc; }
.tab-panel ol { list-style: decimal; }
.tab-panel li {
    margin-bottom: 0.5rem;
    line-height: 1.75;
    overflow-wrap: anywhere;
}
.tab-panel li::marker {
    color: var(--primary);
    font-weight: 600;
}
.tab-panel ul ul,
.tab-panel ul ol,
.tab-panel ol ul,
.tab-panel ol ol {
    margin-top: 0.5rem;
    margin-bottom: 0;
}
.tab-panel li > p {
    margin-bottom: 0.5rem;
}

/* --- Inline emphasis --- */
.tab-panel strong,
.tab-panel b {
    color: var(--gray-900);
    font-weight: 600;
}
.tab-panel em,
.tab-panel i {
    font-style: italic;
}

/* --- Links --- */
.tab-panel a {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    transition: var(--transition);
    overflow-wrap: anywhere;
}
.tab-panel a:hover {
    color: var(--primary-dark);
}

/* --- Images --- */
.tab-panel img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    background: var(--gray-100);
}
.tab-panel figure {
    margin: 1.75rem 0;
    text-align: center;
}
.tab-panel figure img {
    margin: 0 auto 0.75rem;
}
.tab-panel figcaption {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-style: italic;
    text-align: center;
    line-height: 1.6;
}

/* --- Horizontal rule --- */
.tab-panel hr {
    border: none;
    height: 1px;
    background: var(--gray-200);
    margin: 2rem 0;
}

/* --- Blockquote / callout --- */
.tab-panel blockquote {
    position: relative;
    border-left: 4px solid var(--primary);
    background: rgba(var(--primary-rgb), 0.05);
    padding: 1rem 1.5rem;
    margin: 1.75rem 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--gray-700);
    font-style: italic;
    line-height: 1.75;
}
.tab-panel blockquote p:last-child {
    margin-bottom: 0;
}
.tab-panel blockquote cite {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-500);
    font-style: normal;
    font-weight: 600;
}

/* --- Inline code --- */
.tab-panel code {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas,
                 'Liberation Mono', monospace;
    font-size: 0.86em;
    font-weight: 500;
    background: rgba(var(--primary-rgb), 0.09);
    color: var(--primary-dark);
    padding: 0.15em 0.45em;
    border-radius: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* --- Code blocks --- */
.tab-panel pre {
    background: var(--gray-900);
    color: var(--gray-100);
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas,
                 'Liberation Mono', monospace;
    font-size: 0.83rem;
    line-height: 1.7;
    padding: 1.25rem 1.4rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.5rem 0;
    tab-size: 4;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-600) var(--gray-800);
}
.tab-panel pre::-webkit-scrollbar {
    height: 8px;
}
.tab-panel pre::-webkit-scrollbar-track {
    background: var(--gray-800);
    border-radius: 100px;
}
.tab-panel pre::-webkit-scrollbar-thumb {
    background: var(--gray-600);
    border-radius: 100px;
}
.tab-panel pre::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* Code inside a pre should NOT be treated like inline code */
.tab-panel pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    font-weight: inherit;
    white-space: pre;
}

/* --- Tables --- */
.tab-panel table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tab-panel thead {
    background: var(--gray-50);
}

.tab-panel th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.tab-panel td {
    padding: 0.75rem 1rem;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-100);
    line-height: 1.6;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.tab-panel tbody tr:last-child td {
    border-bottom: none;
}

.tab-panel tbody tr:nth-child(even) {
    background: var(--gray-50);
}

.tab-panel tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.04);
}

/* Any nested table styling */
.tab-panel table table {
    margin: 0;
    font-size: 0.85rem;
}

/* --- Definition lists (occasionally used) --- */
.tab-panel dl {
    margin: 1rem 0;
}
.tab-panel dt {
    font-weight: 600;
    color: var(--gray-900);
    margin-top: 0.75rem;
}
.tab-panel dd {
    margin-left: 1.5rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

/* ===== ACTION BAR ===== */
.action-bar {
    background: var(--white);
    padding: 2.5rem 0;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
}
.action-bar .actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

/* ===== PAGE-SPECIFIC BUTTON VARIANT ===== */
/* .btn-dark wasn't defined anywhere → inherited the blue default link colour. */
.btn-dark {
    background: var(--gray-900);
    color: var(--white);
    border: none;
}
.btn-dark:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.30);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .section-title { font-size: 2rem; }
    .detail-header h1 { font-size: 2rem; }

    /* --- Tabs --- */
    .tab-nav {
        padding: 0.5rem 0.5rem 0.35rem;
        gap: 0;
        border-radius: var(--radius) var(--radius) 0 0;
    }
    .tab-btn {
        padding: 0.6rem 1rem;
        font-size: 0.78rem;
        border-bottom-width: 2px;
    }
    .tab-panels {
        padding: 1.5rem 1.25rem;
        border-radius: 0 0 var(--radius) var(--radius);
    }

    /* --- Carousel --- */
    .carousel-btn { width: 34px; height: 34px; font-size: 0.9rem; }
    .carousel-btn.prev { left: 0.5rem; }
    .carousel-btn.next { right: 0.5rem; }

    /* --- Rich content --- */
    .tab-panel pre {
        font-size: 0.78rem;
        padding: 1rem 1.1rem;
        margin-left: -0.25rem;
        margin-right: -0.25rem;
    }
    .tab-panel table {
        font-size: 0.85rem;
    }
    .tab-panel th,
    .tab-panel td {
        padding: 0.6rem 0.75rem;
    }
    .tab-panel blockquote {
        padding: 0.85rem 1.1rem;
    }
}

@media (max-width: 480px) {
    .detail-header { padding: 8rem 0 1.75rem; }
    .detail-header h1 { font-size: 1.6rem; }

    .action-bar .actions .btn {
        width: 100%;
        justify-content: center;
    }

    .tab-nav {
        padding: 0.4rem 0.35rem 0.3rem;
        /* Slightly wider scrollbar on touch — easier to grab */
        scrollbar-width: auto;
    }
    .tab-nav::-webkit-scrollbar {
        height: 8px;
    }
    .tab-btn {
        font-size: 0.72rem;
        padding: 0.55rem 0.85rem;
    }
    .tab-panels { padding: 1.25rem 1rem; }
    .tab-panel p { font-size: 0.94rem; }
    .tab-panel h2 { font-size: 1.2rem; }
    .tab-panel h3 { font-size: 1.05rem; }

    /* Let the code block bleed edge-to-edge slightly for more room */
    .tab-panel pre {
        font-size: 0.75rem;
        padding: 0.9rem 1rem;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-radius: var(--radius-sm);
    }

    .tab-panel table {
        font-size: 0.8rem;
    }
    .tab-panel th,
    .tab-panel td {
        padding: 0.5rem 0.6rem;
    }
}