/* ===================================================================
   Resources Hub — Docs-style layout with left sidebar
   =================================================================== */

/* Shared width variable so ribbon, header logo block,
   and the page gradient all line up perfectly. */
:root {
    --left-ribbon-width: 280px;
}

/* --- Full-page split background ---
   Left ribbon uses --text-color2-t (same tint as the active sidebar item)
   painted ON TOP of the opaque bgColor that coloring.js sets inline.
   We only set background-image so we don't clobber that opaque color. */
body.resources-page {
    background-image: linear-gradient(
        to right,
        var(--text-color2-t) 0,
        var(--text-color2-t) var(--left-ribbon-width),
        transparent var(--left-ribbon-width),
        transparent 100%
    );
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* Header sits in both color zones — logo block occupies the ribbon width
   so the rest of the header nav visually lives on the right (dark) side.
   Mobile keeps its existing header behavior. */
@media (min-width: 769px) {
    body.resources-page header {
        padding-left: 0;
    }

    body.resources-page #site-title {
        width: var(--left-ribbon-width);
        min-width: var(--left-ribbon-width);
        padding: 0 20px;
        position: fixed;
        box-sizing: border-box;
        font-size: clamp(18px, 1.4vw, 22px);
    }
}

@media (max-width: 768px) {
    body.resources-page {
        background-image: none;
    }
}

/* --- Layout Shell --- */
.resources-layout {
    display: flex;
    min-height: calc(100dvh - 60px);
    color: var(--text-color);
}

/* --- Left Sidebar (Ribbon) --- */
.resources-sidebar {
    position: sticky;
    top: 60px;
    width: var(--left-ribbon-width);
    min-width: var(--left-ribbon-width);
    height: calc(100dvh - 60px);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-scrollable {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 0 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--text-color-t) transparent;
}

.sidebar-scrollable::-webkit-scrollbar { width: 4px; }
.sidebar-scrollable::-webkit-scrollbar-thumb { background: var(--text-color-t); }

/* --- Social icons strip pinned to sidebar bottom --- */
.sidebar-social {
    flex-shrink: 0;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--text-color-t);
}

.sidebar-social .social-icons {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-evenly;
}

.sidebar-social .social-icons a {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sidebar-social .social-icons a:hover {
    transform: scale(1.15);
}

.sidebar-social .social-icons img {
    image-rendering: pixelated;
    cursor: cell;

}

/* --- Home Link --- */
.sidebar-home {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text-color);
    font-family: 'Press Start 2P', cursive;
    font-size: 0.55rem;
    letter-spacing: 1px;
    border-left: 3px solid transparent;
    cursor: cell;
    transition: color 0.15s;
}

.sidebar-home:hover,
.sidebar-home.active {
    color: var(--contrast-color);
    border-left-color: var(--contrast-color);
}



/* --- Sidebar Section Group --- */
.sidebar-group {
    margin-bottom: 4px;
}

/* --- Sidebar Category Label (clickable) --- */
.sidebar-label {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-color);
    padding: 12px 20px 6px;
    margin: 0;
    user-select: none;
    cursor: cell;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: opacity 0.15s;
}

.sidebar-label:hover {
    color: var(--contrast-color);
}

.sidebar-label::after {
    content: '>';
    font-family: 'Press Start 2P', cursive;
    font-size: 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    line-height: 1;
    transform-origin: center center;
    transition: transform 0.2s;
    transform: rotate(90deg);
}

.sidebar-group.collapsed .sidebar-label::after {
    transform: rotate(0deg);
}

/* --- Collapsible Link Container --- */
.sidebar-links {
    overflow: hidden;
    max-height: 600px;
    transition: max-height 0.25s ease;
}

.sidebar-group.collapsed .sidebar-links {
    max-height: 0;
}

/* --- Sidebar Links --- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 20px 7px 24px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.8rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
    cursor: cell;
    border-left: 3px solid transparent;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link:hover {
    background-color: var(--text-color2-t);
    color: var(--contrast-color);
    border-left-color: var(--contrast-color);
}

.sidebar-link.active {
    background-color: var(--text-color2-t);
    color: var(--contrast-color);
    border-left-color: var(--contrast-color);
}

.sidebar-link img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    flex-shrink: 0;
    object-fit: contain;
    object-position: center;
}

/* --- Mobile sidebar toggle --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 600;
    width: 40px;
    height: 40px;
    border: 2px solid var(--text-color);
    background-color: var(--text-color2);
    color: var(--text-color);
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    cursor: cell;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
    border-color: var(--contrast-color);
    color: var(--contrast-color);
}

/* --- Main Content Area --- */
.resources-main {
    flex: 1;
    min-width: 0;
    padding: 32px 40px 64px;
    max-width: 900px;
    text-align: left;
}

.resources-main,
.resources-main h1,
.resources-main h2,
.resources-main h3,
.resources-main h4,
.resources-main h5,
.resources-main h6,
.resources-main p,
.resources-main li,
.resources-main div {
    text-align: left;
}

/* --- Right-side TOC (section nav) --- */
.resources-toc {
    position: sticky;
    top: 60px;
    align-self: flex-start;
    width: 200px;
    min-width: 200px;
    height: calc(100dvh - 60px);
    overflow-y: auto;
    padding: 32px 20px;
    flex-shrink: 0;
    font-size: 0.75rem;
    line-height: 1.5;
    border-left: 1px solid var(--text-color-t);
    scrollbar-width: thin;
    scrollbar-color: var(--text-color-t) transparent;
}

.resources-toc:empty {
    display: none;
}

.resources-toc .toc-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-color);
    margin: 0 0 12px;
    opacity: 0.7;
}

.resources-toc a {
    display: block;
    text-decoration: none;
    text-align: start;
    color: var(--text-color);
    opacity: 0.6;
    padding: 4px 0 4px 10px;
    border-left: 2px solid transparent;
    transition: opacity 0.15s, color 0.15s, border-color 0.15s;
    cursor: cell;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resources-toc a.toc-h3 {
    padding-left: 22px;
    font-size: 0.7rem;
}

.resources-toc a:hover,
.resources-toc a.active {
    opacity: 1;
    color: var(--contrast-color);
    border-left-color: var(--contrast-color);
}

.resources-main.loading {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.15s;
}

/* --- Page Title --- */
.resources-title {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    line-height: 1.6;
    margin: 0 0 8px;
}

.resources-lead {
    font-size: 1rem;
    line-height: 1.7;
    opacity: 0.8;
    margin: 0 0 40px;
    max-width: 600px;
}

/* Offset anchor scroll so headings land below the fixed 60px header */
.resources-main h2,
.resources-main h3,
.resources-main h4 {
    scroll-margin-top: 32px;
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(0.7rem, 1.5vw, 0.95rem);
    margin: 48px 0 8px;
    padding-bottom: 8px;
    line-height: 1.5;
    color: var(--contrast-color);
}

/* --- Article Cards --- */
.article-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1px;
    background-color: var(--text-color-t);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 32px;

}



.article-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    min-width: 0;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.15s;
    cursor: cell;
    position: relative;
}

.article-card:hover {
    background-image:
        linear-gradient(45deg, var(--text-color2-t) 25%, transparent 25%),
        linear-gradient(-45deg, var(--text-color2-t) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--text-color2-t) 75%),
        linear-gradient(-45deg, transparent 75%, var(--text-color2-t) 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

.article-card-thumb {
    width: 64px;
    height: 64px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.article-card-thumb img {
    width: 100%;
    height: 100%;
    margin: 0 !important;
    object-fit: cover;
    image-rendering: pixelated;
    display: block;
}

.article-card-text {
    flex: 1;
    min-width: 0;
}

.article-card-text h3 {
    font-size: 0.88rem;
    font-weight: 700;
    margin: 0 0 3px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-card-text p {
    font-size: 0.78rem;
    margin: 0;
    opacity: 0.65;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card-meta {
    font-size: 0.65rem;
    opacity: 0.5;
    flex-shrink: 0;
    white-space: nowrap;
}

.article-card-tags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.article-card-tag {
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: 8px;
    background-color: var(--text-color);
    color: var(--text-color2);
    font-weight: 600;
    text-transform: lowercase;
}

/* --- Gallery Showcase Strip --- */
.showcase-section {
    margin: 32px 0;
}

.showcase-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}

.showcase-strip a {
    display: block;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
    cursor: cell;
}

.showcase-strip a:hover {
    transform: scale(1.08);
    border-color: var(--contrast-color);
}

.showcase-strip img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    image-rendering: pixelated;
    display: block;
}

/* --- Quick Links Row --- */
.quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0 40px;
}

.quick-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--text-color-t);
    border-radius: 6px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: border-color 0.15s, color 0.15s;
    cursor: cell;
}

.quick-link:hover {
    border-color: var(--contrast-color);
    color: var(--contrast-color);
}

.quick-link img {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

/* --- About Tab Fragment --- */
.about-tab-fragment {
    max-width: 800px;
}

.about-tab-image {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    margin-bottom: 16px;
}

.about-tab-title {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(1rem, 2vw, 1.5rem);
    line-height: 1.6;
    margin: 0 0 24px;
}

.about-tab-body {
    line-height: 2em;
    font-size: 0.95rem;
}

.about-tab-body a {
    color: var(--contrast-color);
    text-decoration: none;
}

.about-tab-body h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8em;
    margin-top: 24px;
    color: var(--contrast-color);
}

.about-tab-body h4 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7em;
    margin-top: 20px;
    color: var(--contrast-color);
}

.about-tab-body ul {
    padding-left: 20px;
}

.about-tab-body li {
    margin-bottom: 8px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .resources-layout {
        flex-direction: column;
    }

    .resources-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        min-width: 260px;
        height: 100dvh;
        z-index: 800;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        background-color: var(--text-color2-t);
        border-right: 1px solid var(--text-color-t);
        transition: left 0.2s ease-out;
        padding-top: 16px;
    }

    .resources-sidebar.open {
        left: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .resources-main {
        padding: 20px 16px 48px;
    }

    .resources-toc {
        display: none;
    }

    .article-card {
        padding: 12px 14px;
    }

    .article-card-thumb {
        width: 40px;
        height: 40px;
    }

    .showcase-strip {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    }
}

@media (max-width: 1100px) {
    .resources-toc {
        display: none;
    }
}

@media (min-width: 1400px) {
    .resources-sidebar {
        width: 280px;
        min-width: 280px;
    }

    .resources-main {
        padding: 40px 56px 80px;
    }
}

/* --- Keyboard shortcut strip in TOC --- */
.toc-shortcuts {
    display: flex;
    gap: 12px;
    padding: 14px 10px;
    border-bottom: 1px solid var(--text-color-t);
    margin-bottom: 12px;
    justify-content: center;
}

.toc-shortcut-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 1.5em !important;
}

.toc-key {
    cursor: cell;
}

.toc-key--active {
    color: var(--contrast-color);
}

.kbd-pressing {
    transform: translateY(2px) !important;
    border-bottom-width: 1px !important;
}

.toc-key-label {
    font-size: 0.5rem;
    color: var(--text-color);
    opacity: 0.6;
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
}

/* ===================================================================
   Side Panel Layout Shift Integration
   =================================================================== */

/* Ensure layout shifts smoothly at the exact speed of the side panel */
.resources-layout {
    transition: padding-right 0.1s ease-out;
    box-sizing: border-box;
}

/* On desktop */
@media (min-width: 769px) {
    /* Compress the main content area by exactly the panel's width */
    body.panel-open .resources-layout {
        padding-right: 400px;
    }

    /* Hide the right-side TOC ribbon when the panel is open */
    body.panel-open .resources-toc {
        display: none;
    }
}

/* On massive screens */
@media (min-width: 1800px) {
    /* Compress by 25% to match the scaled panel width */
    body.panel-open .resources-layout {
        padding-right: 25%;
    }
}
