/* ============================================================
   scriptswirl.com - Seapunk Scripting Aesthetic
   ============================================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(16px, 1.5vw, 18px);
    line-height: 1.75;
    color: #4A4A5A;
    background: #FFF8F4;
    overflow-x: hidden;
}

/* ---------- Typography ---------- */
.heading-clean {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
}

.heading-hand {
    font-family: 'Caveat', cursive;
    font-weight: 400;
}

.code-font {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 13px;
}

.section-heading {
    font-size: clamp(28px, 5vw, 56px);
    line-height: 1.2;
    margin-bottom: 24px;
    color: #4A4A5A;
}

.section-heading .heading-hand {
    color: #8B5CF6;
}

/* ---------- Split-Screen Layout ---------- */
.split-screen {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

/* ---------- THE WHIRLPOOL (Hero) ---------- */
#whirlpool {
    position: relative;
    background: linear-gradient(135deg, #E8E0F0 0%, #D0F0F0 100%);
}

.whirlpool-left {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swirl-bg {
    position: absolute;
    width: 600px;
    height: 600px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: conic-gradient(
        from 0deg,
        #E8E0F0,
        #D0F0F0,
        #FDB5B5,
        #8B5CF6,
        #D0F0F0,
        #E8E0F0
    );
    border-radius: 50%;
    opacity: 0.4;
    filter: blur(40px);
    animation: swirlRotate 20s linear infinite;
}

@keyframes swirlRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.glitch-center {
    position: absolute;
    width: 8px;
    height: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #8B5CF6;
    border-radius: 50%;
    animation: glitchFlicker 5s ease-in-out infinite;
    z-index: 5;
}

@keyframes glitchFlicker {
    0%, 96% { opacity: 0; box-shadow: none; }
    97% {
        opacity: 1;
        box-shadow:
            4px 0 0 #FDB5B5,
            -4px 0 0 #0D9488,
            0 0 20px rgba(139, 92, 246, 0.6);
        width: 12px;
        height: 12px;
    }
    98% {
        opacity: 0.5;
        box-shadow:
            -3px 2px 0 #FDB5B5,
            3px -2px 0 #0D9488;
    }
    99% {
        opacity: 1;
        box-shadow:
            2px -1px 0 #D0F0F0,
            -2px 1px 0 #8B5CF6,
            0 0 30px rgba(139, 92, 246, 0.4);
    }
    100% { opacity: 0; box-shadow: none; }
}

.icon-orbit-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.orbit-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    font-family: 'Fira Code', monospace;
    font-size: var(--icon-size, 20px);
    color: var(--icon-color, #8B5CF6);
    opacity: var(--icon-opacity, 0.3);
    animation: orbit var(--orbit-duration, 10s) linear infinite;
    transform-origin: 0 0;
}

@keyframes orbit {
    from {
        transform: rotate(0deg) translateX(var(--radius)) rotate(0deg);
    }
    to {
        transform: rotate(360deg) translateX(var(--radius)) rotate(-360deg);
    }
}

.whirlpool-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 60px;
    background: rgba(255, 248, 244, 0.85);
    backdrop-filter: blur(10px);
}

.wordmark {
    font-size: clamp(36px, 6vw, 72px);
    line-height: 1.1;
    margin-bottom: 16px;
    opacity: 0;
    animation: wordmarkFadeIn 0.8s ease-out 0.4s forwards;
}

.wordmark-script {
    font-family: 'Archivo', sans-serif;
    font-weight: 700;
    color: #4A4A5A;
}

.wordmark-swirl {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    color: #8B5CF6;
}

.wordmark-dot {
    font-family: 'Archivo', sans-serif;
    font-weight: 400;
    color: #0D9488;
    font-size: 0.6em;
}

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

.tagline {
    font-family: 'Caveat', cursive;
    font-size: clamp(20px, 3vw, 32px);
    color: #8B5CF6;
    margin-bottom: 20px;
    opacity: 0;
    animation: wordmarkFadeIn 0.8s ease-out 0.7s forwards;
}

.description {
    font-size: clamp(16px, 1.5vw, 18px);
    color: #4A4A5A;
    max-width: 480px;
    opacity: 0;
    animation: wordmarkFadeIn 0.8s ease-out 1s forwards;
}

/* ---------- DUAL-NATURE SECTIONS ---------- */
.dual-nature {
    position: relative;
}

.dual-nature.reverse {
    direction: rtl;
}

.dual-nature.reverse > * {
    direction: ltr;
}

.swirl-panel {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #E8E0F0, #D0F0F0);
    padding: 60px 40px;
}

.code-density-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.code-density-bg .density-symbol {
    position: absolute;
    font-family: 'Fira Code', monospace;
    color: var(--sym-color, #8B5CF6);
    font-size: var(--sym-size, 20px);
    opacity: var(--sym-opacity, 0.15);
    transform: rotate(var(--sym-rotation, 0deg));
}

.swirl-text {
    position: relative;
    z-index: 2;
    text-align: center;
}

.swirl-text .code-font {
    color: #0D9488;
    background: rgba(255, 248, 244, 0.7);
    padding: 12px 20px;
    border-radius: 8px;
    display: inline-block;
    max-width: 100%;
    word-break: break-all;
}

.structure-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 50px;
    background: #FFF8F4;
}

.structure-panel p {
    margin-bottom: 16px;
    max-width: 520px;
}

/* ---------- THE SUNKEN CITY ---------- */
#sunken-city {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #D0F0F0 0%, #E8E0F0 40%, #4A4A5A 100%);
    overflow: hidden;
}

.city-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center bottom, transparent 30%, rgba(74, 74, 90, 0.3) 100%);
    z-index: 1;
}

.city-skyline {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    z-index: 2;
    opacity: 0.5;
}

.city-building {
    position: absolute;
    bottom: 0;
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.3), rgba(74, 74, 90, 0.5));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-bottom: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 10px;
    overflow: hidden;
    border-radius: 2px 2px 0 0;
}

.city-building .building-symbol {
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    color: rgba(208, 240, 240, 0.4);
    line-height: 1.3;
    white-space: nowrap;
}

.city-content {
    position: relative;
    z-index: 3;
    text-align: center;
    padding: 40px;
}

.city-heading {
    color: #FFF8F4;
}

.city-heading .heading-hand {
    color: #FDB5B5;
}

.city-description {
    color: #D0F0F0;
    max-width: 600px;
    margin: 0 auto;
    font-size: clamp(16px, 1.5vw, 18px);
}

.glitch-bar {
    position: absolute;
    width: 100%;
    height: 3px;
    z-index: 4;
    opacity: 0;
}

.glitch-bar-1 {
    top: 30%;
    background: #FDB5B5;
    animation: glitchBar 6s ease-in-out infinite;
}

.glitch-bar-2 {
    top: 65%;
    background: #0D9488;
    animation: glitchBar 6s ease-in-out 3s infinite;
}

@keyframes glitchBar {
    0%, 95% { opacity: 0; transform: translateX(0) scaleX(1); }
    96% { opacity: 0.6; transform: translateX(-5px) scaleX(1.02); }
    97% { opacity: 0.3; transform: translateX(3px) scaleX(0.98); }
    98% { opacity: 0.8; transform: translateX(-2px) scaleX(1.01); }
    99% { opacity: 0.1; transform: translateX(0) scaleX(1); }
    100% { opacity: 0; transform: translateX(0) scaleX(1); }
}

/* ---------- SEAFOAM FOOTER ---------- */
#seafoam-footer {
    position: relative;
    min-height: 40vh;
    background: linear-gradient(180deg, #FFF8F4 0%, #D0F0F0 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 60px 20px;
}

.footer-icons {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.footer-icon {
    position: absolute;
    font-family: 'Fira Code', monospace;
    color: var(--fi-color, #8B5CF6);
    font-size: var(--fi-size, 14px);
    opacity: var(--fi-opacity, 0.12);
    animation: settleDown var(--fi-duration, 8s) ease-in-out infinite;
    animation-delay: var(--fi-delay, 0s);
}

@keyframes settleDown {
    0% { transform: translateY(-10px) rotate(0deg); }
    50% { transform: translateY(5px) rotate(5deg); }
    100% { transform: translateY(-10px) rotate(0deg); }
}

.footer-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.footer-wordmark {
    font-size: clamp(24px, 4vw, 40px);
    line-height: 1.2;
    margin-bottom: 8px;
}

.footer-wordmark .heading-clean {
    color: #4A4A5A;
}

.footer-wordmark .heading-hand {
    color: #8B5CF6;
}

.footer-dot {
    font-family: 'Archivo', sans-serif;
    font-weight: 400;
    color: #0D9488;
    font-size: 0.6em;
}

.footer-tagline {
    font-family: 'Caveat', cursive;
    font-size: clamp(16px, 2vw, 22px);
    color: #0D9488;
}

/* ---------- Glitch Transition Effect ---------- */
.glitch-transition {
    position: relative;
}

.glitch-transition::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, #FDB5B5, #8B5CF6, #0D9488, transparent);
    opacity: 0;
    animation: borderGlitch 8s ease-in-out infinite;
}

@keyframes borderGlitch {
    0%, 90% { opacity: 0; }
    93% { opacity: 0.5; transform: scaleX(0.95); }
    95% { opacity: 0.8; transform: scaleX(1.02); }
    97% { opacity: 0.3; transform: scaleX(0.98); }
    100% { opacity: 0; transform: scaleX(1); }
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #E8E0F0;
}

::-webkit-scrollbar-thumb {
    background: #8B5CF6;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0D9488;
}

/* ---------- Selection ---------- */
::selection {
    background: rgba(139, 92, 246, 0.2);
    color: #4A4A5A;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .split-screen {
        grid-template-columns: 1fr;
    }

    .whirlpool-left {
        min-height: 50vh;
    }

    .whirlpool-right {
        padding: 30px 24px;
    }

    .dual-nature.reverse {
        direction: ltr;
    }

    .swirl-panel {
        min-height: 50vh;
    }

    .structure-panel {
        padding: 40px 24px;
    }

    .city-content {
        padding: 20px;
    }
}
