/* === CSS Custom Properties === */
:root {
    --bg-primary: #060e1f;
    --card-surface: #0b1a3b;
    --card-elevated: #0f2248;
    --text-primary: #e8edf5;
    --text-secondary: #8b9bc0;
    --text-tertiary: #4a5a8a;
    --accent-primary: #3d7ec7;
    --accent-gold: #c0a46b;
    --border-color: rgba(192, 199, 214, 0.15); /* #c0c7d6 at 15% */
    --border-hover: rgba(61, 126, 199, 0.35);
    --tier: 1;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100'%3E%3Cpolygon points='28,2 52,15 52,41 28,54 4,41 4,15' fill='none' stroke='%233d7ec7' stroke-width='0.5' opacity='0.04'/%3E%3Cpolygon points='28,52 52,65 52,91 28,104 4,91 4,65' fill='none' stroke='%233d7ec7' stroke-width='0.5' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 28px 50px;
}

/* === Typography === */
h1, h2, h3 {
    font-family: 'Nunito', sans-serif;
    color: var(--text-primary);
    letter-spacing: 0.03em;
}

.tier-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: clamp(2.8rem, 7vw, 6rem);
    color: var(--text-primary);
    margin-bottom: 3rem;
    padding-left: 60px;
}

.body-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.72;
}

.icon-caption, .stamp-caption, .cocktail-ingredients, .data-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-variant: small-caps;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* === Fixed Left Rail Navigation === */
#tier-nav {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    z-index: 100;
}

.tier-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: transform 0.3s ease, color 0.3s ease;
}

.tier-link:hover {
    transform: scale(1.4);
    color: var(--accent-primary);
}

.tier-link.active {
    color: var(--text-primary);
    animation: gentle-pulse 3s ease-in-out infinite;
}

.tier-label {
    position: absolute;
    left: 48px;
    white-space: nowrap;
    font-family: 'IBM Plex Sans', sans-serif;
    font-variant: small-caps;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--text-tertiary);
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.tier-link:hover .tier-label {
    opacity: 1;
    transform: translateX(0);
}

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

/* === Tier 1: Exosphere === */
.tier-1 {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.moon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3rem;
}

#moon {
    width: min(50vw, 400px);
    height: min(50vw, 400px);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 40%, #e8edf5 0%, #8b9bc0 40%, #0b1a3b 70%, #060e1f 100%);
    opacity: 0;
    transform: scale(0.85);
    animation: moon-entrance 1.8s cubic-bezier(0.16, 1, 0.3, 1) 0.6s forwards;
}

@keyframes moon-entrance {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.title-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--text-primary);
    letter-spacing: 0.03em;
    opacity: 0;
}

.subtitle-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-variant: small-caps;
    letter-spacing: 0.12em;
    font-size: 0.9rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
    opacity: 0;
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    animation: indicator-pulse 2.5s ease-in-out infinite;
    opacity: 0.6;
}

@keyframes indicator-pulse {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(8px); opacity: 0.3; }
}

/* === Masonry Grid === */
.masonry-grid {
    padding: 0 2.4rem 4rem;
    padding-left: calc(48px + 2.4rem);
    display: grid;
    gap: 2.4rem;
}

.masonry-3col {
    grid-template-columns: repeat(3, 1fr);
}

.masonry-4col {
    grid-template-columns: repeat(4, 1fr);
}

/* === Masonry Blocks === */
.masonry-block {
    background: var(--card-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2rem;
    opacity: 0;
    transform: scale(0.92);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease, border-color 0.3s ease;
}

.masonry-block.visible {
    opacity: 1;
    transform: scale(1);
}

.masonry-block:hover {
    transform: scale(1.03);
    border-color: var(--border-hover);
}

.block-wide {
    grid-column: span 2;
}

.block-tall {
    grid-row: span 2;
}

/* Diamond connectors at block intersections */
.masonry-block::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    opacity: 0;
    transform: rotate(45deg);
    transition: opacity 0.3s;
}

.masonry-block:hover::before {
    opacity: 0.4;
}

/* === Tier 2: Thermosphere === */
.tier-2 {
    min-height: 250vh;
    padding-top: 6rem;
    padding-bottom: 6rem;
}

/* === Tier 3: Mesosphere === */
.tier-3 {
    min-height: 200vh;
    padding-top: 6rem;
    padding-bottom: 6rem;
}

.tier-3 .masonry-block {
    background: var(--card-elevated);
}

/* === Block Types === */
.block-icon, .block-stamp {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.iso-icon {
    width: 100%;
    max-width: 160px;
    height: auto;
    margin-bottom: 1rem;
}

.iso-small {
    max-width: 100px;
}

.icon-caption {
    margin-top: 0.5rem;
}

/* Stamp blocks */
.block-stamp {
    padding: 1.5rem;
    aspect-ratio: 1;
    max-width: 180px;
}

.block-stamp .iso-icon {
    max-width: 80px;
}

.stamp-caption {
    display: block;
    margin-top: 0.75rem;
    text-align: center;
    text-transform: uppercase;
}

/* Cocktail blocks */
.block-cocktail {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.cocktail-name {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0.75rem 0 0.5rem;
}

.cocktail-desc {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.cocktail-ingredients {
    list-style: none;
    width: 100%;
}

.cocktail-ingredients li {
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
}

.cocktail-ingredients li:last-child {
    border-bottom: none;
}

/* Data table blocks */
.block-data {
    padding: 1.5rem;
}

.data-title {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table td {
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(74, 90, 138, 0.3);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.data-table td:last-child {
    text-align: right;
    font-family: 'IBM Plex Sans', sans-serif;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.block-small {
    font-size: 0.9rem;
}

.block-small .body-text {
    font-size: 0.9rem;
}

.block-small .cocktail-name {
    font-size: 1.1rem;
}

/* === Tier 4: Troposphere === */
.tier-4 {
    min-height: 150vh;
    padding-top: 8rem;
    padding-bottom: 6rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.closing-column {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 2.4rem;
    padding-left: calc(48px + 2.4rem);
    text-align: center;
}

.closing-column .tier-heading {
    padding-left: 0;
    text-align: center;
}

.closing-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.85;
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    margin-bottom: 5rem;
    text-align: left;
}

/* === Geometric Seal === */
#geometric-seal {
    margin: 0 auto 4rem;
    width: 280px;
    height: 280px;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 1.5s ease, transform 1.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 1.5s ease;
}

#geometric-seal.visible {
    opacity: 1;
    transform: scale(1);
    filter: drop-shadow(0 0 60px rgba(192, 164, 107, 0.15));
}

.seal-svg {
    width: 100%;
    height: 100%;
}

/* Domain final text */
.domain-final {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: var(--accent-gold);
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 1s ease 0.5s;
}

.domain-final.visible {
    opacity: 1;
}

/* === Responsive === */
@media (max-width: 1024px) {
    .masonry-3col {
        grid-template-columns: repeat(2, 1fr);
    }
    .masonry-4col {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    #tier-nav {
        display: none;
    }
    .masonry-grid {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    .masonry-3col, .masonry-4col {
        grid-template-columns: 1fr;
    }
    .block-wide {
        grid-column: span 1;
    }
    .closing-column {
        padding-left: 1.5rem;
    }
    .tier-heading {
        padding-left: 1.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
