/* ========================================
   THE BARD - MOBILE-FIRST UNIFIED STYLESHEET
   Optimized for mobile users, 2026 Design Era
   ======================================== */

/* ========================================
   FONT IMPORTS - LOCAL + GOOGLE FALLBACK
   ======================================== */

@font-face {
    font-family: 'Satoshi';
    src: url('../fonts/Satoshi-Variable.woff2') format('woff2'),
         url('../fonts/Satoshi-Variable.woff') format('woff');
    font-weight: 300 900;
    font-display: swap;
}

@font-face {
    font-family: 'Neue Machina';
    src: url('../fonts/NeueMachina-Regular.woff2') format('woff2'),
         url('../fonts/NeueMachina-Regular.woff') format('woff');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Regular.woff2') format('woff2'),
         url('../fonts/Poppins-Regular.woff') format('woff');
    font-weight: 300 700;
    font-display: swap;
}

@import url('https://fonts.googleapis.com/css2?family=Satoshi:wght@300;400;500;600;700;900&family=Poppins:wght@300;400;500;600;700&display=swap');

/* ========================================
   1. CSS CUSTOM PROPERTIES (VARIABLES)
   ======================================== */

:root {
    /* Base Colors - 2026 Design Era */
    --bg-color: #faf9f6;
    --text-color: #1A1A1A;
    --text-light: #4A4A4A;
    --accent-color: #B8860B;
    --link-color: #0066CC;
    --link-visited: #663399;
    --border-color: #8B7355;
    --link-hover-bg: #F2EDE0;
    --aged-border: #8B7355;
    --aged-border-light: #C4B5A0;
    --parchment: #FFFEF8;
    --aged-parchment: #F5F2E8;
    --ink-dark: #1A1614;
    --ink-medium: #4A4642;
    --gold-accent: #B8860B;
    --gold-hover: #D4A517;
    --narrative-bg: var(--parchment);
    --technical-bg: #F8F9FA;
    --bards-notes-bg: #FFF9E6;
    --code-block-bg: #0A0E14;
    --code-text-color: #0A0E14;
    --neon-pink: #FF00FF;
    --neon-cyan: #00FFFF;
    --neon-green: #00FF00;
    --terminal-green: #33FF33;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-moderate: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-strong: 0 10px 25px rgba(0, 0, 0, 0.15);
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --serif-narrative: Georgia, "Palatino Linotype", "Book Antiqua", serif;
    --mono-technical: var(--mono);
    --sans-interface: var(--sans);
    
    /* Typography - 2026 Modern + Retro */
    --serif: Georgia, "Times New Roman", serif;
    --sans: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", Menlo, "Cascadia Code", "Roboto Mono", "Courier New", monospace;
    --font-header: 'Neue Machina', 'Satoshi', var(--sans);
    --font-title: 'Satoshi', 'Poppins', var(--sans);
    
    /* Mobile-first spacing */
    --space-xs: 0.25rem;    /* 4px */
    --space-sm: 0.5rem;     /* 8px */
    --space-md: 0.75rem;    /* 12px */
    --space-lg: 1rem;       /* 16px */
    --space-xl: 1.5rem;     /* 24px */
    --space-xxl: 2rem;      /* 32px */
    
    /* Mobile-first layout */
    --mobile-padding: var(--space-lg);
    --content-width: 100%;
    --line-height: 1.6;
    --touch-target: 44px;   /* iOS/Android minimum */
    
    /* Container system */
    --container-mobile: 100%;
    --container-tablet: 768px;
    --container-desktop: 1200px;
}

/* ========================================
   2. RESET AND BASE STYLES
   ======================================== */

/* Modern CSS reset optimized for mobile */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    /* Mobile viewport height fix - accounts for address bar on iOS/Android */
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

body {
    font-family: var(--serif);
    font-size: 1rem;
    line-height: var(--line-height);
    color: var(--text-color);
    background: var(--bg-color, transparent);
    /* Mobile viewport height fix */
    min-height: 100vh;
    min-height: -webkit-fill-available;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    word-wrap: break-word;
    position: relative;
    z-index: 1;
}

/* ========================================
   3. MOBILE-FIRST TYPOGRAPHY - 2026 ERA
   ======================================== */

/* Fluid typography scale with modern fonts */
h1 { 
    font-size: clamp(1.75rem, 5vw, 2.5rem); 
    line-height: 1.1; 
    margin-bottom: var(--space-lg);
    font-family: var(--font-header);
    font-weight: 700;
    letter-spacing: -0.02em;
}

h2 { 
    font-size: clamp(1.5rem, 4vw, 2rem); 
    line-height: 1.2; 
    margin-bottom: var(--space-md);
    font-family: var(--font-title);
    font-weight: 700;
    letter-spacing: -0.015em;
}

h3 { 
    font-size: clamp(1.25rem, 3.5vw, 1.75rem); 
    line-height: 1.3; 
    margin-bottom: var(--space-md);
    font-family: var(--font-title);
    font-weight: 700;
    letter-spacing: -0.01em;
}

h4 { 
    font-size: clamp(1.125rem, 3vw, 1.5rem); 
    line-height: 1.4; 
    margin-bottom: var(--space-sm);
}

h5, h6 { 
    font-size: clamp(1rem, 2.5vw, 1.25rem); 
    line-height: 1.4; 
    margin-bottom: var(--space-sm);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--sans);
    font-weight: 700;
    color: var(--accent-color);
    margin-top: var(--space-xl);
    text-wrap: balance;
}

/* Optimized paragraph spacing for maximum readability */
p {
    margin-bottom: var(--space-xl);
    line-height: 1.8;
    max-width: 100%;
    hyphens: auto;
}

/* Enhanced readability - optimal line length and spacing */
.content p, .post-content p, article p {
    font-size: clamp(1.0625rem, 2.5vw, 1.1875rem);
    line-height: 1.8;
    margin-bottom: var(--space-xxl);
    word-spacing: 0.05em;
    letter-spacing: 0.01em;
    max-width: 75ch; /* Optimal line length for reading */
}

/* Post and page reading body: lean into serif, journal feel */
.post-layout .post-content p,
.post-layout .post-content li,
.page-content .page-body p,
.page-content .page-body li {
    font-family: var(--serif);
}

/* Links optimized for reading experience */
a {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    touch-action: manipulation;
    cursor: pointer;
}

a:visited { 
    color: var(--link-visited); 
}

a:hover, a:focus {
    background: var(--link-hover-bg);
    padding: 0.125rem 0.375rem;
    margin: -0.125rem -0.375rem;
    text-decoration: none;
    outline: none;
}

a:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Inside long-form reading, avoid layout shift on link hover */
.post-content a:hover,
.post-content a:focus,
.page-body a:hover,
.page-body a:focus {
    padding: 0;
    margin: 0;
    background: var(--link-hover-bg);
}

/* Optimized lists for readability */
ul, ol {
    margin: var(--space-xl) 0;
    padding-left: var(--space-xxl);
    max-width: 75ch;
}

li {
    margin-bottom: var(--space-md);
    line-height: 1.7;
}

li + li {
    margin-top: var(--space-sm);
}

/* Code optimized for mobile */
code {
    font-family: var(--mono);
    background: var(--link-hover-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9em;
    word-break: break-all;
    color: var(--text-color);
}

pre {
    background: var(--link-hover-bg);
    padding: var(--space-lg);
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: var(--space-lg) 0;
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    line-height: 1.5;
    -webkit-overflow-scrolling: touch;
}

pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    word-break: normal;
}

/* ========================================
   4. MOBILE-FIRST LAYOUT SYSTEM
   ======================================== */

.container {
    /* Mobile: Single column stack */
    display: grid;
    grid-template-areas: 
        "header"
        "main"
        "sidebar"
        "footer";
    grid-template-rows: auto 1fr auto auto;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    gap: 0;
}

/* Post layout tweaks - calmer journal page feel */
.post-layout .site-header {
    position: static;
    border-bottom-width: 2px;
}

.post-layout .main-content {
    padding-inline: var(--space-lg);
}

@media (min-width: 768px) {
    .post-layout .main-content {
        padding-inline: var(--space-xl);
    }
}

/* Post sidebar on small screens: keep it quiet and focused */
@media (max-width: 767.98px) {
    .post-layout .sidebar .site-stats,
    .post-layout .sidebar .classic-elements {
        display: none;
    }
}

/* Tablet breakpoint */
@media (min-width: 768px) {
    .container {
        grid-template-areas: 
            "header header"
            "main sidebar"
            "footer footer";
        grid-template-columns: 1fr 300px;
        grid-template-rows: auto 1fr auto;
        max-width: var(--container-tablet);
        margin: 0 auto;
        padding: 0 var(--space-lg);
        gap: var(--space-lg);
    }
}

/* Desktop breakpoint */
@media (min-width: 1024px) {
    .container {
        max-width: var(--container-desktop);
        grid-template-columns: 1fr 320px;
        gap: var(--space-xxl);
    }
}

/* ========================================
   5. HEADER AND NAVIGATION
   ======================================== */

.site-header {
    grid-area: header;
    background: var(--bg-color);
    padding: var(--space-lg);
    text-align: center;
    border-bottom: 3px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.site-title {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    font-family: var(--serif);
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: var(--space-sm);
    word-break: break-word;
}

.site-title a {
    text-decoration: none;
    color: inherit;
}

.tagline {
    font-style: italic;
    color: var(--text-light);
    margin-bottom: var(--space-lg);
    font-size: clamp(0.875rem, 2.5vw, 1rem);
}

/* Theme Controls */
.theme-controls {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    z-index: 110;
}

.theme-selector-btn {
    background: var(--accent-color);
    color: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: var(--space-sm) var(--space-md);
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    min-height: var(--touch-target);
}

.theme-selector-btn:hover,
.theme-selector-btn:focus {
    background: var(--text-color);
    border-color: var(--text-color);
}

/* Theme selector turned into an accessible floating modal */
.theme-selector {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 10, 15, 0.45); /* subtle backdrop */
    z-index: 1200;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
    transition: opacity 180ms ease, transform 180ms cubic-bezier(.2,.9,.2,1);
}

.theme-selector.show,
.theme-selector[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

/* Inner panel that holds neumorphic buttons */
.theme-selector .theme-panel {
    position: absolute;
    inset: 0; /* occupy the whole viewport */
    background: var(--bg-color);
    border: none;
    padding: 32px; /* spacing for the centered content */
    border-radius: 0;
    width: 100%;
    height: 100%;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Centered content area inside the full-page panel */
.theme-selector .theme-panel .theme-content {
    width: calc(100% - 64px);
    max-width: 1200px;
    background: transparent;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: center;
    justify-items: center;
}

/* Large flat theme option buttons (no neumorphic gradients) */
.theme-option {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 72px;
    padding: 14px 16px;
    font-family: var(--sans);
    font-weight: 700;
    font-size: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--link-hover-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
    text-align: center;
    flex: 1 1 160px;
    min-width: 140px;
}

.theme-option:hover,
.theme-option:focus {
    transform: translateY(-3px);
    border-color: var(--accent-color);
    outline: none;
}

.theme-option:active {
    transform: translateY(0);
}

/* Highlight the currently selected theme while the modal is open */
.theme-option.current,
.theme-option.current:hover,
.theme-option.current:focus {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
}

/* Make sure when the panel is small, options stretch nicely */
.theme-option > span { display:block; }

/* Toast notification for theme changes */
.theme-toast {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-color);
    color: var(--bg-color);
    padding: var(--space-md) var(--space-xl);
    border: 2px solid var(--border-color);
    font-family: var(--sans);
    font-size: 0.9rem;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
}

.theme-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Mobile-first navigation */
.main-nav {
    position: relative;
}

/* Normalize navigation lists so both <ul> and .nav-menu markup render consistently */
.main-nav ul,
.nav-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Default: hide legacy <ul> based nav on small screens (use hamburger/.nav-menu) */
.main-nav ul {
    display: none;
}

/* Hamburger menu button - only visible on mobile */
.nav-toggle {
    display: block;
    background: var(--accent-color);
    color: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: var(--space-md);
    font-family: var(--sans);
    font-weight: 600;
    min-height: var(--touch-target);
    cursor: pointer;
    margin-top: var(--space-lg);
    position: relative;
    z-index: 200;
}

.nav-toggle:hover, .nav-toggle:focus {
    background: var(--text-color);
}

.nav-toggle[aria-expanded="true"] {
    background: var(--text-color);
}

/* Hamburger icon */
.nav-toggle::before {
    content: "Γÿ░";
    font-size: 1.2em;
    margin-right: var(--space-sm);
}

.nav-toggle[aria-expanded="true"]::before {
    content: "Γ£ò";
}

/* Navigation menu - hidden by default on mobile */
.nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    z-index: 100;
    margin-top: var(--space-sm);
    padding: var(--space-sm);
}

.nav-menu.active {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.nav-menu a {
    display: block;
    padding: var(--space-md) var(--space-lg);
    background: var(--link-hover-bg);
    border: 1px solid var(--border-color);
    text-decoration: none;
    font-family: var(--sans);
    font-weight: 600;
    text-align: center;
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
}

.nav-menu a:hover, .nav-menu a:focus {
    background: var(--accent-color);
    color: var(--bg-color);
}

.nav-menu a.current {
    background: var(--accent-color);
    color: var(--bg-color);
}

/* Backdrop to dim content when mobile nav is open */
.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
    z-index: 150;
}

.nav-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Smooth reveal for mobile nav */
.nav-menu {
    transition: transform 220ms cubic-bezier(.2,.9,.2,1), opacity 180ms ease;
    transform-origin: top center;
    transform: translateY(-6px);
    opacity: 0;
}

.nav-menu.active {
    transform: translateY(0);
    opacity: 1;
}

/* When nav is open, prevent background scroll */
body.nav-open {
    overflow: hidden;
    touch-action: none;
}

/* Tablet and desktop: horizontal nav, hide hamburger */
@media (min-width: 768px) {
    .nav-toggle {
        display: none;
    }
    /* If a legacy <ul> is present, show it as a horizontal nav on desktop */
    .main-nav ul {
        display: flex;
        gap: var(--space-md);
        justify-content: center;
        align-items: center;
    }
    .main-nav ul li {
        list-style: none;
    }
    .main-nav ul a {
        display: inline-block;
        padding: var(--space-sm) var(--space-md);
        background: transparent;
        border: none;
        min-width: auto;
    }

    .nav-menu {
        display: flex !important;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-md);
        background: transparent;
        border: none;
        box-shadow: none;
        margin-top: var(--space-lg);
        padding: 0;
        /* Ensure desktop nav is fully visible (override mobile reveal animation) */
        transform: none !important;
        opacity: 1 !important;
        transition: none !important;
    }
    
    .nav-menu a {
        flex: 1;
        min-width: 120px;
        max-width: 160px;
    }
}

/* Homepage-specific header layout: centered title, separator and vertical nav buttons */
.home-header {
    text-align: center;
    padding-top: var(--space-3xl);
}

.home-header .site-title {
    font-size: 3.25rem;
    color: var(--gold-accent);
    font-weight: 700;
    letter-spacing: 1px;
    margin: 0;
}

.home-header .site-subtitle {
    margin-top: var(--space-md);
    margin-bottom: var(--space-lg);
}

.home-header .separator {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-lg);
    max-width: 60%;
}

.home-header .nav-menu,
.home-header .main-nav ul {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    align-items: center;
    margin: 0 auto;
}

.home-header .nav-menu a,
.home-header .main-nav ul a {
    display: block;
    width: 220px;
    padding: var(--space-lg);
    text-decoration: none;
    text-align: center;
    border: 1px solid var(--aged-border-light);
    background: var(--narrative-bg);
    color: var(--text-color, var(--ink-dark));
    font-weight: 700;
    border-radius: 4px;
}

.home-header .nav-menu a.current,
.home-header .main-nav ul a.current {
    background: var(--gold-accent);
    color: var(--bg-color);
}

/* ========================================
   6. MAIN CONTENT - OPTIMIZED FOR READING
   ======================================== */

.content {
    grid-area: main;
    padding: var(--space-xl) var(--space-lg);
    background: var(--bg-color);
    min-height: 60vh;
}

/* Article/Post content wrapper for optimal readability */
article, .post-content, .page-content {
    max-width: 75ch;
    margin: 0 auto;
}

/* First paragraph drop cap for retro style */
article > p:first-of-type::first-letter,
.post-content > p:first-of-type::first-letter {
    font-size: 3.5em;
    font-weight: bold;
    line-height: 0.9;
    float: left;
    margin: 0.1em 0.1em 0 0;
    color: var(--accent-color);
    font-family: var(--serif);
}

/* Blockquotes - retro style */
blockquote {
    margin: var(--space-xxl) 0;
    padding: var(--space-lg) var(--space-xl);
    border-left: 4px solid var(--accent-color);
    background: var(--link-hover-bg);
    font-style: italic;
    color: var(--text-light);
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* Horizontal rules - retro separator */
hr, .separator {
    margin: var(--space-xxl) auto;
    border: none;
    border-top: 3px double var(--border-color);
    max-width: 50%;
}

@media (min-width: 768px) {
    .content {
        padding: var(--space-xxl);
    }
}

/* ========================================
   7. SIDEBAR
   ======================================== */

.sidebar {
    grid-area: sidebar;
    padding: var(--space-lg);
    background: var(--link-hover-bg);
    border: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .sidebar {
        border: 2px solid var(--border-color);
    }
}

.sidebar h3 {
    font-size: 1.25rem;
    margin-bottom: var(--space-md);
    color: var(--accent-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: var(--space-sm);
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    margin-bottom: var(--space-sm);
}

.sidebar a {
    text-decoration: none;
    padding: var(--space-sm);
    display: block;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.sidebar a:hover {
    background: var(--bg-color);
}

/* Author widget styles */
.author-widget {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}
.author-avatar {
    border: 2px solid var(--border-color);
    padding: 4px;
    border-radius: 4px;
    background: white;
}
.author-name {
    margin-top: 0.25rem;
    font-size: 1rem;
    color: var(--accent-color);
}
.author-name a { text-decoration: none; color: inherit; }
.author-bio {
    font-size: 0.95rem;
    color: var(--text-light);
}
.author-contact a { margin-right: 0.5rem; color: var(--link-color); }

/* ========================================
   8. FOOTER
   ======================================== */

.site-footer {
    grid-area: footer;
    background: var(--link-hover-bg);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    border-top: 3px solid var(--border-color);
    margin-top: var(--space-xxl);
}

.site-footer p {
    margin-bottom: var(--space-sm);
    font-size: 0.875rem;
    color: var(--text-light);
}

/* ========================================
   9. COMPONENTS - RETRO STYLE
   ======================================== */

/* Post/Story listings */
.story-item, .featured-story {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.story-item:hover, .featured-story:hover {
    border-color: var(--accent-color);
    background: var(--link-hover-bg);
}

.story-item h3, .featured-story h3 {
    margin-top: 0;
}

/* Post metadata */
.post-meta {
    font-size: 0.9em;
    color: var(--text-light);
    font-family: var(--sans);
    margin-bottom: var(--space-md);
    font-style: italic;
}

/* Buttons - simple retro style */
.btn, button {
    background: var(--accent-color);
    color: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: var(--space-md) var(--space-xl);
    font-family: var(--sans);
    font-weight: 600;
    min-height: var(--touch-target);
    cursor: pointer;
    touch-action: manipulation;
}

.btn:hover, button:hover {
    background: var(--text-color);
    border-color: var(--text-color);
}

/* Form elements - clean and accessible */
input, textarea, select {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--border-color);
    font-family: var(--sans);
    font-size: 1rem;
    min-height: var(--touch-target);
    background: var(--bg-color);
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-color: var(--accent-color);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 600;
    font-family: var(--sans);
}

/* Images and media - responsive */
img, video, iframe {
    max-width: 100%;
    height: auto;
    display: block;
    margin: var(--space-xl) auto;
    border: 2px solid var(--border-color);
}

/* Figure captions */
figure {
    margin: var(--space-xxl) 0;
}

figcaption {
    text-align: center;
    font-style: italic;
    color: var(--text-light);
    font-size: 0.9em;
    margin-top: var(--space-sm);
}

/* Guestbook iframe embed */
.guestbook-embed {
    margin: var(--space-xl) 0;
}

.guestbook-embed iframe {
    width: 100%;
    min-height: 600px;
    border: 2px solid var(--border-color);
}

@media (min-width: 768px) {
    .guestbook-embed iframe {
        min-height: 800px;
    }
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-lg) 0;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
}

th, td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--link-hover-bg);
    font-weight: 600;
}

/* ========================================
   10. ACCESSIBILITY FEATURES
   ======================================== */

/* Skip links - visually discrete but accessible */
.skip-link {
    position: absolute;
    top: -28px; /* sit a little closer when hidden */
    left: var(--space-sm);
    background: transparent; /* visually subtle when hidden */
    color: var(--text-light);
    padding: 6px 8px; /* compact touch area */
    font-size: 0.875rem;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    z-index: 1000;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    transform: translateY(-6px);
    opacity: 0; /* hidden until focused */
    border: 1px solid transparent;
}

.skip-link:focus,
.skip-link:active {
    top: 6px;
    transform: translateY(0);
    opacity: 1;
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--border-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --text-color: #000000;
        --bg-color: #FFFFFF;
        --accent-color: #0000FF;
        --link-color: #0000EE;
        --border-color: #000000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
    
    .nav-menu.active {
        animation: none;
    }
    
    @keyframes slideDown {
        from, to { opacity: 1; transform: translateY(0); }
    }
}

/* Theme variants live in individual `assets/styles/theme-*.css` files,
   loaded dynamically by mobile-first.js when the user picks a theme. */


/* ========================================
   12. MOBILE-SPECIFIC OPTIMIZATIONS
   ======================================== */

/* Very small screens */
@media (max-width: 360px) {
    .site-header {
        padding: var(--space-md);
    }
    
    .content {
        padding: var(--space-md);
    }
    
    .main-nav a {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.875rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    a, button, input, .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .story-item:hover, .featured-story:hover {
        transform: none;
    }
}

/* Landscape phone orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .site-header {
        position: static;
        padding: var(--space-sm) var(--space-lg);
    }
    
    .main-nav {
        flex-direction: row;
        gap: var(--space-sm);
    }
}

/* Large screens */
@media (min-width: 1400px) {
    .container {
        max-width: 1200px;
    }
    
    .content {
        font-size: 1.125rem;
    }
}

/* ========================================
   13. PRINT STYLES
   ======================================== */

@media print {
    .main-nav, .sidebar, .site-footer {
        display: none;
    }
    
    .container {
        grid-template-areas: "header" "main";
        grid-template-columns: 1fr;
    }
    
    .content {
        padding: 0;
        background: white;
        box-shadow: none;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
}

/* ========================================
   14. POST SECTION STYLES (THREE-PART POSTS)
   ======================================== */

/* Narrative Section */
.narrative-section {
    margin: var(--space-xl) 0;
    padding: var(--space-xl) 0;
}

/* Technical Deep Dive */
.technical-section,
.technical-content {
    background: rgba(0, 0, 0, 0.02);
    border-left: 4px solid var(--link-color);
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    border-radius: 4px;
}

.section-header {
    font-family: var(--font-header);
    font-weight: 700;
    margin-bottom: var(--space-lg);
    color: var(--text-color);
}

/* Bard's Notes */
.bards-notes,
.notes-content {
    background: rgba(255, 250, 205, 0.1);
    border-left: 4px solid var(--accent-color);
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    border-radius: 4px;
    font-style: italic;
}

/* Connected Chronicles Navigation */
.chronicle-web {
    background: rgba(200, 200, 200, 0.05);
    border: 2px solid var(--border-color);
    padding: var(--space-lg);
    margin: var(--space-xl) 0;
    border-radius: 4px;
}

.chronicle-list {
    list-style: none;
    padding: 0;
}

.chronicle-list li {
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-color);
}

.chronicle-list a {
    text-decoration: none;
    color: var(--link-color);
    font-weight: 500;
}

.chronicle-list small {
    display: block;
    color: var(--text-light);
    font-size: 0.85em;
    margin-top: var(--space-xs);
}

/* Post preview cards */
.post-preview {
    margin: var(--space-lg) 0;
    padding: var(--space-lg);
    background: var(--link-hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.post-header h4 {
    margin: 0 0 var(--space-sm) 0;
    font-size: 1.25rem;
}

.post-meta {
    color: var(--text-light);
    font-size: 0.9em;
    margin: 0;
}

.post-excerpt {
    margin-top: var(--space-md);
}

.post-excerpt p:first-child {
    margin-top: 0;
}

.post-excerpt p:last-child {
    margin-bottom: 0;
}

/* Welcome section - homepage */
.welcome-section {
    background: linear-gradient(135deg, rgba(184, 134, 11, 0.08) 0%, rgba(200, 200, 200, 0.05) 100%);
    border: 2px solid var(--border-color);
    padding: var(--space-xl);
    margin: 0 0 var(--space-xxl) 0;
    border-radius: 4px;
    text-align: center;
}

.welcome-section h2 {
    margin-top: 0;
    color: var(--accent-color);
}

.welcome-section p {
    margin: var(--space-md) 0;
    line-height: 1.8;
}

/* Recent stories section */
.recent-stories {
    margin: var(--space-xxl) 0;
}

.recent-stories h3 {
    text-align: center;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 2px double var(--border-color);
}

/* CTA section */
.cta-section {
    background: var(--link-hover-bg);
    border: 2px solid var(--border-color);
    padding: var(--space-xl);
    margin: var(--space-xxl) 0;
    border-radius: 4px;
    text-align: center;
}

.cta-section h3 {
    margin-top: 0;
    color: var(--text-color);
}

.cta-section p {
    margin: var(--space-md) 0;
    line-height: 1.7;
}

.cta-section a {
    font-weight: 600;
    color: var(--link-color);
}

.cta-section a:visited {
    color: var(--link-visited);
}

/* Sidebar sections */
.sidebar-section {
    margin-bottom: var(--space-xl);
}

.sidebar-section h3,
.sidebar-section h4 {
    font-size: 1rem;
    margin-bottom: var(--space-md);
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: var(--space-sm);
}

.sidebar-section ul {
    list-style: none;
    padding: 0;
}

.sidebar-section li {
    margin-bottom: var(--space-sm);
}

.sidebar-section a {
    color: var(--link-color);
    text-decoration: none;
}

.sidebar-section a:hover {
    text-decoration: underline;
}

/* Statistics grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: var(--space-md);
    margin: var(--space-md) 0;
}

.stat-item {
    text-align: center;
    padding: var(--space-md);
    background: var(--link-hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: var(--space-xs);
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Retro button */
.retro-button {
    display: inline-block;
    background: var(--accent-color);
    color: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: var(--space-md) var(--space-lg);
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    min-height: var(--touch-target);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.retro-button:hover,
.retro-button:focus {
    background: var(--text-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Blink animation for retro feel */
.blink {
    animation: blink-animation 1.5s infinite;
}

@keyframes blink-animation {
    0%, 49%, 100% { opacity: 1; }
    50%, 99% { opacity: 0.5; }
}

/* ========================================
   15. RETRO AESTHETIC & READING ENHANCEMENTS
   ======================================== */

/* Retro text selection */
::selection {
    background: var(--accent-color);
    color: var(--bg-color);
}

::-moz-selection {
    background: var(--accent-color);
    color: var(--bg-color);
}

/* Reading progress indicator */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--accent-color);
    z-index: 9999;
}

/* Thin reading progress line for post pages */
.reading-progress-line {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.05);
    z-index: 200;
}

.reading-progress-line__bar {
    display: block;
    width: 0;
    height: 100%;
    background: var(--gold-accent);
    transition: width 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    .reading-progress-line__bar {
        transition: none;
    }
}

/* Reading progress bar (alternate naming) */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--accent-color);
    z-index: 9999;
    transition: width 0.3s ease;
}

/* Back to top - retro style */
.back-to-top {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    background: var(--accent-color);
    color: var(--bg-color);
    border: 2px solid var(--border-color);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    text-decoration: none;
    opacity: 0;
    pointer-events: none;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: all;
}

/* Article header styling */
.post-header, .page-header {
    text-align: center;
    margin-bottom: var(--space-xxl);
    padding-bottom: var(--space-xl);
    border-bottom: 3px double var(--border-color);
}

.post-title, .page-title {
    margin-bottom: var(--space-md);
}

/* Read time indicator */
.read-time {
    font-size: 0.9em;
    color: var(--text-light);
    font-family: var(--sans);
}

/* Table of contents */
.toc {
    background: var(--link-hover-bg);
    border: 2px solid var(--border-color);
    padding: var(--space-lg);
    margin: var(--space-xxl) 0;
}

.toc h2, .toc h3 {
    margin-top: 0;
    font-size: 1.25rem;
}

.toc ul {
    margin: var(--space-sm) 0 0 0;
}

.toc li {
    margin-bottom: var(--space-xs);
}

/* Footnotes */
.footnotes {
    margin-top: var(--space-xxl);
    padding-top: var(--space-xl);
    border-top: 2px solid var(--border-color);
    font-size: 0.9em;
}

/* ========================================
   16. UTILITY CLASSES
   ======================================== */

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: var(--space-sm) !important; }
.mb-md { margin-bottom: var(--space-md) !important; }
.mb-lg { margin-bottom: var(--space-lg) !important; }

/* ========================================
   Responsive: horizontal nav on laptop/desktop
   Switch the index/home nav from stacked (mobile) to horizontal for
   laptop screens (>=1024px). Keeps mobile vertical behavior intact.
   ======================================== */
@media (min-width: 1024px) {
    /* Make any main nav menus lay out inline */
    .home-header .nav-menu,
    .main-nav .nav-menu {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: var(--space-md);
    }

    /* Make nav links inline and remove the boxed look used on mobile */
    .home-header .nav-menu a,
    .main-nav .nav-menu a,
    .home-header .main-nav ul a {
        display: inline-block;
        width: auto;
        padding: var(--space-sm) var(--space-md);
        background: transparent;
        border: none;
        color: var(--text-color, var(--ink-dark));
        border-radius: 4px;
        text-align: center;
    }

    /* Keep current state highlighted but adapt colors for desktop */
    .home-header .nav-menu a.current,
    .home-header .main-nav ul a.current {
        background: var(--gold-accent);
        color: var(--bg-color);
    }

    /* Hide hamburger toggle on larger screens */
    .nav-toggle {
        display: none !important;
    }

    /* Backdrop isn't needed on non-modal desktop nav */
    .nav-backdrop {
        display: none !important;
    }

    /* Ensure nav-menu is positioned statically on desktop */
    .nav-menu {
        position: static !important;
        box-shadow: none !important;
    }
}

.mt-0 { margin-top: 0 !important; }
.mt-sm { margin-top: var(--space-sm) !important; }
.mt-md { margin-top: var(--space-md) !important; }
.mt-lg { margin-top: var(--space-lg) !important; }

.p-0 { padding: 0 !important; }
.p-sm { padding: var(--space-sm) !important; }
.p-md { padding: var(--space-md) !important; }
.p-lg { padding: var(--space-lg) !important; }

.hide-mobile { display: none; }
.show-mobile { display: block; }

@media (min-width: 768px) {
    .hide-mobile { display: block; }
    .show-mobile { display: none; }
    .hide-desktop { display: none; }
    .show-desktop { display: block; }
}
