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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Sans 3', sans-serif;
    background-color: #E8E0D4;
    color: #2A2520;
    line-height: 1.65;
    font-size: clamp(1rem, 1.6vw, 1.15rem);
    font-weight: 400;
    position: relative;
    overflow-x: hidden;
}

/* ===== Grain Texture Layers ===== */

/* Fine grain overlay - tiled at 200x200px */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpi2r9//38gIAAAFwAF/qjL59kAAAAASUVORK5CYII=');
    background-size: 200px 200px;
    opacity: 0.15;
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: overlay;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #8B7D6B;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

/* Ensure content renders above grain */
html > * {
    position: relative;
    z-index: 2;
}

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

h1, h2, h3 {
    font-family: 'Zilla Slab', serif;
    letter-spacing: 0.03em;
    color: #2A2520;
}

h1 {
    font-size: clamp(2.4rem, 5vw, 4.2rem);
    font-weight: 700;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 600;
    margin-bottom: 0.8rem;
}

h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
}

p {
    margin: 0;
    line-height: 1.65;
}

code, .monospace {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    font-weight: 400;
    color: #7A8B6E;
}

/* ===== Hero Plate ===== */

.hero-plate {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #E8E0D4 0%, #D4C8B8 100%);
    overflow: hidden;
}

/* Hero plate grain at maximum intensity */
.hero-plate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(139, 125, 107, 0.25) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 125, 107, 0.2) 0%, transparent 50%),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(139, 125, 107, 0.1) 2px, rgba(139, 125, 107, 0.1) 4px);
    opacity: 0.4;
    pointer-events: none;
    animation: grain-flicker 0.083s steps(4, end) infinite;
}

@keyframes grain-flicker {
    0% { opacity: 0.4; }
    25% { opacity: 0.42; }
    50% { opacity: 0.39; }
    75% { opacity: 0.41; }
    100% { opacity: 0.4; }
}

.hero-content {
    position: relative;
    z-index: 3;
    text-align: center;
    padding: 2rem;
}

.hero-title {
    color: #2A2520;
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: fade-in-up 0.8s ease-out forwards 0.2s;
    filter: drop-shadow(2px 2px 4px rgba(42, 37, 32, 0.1));
}

.hero-tagline {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.95rem;
    color: #7A8B6E;
    letter-spacing: 0.05em;
    opacity: 0;
    animation: typewriter 1.2s steps(55, end) forwards 1s;
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typewriter {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 100%;
        opacity: 1;
    }
}

/* ===== Content Grid ===== */

.content-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
    padding: 3rem 2rem;
    max-width: 1280px;
    margin: 0 auto;
    position: relative;
    z-index: 3;
}

/* Grid lines as subtle background */
.content-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 1.5rem, rgba(42, 37, 32, 0.02) 1.5rem, rgba(42, 37, 32, 0.02) 1.51rem),
        repeating-linear-gradient(90deg, transparent, transparent calc(100% / 12), rgba(42, 37, 32, 0.02) calc(100% / 12), rgba(42, 37, 32, 0.02) calc(100% / 12 + 1px));
    pointer-events: none;
    z-index: 0;
}

/* ===== Card System ===== */

.card {
    position: relative;
    border: 4px solid #E8E0D4;
    border-radius: 0;
    background-color: #E8E0D4;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(40px);
    animation: card-fade-in 0.5s ease-out forwards;
    box-shadow: 2px 2px 8px rgba(42, 37, 32, 0.08),
                inset 0 0 20px rgba(139, 125, 107, 0.05);
    z-index: 3;
}

@keyframes card-fade-in {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for cards */
.card:nth-child(1) { animation-delay: 0.6s; }
.card:nth-child(2) { animation-delay: 0.7s; }
.card:nth-child(3) { animation-delay: 0.8s; }
.card:nth-child(4) { animation-delay: 0.9s; }
.card:nth-child(5) { animation-delay: 1s; }
.card:nth-child(6) { animation-delay: 1.1s; }
.card:nth-child(7) { animation-delay: 1.2s; }
.card:nth-child(8) { animation-delay: 1.3s; }
.card:nth-child(9) { animation-delay: 1.4s; }
.card:nth-child(10) { animation-delay: 1.5s; }

/* Film Frame Cards (4-col) */
.card--film {
    grid-column: span 4;
    aspect-ratio: 3 / 2;
    background-color: #E8E0D4;
}

.card--film .card-inner {
    padding: 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: linear-gradient(180deg, rgba(232, 224, 212, 0) 0%, rgba(196, 114, 58, 0.08) 100%);
    position: relative;
}

.card--film::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.7" numOctaves="4" /></filter><rect width="100" height="100" fill="%23E8E0D4" filter="url(%23noise)"/></svg>');
    opacity: 0.3;
    pointer-events: none;
    z-index: 1;
}

.card--film .card-inner {
    position: relative;
    z-index: 2;
}

/* Text Slab Cards (3-col) */
.card--slab {
    grid-column: span 3;
    background-color: #D4C8B8;
    padding: 1.5rem;
}

.card--slab .card-inner {
    position: relative;
    z-index: 2;
}

/* Wide Film Cards (6-col) */
.card--wide {
    grid-column: span 6;
}

/* Card Inner Content */
.card-inner {
    position: relative;
    z-index: 2;
}

.card-inner h2,
.card-inner h3 {
    margin-bottom: 0.8rem;
}

.card-inner p {
    opacity: 0.85;
}

/* ===== Card Hover Interaction ===== */

.card {
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 4px 4px 12px rgba(42, 37, 32, 0.15),
                inset 0 0 20px rgba(196, 114, 58, 0.1);
}

.card:hover::before {
    opacity: 0.5;
}

/* Shake-error micro-animation on hover */
.card:hover {
    animation: shake-error 0.15s ease-in-out;
}

@keyframes shake-error {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(2px); }
    50% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* ===== Scroll Progress Indicator ===== */

.scroll-progress {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 8px;
    height: 8px;
    background-color: #C4723A;
    border-radius: 50%;
    z-index: 100;
    box-shadow: 0 0 8px rgba(196, 114, 58, 0.3);
    animation: pulse-progress 2s ease-in-out infinite;
}

@keyframes pulse-progress {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* ===== Flowing Curves SVG ===== */

.flowing-curves {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.curve-path {
    fill: none;
    stroke: #C4723A;
    stroke-width: 1.5px;
    opacity: 0.3;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

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

@media (max-width: 1024px) {
    .card--film {
        grid-column: span 6;
    }

    .card--slab {
        grid-column: span 4;
    }

    .card--wide {
        grid-column: span 12;
    }
}

@media (max-width: 768px) {
    .card--film,
    .card--slab,
    .card--wide {
        grid-column: span 12;
        aspect-ratio: auto;
    }

    .card--film .card-inner,
    .card--slab {
        padding: 1.5rem;
    }

    .content-grid {
        padding: 2rem 1rem;
        gap: 1rem;
    }

    .scroll-progress {
        bottom: 1rem;
        right: 1rem;
    }
}

/* ===== Accessibility ===== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Print Styles ===== */

@media print {
    .scroll-progress,
    .flowing-curves {
        display: none;
    }

    .card {
        page-break-inside: avoid;
    }
}
