/* Responsive Design */

/* TOC toggle button — shown only on tablet/mobile */
.toc-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    width: 52px;
    height: 52px;
    background: var(--secondary);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 250;
    transition: background 0.2s, box-shadow 0.2s;
    font-weight: bold;
}

.toc-toggle:active,
.toc-toggle:hover {
    background: var(--accent);
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

/* Sidebar drawer on tablet/mobile */
.sidebar-drawer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background: var(--white);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    z-index: 300;
    overflow-y: auto;
    padding: 1rem;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.sidebar-drawer.open {
    transform: translateX(0);
    display: block;
}

.sidebar-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 299;
    cursor: pointer;
}

.sidebar-drawer-overlay.open {
    display: block;
}

.sidebar-drawer-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--gray-600);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar content inside drawer — must override `.sidebar { display:none }` from the 1024px breakpoint */
.sidebar-drawer .sidebar {
    display: block !important;
    background: transparent;
    padding: 2.5rem 0 0 0;
    box-shadow: none;
    position: static;
    max-height: none;
    border: none;
}

.sidebar-drawer .sidebar h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--primary);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
}

.sidebar-drawer .sidebar ul {
    list-style: none;
}

.sidebar-drawer .sidebar li {
    margin: 0;
}

.sidebar-drawer .sidebar a {
    color: var(--gray-700);
    font-size: 0.9rem;
    padding: 0.5rem 0;
    display: block;
}

@media (max-width: 1200px) {
    .board-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .sidebar {
        display: none; /* left TOC hidden on tablet/mobile */
    }

    .image-thumbnail-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    /* Compact header on tablet */
    header {
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }

    .header-content {
        padding: 0.6rem 1rem;
        gap: 0.5rem;
    }

    .logo-img {
        height: 32px;
    }

    /* Burger button shows the TOP navigation as a dropdown */
    .nav-toggle {
        display: block;
        margin-left: auto;
        font-size: 1.5rem;
        line-height: 1;
    }

    nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        border-bottom: 1px solid var(--gray-200);
        box-shadow: var(--shadow);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        z-index: 49;
    }

    nav.open {
        max-height: 320px;
    }

    nav ul {
        flex-direction: column;
        gap: 0;
        padding: 0.25rem 1rem 0.75rem;
    }

    nav li {
        width: 100%;
    }

    nav a {
        display: block;
        padding: 0.85rem 0.25rem;
        font-size: 1rem;
        border-bottom: 1px solid var(--gray-100);
    }

    nav li:last-child a {
        border-bottom: none;
    }

    .home-hero {
        padding: 3rem 1.5rem;
    }

    .home-hero h1 {
        font-size: 2.25rem;
        line-height: 1.3;
    }

    .home-hero p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    .home-hero-stats {
        gap: 1.5rem;
        flex-wrap: wrap;
        margin-bottom: 1.5rem;
    }

    .hero-stat {
        flex: 1;
        min-width: 120px;
    }

    .hero-stat span {
        font-size: 2.25rem;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .category-card {
        overflow: hidden;
    }

    .category-card-img {
        height: 140px;
    }

    .category-card-body {
        padding: 1rem;
    }

    .category-card-body h3 {
        font-size: 1rem;
    }

    .category-card-body p {
        font-size: 0.8rem;
    }

    .board-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .board-card {
        border-radius: 8px;
    }

    .board-card-img {
        height: 110px;
    }

    .board-card-body {
        padding: 0.75rem;
    }

    .board-card-body h3 {
        font-size: 0.85rem;
    }

    .listing-page { padding: 0 1rem 2rem; }

    .content-wrapper {
        padding: 2rem 1.5rem;
    }

    .page-title {
        font-size: 2rem;
    }

    .specs-grid {
        grid-template-columns: 1fr;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn {
        text-align: center;
        justify-content: center;
        width: 100%;
    }

    .image-gallery {
        grid-template-columns: 1fr;
    }

    table, .data-table {
        font-size: 0.875rem;
    }

    table th, .data-table th {
        padding: 0.75rem 1rem;
    }

    table td, .data-table td {
        padding: 0.75rem 1rem;
    }

    .container {
        padding: 1rem;
    }

    .sidebar {
        padding: 1.5rem;
    }

    .feature-list li {
        padding: 0.75rem 0;
    }

    .meta-info {
        padding: 1rem;
        margin: 1rem 0;
    }

    .sidebar h3 {
        font-size: 1rem;
    }

    .sidebar a {
        font-size: 0.9rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    /* ─── HEADER ─────────────────────────────────────────────────────────── */
    header {
        box-shadow: 0 1px 2px rgba(0,0,0,0.08);
        padding: 0;
    }

    .header-content {
        padding: 0.4rem 0.6rem;
        gap: 0;
        max-width: 100%;
    }

    .logo {
        flex-shrink: 0;
    }

    .logo-img {
        height: 24px;
    }

    /* nav dropdown behaviour inherited from the 768px breakpoint */

    /* ─── HERO ────────────────────────────────────────────────────────────── */
    .home-hero {
        padding: 1.5rem 0.8rem;
        margin: 0;
    }

    .home-hero h1 {
        font-size: 1.5rem;
        line-height: 1.2;
        margin: 0 0 0.5rem;
        font-weight: 700;
    }

    .home-hero p {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
        opacity: 0.95;
        line-height: 1.5;
    }

    .home-hero-stats {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
        justify-content: space-around;
        flex-wrap: wrap;
    }

    .hero-stat {
        flex: 0 1 auto;
        font-size: 0.65rem;
        text-align: center;
    }

    .hero-stat span {
        font-size: 1.4rem;
        display: block;
        font-weight: 700;
        line-height: 1;
        margin-bottom: 0.2rem;
    }

    .home-hero-actions {
        flex-direction: column;
        gap: 0.4rem;
        width: 100%;
    }

    .btn {
        min-height: 40px;
        padding: 0.55rem 1rem;
        font-size: 0.85rem;
        border-radius: 6px;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
    }

    /* ─── CARDS ────────────────────────────────────────────────────────────── */
    .category-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        margin: 0 -0.8rem;
        padding: 0 0.8rem;
    }

    .category-card {
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    }

    .category-card:active {
        transform: translateY(-2px);
    }

    .category-card-img {
        height: 120px;
        background: linear-gradient(135deg, #f0f4f8 0%, #e6eef7 100%);
    }

    .category-card-img img {
        padding: 0.75rem;
    }

    .category-card-body {
        padding: 0.8rem;
    }

    .category-card-body h3 {
        font-size: 0.95rem;
        font-weight: 600;
        margin: 0 0 0.35rem;
        color: #1a365d;
    }

    .category-card-body p {
        font-size: 0.75rem;
        margin: 0;
        color: #718096;
        line-height: 1.4;
    }

    .board-grid {
        grid-template-columns: 1fr;
        gap: 0.6rem;
        margin: 0 -0.8rem;
        padding: 0 0.8rem;
    }

    .board-card {
        border-radius: 6px;
        border: none;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }

    .board-card:active {
        transform: translateY(-2px);
    }

    .board-card-img {
        height: 100px;
        background: #f7fafc;
    }

    .board-card-body {
        padding: 0.65rem;
    }

    .board-card-body h3 {
        font-size: 0.8rem;
        line-height: 1.3;
        margin: 0;
        margin-bottom: 0.25rem;
    }

    .board-card-tag {
        font-size: 0.6rem;
        margin-bottom: 0.2rem;
    }

    /* ─── LISTING PAGE ───────────────────────────────────────────────────── */
    .listing-page {
        padding: 0.8rem 0.8rem 1.5rem;
    }

    .listing-hero {
        margin-bottom: 1.5rem;
        text-align: center;
    }

    .listing-hero h1 {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }

    .listing-hero p {
        font-size: 0.8rem;
        color: #718096;
    }

    .listing-section {
        margin-bottom: 1.5rem;
    }

    .listing-section-title {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .listing-count {
        font-size: 0.8rem;
        font-weight: 400;
        color: #a0aec0;
    }

    /* ─── CONTENT ──────────────────────────────────────────────────────────── */
    .container {
        padding: 0.8rem;
        gap: 0.75rem;
    }

    .content-wrapper {
        padding: 1rem 0.8rem;
    }

    .page-title {
        font-size: 1.4rem;
        margin: 0 0 1rem;
    }

    .section-title {
        font-size: 1.15rem;
        margin: 1.25rem 0 0.75rem;
    }

    h1 {
        font-size: 1.35rem;
        margin: 1.5rem 0 0.75rem;
    }

    h2 {
        font-size: 1.1rem;
        margin: 1.25rem 0 0.65rem;
    }

    h3 {
        font-size: 0.95rem;
        margin: 1rem 0 0.5rem;
    }

    p {
        font-size: 0.9rem;
        line-height: 1.6;
        margin-bottom: 0.8rem;
    }

    /* ─── IMAGES ───────────────────────────────────────────────────────────── */
    .image-main-wrapper {
        height: 180px;
        margin-bottom: 0.8rem;
    }

    .image-thumbnail-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .image-thumbnail {
        height: 40px;
    }

    /* ─── TABLES ────────────────────────────────────────────────────────────── */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0.8rem -0.8rem;
        padding: 0 0.8rem;
        border-radius: 0;
    }

    table, .data-table {
        font-size: 0.75rem;
        border-collapse: collapse;
        min-width: 100%;
    }

    table th, .data-table th {
        padding: 0.5rem;
        font-weight: 600;
    }

    table td, .data-table td {
        padding: 0.5rem;
    }

    /* ─── SIDEBAR & BREADCRUMB ──────────────────────────────────────────────── */
    .sidebar {
        padding: 0.8rem;
    }

    .sidebar h3 {
        font-size: 0.9rem;
        margin-bottom: 0.8rem;
    }

    .sidebar a {
        font-size: 0.8rem;
        padding: 0.3rem 0;
    }

    .breadcrumb {
        font-size: 0.7rem;
        margin-bottom: 1rem;
        gap: 0.5rem;
    }

    /* ─── METADATA ────────────────────────────────────────────────────────────── */
    .meta-info {
        padding: 0.7rem;
        margin: 0.8rem 0;
        font-size: 0.85rem;
    }

    .meta-label, .meta-value {
        display: block;
        font-size: 0.85rem;
    }

    /* ─── BUTTONS & LINKS ────────────────────────────────────────────────────── */
    .btn-group, .buy-links {
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
    }

    .buy-links a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.85rem;
        padding: 0.65rem;
    }

    .feature-list li {
        gap: 0.5rem;
        padding: 0.4rem 0;
        font-size: 0.9rem;
    }

    /* ─── FOOTER ────────────────────────────────────────────────────────────── */
    footer {
        padding: 1.2rem 0.8rem;
        margin-top: 1.5rem;
    }

    footer p {
        font-size: 0.75rem;
        margin-bottom: 0.4rem;
        line-height: 1.4;
    }

    /* ─── GENERAL ────────────────────────────────────────────────────────────── */
    body {
        font-size: 16px;
    }

    .quick-specs {
        padding: 1rem;
        margin: 1.2rem 0;
    }

    .specs-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .spec-label {
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    .spec-value {
        font-size: 0.9rem;
        font-weight: 600;
    }
}
