/* historygrapher.net - Grainy-textured temporal cartography */
/* Colors: #1A0A2E #2D1B69 #FF3C78 #FFD23F #00E5FF #F0E6D3 #A89EC9 #4ECDC4 #1E0F35 #0D0519 #3D2B79 */
/* Font: Commissioner (variable, 100-900) */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Commissioner', sans-serif;
    font-weight: 350;
    background-color: #1A0A2E;
    color: #F0E6D3;
    overflow-x: hidden;
    line-height: 1.72;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   GRAIN CANVAS OVERLAY
   ============================================ */
#grain-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
}

/* ============================================
   MAIN CONTAINER
   ============================================ */
#strata-container {
    position: relative;
    width: 100%;
}

/* ============================================
   STRATA BASE STYLES
   ============================================ */
.stratum {
    position: relative;
    width: 100%;
}

#stratum-1 {
    min-height: 120vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1A0A2E;
    position: relative;
}

#stratum-1::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #FF3C78;
    opacity: 0.08;
    z-index: 0;
}

#stratum-2 {
    min-height: 160vh;
    padding: 8rem 4rem;
    background: linear-gradient(to bottom, #1A0A2E, #2D1B69 15vh, #2D1B69);
}

#stratum-3 {
    min-height: 120vh;
    padding: 6rem 2rem;
    background: linear-gradient(to bottom, #2D1B69, #1A0A2E 15vh, #1A0A2E);
}

#stratum-4 {
    min-height: 120vh;
    padding: 6rem 3rem;
    background: linear-gradient(to bottom, #1A0A2E, #1E0F35 10vh, #1E0F35);
}

#stratum-5 {
    min-height: 100vh;
    padding: 0;
    background: linear-gradient(to bottom, #1E0F35, #0D0519 20vh, #0D0519);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ============================================
   STRATUM I: THE SURFACE LAYER
   ============================================ */
.stratum-1-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

#main-title {
    font-size: clamp(3rem, 10vw, 8rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    text-transform: uppercase;
    color: #FFD23F;
    text-shadow: 0 0 40px rgba(255, 210, 63, 0.15);
    line-height: 1.1;
}

#main-title .letter {
    display: inline-block;
    opacity: 0;
    font-variation-settings: 'wght' 100;
    transition: opacity 0.6s ease, font-variation-settings 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#main-title .letter.visible {
    opacity: 1;
    font-variation-settings: 'wght' 800;
}

.stratum-subtitle {
    font-size: clamp(0.9rem, 1.4vw, 1.15rem);
    font-weight: 350;
    color: #A89EC9;
    margin-top: 2rem;
    letter-spacing: 0.05em;
    max-width: 40ch;
    margin-left: auto;
    margin-right: auto;
}

.scroll-indicator {
    position: absolute;
    bottom: 4rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.scroll-arrow {
    display: block;
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, transparent, #A89EC9);
    animation: scrollPulse 2s ease-in-out infinite;
    position: relative;
}

.scroll-arrow::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-right: 2px solid #A89EC9;
    border-bottom: 2px solid #A89EC9;
    transform: translateX(-50%) rotate(45deg);
}

@keyframes scrollPulse {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(8px); }
}

/* ============================================
   STRATUM LABELS
   ============================================ */
.stratum-label {
    display: block;
    margin-bottom: 4rem;
    text-align: center;
}

/* ============================================
   CAPTION TEXT STYLE
   ============================================ */
.caption-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-stretch: 87.5%;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #FF3C78;
}

/* ============================================
   SKELETON LOADING SYSTEM
   ============================================ */
.skeleton-block {
    position: relative;
}

.skeleton-block::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #2D1B69, #3D2B79, #2D1B69);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
    z-index: 2;
    transition: opacity 0.5s ease;
}

.skeleton-block.revealed::before {
    opacity: 0;
    pointer-events: none;
}

.skeleton-block > * {
    clip-path: circle(0% at 50% 50%);
    transition: clip-path 0.8s ease-out;
}

.skeleton-block.revealed > * {
    clip-path: circle(100% at 50% 50%);
}

/* Special handling for inline elements and self-content blocks */
.skeleton-block.revealed .artifact-inner,
.skeleton-block.revealed .mosaic-inner,
.skeleton-block.revealed .timeline-content,
.skeleton-block.revealed .timeline-year {
    clip-path: circle(100% at 50% 50%);
}

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

/* ============================================
   CULTURAL PATTERN BORDERS
   ============================================ */
.pattern-border {
    width: 100%;
    height: 3rem;
    opacity: 0.2;
    transition: opacity 0.6s ease;
    position: relative;
    z-index: 1;
}

.pattern-border:hover {
    opacity: 0.6;
}

/* ============================================
   STRATUM II: THE ARCHAEOLOGICAL GRID
   ============================================ */
.stratum-2-grid {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 6rem;
    max-width: 1400px;
    margin: 0 auto;
}

.artifact-card {
    min-height: 300px;
    padding: 2.5rem;
    background: rgba(45, 27, 105, 0.4);
    border: 1px solid rgba(168, 158, 201, 0.1);
    position: relative;
    overflow: hidden;
}

.artifact-card:nth-child(1) {
    grid-column: 1 / 2;
    transform: translateY(4rem);
}

.artifact-card:nth-child(2) {
    grid-column: 2 / 3;
    transform: translateY(0);
}

.artifact-card:nth-child(3) {
    grid-column: 1 / 3;
    transform: translateY(2rem);
}

.artifact-card:nth-child(4) {
    grid-column: 3 / 4;
    transform: translateY(-2rem);
}

.artifact-inner {
    position: relative;
    z-index: 1;
}

.artifact-date {
    display: block;
    margin-bottom: 1rem;
}

.artifact-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    color: #FFD23F;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.artifact-desc {
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    font-weight: 350;
    line-height: 1.72;
    color: #F0E6D3;
    max-width: 62ch;
    margin-bottom: 1.5rem;
}

.artifact-desc::first-line {
    text-indent: 2rem;
}

.artifact-origin {
    display: block;
    color: #A89EC9;
    font-weight: 500;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* ============================================
   STRATUM III: THE TIMELINE CORRIDOR
   ============================================ */
.timeline-corridor {
    max-width: 680px;
    margin: 0 auto;
    position: relative;
    padding: 2rem 0;
}

.timeline-line {
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, transparent, #3D2B79 10%, #3D2B79 90%, transparent);
}

.timeline-node {
    position: relative;
    padding: 2rem 0 3rem 3.5rem;
    min-height: 120px;
}

.timeline-node::before {
    content: '';
    position: absolute;
    left: 0;
    top: 2.2rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #FFD23F;
    border: 4px solid #1A0A2E;
    box-shadow: 0 0 0 2px #FFD23F;
    z-index: 2;
}

.timeline-year {
    display: inline-block;
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    color: #1A0A2E;
    background: #FFD23F;
    border-radius: 100px;
    padding: 0.3em 1em;
    margin-bottom: 1rem;
}

.timeline-content h3 {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: #F0E6D3;
    margin-bottom: 0.5rem;
}

.timeline-content p {
    font-size: clamp(0.95rem, 1.4vw, 1.1rem);
    font-weight: 350;
    line-height: 1.72;
    color: #A89EC9;
    max-width: 52ch;
}

/* ============================================
   STRATUM IV: THE CULTURAL MOSAIC
   ============================================ */
.mosaic-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.mosaic-block {
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
    background: rgba(30, 15, 53, 0.6);
    border: 1px solid rgba(168, 158, 201, 0.08);
}

.mosaic-a {
    grid-column: 1 / 8;
    grid-row: 1;
}

.mosaic-b {
    grid-column: 6 / 13;
    grid-row: 2;
    margin-top: -3rem;
}

.mosaic-c {
    grid-column: 1 / 6;
    grid-row: 3;
}

.mosaic-d {
    grid-column: 5 / 13;
    grid-row: 3;
    margin-top: 2rem;
}

.mosaic-e {
    grid-column: 3 / 11;
    grid-row: 4;
}

.mosaic-inner {
    position: relative;
    z-index: 1;
}

.mosaic-tag {
    display: block;
    margin-bottom: 1rem;
}

.mosaic-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: #FFD23F;
    text-transform: uppercase;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.mosaic-block p {
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    font-weight: 350;
    line-height: 1.72;
    color: #F0E6D3;
    max-width: 62ch;
}

/* ============================================
   STRATUM V: THE SEDIMENTATION
   ============================================ */
.geological-svg-container {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

#geological-strata {
    width: 100%;
    height: 100%;
}

.geo-layer {
    animation: undulate 6s ease-in-out infinite alternate;
}

.geo-layer[data-layer="2"] { animation-delay: -0.8s; }
.geo-layer[data-layer="3"] { animation-delay: -1.6s; }
.geo-layer[data-layer="4"] { animation-delay: -2.4s; }
.geo-layer[data-layer="5"] { animation-delay: -3.2s; }
.geo-layer[data-layer="6"] { animation-delay: -4s; }
.geo-layer[data-layer="7"] { animation-delay: -4.8s; }

@keyframes undulate {
    0% { transform: translateY(0px); }
    100% { transform: translateY(6px); }
}

.sedimentation-text {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 10rem 2rem;
    max-width: 700px;
    margin: 0 auto;
}

.sed-line {
    font-family: 'Commissioner', sans-serif;
    font-style: italic;
    font-weight: 350;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: #F0E6D3;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.sed-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.sed-line:last-child {
    font-weight: 700;
    font-style: normal;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    color: #FFD23F;
    margin-top: 2rem;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

/* ============================================
   FONT VARIATION ANIMATION FOR STRATUM TITLES
   ============================================ */
.stratum-title-animated {
    font-variation-settings: 'wght' 100;
    transition: font-variation-settings 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.stratum-title-animated.weight-active {
    font-variation-settings: 'wght' 800;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 900px) {
    .stratum-2-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
        padding: 0 1rem;
    }

    .artifact-card:nth-child(1),
    .artifact-card:nth-child(2),
    .artifact-card:nth-child(3),
    .artifact-card:nth-child(4) {
        grid-column: 1;
        transform: translateY(0);
    }

    #stratum-2 {
        padding: 4rem 2rem;
    }

    .mosaic-grid {
        grid-template-columns: 1fr;
    }

    .mosaic-a,
    .mosaic-b,
    .mosaic-c,
    .mosaic-d,
    .mosaic-e {
        grid-column: 1;
        grid-row: auto;
        margin-top: 0;
    }

    #stratum-4 {
        padding: 4rem 2rem;
    }

    .timeline-corridor {
        padding: 2rem 1rem;
    }
}

@media (max-width: 600px) {
    #main-title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }

    .sedimentation-text {
        padding: 6rem 1.5rem;
    }
}