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

/* CSS Variables for theming */
:root {
    --bg-primary: #fafafa;
    --bg-secondary: #fff;
    --text-primary: #333;
    --text-secondary: #666;
    --text-heading: #1a1a1a;
    --text-content: #292929;
    --border-color: #e0e0e0;
    --border-light: #f0f0f0;
    --hover-bg: #f5f5f5;
    --link-color: #007bff;
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #ccc;
    --scrollbar-thumb-hover: #999;
    --dropdown-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Dark mode variables */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-heading: #f0f0f0;
    --text-content: #d0d0d0;
    --border-color: #404040;
    --border-light: #333;
    --hover-bg: #333;
    --link-color: #4da3ff;
    --scrollbar-track: #2a2a2a;
    --scrollbar-thumb: #555;
    --scrollbar-thumb-hover: #777;
    --dropdown-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Text size classes - Comprehensive scaling system */
/* Small text size */
.text-size-small {
    --scale-factor: 0.85;
}

.text-size-small h2 {
    font-size: calc(2rem * var(--scale-factor)) !important;
}

.text-size-small h3 {
    font-size: calc(1.5rem * var(--scale-factor)) !important;
}

.text-size-small p,
.text-size-small li {
    font-size: calc(1.125rem * var(--scale-factor)) !important;
}

.text-size-small .nav-section h3 {
    font-size: calc(0.875rem * var(--scale-factor)) !important;
}

.text-size-small .nav-link {
    font-size: calc(0.9rem * var(--scale-factor)) !important;
}

.text-size-small .site-title {
    font-size: calc(1.25rem * var(--scale-factor)) !important;
}

.text-size-small .dropdown-toggle {
    font-size: calc(0.95rem * var(--scale-factor)) !important;
}

.text-size-small .top-nav {
    min-height: calc(60px * var(--scale-factor)) !important;
}

/* Normal text size (default) */
.text-size-normal {
    --scale-factor: 1;
}

/* Big text size */
.text-size-big {
    --scale-factor: 1.15;
}

.text-size-big h2 {
    font-size: calc(2rem * var(--scale-factor)) !important;
}

.text-size-big h3 {
    font-size: calc(1.5rem * var(--scale-factor)) !important;
}

.text-size-big p,
.text-size-big li {
    font-size: calc(1.125rem * var(--scale-factor)) !important;
}

.text-size-big .nav-section h3 {
    font-size: calc(0.875rem * var(--scale-factor)) !important;
}

.text-size-big .nav-link {
    font-size: calc(0.9rem * var(--scale-factor)) !important;
}

.text-size-big .site-title {
    font-size: calc(1.25rem * var(--scale-factor)) !important;
}

.text-size-big .dropdown-toggle {
    font-size: calc(0.95rem * var(--scale-factor)) !important;
}

.text-size-big .top-nav {
    min-height: calc(60px * var(--scale-factor)) !important;
}

/* Ultra big text size */
.text-size-ultrabig {
    --scale-factor: 1.4;
}

.text-size-ultrabig h2 {
    font-size: calc(2rem * var(--scale-factor)) !important;
}

.text-size-ultrabig h3 {
    font-size: calc(1.5rem * var(--scale-factor)) !important;
}

.text-size-ultrabig p,
.text-size-ultrabig li {
    font-size: calc(1.125rem * var(--scale-factor)) !important;
}

.text-size-ultrabig .nav-section h3 {
    font-size: calc(0.875rem * var(--scale-factor)) !important;
}

.text-size-ultrabig .nav-link {
    font-size: calc(0.9rem * var(--scale-factor)) !important;
}

.text-size-ultrabig .site-title {
    font-size: calc(1.25rem * var(--scale-factor)) !important;
}

.text-size-ultrabig .dropdown-toggle {
    font-size: calc(0.95rem * var(--scale-factor)) !important;
}

.text-size-ultrabig .top-nav {
    min-height: calc(60px * var(--scale-factor)) !important;
}

.welcome-header {
    padding: 50px;
    text-align: center;
    padding-bottom: 50px;
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s, color 0.3s;
}

/* Top Navigation */
.top-nav {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    min-height: 60px;
    transition: background-color 0.3s, border-color 0.3s;
}

.top-nav .container {
    max-width: 100%;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    min-height: inherit;
    gap: 12px;
    overflow: visible;
}

.nav-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.site-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-left: 20px;
    transition: color 0.3s;
    white-space: nowrap;
}

/* Dropdown Navigation for Desktop/Tablet */
.desktop-nav {
    display: none;
    flex: 1;
    margin: 0 20px;
    min-width: 0;
    overflow: visible;
}

.dropdown-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    padding: 2px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dropdown-nav::-webkit-scrollbar {
    display: none;
}

.dropdown {
    position: relative;
    flex-shrink: 0;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
    flex-shrink: 0;
}

.dropdown-toggle:hover {
    background-color: var(--hover-bg);
    color: var(--link-color);
}

.dropdown-arrow {
    font-size: 0.75em;
    transition: transform 0.2s;
}

.dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: fixed;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--dropdown-shadow);
    min-width: 280px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 9999;
    pointer-events: none;
}

.dropdown.active .dropdown-menu {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    display: block !important;
    pointer-events: auto !important;
}

.dropdown-menu ul {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.dropdown-menu .nav-link {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.dropdown-menu .nav-link:hover {
    background-color: var(--hover-bg);
    color: var(--link-color);
}

/* Theme and Text Controls */
.nav-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.text-size-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: var(--hover-bg);
    border-radius: 20px;
    padding: 4px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.text-size-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 16px;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.text-size-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.text-size-btn.active {
    background-color: var(--link-color);
    color: white;
}

/* Text size symbols - Fixed sizes that don't scale with page text size */
.text-size-btn[data-size="small"] {
    font-size: 11px !important;
}

.text-size-btn[data-size="normal"] {
    font-size: 14px !important;
}

.text-size-btn[data-size="big"] {
    font-size: 16px !important;
}

.text-size-btn[data-size="ultrabig"] {
    font-size: 18px !important;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-primary);
    font-size: 20px;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background-color: var(--hover-bg);
    transform: scale(1.05);
}

.theme-icon {
    transition: transform 0.3s;
}

.theme-toggle:active .theme-icon {
    transform: rotate(180deg);
}

/* Main Layout */
.main-wrapper {
    display: flex;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
}

/* Adjust main wrapper margin for text sizes using scale factor */
.text-size-small .main-wrapper {
    margin-top: calc(60px * 0.85);
    min-height: calc(100vh - (60px * 0.85));
}

.text-size-big .main-wrapper {
    margin-top: calc(60px * 1.15);
    min-height: calc(100vh - (60px * 1.15));
}

.text-size-ultrabig .main-wrapper {
    margin-top: calc(60px * 1.4);
    min-height: calc(100vh - (60px * 1.4));
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: background-color 0.3s, border-color 0.3s;
}

/* Adjust sidebar positioning for text sizes */
.text-size-small .sidebar {
    top: calc(60px * 0.85);
}

.text-size-big .sidebar {
    top: calc(60px * 1.15);
}

.text-size-ultrabig .sidebar {
    top: calc(60px * 1.4);
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 20px 0;
}

/* Navigation Sections */
.nav-section {
    margin-bottom: 30px;
    padding: 0 20px;
}

.nav-section h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    transition: color 0.3s, border-color 0.3s;
}

.nav-section ul {
    list-style: none;
}

.nav-section li {
    margin-bottom: 2px;
}

.nav-link {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.9rem;
    line-height: 1.4;
}

.nav-link:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
    padding-left: 16px;
}

.nav-link.active {
    background-color: var(--link-color);
    color: white;
    font-weight: 500;
}

.nav-link.current-page {
    color: var(--link-color);
    font-weight: 500;
}

/* Sidebar Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

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

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Main Content */
.content {
    flex: 1;
    margin-left: 300px;
    background-color: var(--bg-secondary);
    min-height: 100%;
    transition: background-color 0.3s;
}

article {
    max-width: 750px;
    margin: 0 auto;
    padding: 60px 40px;
}

/* Typography - Medium.com inspired */
.content-section {
    margin-bottom: 48px;
    scroll-margin-top: calc(60px + 40px); /* Base nav height + padding */
}

/* Adjust scroll margin for different text sizes */
.text-size-small .content-section {
    scroll-margin-top: calc((60px * 0.85) + (40px * 0.85));
}

.text-size-big .content-section {
    scroll-margin-top: calc((60px * 1.15) + (40px * 1.15));
}

.text-size-ultrabig .content-section {
    scroll-margin-top: calc((60px * 1.4) + (40px * 1.4));
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 24px;
    color: var(--text-heading);
    letter-spacing: -0.5px;
    transition: color 0.3s;
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 16px;
    margin-top: 32px;
    color: var(--text-heading);
    transition: color 0.3s;
}

p {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 20px;
    color: var(--text-content);
    font-weight: 400;
    transition: color 0.3s;
}

/* Lists */
ul {
    margin-left: 30px;
    margin-bottom: 20px;
}

li {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 8px;
    color: var(--text-content);
    transition: color 0.3s;
}

/* Links */
article a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, color 0.3s;
}

article a:hover {
    border-bottom-color: var(--link-color);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
}

.mobile-menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-primary);
    margin: 5px 0;
    transition: 0.3s;
}

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

/* Adjust overlay position for different text sizes */
.text-size-small .sidebar-overlay {
    top: calc(60px * 0.85);
}

.text-size-big .sidebar-overlay {
    top: calc(60px * 1.15);
}

.text-size-ultrabig .sidebar-overlay {
    top: calc(60px * 1.4);
}

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

/* Desktop and Tablet - Show dropdown nav, hide sidebar */
@media (min-width: 769px) {
    .desktop-nav {
        display: block;
    }
    
    .sidebar {
        display: none;
    }
    
    .content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .top-nav {
        padding: 8px 0;
    }
    
    .top-nav .container {
        align-items: center;
        padding: 0 16px;
    }
    
    /* Responsive site title */
    .site-title {
        font-size: 1.1rem;
        margin-left: 0;
    }
    
    /* Space-aware navigation - when there's insufficient space */
    .nav-space-constrained .desktop-nav {
        display: none;
    }
    
    .nav-space-constrained .mobile-menu-toggle {
        display: block !important;
    }
    
    .nav-space-constrained .sidebar {
        display: block;
        width: 280px;
        left: -280px;
        transition: left 0.3s;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        z-index: 999;
    }
    
    .nav-space-constrained .sidebar.mobile-open {
        left: 0;
    }
    
    .nav-space-constrained .content {
        margin-left: 0;
    }
    
    /* Adjust sidebar positioning for space-constrained mode with different text sizes */
    .nav-space-constrained.text-size-small .sidebar {
        top: calc(60px * 0.85);
    }
    
    .nav-space-constrained.text-size-big .sidebar {
        top: calc(60px * 1.15);
    }
    
    .nav-space-constrained.text-size-ultrabig .sidebar {
        top: calc(60px * 1.4);
    }
    
    /* Adjust overlay positioning for space-constrained mode */
    .nav-space-constrained.text-size-small .sidebar-overlay {
        top: calc(60px * 0.85);
    }
    
    .nav-space-constrained.text-size-big .sidebar-overlay {
        top: calc(60px * 1.15);
    }
    
    .nav-space-constrained.text-size-ultrabig .sidebar-overlay {
        top: calc(60px * 1.4);
    }
}

/* Responsive Design */
@media (max-width: 1024px) and (min-width: 769px) {
    .dropdown-nav {
        gap: 5px;
    }
    
    .dropdown-toggle {
        padding: 6px 10px;
        font-size: 0.9rem;
    }
    
    .nav-controls {
        gap: 10px;
    }
}

/* Force mobile navigation on small screens regardless of space calculation */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block !important;
    }
    
    .desktop-nav {
        display: none !important;
    }
    
    /* Remove space constraint class effects on mobile since we always use mobile nav */
    .nav-space-constrained .mobile-menu-toggle {
        display: block !important;
    }
    
    .nav-controls {
        gap: 8px;
    }
    
    .text-size-controls {
        gap: 2px;
        padding: 2px;
    }
    
    .text-size-btn {
        padding: 4px 6px;
        font-size: 12px;
    }
    
    .theme-toggle {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .sidebar {
        width: 280px;
        left: -280px;
        transition: left 0.3s;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        z-index: 999;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }
    
    .content {
        margin-left: 0;
    }
    
    article {
        padding: 40px 20px;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    p, li {
        font-size: 1rem;
    }
    
    .site-title {
        font-size: 1.1rem;
        margin-left: 10px;
    }
}

@media (max-width: 480px) {
    .site-title {
        display: none;
    }
    
    .nav-controls {
        flex: 1;
        justify-content: flex-end;
    }
}

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

/* Image Styles for Content */
.photo {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 24px auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-light);
    transition: box-shadow 0.3s;
}

.photo:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.caption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 8px 0 24px 0;
    font-style: italic;
    transition: color 0.3s;
}

/* Responsive image sizing */
@media (max-width: 768px) {
    .photo {
        margin: 16px auto;
        border-radius: 6px;
    }
    
    .caption {
        font-size: 0.85rem;
        margin: 6px 0 16px 0;
    }
}

/* Print Styles */
@media print {
    .sidebar, .top-nav {
        display: none;
    }
    
    .content {
        margin-left: 0;
    }
    
    .photo {
        max-width: 80%;
        margin: 16px auto;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

