/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: #f0f8ff; /* AliceBlue - easy on eyes */
    color: #333;
}

/* Performance & SEO Tweaks */
img {
    max-width: 100%;
    height: auto; /* Prevent layout shift if width is set */
    display: block; /* Remove bottom space */
}

/* Header & Navigation */
header {
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #007bff;
    text-decoration: none;
}

.nav-links {
    list-style: none;
    display: flex;
}

.nav-links li {
    margin-left: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: #007bff;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.bar {
    height: 3px;
    width: 25px;
    background-color: #333;
    margin: 4px 0;
    transition: 0.4s;
}

/* Mobile Menu Logic */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        text-align: center;
        background-color: #fff;
        position: absolute;
        top: 60px; /* Adjust based on navbar height */
        left: 0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        margin: 1.5rem 0;
    }
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #6dd5fa, #2980b9);
    color: white;
    text-align: center;
    padding: 4rem 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.btn {
    display: inline-block;
    padding: 0.8rem 2rem;
    background-color: #fff;
    color: #2980b9;
    border-radius: 50px;
    text-decoration: none;
    font-weight: bold;
    transition: background 0.3s;
}

.btn:hover {
    background-color: #f1f1f1;
}

/* Content Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
    }
}

/* Main Content Styles */
.main-content {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    content-visibility: auto; /* Performance: skip rendering off-screen */
    contain-intrinsic-size: 1000px;
}

.sidebar {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: fit-content;
    content-visibility: auto;
    contain-intrinsic-size: 500px;
}

.sidebar h3 {
    margin-bottom: 1rem;
    color: #007bff;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

.sidebar ul {
    list-style: none;
}

.sidebar li {
    margin-bottom: 0.8rem;
}

.sidebar a {
    text-decoration: none;
    color: #555;
}

.sidebar a:hover {
    color: #007bff;
    text-decoration: underline;
}

/* Footer */
footer {
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

/* Table Styles for Multiplication Chart */
.multiplication-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 1.1rem;
}

.multiplication-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: center;
}

.multiplication-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.multiplication-table th {
    background-color: #007bff;
    color: white;
    padding: 12px;
}

/* Ladder Style (Pyramid) */
.ladder-row {
    display: flex;
    margin-bottom: 10px;
}

.ladder-cell {
    border: 1px solid #ccc;
    padding: 10px;
    margin-right: 5px;
    background-color: #e3f2fd;
    border-radius: 4px;
    min-width: 100px;
    text-align: center;
}

/* Print Gallery Styles */
.print-gallery .card {
    transition: transform 0.2s, box-shadow 0.2s;
    background: #fff;
}
.print-gallery .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

/* Print Styles */
@media print {
    header, footer, .sidebar, .hero, .print-hide {
        display: none !important;
    }
    
    .container {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .main-content {
        box-shadow: none;
        padding: 0;
        border: none;
        content-visibility: visible; /* Ensure visible for print */
    }

    body {
        background-color: #fff;
        font-size: 12pt;
    }
    
    a[href]:after {
        content: none !important;
    }

    /* Specialized print rules for chart pages */
    .print-chart-page .main-content > *:not(.chart-container) {
        display: none !important;
    }
    
    .print-chart-page .chart-container {
        display: block !important;
        width: 100%;
        margin: 0;
        padding: 0;
        page-break-inside: avoid;
    }
    
    /* Ensure table fits on page */
    .print-chart-page .multiplication-table {
        font-size: 10pt; /* Slightly smaller for print */
    }
    
    .print-chart-page .big99-table {
        font-size: 8pt;
    }
}
