/* ============================================
   pmt.moe - Frutiger Aero meets Moe Culture
   ============================================ */

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

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

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1vw, 17px);
    line-height: 1.8;
    color: #3A1830;
    background: #FFF8F0;
    overflow-x: hidden;
}

/* --- Nature Motifs Layer --- */
#nature-motifs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.nature-motif {
    position: absolute;
    opacity: 0;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.nature-motif--flower {
    animation-name: floatFlower;
}

.nature-motif--leaf {
    animation-name: floatLeaf;
}

.nature-motif--star {
    animation-name: floatStar;
}

@keyframes floatFlower {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translate(120px, -100vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes floatLeaf {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.25;
    }
    50% {
        transform: translate(80px, -50vh) rotate(180deg) scale(1.1);
    }
    90% {
        opacity: 0.25;
    }
    100% {
        transform: translate(-40px, -100vh) rotate(360deg) scale(1);
        opacity: 0;
    }
}

@keyframes floatStar {
    0% {
        transform: translate(0, 0) scale(0.8);
        opacity: 0;
    }
    10% {
        opacity: 0.35;
    }
    50% {
        transform: translate(-60px, -50vh) scale(1.2);
    }
    90% {
        opacity: 0.35;
    }
    100% {
        transform: translate(40px, -100vh) scale(0.8);
        opacity: 0;
    }
}

/* --- Scanline Overlay --- */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(58, 24, 48, 0.015) 2px,
        rgba(58, 24, 48, 0.015) 4px
    );
    opacity: 0;
    transition: opacity 0.1s;
}

#scanline-overlay.active {
    opacity: 1;
}

/* --- Glitch Flash --- */
#glitch-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
    background: linear-gradient(
        135deg,
        rgba(48, 255, 128, 0.3),
        rgba(255, 128, 144, 0.3),
        rgba(128, 192, 255, 0.3)
    );
    opacity: 0;
    mix-blend-mode: screen;
}

#glitch-flash.active {
    animation: glitchFlash 100ms ease-out forwards;
}

@keyframes glitchFlash {
    0% { opacity: 0.8; }
    50% { opacity: 0.4; transform: translateX(3px); }
    100% { opacity: 0; transform: translateX(0); }
}

/* --- Glow Entrance --- */
#glow-entrance {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.entrance-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        #FF8090 0%,
        #FFB060 40%,
        #80C0FF 100%
    );
    z-index: 0;
}

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

#site-title {
    font-family: 'Righteous', cursive;
    font-weight: 400;
    font-size: clamp(48px, 8vw, 120px);
    color: #FFF8F0;
    text-shadow:
        0 2px 20px rgba(58, 24, 48, 0.2),
        0 0 60px rgba(255, 176, 96, 0.4);
    position: relative;
    display: inline-block;
    transform: scale(0.8);
    opacity: 0;
    overflow: hidden;
}

#site-title.animate-in {
    animation: titleBounceIn 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes titleBounceIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.title-text {
    position: relative;
    z-index: 1;
}

.aero-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 248, 240, 0.5),
        transparent
    );
    z-index: 2;
    transform: skewX(-20deg);
}

.aero-shine.sweep {
    animation: shineSweep 800ms ease-in-out forwards;
    animation-delay: 600ms;
}

@keyframes shineSweep {
    0% { left: -100%; }
    100% { left: 150%; }
}

.entrance-tagline {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(14px, 1.5vw, 20px);
    color: rgba(255, 248, 240, 0.8);
    margin-top: 16px;
    opacity: 0;
    transform: translateY(10px);
}

.entrance-tagline.animate-in {
    animation: fadeInUp 600ms ease-out forwards;
    animation-delay: 800ms;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Story Stream --- */
#story-stream {
    position: relative;
    background: #FFF8F0;
}

/* --- Scene --- */
.scene {
    position: relative;
    width: 100%;
    padding: 0;
}

.glitch-transition {
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #FF8090, #30FF80, #80C0FF);
    opacity: 0;
    transition: opacity 0.1s;
    position: relative;
    overflow: hidden;
}

.glitch-transition.active {
    animation: glitchLine 100ms steps(3) forwards;
}

@keyframes glitchLine {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    33% {
        transform: translateX(-5px);
        background: linear-gradient(90deg, #30FF80, #FF8090, #80C0FF);
    }
    66% {
        transform: translateX(5px);
        background: linear-gradient(90deg, #80C0FF, #30FF80, #FF8090);
    }
    100% {
        opacity: 0;
        transform: translateX(0);
    }
}

/* --- Aero Panel --- */
.aero-panel {
    max-width: 680px;
    margin: 0 auto;
    padding: 48px 40px;
    position: relative;
    background: linear-gradient(
        180deg,
        rgba(255, 248, 240, 0.95) 0%,
        rgba(232, 216, 240, 0.4) 50%,
        rgba(255, 248, 240, 0.9) 100%
    );
    border-radius: 16px;
    box-shadow:
        0 4px 24px rgba(58, 24, 48, 0.08),
        0 1px 3px rgba(58, 24, 48, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-top: 24px;
    margin-bottom: 24px;
}

.aero-panel:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 32px rgba(58, 24, 48, 0.12),
        0 2px 6px rgba(58, 24, 48, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.aero-panel-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(232, 216, 240, 0.3),
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transform: skewX(-20deg);
    pointer-events: none;
    z-index: 1;
}

.aero-panel-shine.sweep {
    animation: panelShineSweep 800ms ease-in-out forwards;
}

@keyframes panelShineSweep {
    0% { left: -100%; }
    100% { left: 150%; }
}

.aero-panel:hover .aero-panel-shine {
    animation: panelShineSweep 800ms ease-in-out forwards;
}

/* --- Scene Title --- */
.scene-title {
    font-family: 'Righteous', cursive;
    font-weight: 400;
    font-size: 22px;
    color: #3A1830;
    margin-bottom: 20px;
    text-shadow:
        1px 1px 0 rgba(255, 128, 144, 0.3),
        -1px -1px 0 rgba(128, 192, 255, 0.2);
    transition: text-shadow 0.3s ease;
}

.aero-panel:hover .scene-title {
    text-shadow:
        2px 2px 0 rgba(255, 128, 144, 0.5),
        -2px -2px 0 rgba(128, 192, 255, 0.4);
}

/* --- Scene Content --- */
.scene-content p {
    margin-bottom: 16px;
    color: #3A1830;
}

.scene-content p:last-child {
    margin-bottom: 0;
}

.aside {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: 13px;
    color: rgba(58, 24, 48, 0.6);
    padding-left: 16px;
    border-left: 2px solid rgba(255, 128, 144, 0.3);
}

/* --- Shake Text --- */
.shake-text {
    font-weight: 400;
    color: #FF8090;
    display: inline-block;
    cursor: default;
}

.shake-text.shaking {
    animation: shakeError 200ms ease-in-out;
}

@keyframes shakeError {
    0% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

/* --- Glitch Gallery --- */
.glitch-gallery {
    display: flex;
    width: 100%;
    gap: 0;
    overflow: hidden;
    padding: 32px 0;
}

.glitch-panel {
    flex: 1;
    height: 180px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(
        135deg,
        #FF8090,
        #FFB060,
        #80C0FF
    );
}

.glitch-panel:nth-child(2) {
    background: linear-gradient(
        135deg,
        #80C0FF,
        #E8D8F0,
        #FF8090
    );
}

.glitch-panel:nth-child(3) {
    background: linear-gradient(
        135deg,
        #FFB060,
        #30FF80,
        #80C0FF
    );
}

.glitch-bar {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(48, 255, 128, 0.6);
    opacity: 0;
}

.glitch-bar:nth-child(1) { top: 25%; }
.glitch-bar:nth-child(2) { top: 50%; }
.glitch-bar:nth-child(3) { top: 75%; }

.glitch-panel.glitching .glitch-bar {
    animation: glitchBarSlide 150ms steps(2) forwards;
}

@keyframes glitchBarSlide {
    0% {
        opacity: 0.8;
        transform: translateX(0);
    }
    50% {
        opacity: 1;
        transform: translateX(10px);
    }
    100% {
        opacity: 0;
        transform: translateX(-5px);
    }
}

.glitch-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.glitch-symbol {
    font-size: 48px;
    color: rgba(255, 248, 240, 0.6);
    text-shadow: 0 0 20px rgba(255, 248, 240, 0.4);
    display: block;
}

.glitch-panel.glitching .glitch-symbol {
    animation: glitchSymbol 150ms steps(3);
}

@keyframes glitchSymbol {
    0% {
        transform: translate(0, 0);
        color: rgba(255, 248, 240, 0.6);
    }
    33% {
        transform: translate(3px, -2px);
        color: rgba(255, 128, 144, 0.8);
    }
    66% {
        transform: translate(-3px, 2px);
        color: rgba(48, 255, 128, 0.8);
    }
    100% {
        transform: translate(0, 0);
        color: rgba(255, 248, 240, 0.6);
    }
}

/* --- End Card (Footer) --- */
#end-card {
    position: relative;
    width: 100%;
    padding: 80px 20px;
    text-align: center;
    overflow: hidden;
}

.end-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        #FFB060 0%,
        #FF8090 40%,
        #E8D8F0 70%,
        #80C0FF 100%
    );
    z-index: 0;
}

.end-content {
    position: relative;
    z-index: 1;
}

.end-title {
    font-family: 'Righteous', cursive;
    font-weight: 400;
    font-size: clamp(28px, 3.5vw, 52px);
    color: #FFF8F0;
    text-shadow: 0 2px 20px rgba(58, 24, 48, 0.2);
    margin-bottom: 8px;
}

.end-subtitle {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: 13px;
    color: rgba(255, 248, 240, 0.7);
    margin-bottom: 24px;
}

.end-motifs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.end-motifs svg {
    animation: endFloat 3s ease-in-out infinite;
}

.end-motifs svg:nth-child(2) { animation-delay: 0.3s; }
.end-motifs svg:nth-child(3) { animation-delay: 0.6s; }
.end-motifs svg:nth-child(4) { animation-delay: 0.9s; }
.end-motifs svg:nth-child(5) { animation-delay: 1.2s; }

@keyframes endFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* --- Scroll-based Gradient Shift --- */
body {
    transition: background-color 0.5s ease;
}

#story-stream {
    background: linear-gradient(
        180deg,
        #FFF8F0 0%,
        #FFF8F0 30%,
        rgba(232, 216, 240, 0.2) 60%,
        rgba(232, 216, 240, 0.4) 100%
    );
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .aero-panel {
        margin-left: 12px;
        margin-right: 12px;
        padding: 32px 24px;
        border-radius: 12px;
    }

    .glitch-gallery {
        padding: 20px 0;
    }

    .glitch-panel {
        height: 120px;
    }

    .glitch-symbol {
        font-size: 32px;
    }

    #end-card {
        padding: 60px 16px;
    }
}

@media (max-width: 480px) {
    .aero-panel {
        padding: 24px 16px;
        margin-left: 8px;
        margin-right: 8px;
    }

    .scene-title {
        font-size: 18px;
    }

    .glitch-panel {
        height: 90px;
    }

    .glitch-symbol {
        font-size: 24px;
    }
}

/* --- Glitch color channel split on transition elements --- */
.scene.glitch-active .scene-title {
    animation: colorChannelSplit 100ms steps(2);
}

@keyframes colorChannelSplit {
    0% {
        text-shadow:
            1px 1px 0 rgba(255, 128, 144, 0.3),
            -1px -1px 0 rgba(128, 192, 255, 0.2);
    }
    50% {
        text-shadow:
            4px 0 0 rgba(255, 128, 144, 0.6),
            -4px 0 0 rgba(48, 255, 128, 0.6),
            0 0 0 rgba(128, 192, 255, 0.6);
    }
    100% {
        text-shadow:
            1px 1px 0 rgba(255, 128, 144, 0.3),
            -1px -1px 0 rgba(128, 192, 255, 0.2);
    }
}
