/* ============================================================
   diplomatic.bar - Styles
   Earth-tone palette | Masonry desk layout | Playful diplomacy
   Fonts: Space Grotesk, DM Sans, Libre Baskerville, IBM Plex Mono
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --warm-sand: #F5E6D3;
    --espresso-earth: #3B2412;
    --burnt-clay: #C4572A;
    --grove-shadow: #4A5D3A;
    --mustard-seal: #D4A020;
    --adobe-wall: #A0744F;
    --parchment: #FFF8F0;
    --sage-mist: #B8C4A8;
    --ink-residue: #2C2620;

    --font-display: 'Space Grotesk', sans-serif;
    --font-secondary: 'DM Sans', sans-serif;
    --font-body: 'Libre Baskerville', serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --bounce-enter: cubic-bezier(0.34, 1.56, 0.64, 1);

    --shadow-x: 4px;
    --shadow-y: 6px;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: linear-gradient(165deg, #F5E6D3 0%, #FFF8F0 40%, #F5E6D3 100%);
    color: var(--espresso-earth);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Floating Background Elements --- */
.floaters {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floater {
    position: absolute;
    will-change: transform;
}

.floater-1 {
    top: 8%;
    left: 5%;
    animation: floatPath1 25s ease-in-out infinite;
}
.floater-2 {
    top: 15%;
    right: 10%;
    animation: floatPath2 30s ease-in-out infinite;
}
.floater-3 {
    top: 35%;
    left: 12%;
    animation: floatPath3 22s ease-in-out infinite;
}
.floater-4 {
    top: 50%;
    right: 8%;
    animation: floatPath4 35s ease-in-out infinite;
}
.floater-5 {
    top: 70%;
    left: 20%;
    animation: floatPath5 28s ease-in-out infinite;
}
.floater-6 {
    top: 85%;
    right: 25%;
    animation: floatPath6 20s ease-in-out infinite;
}
.floater-7 {
    top: 25%;
    left: 45%;
    animation: floatPath7 32s ease-in-out infinite;
}
.floater-8 {
    top: 60%;
    right: 35%;
    animation: floatPath8 18s ease-in-out infinite;
}
.floater-9 {
    top: 40%;
    left: 70%;
    animation: floatPath9 27s ease-in-out infinite;
}
.floater-10 {
    top: 75%;
    right: 55%;
    animation: floatPath10 33s ease-in-out infinite;
}
.floater-11 {
    top: 10%;
    left: 60%;
    animation: floatPath11 24s ease-in-out infinite;
}
.floater-12 {
    top: 90%;
    left: 35%;
    animation: floatPath12 40s ease-in-out infinite;
}

/* Floater animation paths (15-40s durations, unique drift paths) */
@keyframes floatPath1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(60px, 40px) rotate(15deg); }
    50% { transform: translate(20px, 80px) rotate(-10deg); }
    75% { transform: translate(-40px, 30px) rotate(5deg); }
}
@keyframes floatPath2 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-50px, 60px) rotate(-20deg); }
    50% { transform: translate(-80px, 20px) rotate(10deg); }
    75% { transform: translate(-20px, -30px) rotate(-5deg); }
}
@keyframes floatPath3 {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(70px, -40px); }
    66% { transform: translate(30px, 50px); }
}
@keyframes floatPath4 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-30px, -60px) rotate(25deg); }
    50% { transform: translate(40px, -30px) rotate(-15deg); }
    75% { transform: translate(20px, 40px) rotate(10deg); }
}
@keyframes floatPath5 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(80px, -50px); }
}
@keyframes floatPath6 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-60px, -40px) rotate(-30deg); }
    66% { transform: translate(30px, -70px) rotate(15deg); }
}
@keyframes floatPath7 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-40px, 50px); }
    50% { transform: translate(30px, 90px); }
    75% { transform: translate(60px, 40px); }
}
@keyframes floatPath8 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(-50px, 40px) rotate(20deg); }
}
@keyframes floatPath9 {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(40px, 60px); }
    66% { transform: translate(-30px, 30px); }
}
@keyframes floatPath10 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(50px, -40px) rotate(-10deg); }
    75% { transform: translate(-30px, 50px) rotate(15deg); }
}
@keyframes floatPath11 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-70px, 60px); }
}
@keyframes floatPath12 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(60px, -50px) rotate(20deg); }
    66% { transform: translate(-40px, -20px) rotate(-10deg); }
}

/* --- Floating Badge Navigation --- */
.badge-nav {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: navDrift 6s ease-in-out infinite;
}

@keyframes navDrift {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(-3px, 4px); }
    66% { transform: translate(2px, -3px); }
}

.badge-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--adobe-wall);
    background: var(--parchment);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s var(--bounce-enter), box-shadow 0.3s ease, border-color 0.3s ease;
    box-shadow: 2px 3px 8px rgba(59, 36, 18, 0.15);
}

.badge-btn:hover {
    transform: scale(1.15) rotate(15deg);
    box-shadow: 3px 5px 14px rgba(59, 36, 18, 0.25);
    border-color: var(--burnt-clay);
}

.badge-btn:active {
    transform: scale(1.05) rotate(10deg);
}

/* --- ACT 1: ARRIVAL --- */
.act-arrival {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    padding: 40px 20px;
}

.arrival-content {
    text-align: center;
    position: relative;
}

.embassy-building {
    margin: 0 auto 40px;
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    transition: opacity 0.8s ease, transform 0.8s var(--bounce-enter);
}

.embassy-building.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.embassy-svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 16px rgba(59, 36, 18, 0.2));
}

/* Building scatter animation on scroll past hero */
.embassy-building.scattered .embassy-svg {
    animation: buildingScatter 1s var(--bounce-enter) forwards;
}

@keyframes buildingScatter {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.6); opacity: 0.3; filter: blur(2px); }
}

/* Site Title */
.site-title {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease 0.4s, transform 0.6s var(--bounce-enter) 0.4s;
}

.site-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.title-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5.5vw, 4.5rem);
    letter-spacing: -0.025em;
    color: var(--espresso-earth);
    line-height: 1.1;
    margin-bottom: 16px;
}

/* Character-level bounce-enter animation with staggered delay */
.char {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: charBounce 0.6s var(--bounce-enter) forwards;
    animation-delay: calc(var(--delay) * 60ms + 0.6s);
}

.char.dot {
    color: var(--burnt-clay);
}

@keyframes charBounce {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.subtitle {
    font-family: var(--font-secondary);
    font-weight: 500;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    letter-spacing: 0.01em;
    color: var(--adobe-wall);
    opacity: 0;
    animation: fadeUp 0.8s ease 1.6s forwards;
}

@keyframes fadeUp {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll hint */
.scroll-hint {
    margin-top: 48px;
    opacity: 0;
    animation: fadeUp 0.8s ease 2.2s forwards;
}

.scroll-dot {
    animation: scrollDotBounce 2s ease-in-out infinite;
}

@keyframes scrollDotBounce {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(12px); opacity: 0.2; }
}

/* --- Stamp Strip Section Dividers --- */
.stamp-strip {
    width: 100%;
    overflow: hidden;
    padding: 20px 0;
    position: relative;
    z-index: 1;
    background: linear-gradient(180deg, transparent, rgba(160, 116, 79, 0.06), transparent);
}

.stamp-strip-inner {
    display: flex;
    gap: 40px;
    align-items: center;
    width: max-content;
    animation: stampScroll 20s linear infinite;
}

/* Continuous horizontal scroll at ~30px/s */
@keyframes stampScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.stamp-icon {
    flex-shrink: 0;
    opacity: 0.6;
}

/* --- ACT 2: THE DESK --- */
.act-desk {
    position: relative;
    z-index: 1;
    padding: 60px clamp(16px, 4vw, 60px) 80px;
    min-height: 300vh;
}

.desk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 16px;
    border-bottom: 2px dashed var(--adobe-wall);
}

.desk-label {
    font-family: var(--font-secondary);
    font-weight: 500;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    letter-spacing: 0.01em;
    color: var(--espresso-earth);
}

.desk-ref {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--adobe-wall);
}

/* Masonry Grid */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: 20px;
    gap: clamp(12px, 2vw, 24px);
}

/* Tile span heights - variable row counts for uneven tile effect */
.tile-span-8 { grid-row: span 8; }
.tile-span-12 { grid-row: span 12; }
.tile-span-16 { grid-row: span 16; }
.tile-span-20 { grid-row: span 20; }

/* Masonry Tile - diplomatic folder tab profile */
.masonry-tile {
    background: var(--parchment);
    border-radius: 6px 6px 2px 2px;
    padding: clamp(16px, 2vw, 28px);
    transform: rotate(var(--rot, 0deg));
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    box-shadow: var(--shadow-x) var(--shadow-y) 16px rgba(59, 36, 18, 0.12);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    cursor: default;
    display: flex;
    flex-direction: column;
}

/* Tile hover: lift 4px, deepen shadow, border transitions to burnt clay */
.masonry-tile:hover {
    transform: rotate(var(--rot, 0deg)) translateY(-4px);
    box-shadow: var(--shadow-x) calc(var(--shadow-y) + 4px) 24px rgba(59, 36, 18, 0.18);
    border-color: var(--burnt-clay);
}

/* Stamp texture overlay: concentric circles at 4% opacity */
.tile-stamp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.04;
    background-image: radial-gradient(circle, #3B2412 1px, transparent 1px),
                       radial-gradient(circle, #3B2412 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
}

/* Decorative borders: alternating #C4572A and #D4A020 dashed pattern */
.masonry-tile:nth-child(odd) {
    border-image: linear-gradient(135deg, #C4572A, #D4A020) 1;
    border-width: 2px;
    border-style: dashed;
}

.masonry-tile:nth-child(even) {
    border: 2px solid rgba(160, 116, 79, 0.2);
}

.masonry-tile:nth-child(even):hover {
    border-color: var(--burnt-clay);
}

/* Tile animate-in (scroll-triggered via IntersectionObserver) */
.masonry-tile[data-animate] {
    opacity: 0;
    transform: rotate(var(--rot, 0deg)) translateY(30px);
}

.masonry-tile[data-animate].animate-in {
    opacity: 1;
    transform: rotate(var(--rot, 0deg)) translateY(0);
    transition: opacity 0.6s ease, transform 0.6s var(--bounce-enter);
}

.tile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.tile-ref {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--burnt-clay);
}

.tile-date {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--adobe-wall);
}

.tile-icon {
    margin: 8px 0 16px;
    display: flex;
    justify-content: center;
}

/* Icon hover: float up 6px, shadow expands */
.tile-icon svg {
    transition: transform 0.3s ease, filter 0.3s ease;
    filter: drop-shadow(0 4px 6px rgba(59, 36, 18, 0.15));
}

.masonry-tile:hover .tile-icon svg {
    transform: translateY(-6px);
    filter: drop-shadow(0 8px 10px rgba(59, 36, 18, 0.12));
}

.tile-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    letter-spacing: -0.025em;
    color: var(--espresso-earth);
    margin-bottom: 10px;
    line-height: 1.2;
}

.tile-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1rem);
    line-height: 1.72;
    color: var(--espresso-earth);
    margin-bottom: 10px;
}

.tile-list {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1rem);
    line-height: 1.72;
    color: var(--espresso-earth);
    padding-left: 1.5em;
    margin-bottom: 10px;
}

.tile-list li {
    margin-bottom: 4px;
}

.tile-list li::marker {
    color: var(--burnt-clay);
}

.tile-footer {
    margin-top: auto;
    padding-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tile-tag {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--grove-shadow);
    background: var(--sage-mist);
    padding: 3px 10px;
    border-radius: 3px;
}

/* --- ACT 3: THE TOAST --- */
.act-toast {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px 0;
    /* Background gradient shifts warmer - golden-hour light */
    background: linear-gradient(180deg, var(--warm-sand), var(--parchment));
}

.toast-content {
    text-align: center;
    max-width: 680px;
    margin: 0 auto;
    position: relative;
}

/* Large Cocktail Glass - bounce-enter on visibility */
.toast-glass {
    margin: 0 auto 60px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s var(--bounce-enter);
    position: relative;
}

.toast-glass.visible {
    opacity: 1;
    transform: translateY(0);
}

.glass-svg {
    filter: drop-shadow(0 8px 20px rgba(59, 36, 18, 0.15));
}

/* Orbiting Icons Ring - 20-second rotation loop */
.orbit-ring {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 320px;
    animation: orbitSpin 20s linear infinite;
    pointer-events: none;
}

@keyframes orbitSpin {
    0% { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

.orbit-icon {
    position: absolute;
    width: 40px;
    height: 40px;
    /* Counter-rotate to keep icons upright */
    animation: orbitCounterSpin 20s linear infinite;
}

@keyframes orbitCounterSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

.orbit-icon-1 {
    top: 0;
    left: 50%;
    margin-left: -20px;
}

.orbit-icon-2 {
    top: 50%;
    right: 0;
    margin-top: -20px;
}

.orbit-icon-3 {
    bottom: 0;
    left: 50%;
    margin-left: -20px;
}

.orbit-icon-4 {
    top: 50%;
    left: 0;
    margin-top: -20px;
}

/* Toast Text - bounce-enter on visibility */
.toast-text {
    margin-top: 40px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s var(--bounce-enter);
}

.toast-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: -0.025em;
    color: var(--espresso-earth);
    margin-bottom: 24px;
}

.toast-communique {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: var(--espresso-earth);
    margin-bottom: 16px;
    text-align: left;
}

/* Final communique line - italic emphasis in burnt clay */
.toast-communique.last-communique {
    font-weight: 700;
    font-style: italic;
    text-align: center;
    margin-top: 28px;
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    color: var(--burnt-clay);
}

.toast-signature {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sig-seal {
    opacity: 0.6;
    margin-bottom: 4px;
}

.sig-line {
    display: block;
    width: 120px;
    height: 2px;
    background: var(--espresso-earth);
}

.sig-text {
    font-family: var(--font-secondary);
    font-weight: 500;
    font-size: 1rem;
    letter-spacing: 0.01em;
    color: var(--espresso-earth);
}

.sig-ref {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--adobe-wall);
}

/* --- Footer --- */
.site-footer {
    margin-top: 80px;
    padding: 40px 20px;
    text-align: center;
    background: var(--espresso-earth);
    border-radius: 6px 6px 0 0;
    width: 100%;
}

.footer-seal {
    margin-bottom: 16px;
}

.footer-text {
    font-family: var(--font-secondary);
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--warm-sand);
    margin-bottom: 8px;
}

.footer-ref {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--adobe-wall);
}

/* --- Responsive: Mobile (< 640px) --- */
@media (max-width: 640px) {
    .masonry-grid {
        grid-template-columns: 1fr;
    }

    .tile-span-8,
    .tile-span-12,
    .tile-span-16,
    .tile-span-20 {
        grid-row: span 1;
    }

    .masonry-tile {
        height: auto;
    }

    .badge-nav {
        top: 12px;
        right: 12px;
    }

    .badge-btn {
        width: 40px;
        height: 40px;
    }

    /* Reduce to 5 floaters on mobile */
    .floater-6,
    .floater-7,
    .floater-8,
    .floater-9,
    .floater-10,
    .floater-11,
    .floater-12 {
        display: none;
    }

    .orbit-ring {
        width: 240px;
        height: 240px;
    }

    .embassy-svg {
        width: 280px;
        height: auto;
    }

    .desk-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .scroll-hint {
        margin-top: 32px;
    }
}

@media (max-width: 400px) {
    .title-text {
        font-size: 1.8rem;
    }

    .toast-heading {
        font-size: 1.8rem;
    }
}

/* --- Selection Color --- */
::selection {
    background: var(--burnt-clay);
    color: var(--parchment);
}

/* --- Scrollbar Styling (Webkit) --- */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--warm-sand);
}

::-webkit-scrollbar-thumb {
    background: var(--adobe-wall);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--burnt-clay);
}
