/* ============================================
   Catppuccin Color Palettes
   ============================================ */
:root {
    /* Mocha Palette (Dark Mode) */
    --mocha-base: #1e1e2e;
    --mocha-mantle: #181825;
    --mocha-crust: #11111b;
    --mocha-text: #cdd6f4;
    --mocha-subtext0: #a6adc8;
    --mocha-subtext1: #bac2de;
    --mocha-surface0: #313244;
    --mocha-surface1: #45475a;
    --mocha-surface2: #585b70;
    --mocha-rosewater: #f5e0dc;
    --mocha-flamingo: #f2cdcd;
    --mocha-peach: #fab387;
    --mocha-mauve: #cba6f7;
    --mocha-lavender: #b4befe;
    --mocha-sapphire: #74c7ec;

    /* Latte Palette (Light Mode) */
    --latte-base: #eff1f5;
    --latte-mantle: #e6e9ef;
    --latte-crust: #dce0e8;
    --latte-text: #4c4f69;
    --latte-subtext0: #6c6f85;
    --latte-subtext1: #5c5f77;
    --latte-surface0: #ccd0da;
    --latte-surface1: #bcc0cc;
    --latte-surface2: #acb0be;
    --latte-rosewater: #dc8a78;
    --latte-flamingo: #dd7878;
    --latte-peach: #fe640b;
    --latte-mauve: #8839ef;
    --latte-lavender: #7287fd;
    --latte-sapphire: #209fb5;

    /* Semantic tokens */
    --color-bg: var(--mocha-base);
    --color-bg-elevated: var(--mocha-mantle);
    --color-text: var(--mocha-text);
    --color-text-muted: var(--mocha-subtext0);
    --color-text-subtle: var(--mocha-subtext1);
    --color-accent: var(--mocha-peach);
    --color-accent-soft: var(--mocha-rosewater);
    --color-accent-vibrant: var(--mocha-mauve);
    --color-border: var(--mocha-surface0);
    --color-decorative: var(--mocha-surface0);

    /* Typography scale - refined, editorial */
    --font-display: "Lora", Georgia, serif;
    --font-body: "Literata", Georgia, serif;

    /* Fluid type scale */
    --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
    --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.5rem);
    --text-xl: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);
    --text-2xl: clamp(2rem, 1.5rem + 2.5vw, 3.5rem);
    --text-3xl: clamp(2.5rem, 1.75rem + 3.75vw, 4.5rem);

    /* Fluid spacing */
    --space-xs: clamp(0.5rem, 0.45rem + 0.25vw, 0.75rem);
    --space-sm: clamp(0.75rem, 0.65rem + 0.5vw, 1.25rem);
    --space-md: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);
    --space-lg: clamp(2.5rem, 1.75rem + 3.75vw, 4.5rem);
    --space-xl: clamp(4rem, 2.5rem + 7.5vw, 8rem);

    /* Layout */
    --content-width: 65ch;
    --content-width-wide: 80ch;
}

/* ============================================
   Light Mode (Latte Palette)
   ============================================ */
@media (prefers-color-scheme: light) {
    :root {
        /* Remap semantic tokens to Latte palette */
        --color-bg: var(--latte-base);
        --color-bg-elevated: var(--latte-mantle);
        --color-text: var(--latte-text);
        --color-text-muted: var(--latte-subtext0);
        --color-text-subtle: var(--latte-subtext1);
        --color-accent: var(--latte-peach);
        --color-accent-soft: var(--latte-rosewater);
        --color-accent-vibrant: var(--latte-mauve);
        --color-border: var(--latte-surface0);
        --color-decorative: var(--latte-surface0);
    }
}

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

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-accent);
    color: var(--color-bg);
    padding: var(--space-xs) var(--space-sm);
    text-decoration: none;
    font-weight: 400;
    z-index: 100;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
}

html {
    font-size: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    font-weight: 300;
}

/* ============================================
   Typography
   ============================================ */
.site-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 300;
    font-style: italic;
    letter-spacing: -0.02em;
    color: var(--color-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ============================================
   Header
   ============================================ */
.site-header {
    padding: var(--space-md) var(--space-sm);
    border-bottom: 1px solid var(--color-border);
}

.header-content {
    max-width: var(--content-width-wide);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.site-nav {
    display: flex;
    gap: var(--space-md);
}

.nav-link {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 300;
    transition: color 0.2s ease-out;
    letter-spacing: 0.02em;
    border-radius: 2px;
}

.nav-link:hover {
    color: var(--color-accent);
}

.nav-link:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
    color: var(--color-accent);
}

.nav-link.active {
    color: var(--color-text);
}

/* ============================================
   Main Content
   ============================================ */
.content {
    max-width: var(--content-width-wide);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* ============================================
   Quote Entries - Editorial Style
   ============================================ */
.quote-entry {
    position: relative;
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--color-border);
    max-width: var(--content-width);
    contain: layout style; /* Isolate for better rendering performance */
}

.quote-entry.featured {
    padding-top: 0;
    border-top: none;
}

.quote-entry.align-right {
    margin-left: auto;
    text-align: right;
}

.quote-entry.align-right .quote-mark {
    left: auto;
    right: -0.5em;
}

.quote-mark {
    position: absolute;
    left: -0.5em;
    top: 0.85em;
    font-family: var(--font-display);
    font-size: 8rem;
    line-height: 0.5;
    color: var(--color-decorative);
    font-weight: 300;
    user-select: none;
    pointer-events: none;
    opacity: 0.5;
}

.quote-text {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    line-height: 1.35;
    font-weight: 300;
    color: var(--color-text);
    margin: 0 0 var(--space-sm) 0;
    letter-spacing: -0.02em;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.quote-entry.featured .quote-text {
    color: var(--color-text-subtle);
}

.quote-source {
    display: block;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-style: normal;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
    font-weight: 300;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.reflection {
    max-width: 55ch;
    margin-top: var(--space-md);
    padding-left: var(--space-sm);
    border-left: 2px solid var(--color-border);
}

.quote-entry.align-right .reflection {
    margin-left: auto;
    margin-right: 0;
    padding-left: 0;
    padding-right: var(--space-sm);
    border-left: none;
    border-right: 2px solid var(--color-border);
}

.reflection p {
    font-size: var(--text-base);
    color: var(--color-text-muted);
    line-height: 1.7;
    font-style: italic;
    font-weight: 300;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.entry-date {
    display: block;
    margin-top: var(--space-sm);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-weight: 300;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ============================================
   Blog Entries
   ============================================ */
.blog-entry {
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--color-border);
    max-width: var(--content-width);
    contain: layout style; /* Isolate for better rendering performance */
}

.blog-header {
    margin-bottom: var(--space-md);
}

.entry-type {
    display: inline-block;
    font-size: var(--text-xs);
    color: var(--color-accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 400;
    margin-bottom: var(--space-xs);
}

.blog-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    line-height: 1.25;
    font-weight: 400;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
    letter-spacing: -0.02em;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-content {
    font-size: var(--text-base);
    line-height: 1.8;
    color: var(--color-text);
}

.blog-content p {
    margin-bottom: var(--space-sm);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.blog-content p:last-child {
    margin-bottom: 0;
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
    padding: var(--space-lg) var(--space-sm);
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-xl);
}

.site-footer p {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    max-width: var(--content-width);
    margin: 0 auto;
    font-style: italic;
    font-weight: 300;
}

/* ============================================
   Responsive Adaptations
   ============================================ */

/* Tablet Breakpoint (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Slightly reduce spacing on tablets */
    .content {
        padding: var(--space-lg) var(--space-sm);
    }

    /* Reduce quote mark size slightly */
    .quote-mark {
        font-size: 6.5rem;
    }
}

/* Mobile Breakpoint (320px - 767px) */
@media (max-width: 767px) {
    /* Optimize text sizing for small screens */
    html {
        font-size: 100%; /* Maintain 16px base for readability */
    }

    /* Increase touch target size for navigation */
    .nav-link {
        padding: var(--space-xs) 0;
        min-height: 44px; /* iOS minimum touch target */
        display: inline-flex;
        align-items: center;
    }

    /* Stack header on mobile */
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    /* Reduce navigation gap on mobile */
    .site-nav {
        gap: var(--space-sm);
        width: 100%;
    }

    /* Simplify asymmetry on mobile (better readability) */
    .quote-entry.align-right {
        margin-left: 0;
        text-align: left;
    }

    .quote-entry.align-right .quote-mark {
        left: -0.5em;
        right: auto;
    }

    .quote-entry.align-right .reflection {
        margin-left: 0;
        padding-left: var(--space-sm);
        padding-right: 0;
        border-left: 2px solid var(--color-border);
        border-right: none;
    }

    /* Scale down decorative quote marks on mobile */
    .quote-mark {
        font-size: 4rem;
        opacity: 0.3; /* Reduce visual weight on small screens */
    }

    /* Optimize spacing for mobile reading */
    .content {
        padding: var(--space-md) var(--space-sm);
        gap: var(--space-lg);
    }

    /* Reduce entry padding on mobile */
    .quote-entry {
        padding: var(--space-md) 0;
    }

    /* Ensure blog content is readable on mobile */
    .blog-content {
        font-size: var(--text-base);
    }

    /* Add more breathing room to reflections on mobile */
    .reflection {
        margin-top: var(--space-sm);
        padding-left: var(--space-sm);
    }

    /* Enable hyphenation only on narrow screens to prevent overflow */
    .quote-text,
    .blog-title {
        hyphens: auto;
    }
}

/* Extra small mobile devices (320px - 374px) */
@media (max-width: 374px) {
    /* Further reduce decorative elements */
    .quote-mark {
        font-size: 3rem;
    }

    /* Tighter spacing on very small screens */
    .site-header {
        padding: var(--space-sm);
    }

    .content {
        padding: var(--space-sm);
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    /* Force light mode for print */
    :root {
        --color-bg: #ffffff;
        --color-bg-elevated: #f5f5f5;
        --color-text: #000000;
        --color-text-muted: #333333;
        --color-text-subtle: #555555;
        --color-accent: #fe640b;
        --color-accent-soft: #dc8a78;
        --color-accent-vibrant: #8839ef;
        --color-border: #cccccc;
        --color-decorative: #dddddd;
    }

    * {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body {
        background: white;
        color: black;
        font-size: 12pt;
        line-height: 1.5;
    }

    /* Hide interactive elements */
    .skip-link,
    .site-nav,
    .site-footer {
        display: none;
    }

    /* Simplify header for print */
    .site-header {
        border-bottom: 2px solid #000;
        padding: 1rem 0;
        margin-bottom: 2rem;
    }

    .site-title {
        font-size: 24pt;
        color: #000 !important;
    }

    /* Optimize content for print */
    .content {
        max-width: 100%;
        padding: 0;
        gap: 2rem;
    }

    /* Remove decorative quote marks for print */
    .quote-mark {
        display: none;
    }

    /* Quote styling for print */
    .quote-entry {
        page-break-inside: avoid;
        border-top: 1px solid #ccc;
        padding: 1.5rem 0;
        margin-bottom: 1rem;
    }

    .quote-entry.featured {
        border-top: 2px solid #000;
        padding-top: 0;
    }

    .quote-text {
        font-size: 16pt;
        color: #000 !important;
        margin-bottom: 0.5rem;
        font-style: italic;
    }

    .quote-entry.featured .quote-text {
        font-size: 20pt;
    }

    .quote-source {
        font-size: 10pt;
        color: #333 !important;
        margin-bottom: 0.5rem;
    }

    .reflection {
        border-left: 3px solid #ccc;
        padding-left: 1rem;
        margin-top: 1rem;
        page-break-inside: avoid;
    }

    .reflection p {
        font-size: 11pt;
        color: #333 !important;
    }

    .entry-date {
        font-size: 9pt;
        color: #666 !important;
        margin-top: 0.5rem;
    }

    /* Blog entry styling for print */
    .blog-entry {
        page-break-inside: avoid;
        border-top: 2px solid #000;
        padding: 1.5rem 0;
        margin-bottom: 1rem;
    }

    .entry-type {
        font-size: 9pt;
        color: #666 !important;
    }

    .blog-title {
        font-size: 18pt;
        color: #000 !important;
        margin-bottom: 0.5rem;
    }

    .blog-content {
        font-size: 11pt;
        line-height: 1.6;
        color: #000 !important;
    }

    .blog-content p {
        margin-bottom: 0.75rem;
    }

    /* Add page breaks */
    .blog-entry {
        page-break-before: auto;
    }

    /* Print URLs for links */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }

    /* Don't print hash links */
    a[href^="#"]:after {
        content: "";
    }
}

/* ============================================
   Subtle Motion - Performance Optimized
   ============================================ */
@media (prefers-reduced-motion: no-preference) {
    .quote-entry,
    .blog-entry {
        opacity: 0;
        animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        /* Only animate transform and opacity - GPU accelerated */
        will-change: transform, opacity;
    }

    /* Remove will-change after animation completes to free GPU memory */
    .quote-entry.animated,
    .blog-entry.animated {
        will-change: auto;
    }

    /* Stagger animations - optimized delays */
    .quote-entry:nth-child(1) { animation-delay: 0.05s; }
    .quote-entry:nth-child(2) { animation-delay: 0.1s; }
    .quote-entry:nth-child(3) { animation-delay: 0.15s; }
    .blog-entry:nth-child(4) { animation-delay: 0.2s; }
    .quote-entry:nth-child(5) { animation-delay: 0.25s; }

    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(1rem);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Performance optimization: Use hardware acceleration hints */
.quote-entry,
.blog-entry {
    /* Create compositing layer only when animating */
    transform: translateZ(0);
    backface-visibility: hidden;
}
