/*
 * HTML Book Module - Modern Layout
 * CSS Grid-based 3-column responsive layout
 */

/* CSS Custom Properties for theming */
:root {
    --sidebar-width: 280px;
    --toc-width: 200px;
    --max-content-width: 1600px;
    --header-height: 70px;
    --spacing-unit: 20px;
    --border-radius: 12px;
    --transition-speed: 0.3s;

    /* Colors - will be overridden by theme files */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent: #0095DD;
    --accent-hover: #007ACC;
    --border-color: #dee2e6;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sylfaen', 'Arial', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
}

/* Main Container - CSS Grid */
.html-book-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
    grid-template-areas: "sidebar content toc";
    gap: var(--spacing-unit);
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: var(--spacing-unit);
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar Navigation */
.sidebar {
    grid-area: sidebar;
    position: sticky;
    top: calc(var(--header-height) + var(--spacing-unit));
    height: fit-content;
    max-height: calc(100vh - var(--header-height) - 2 * var(--spacing-unit));
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-unit);
    box-shadow: var(--shadow-sm);
}

/* Main Content Area */
.content-area {
    grid-area: content;
    background-color: var(--bg-primary);
    padding: var(--spacing-unit);
}

/* Table of Contents (Optional) */
.toc-sidebar {
    grid-area: toc;
    position: sticky;
    top: calc(var(--header-height) + var(--spacing-unit));
    height: fit-content;
    max-height: calc(100vh - var(--header-height) - 2 * var(--spacing-unit));
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-unit);
    box-shadow: var(--shadow-sm);
}

/* Header Styles */
.html-book-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-unit);
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Home Button */
.home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition-speed);
    margin-right: 12px;
    flex-shrink: 0;
}

.home-btn:hover {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.home-btn:active {
    transform: translateY(0);
}

.home-btn svg {
    width: 20px;
    height: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0;
}

/* Hamburger Menu Button (Mobile) */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1100;
    margin-right: 15px;
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition-speed);
}

.hamburger-btn.open .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translateY(10px);
}

.hamburger-btn.open .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.open .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translateY(-10px);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* Card Styles (like .eduWinRound) */
.card {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: var(--spacing-unit);
    margin-bottom: var(--spacing-unit);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: box-shadow var(--transition-speed), transform var(--transition-speed);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Category Section */
.category-section {
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.category-header {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--accent);
}

.category-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-unit);
    line-height: 1.5;
}

/* Tag Card */
.tag-card {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: var(--spacing-unit);
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--accent);
    transition: all var(--transition-speed);
}

.tag-card:hover {
    box-shadow: var(--shadow-md);
    border-left-width: 6px;
}

.tag-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--accent);
    font-family: 'Courier New', monospace;
    margin-bottom: 10px;
}

.tag-description {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 15px;
}

/* Code Blocks */
pre {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    margin: 15px 0;
}

code {
    font-family: 'Courier New', 'Consolas', monospace;
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-speed);
    font-family: 'Sylfaen', 'Arial', sans-serif;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
}

/* Search Input */
.search-input {
    width: 100%;
    padding: 10px 15px;
    font-size: 14px;
    font-family: 'Sylfaen', 'Arial', sans-serif;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 149, 221, 0.1);
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar,
.toc-sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.toc-sidebar::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.sidebar::-webkit-scrollbar-thumb,
.toc-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.toc-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus Styles for Accessibility */
a:focus,
button:focus,
input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .sidebar,
    .toc-sidebar,
    .html-book-header {
        display: none;
    }

    .html-book-container {
        grid-template-columns: 1fr;
        grid-template-areas: "content";
    }

    .tag-card {
        page-break-inside: avoid;
    }
}
