/*
 * Narrative Frequencies
 * Typography-first stylesheet
 * Inspired by editorial simplicity
 */

/* ============================================
   CSS Reset & Base Styles
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 18px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
    line-height: 1.7;
    color: #F5E6D3;
    background-color: #456B77;
    padding: 0;
    margin: 0;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.75em;
    color: #FFFBF5;
}

h1 {
    font-size: 2.25rem;
    margin-bottom: 0.5em;
}

h2 {
    font-size: 1.75rem;
    margin-top: 1.5em;
}

h3 {
    font-size: 1.35rem;
    margin-top: 1.25em;
}

h4 {
    font-size: 1.1rem;
}

p {
    margin-bottom: 1.25em;
}

a {
    color: #E77264;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

a:hover {
    color: #FF9B8A;
}

strong {
    font-weight: 600;
}

em {
    font-style: italic;
}

blockquote {
    margin: 2em 0;
    padding-left: 1.5em;
    border-left: 3px solid #E77264;
    font-style: italic;
    color: #E8DCC8;
}

code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    font-size: 0.9em;
    background-color: #2F4F58;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    color: #F5E6D3;
}

pre {
    margin: 1.5em 0;
    padding: 1em;
    background-color: #2F4F58;
    border-radius: 4px;
    overflow-x: auto;
}

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

ul, ol {
    margin-bottom: 1.25em;
    padding-left: 1.5em;
}

li {
    margin-bottom: 0.5em;
}

hr {
    border: none;
    border-top: 1px solid #5A8491;
    margin: 2.5em 0;
}

/* ============================================
   Layout & Container
   ============================================ */

.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ============================================
   Header
   ============================================ */

header {
    background-color: #2F5561;
    border-bottom: 2px solid #E77264;
    padding: 2rem 0;
    margin-bottom: 3rem;
}

.header-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    text-decoration: none;
    display: block;
}

.logo {
    height: 180px;
    width: auto;
    display: block;
}

nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    font-size: 0.95rem;
    text-decoration: none;
    color: #F5E6D3;
    font-weight: 500;
}

.nav-link:hover {
    color: #E77264;
}

/* ============================================
   Footer
   ============================================ */

footer {
    margin-top: 5rem;
    padding: 2rem 0;
    border-top: 2px solid #5A8491;
    color: #D0C5B0;
    font-size: 0.9rem;
}

.footer-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}

.footer-content p {
    margin-bottom: 0.5em;
}

.footer-meta {
    font-size: 0.85rem;
}

.footer-content a {
    color: #E77264;
}

.footer-content a:hover {
    color: #FF9B8A;
}

/* ============================================
   Homepage - Introduction
   ============================================ */

.intro {
    margin-bottom: 3rem;
}

.intro h1 {
    font-size: 2.5rem;
    margin-bottom: 0.25em;
}

.tagline {
    font-size: 1.1rem;
    color: #D0C5B0;
    font-style: italic;
}

/* ============================================
   Reflections List
   ============================================ */

.reflections {
    margin-bottom: 3rem;
}

.reflection-preview {
    margin-bottom: 3.5rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid #5A8491;
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.reflection-preview:last-child {
    border-bottom: none;
}

.preview-cover-container {
    flex-shrink: 0;
}

.preview-cover {
    width: 180px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.preview-cover:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.preview-content {
    flex: 1;
    min-width: 0;
}

.reflection-title {
    margin-bottom: 0.5rem;
}

.reflection-title a {
    color: #FFFBF5;
    text-decoration: none;
}

.reflection-title a:hover {
    color: #E77264;
    text-decoration: underline;
}

.reflection-meta {
    font-size: 0.95rem;
    color: #D0C5B0;
    margin-bottom: 0.75rem;
}

.separator {
    margin: 0 0.35em;
}

.reflection-preview-text {
    margin: 1.25rem 0;
    color: #E8DCC8;
}

.read-more {
    display: inline-block;
    font-size: 0.95rem;
    font-weight: 500;
    color: #E77264;
    text-decoration: none;
}

.read-more:hover {
    color: #FF9B8A;
    text-decoration: underline;
}

.no-posts {
    color: #D0C5B0;
    font-style: italic;
    text-align: center;
    padding: 3rem 0;
}

/* ============================================
   Individual Reflection Page
   ============================================ */

.reflection {
    margin-bottom: 3rem;
    padding: 0 1rem;
}

/* Book intro section with cover and metadata */
.book-intro {
    margin-bottom: 4.5rem;
    display: flex;
    gap: 2.5rem;
    align-items: flex-start;
}

.cover-image-container {
    flex-shrink: 0;
}

.cover-image {
    width: 250px;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cover-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

/* Metadata box with coral accent border */
.book-metadata {
    flex: 1;
    padding: 2rem;
    border-radius: 6px;
    border: 3px solid #E77264;
    box-shadow: 0 6px 16px rgba(231, 114, 100, 0.25);
    background-color: rgba(47, 85, 97, 0.5);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.book-metadata:hover {
    border-color: #FF9B8A;
    box-shadow: 0 8px 20px rgba(231, 114, 100, 0.35);
}

.book-intro .reflection-title {
    font-size: 2.75rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.book-intro .reflection-meta {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.reflection-date {
    font-size: 1.1rem;
    color: #D0C5B0;
    margin-bottom: 0;
}

.reflection-content {
    margin-bottom: 3rem;
}

.reflection-content h1,
.reflection-content h2,
.reflection-content h3 {
    margin-top: 1.75em;
}

.reflection-content h1:first-child,
.reflection-content h2:first-child,
.reflection-content h3:first-child {
    margin-top: 0;
}

.reflection-footer {
    padding-top: 2rem;
    border-top: 1px solid #5A8491;
}

.back-link {
    display: inline-block;
    font-size: 0.95rem;
    color: #E77264;
    text-decoration: none;
}

.back-link:hover {
    color: #FF9B8A;
    text-decoration: underline;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    html {
        font-size: 17px;
    }

    .container,
    .header-content,
    .footer-content {
        padding: 0 1rem;
    }

    .logo {
        height: 140px;
    }

    .intro h1,
    .book-intro .reflection-title {
        font-size: 2rem;
    }

    h1 {
        font-size: 1.85rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .reflection-preview {
        flex-direction: column;
        gap: 1.5rem;
    }

    .preview-cover {
        width: 100%;
        max-width: 250px;
    }

    .book-intro {
        flex-direction: column;
        gap: 1.5rem;
    }

    .cover-image {
        width: 100%;
        max-width: 250px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 16px;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .logo {
        height: 120px;
    }

    nav {
        align-self: flex-start;
    }

    .preview-cover,
    .cover-image {
        max-width: 200px;
    }

    .book-metadata {
        padding: 1.5rem;
    }
}

/* ============================================
   Theme Toggle Controls (Desktop Only)
   ============================================ */

.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    gap: 0.5rem;
    background: rgba(47, 85, 97, 0.95);
    padding: 0.75rem 1rem;
    border-radius: 50px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.theme-toggle button {
    background: transparent;
    border: 2px solid transparent;
    font-size: 1.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    line-height: 1;
}

.theme-toggle button:hover {
    transform: scale(1.15);
    border-color: rgba(231, 114, 100, 0.3);
}

.theme-toggle button.active {
    border-color: #E77264;
    background: rgba(231, 114, 100, 0.15);
}

@media (max-width: 768px) {
    .theme-toggle {
        display: none;
    }
}

/* ============================================
   Desktop Animation Themes (769px+)
   ============================================ */

/* Theme 1: Floating Pages - Gentle drift and parallax effects */
@media (min-width: 769px) {
    @keyframes float {
        0%, 100% {
            transform: translateY(0px);
        }
        50% {
            transform: translateY(-12px);
        }
    }

    @keyframes floatSubtle {
        0%, 100% {
            transform: translateY(0px) translateX(0px);
        }
        25% {
            transform: translateY(-6px) translateX(3px);
        }
        75% {
            transform: translateY(6px) translateX(-3px);
        }
    }

    @keyframes drift {
        0%, 100% {
            transform: translateX(0px) rotate(0deg);
        }
        33% {
            transform: translateX(-8px) rotate(-1deg);
        }
        66% {
            transform: translateX(8px) rotate(1deg);
        }
    }

    [data-theme="floating"] .preview-cover,
    [data-theme="floating"] .cover-image {
        animation: float 6s ease-in-out infinite;
    }

    [data-theme="floating"] .preview-cover:hover,
    [data-theme="floating"] .cover-image:hover {
        animation: float 3s ease-in-out infinite;
        transform: translateY(-8px) scale(1.05);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
    }

    [data-theme="floating"] .book-metadata {
        animation: floatSubtle 8s ease-in-out infinite;
    }

    [data-theme="floating"] .reflection-preview {
        transition: transform 0.3s ease;
    }

    [data-theme="floating"] .reflection-preview:hover {
        transform: translateX(8px);
    }

    [data-theme="floating"] .intro {
        animation: drift 10s ease-in-out infinite;
    }

    [data-theme="floating"] h1,
    [data-theme="floating"] h2 {
        transition: transform 0.3s ease, color 0.3s ease;
    }

    [data-theme="floating"] h1:hover,
    [data-theme="floating"] h2:hover {
        transform: translateX(6px);
        color: #FF9B8A;
    }
}

/* Theme 2: Typewriter - Staggered reveals and writing effects */
@media (min-width: 769px) {
    @keyframes fadeSlideIn {
        from {
            opacity: 0;
            transform: translateX(-30px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    @keyframes fadeSlideInRight {
        from {
            opacity: 0;
            transform: translateX(30px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    @keyframes typewriterUnderline {
        0% {
            width: 0;
        }
        100% {
            width: 100%;
        }
    }

    @keyframes blink {
        0%, 100% {
            opacity: 1;
        }
        50% {
            opacity: 0;
        }
    }

    [data-theme="typewriter"] .reflection-preview {
        animation: fadeSlideIn 0.8s ease-out backwards;
    }

    [data-theme="typewriter"] .reflection-preview:nth-child(1) {
        animation-delay: 0.1s;
    }

    [data-theme="typewriter"] .reflection-preview:nth-child(2) {
        animation-delay: 0.2s;
    }

    [data-theme="typewriter"] .reflection-preview:nth-child(3) {
        animation-delay: 0.3s;
    }

    [data-theme="typewriter"] .preview-cover {
        animation: fadeSlideIn 0.8s ease-out backwards;
    }

    [data-theme="typewriter"] .preview-content {
        animation: fadeSlideInRight 0.8s ease-out backwards;
        animation-delay: 0.2s;
    }

    [data-theme="typewriter"] .cover-image {
        animation: fadeSlideIn 1s ease-out backwards;
    }

    [data-theme="typewriter"] .book-metadata {
        animation: fadeSlideInRight 1s ease-out backwards;
        animation-delay: 0.3s;
    }

    [data-theme="typewriter"] h1 {
        position: relative;
        display: inline-block;
    }

    [data-theme="typewriter"] h1::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 0;
        height: 3px;
        background: #E77264;
        animation: typewriterUnderline 1.5s ease-out forwards;
    }

    [data-theme="typewriter"] .intro h1::after {
        content: '|';
        position: absolute;
        right: -0.5em;
        bottom: auto;
        height: auto;
        background: transparent;
        color: #E77264;
        animation: blink 1s step-end infinite;
    }

    [data-theme="typewriter"] .reflection-title a {
        transition: all 0.3s ease;
    }

    [data-theme="typewriter"] .reflection-title a:hover {
        transform: translateX(8px);
        display: inline-block;
    }
}

/* Theme 3: Morphing - Gradients, transforms, and color shifts */
@media (min-width: 769px) {
    @keyframes gradientShift {
        0% {
            background-position: 0% 50%;
        }
        50% {
            background-position: 100% 50%;
        }
        100% {
            background-position: 0% 50%;
        }
    }

    @keyframes rotate3D {
        0% {
            transform: perspective(1000px) rotateY(0deg);
        }
        100% {
            transform: perspective(1000px) rotateY(360deg);
        }
    }

    @keyframes pulse {
        0%, 100% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.03);
        }
    }

    @keyframes colorPulse {
        0%, 100% {
            filter: hue-rotate(0deg) brightness(1);
        }
        50% {
            filter: hue-rotate(10deg) brightness(1.1);
        }
    }

    @keyframes morphBorder {
        0%, 100% {
            border-radius: 6px;
        }
        25% {
            border-radius: 30px 6px 30px 6px;
        }
        50% {
            border-radius: 6px 30px 6px 30px;
        }
        75% {
            border-radius: 30px 6px 30px 6px;
        }
    }

    [data-theme="morphing"] body {
        background: linear-gradient(135deg, #456B77, #2F5561, #5A8491);
        background-size: 300% 300%;
        animation: gradientShift 15s ease infinite;
    }

    [data-theme="morphing"] .preview-cover,
    [data-theme="morphing"] .cover-image {
        animation: morphBorder 8s ease-in-out infinite, pulse 4s ease-in-out infinite;
        transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }

    [data-theme="morphing"] .preview-cover:hover,
    [data-theme="morphing"] .cover-image:hover {
        transform: scale(1.1) rotate(3deg);
        box-shadow: 0 16px 32px rgba(231, 114, 100, 0.4);
        filter: brightness(1.1);
    }

    [data-theme="morphing"] .book-metadata {
        background: linear-gradient(135deg, rgba(47, 85, 97, 0.6), rgba(90, 132, 145, 0.4));
        background-size: 200% 200%;
        animation: gradientShift 10s ease infinite, morphBorder 10s ease-in-out infinite;
        transition: all 0.3s ease;
    }

    [data-theme="morphing"] .book-metadata:hover {
        transform: scale(1.02);
        background-size: 250% 250%;
    }

    [data-theme="morphing"] .reflection-preview {
        transition: all 0.4s ease;
    }

    [data-theme="morphing"] .reflection-preview:hover {
        transform: translateX(12px);
        filter: brightness(1.05);
    }

    [data-theme="morphing"] h1,
    [data-theme="morphing"] h2,
    [data-theme="morphing"] h3 {
        animation: colorPulse 6s ease-in-out infinite;
        transition: all 0.3s ease;
    }

    [data-theme="morphing"] h1:hover,
    [data-theme="morphing"] h2:hover,
    [data-theme="morphing"] h3:hover {
        transform: scale(1.05);
        text-shadow: 0 0 20px rgba(231, 114, 100, 0.5);
    }

    [data-theme="morphing"] a {
        transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }

    [data-theme="morphing"] a:hover {
        transform: scale(1.05);
        text-shadow: 0 0 12px rgba(231, 114, 100, 0.6);
    }

    [data-theme="morphing"] .intro {
        animation: pulse 8s ease-in-out infinite;
    }
}
