/* 
 * Yan Family Archive
 * Style inspired by tigers.family — bold, minimal, modern
 */

/* ============================================
   CSS Custom Properties
   ============================================ */
:root {
    /* Colors — warm, soft palette */
    --color-bg: #FAF8F5;
    --color-bg-alt: #F3F0EB;
    --color-text: #1A1A1A;
    --color-text-muted: #7A7A7A;
    --color-text-light: #ABABAB;
    --color-accent: #C4A77D;
    --color-accent-light: #E8DED0;
    --color-white: #FFFFFF;
    
    /* Typography — like tigers.family */
    --font-display: 'Space Grotesk', -apple-system, sans-serif;
    --font-body: 'Manrope', -apple-system, sans-serif;
    
    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;
    --space-2xl: 6rem;
    
    /* Animation */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    --duration-slow: 600ms;
    
    /* Layout */
    --max-width: 1400px;
    --content-width: 900px;
}

/* ============================================
   Base Reset & Typography
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    overflow-x: hidden;
}

img, video {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    border: none;
    background: none;
    cursor: pointer;
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: var(--space-xl) var(--space-lg) var(--space-lg);
    position: relative;
    background: linear-gradient(
        180deg,
        var(--color-bg) 0%,
        var(--color-accent-light) 100%
    );
    overflow: hidden;
    perspective: 1000px;
}

/* Hero Subtitle — at the very top */
.hero > .hero-subtitle {
    margin-top: var(--space-md);
    margin-bottom: var(--space-lg);
    animation: fadeInUp 0.8s var(--ease-out-expo);
}

/* Hero Image — like tigers.family */
.hero-image {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: auto;
    z-index: 1;
    pointer-events: none;
    will-change: transform;
    animation: fadeInScale 1.2s var(--ease-out-expo);
    margin-bottom: calc(-1 * var(--space-md));
    margin-top: var(--space-lg);
    transform-style: preserve-3d;
    perspective: 1000px;
}

@media (min-width: 768px) {
    .hero-image {
        max-width: 450px;
    }
}

@media (min-width: 1024px) {
    .hero-image {
        max-width: 500px;
    }
}

.hero-image img {
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: grayscale(10%) contrast(1.05);
    transition: filter 0.3s ease;
}

.hero:hover .hero-image img {
    filter: grayscale(0%) contrast(1.05);
}

/* Golden Halo */
.hero-image::before {
    content: '';
    position: absolute;
    top: -8%;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 15%;
    background: radial-gradient(
        ellipse at center,
        rgba(218, 165, 32, 0.15) 0%,
        rgba(218, 165, 32, 0.05) 50%,
        rgba(218, 165, 32, 0) 80%
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
}

/* Halo ring */
.hero-image::after {
    content: '';
    position: absolute;
    top: -3%;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    aspect-ratio: 2.5 / 1;
    border: 2.5px solid rgba(218, 165, 32, 0.7);
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hero-content {
    text-align: center;
    animation: fadeInUp 1s var(--ease-out-expo);
    animation-delay: 0.2s;
    animation-fill-mode: both;
    position: relative;
    z-index: 2;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(5rem, 25vw, 14rem);
    font-weight: 700;
    line-height: 0.85;
    letter-spacing: -0.03em;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
    text-transform: lowercase;
}

.hero-period {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--color-text-muted);
    letter-spacing: 0.05em;
}

.scroll-indicator {
    position: absolute;
    bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    color: var(--color-text-light);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: lowercase;
    animation: bounce 2s infinite;
    z-index: 2;
}

.scroll-indicator svg {
    width: 20px;
    height: 20px;
}

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* ============================================
   Timeline Navigation
   ============================================ */
.timeline-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(250, 248, 245, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-accent-light);
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    gap: var(--space-lg);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.nav-year {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text-light);
    white-space: nowrap;
    transition: color var(--duration-normal) var(--ease-out);
    position: relative;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    display: inline-block;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.nav-year::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-text);
    transition: width var(--duration-normal) var(--ease-out);
}

.nav-year:hover,
.nav-year.active {
    color: var(--color-text);
}

.nav-year.active::after {
    width: 100%;
}

/* ============================================
   Timeline Main
   ============================================ */
.timeline {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

/* ============================================
   Year Marker (scroll target)
   ============================================ */
.year-marker {
    height: 0;
    margin: 0;
    padding: 0;
    visibility: hidden;
}

/* ============================================
   Month Section
   ============================================ */
.month-section {
    margin-bottom: var(--space-2xl);
}

.month-header {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--color-text);
}

.month-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 10vw, 4rem);
    font-weight: 700;
    line-height: 1;
    color: var(--color-text);
    text-transform: lowercase;
}

.month-year {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

/* ============================================
   Posts Grid
   ============================================ */
.posts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xl);
}

@media (min-width: 640px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .post--featured {
        grid-column: span 2;
    }
    
    .post--milestone {
        grid-column: 1 / -1;
    }
}

/* ============================================
   Post Card
   ============================================ */
.post {
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    border: 1px solid var(--color-accent-light);
    transition: 
        transform var(--duration-slow) var(--ease-out-expo),
        border-color var(--duration-normal) var(--ease-out);
    
    /* Animation on scroll */
    opacity: 0;
    transform: translateY(40px);
    animation: revealPost 0.8s var(--ease-out-expo) forwards;
}

.post:nth-child(1) { animation-delay: 0ms; }
.post:nth-child(2) { animation-delay: 100ms; }
.post:nth-child(3) { animation-delay: 200ms; }
.post:nth-child(4) { animation-delay: 300ms; }
.post:nth-child(5) { animation-delay: 400ms; }
.post:nth-child(6) { animation-delay: 500ms; }

@keyframes revealPost {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post:hover {
    transform: translateY(-4px);
    border-color: var(--color-text-muted);
}

/* Post Media */
.post-media {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: var(--color-bg-alt);
}

.post--featured .post-media {
    aspect-ratio: 16 / 9;
}

.post--milestone .post-media {
    aspect-ratio: 16 / 9;
}

@media (min-width: 1024px) {
    .post--milestone .post-media {
        aspect-ratio: 21 / 9;
    }
}

.post-media img,
.post-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--duration-slow) var(--ease-out-expo);
}

.post:hover .post-media img,
.post:hover .post-media video {
    transform: scale(1.02);
}

/* Play Button */
.play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    border-radius: 0;
    background: var(--color-text);
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 
        transform var(--duration-normal) var(--ease-out),
        background var(--duration-normal) var(--ease-out);
}

.play-btn svg {
    width: 28px;
    height: 28px;
    margin-left: 4px; /* optical alignment */
}

.play-btn:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: var(--color-accent);
}

.post-media.playing .play-btn {
    opacity: 0;
    pointer-events: none;
}

/* Milestone Badge */
.post-milestone-badge {
    position: absolute;
    top: var(--space-sm);
    left: var(--space-sm);
    z-index: 10;
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-text);
    color: var(--color-white);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: lowercase;
}

/* Post Meta */
.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-bg-alt);
}

.post-date {
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
}

.post-author {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

/* Post Comments — ONLY show if has content */
.post-comments {
    padding: var(--space-sm) var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Hide empty comments section */
.post-comments:empty {
    display: none;
}

.comment {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--color-text-muted);
}

.comment-author {
    font-weight: 600;
    color: var(--color-text);
    margin-right: var(--space-xs);
}

.comment-author::after {
    content: '';
}

.comment p {
    display: inline;
}

/* Collapsed comments on mobile */
@media (max-width: 639px) {
    .post-comments {
        max-height: 120px;
        overflow: hidden;
        position: relative;
    }
    
    .post-comments::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 40px;
        background: linear-gradient(transparent, var(--color-white));
        pointer-events: none;
    }
    
    .post-comments.expanded {
        max-height: none;
    }
    
    .post-comments.expanded::after {
        display: none;
    }
}

/* ============================================
   Milestone Post (Full Width)
   ============================================ */
.post--milestone {
    background: var(--color-text);
    color: var(--color-white);
    border-color: var(--color-text);
}

.post--milestone .post-meta {
    padding: var(--space-md) var(--space-lg);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.post--milestone .post-date {
    font-size: 1.125rem;
    color: var(--color-white);
}

.post--milestone .post-author {
    color: rgba(255, 255, 255, 0.6);
}

.post--milestone .post-comments {
    padding: var(--space-md) var(--space-lg);
    background: var(--color-text);
}

.post--milestone .comment {
    color: rgba(255, 255, 255, 0.7);
}

.post--milestone .comment-author {
    color: var(--color-white);
}

.post--milestone .post-milestone-badge {
    background: var(--color-accent);
    color: var(--color-text);
}

.post--milestone .play-btn {
    background: var(--color-white);
    color: var(--color-text);
}

.post--milestone .play-btn:hover {
    background: var(--color-accent);
}

/* ============================================
   Footer
   ============================================ */
.footer {
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    color: var(--color-text-light);
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: lowercase;
}

.footer-heart {
    display: block;
    font-size: 1.5rem;
    margin-top: var(--space-sm);
}

/* ============================================
   Placeholder
   ============================================ */
.month-section--placeholder {
    opacity: 0.5;
}

.placeholder-text {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

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

/* ============================================
   Loading State
   ============================================ */
.post-media.loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        var(--color-bg-alt) 0%,
        var(--color-bg) 50%,
        var(--color-bg-alt) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Year Page Styles (paginated)
   ============================================ */
.year-page {
    min-height: 100vh;
}

.year-header {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-lg);
    background: var(--color-bg);
    border-bottom: 2px solid var(--color-text);
}

.back-link {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: color var(--duration-normal);
}

.back-link:hover {
    color: var(--color-text);
}

.back-link svg {
    width: 16px;
    height: 16px;
}

.year-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 700;
    color: var(--color-text);
    flex: 1;
}

.timeline-nav--sticky {
    position: sticky;
    top: 0;
}

.nav-year--active {
    color: var(--color-text);
    pointer-events: none;
}

.nav-year--active::after {
    width: 100%;
}

/* Page Navigation */
.page-nav {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-xl) var(--space-lg);
    background: var(--color-bg-alt);
}

.page-nav-link {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--color-accent-light);
    transition: all var(--duration-normal);
}

.page-nav-link:hover {
    color: var(--color-text);
    border-color: var(--color-text);
}

/* Year Preview (index page) */
.year-preview {
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
}

.year-preview h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
    text-transform: lowercase;
}

.year-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
}

.year-cards .nav-year {
    font-size: 2rem;
    padding: var(--space-md) var(--space-lg);
    border: 2px solid var(--color-accent-light);
    transition: all var(--duration-normal);
}

.year-cards .nav-year:hover {
    border-color: var(--color-text);
    background: var(--color-text);
    color: var(--color-white);
}

/* ============================================
   Lazy Loading States
   ============================================ */
img.lazy-img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img.lazy-img.loaded {
    opacity: 1;
}

.post-media.loading {
    background: var(--color-bg-alt);
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .timeline-nav,
    .scroll-indicator,
    .play-btn,
    .page-nav {
        display: none;
    }
    
    .hero {
        min-height: auto;
        padding: var(--space-lg);
    }
    
    .post {
        break-inside: avoid;
    }
}
