/* ============================================
   archetype.moe - Pastel Twilight Moe Gallery
   ============================================ */

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

html, body {
    height: 100%;
    overflow: hidden;
    background: #fdf6f0;
    color: #3d3346;
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    line-height: 1.8;
    letter-spacing: 0.02em;
}

/* --- Site Watermark --- */
#site-watermark {
    position: fixed;
    top: 24px;
    left: 28px;
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1.4rem;
    color: #3d3346;
    opacity: 0.4;
    transform: rotate(-2deg);
    z-index: 100;
    cursor: default;
    transition: opacity 200ms ease-out;
    pointer-events: auto;
}

#site-watermark:hover {
    opacity: 0.8;
}

/* --- Sparkle Field --- */
#sparkle-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    animation: sparkle-twinkle var(--sparkle-duration, 2s) ease-in-out infinite;
    animation-delay: var(--sparkle-delay, 0s);
}

.sparkle::before,
.sparkle::after {
    content: '';
    position: absolute;
    background: var(--sparkle-color, #fffbf5);
}

.sparkle::before {
    width: 100%;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.sparkle::after {
    width: 2px;
    height: 100%;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

@keyframes sparkle-twinkle {
    0%, 100% { opacity: 0; transform: scale(0.5) rotate(0deg); }
    50% { opacity: 1; transform: scale(1) rotate(45deg); }
}

/* --- Horizontal Gallery --- */
#gallery {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#gallery::-webkit-scrollbar {
    display: none;
}

/* --- Archetype Room --- */
.archetype-room {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    scroll-snap-align: center;
    position: relative;
    overflow: hidden;
}

.room-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #fdf6f0, #f0e6f6);
    z-index: 0;
}

/* Per-archetype room backgrounds */
[data-archetype="genki"] .room-bg {
    background: linear-gradient(135deg, #fdf6f0 0%, #f0e6f6 40%, rgba(242, 165, 183, 0.15) 100%);
}

[data-archetype="tsundere"] .room-bg {
    background: linear-gradient(135deg, #fdf6f0 0%, rgba(242, 165, 183, 0.12) 50%, rgba(245, 208, 142, 0.1) 100%);
}

[data-archetype="yandere"] .room-bg {
    background: linear-gradient(135deg, #fdf6f0 0%, rgba(242, 165, 183, 0.18) 50%, rgba(196, 167, 215, 0.15) 100%);
}

[data-archetype="ojousama"] .room-bg {
    background: linear-gradient(135deg, #fdf6f0 0%, rgba(245, 208, 142, 0.15) 50%, rgba(196, 167, 215, 0.12) 100%);
}

[data-archetype="megane"] .room-bg {
    background: linear-gradient(135deg, #fdf6f0 0%, rgba(157, 180, 212, 0.12) 50%, rgba(168, 224, 200, 0.1) 100%);
}

[data-archetype="kuudere"] .room-bg {
    background: linear-gradient(135deg, #fdf6f0 0%, rgba(157, 180, 212, 0.15) 50%, rgba(240, 230, 246, 0.2) 100%);
}

.final-bg {
    background: linear-gradient(135deg, #fdf6f0, #f0e6f6) !important;
}

/* --- Kanji Waterfall --- */
.kanji-waterfall {
    position: absolute;
    left: 0;
    top: 0;
    width: 20%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.kanji-char {
    position: absolute;
    font-family: 'Noto Serif JP', serif;
    font-weight: 300;
    font-size: var(--kanji-size, 6rem);
    color: #3d3346;
    opacity: var(--kanji-opacity, 0.08);
    left: var(--kanji-left, 5%);
    filter: blur(1px);
    animation: kanji-fall var(--fall-duration, 20s) linear infinite;
    animation-delay: var(--fall-delay, 0s);
    will-change: transform;
}

@keyframes kanji-fall {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

/* --- Room Content Layout --- */
.room-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0 5%;
    gap: 2%;
}

/* --- Silhouette Area (Left Third) --- */
.silhouette-area {
    flex: 0 0 30%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.gradient-silhouette {
    width: 55%;
    height: 60vh;
    border-radius: 45% 55% 50% 50% / 40% 40% 60% 60%;
    position: relative;
    animation: silhouette-breathe 8s ease-in-out infinite;
    will-change: transform;
}

@keyframes silhouette-breathe {
    0%, 100% { transform: scale(0.98); }
    50% { transform: scale(1.02); }
}

.gradient-silhouette::before {
    content: '';
    position: absolute;
    inset: -20%;
    border-radius: inherit;
    background: radial-gradient(circle at 50% 50%, #fffbf5 0%, transparent 70%);
    z-index: -1;
}

/* Archetype-specific silhouettes using layered radial gradients with screen blend */
.genki-silhouette {
    background:
        radial-gradient(ellipse at 40% 30%, rgba(242, 165, 183, 0.6) 0%, transparent 60%),
        radial-gradient(ellipse at 60% 70%, rgba(245, 208, 142, 0.5) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 251, 245, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse at 35% 60%, rgba(168, 224, 200, 0.3) 0%, transparent 50%);
    background-blend-mode: screen;
}

.tsundere-silhouette {
    background:
        radial-gradient(ellipse at 45% 35%, rgba(242, 165, 183, 0.65) 0%, transparent 55%),
        radial-gradient(ellipse at 55% 65%, rgba(245, 208, 142, 0.5) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 251, 245, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse at 40% 70%, rgba(242, 165, 183, 0.3) 0%, transparent 50%);
    background-blend-mode: screen;
}

.yandere-silhouette {
    background:
        radial-gradient(ellipse at 50% 40%, rgba(242, 165, 183, 0.7) 0%, transparent 55%),
        radial-gradient(ellipse at 40% 60%, rgba(196, 167, 215, 0.5) 0%, transparent 60%),
        radial-gradient(ellipse at 55% 50%, rgba(255, 251, 245, 0.35) 0%, transparent 70%),
        radial-gradient(ellipse at 60% 30%, rgba(242, 165, 183, 0.4) 0%, transparent 50%);
    background-blend-mode: screen;
}

.ojousama-silhouette {
    background:
        radial-gradient(ellipse at 45% 35%, rgba(245, 208, 142, 0.6) 0%, transparent 55%),
        radial-gradient(ellipse at 55% 65%, rgba(196, 167, 215, 0.5) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 251, 245, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse at 35% 55%, rgba(245, 208, 142, 0.3) 0%, transparent 50%);
    background-blend-mode: screen;
}

.megane-silhouette {
    background:
        radial-gradient(ellipse at 45% 35%, rgba(157, 180, 212, 0.6) 0%, transparent 55%),
        radial-gradient(ellipse at 55% 65%, rgba(168, 224, 200, 0.5) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 251, 245, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse at 60% 40%, rgba(157, 180, 212, 0.3) 0%, transparent 50%);
    background-blend-mode: screen;
}

.kuudere-silhouette {
    background:
        radial-gradient(ellipse at 50% 40%, rgba(157, 180, 212, 0.6) 0%, transparent 55%),
        radial-gradient(ellipse at 40% 60%, rgba(240, 230, 246, 0.5) 0%, transparent 60%),
        radial-gradient(ellipse at 55% 50%, rgba(255, 251, 245, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse at 45% 30%, rgba(196, 167, 215, 0.3) 0%, transparent 50%);
    background-blend-mode: screen;
}

/* --- Vertical Kanji (on silhouette) --- */
.vertical-kanji {
    position: absolute;
    left: 15%;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-family: 'Noto Serif JP', serif;
    font-weight: 300;
    font-size: 3rem;
    color: #3d3346;
    opacity: 0.15;
    writing-mode: vertical-rl;
    pointer-events: none;
}

/* --- Center Area --- */
.center-area {
    flex: 0 0 34%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 3;
}

.archetype-title {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 12rem);
    color: #3d3346;
    line-height: 1;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: scale(0.9);
    transition: none;
}

.archetype-title.animate-in {
    animation: title-spring 600ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes title-spring {
    0% { opacity: 0; transform: scale(0.85) translateY(20px); }
    60% { opacity: 1; transform: scale(1.03) translateY(-3px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.description-card {
    background: rgba(255, 251, 245, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 1.8rem 2.2rem;
    max-width: 420px;
    border: 1px solid rgba(196, 167, 215, 0.2);
    opacity: 0;
    transform: translateY(15px);
    transition: none;
}

.description-card.animate-in {
    animation: card-fade-in 500ms 200ms ease-out forwards;
}

@keyframes card-fade-in {
    0% { opacity: 0; transform: translateY(15px); }
    100% { opacity: 1; transform: translateY(0); }
}

.description-card p {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.8;
    letter-spacing: 0.02em;
    color: #3d3346;
}

/* --- Traits Area (Right Third) --- */
.traits-area {
    flex: 0 0 30%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.trait-orbit {
    position: absolute;
    width: 0;
    height: 0;
    top: 50%;
    left: 50%;
    animation: orbit-spin var(--orbit-speed, 20s) linear infinite;
    animation-delay: var(--orbit-delay, 0s);
}

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

.trait-bubble {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%) translateX(var(--orbit-radius, 100px)) rotate(0deg);
    background: rgba(255, 251, 245, 0.7);
    border: 1px solid var(--bubble-border, #c4a7d7);
    border-radius: 50px;
    padding: 8px 18px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    color: #3d3346;
    white-space: nowrap;
    cursor: default;
    transition: transform 200ms ease-out, border-color 200ms ease-out;
    opacity: 0;
    /* Counter-rotate to keep text upright */
    animation: counter-orbit var(--orbit-speed, 20s) linear infinite;
    animation-delay: var(--orbit-delay, 0s);
}

.trait-bubble.animate-in {
    animation: bubble-appear 400ms ease-out forwards, counter-orbit var(--orbit-speed, 20s) linear infinite;
    animation-delay: var(--bubble-stagger, 0s), var(--orbit-delay, 0s);
}

@keyframes bubble-appear {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes counter-orbit {
    0% { transform: translate(-50%, -50%) translateX(var(--orbit-radius, 100px)) rotate(0deg); }
    100% { transform: translate(-50%, -50%) translateX(var(--orbit-radius, 100px)) rotate(-360deg); }
}

.trait-bubble:hover {
    transform: translate(-50%, -50%) translateX(var(--orbit-radius, 100px)) scale(1.15);
    border-color: #f2a5b7;
}

/* Set bubble border colors from data attributes */
[data-color="#f2a5b7"] { --bubble-border: #f2a5b7; }
[data-color="#f5d08e"] { --bubble-border: #f5d08e; }
[data-color="#9db4d4"] { --bubble-border: #9db4d4; }
[data-color="#a8e0c8"] { --bubble-border: #a8e0c8; }
[data-color="#c4a7d7"] { --bubble-border: #c4a7d7; }
[data-color="#f0e6f6"] { --bubble-border: #c4a7d7; }

.orbit-center-motif {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.5;
}

/* --- Final Room --- */
.final-room {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.final-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: #3d3346;
    opacity: 0;
    transition: opacity 800ms ease-out;
}

.final-text.animate-in {
    opacity: 0.7;
}

/* --- Navigation Ribbon --- */
#ribbon-nav {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    z-index: 100;
    background: rgba(255, 251, 245, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 50px;
    padding: 6px 10px;
    border: 1px solid rgba(196, 167, 215, 0.2);
}

.nav-tab {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    color: #3d3346;
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 200ms ease-out, box-shadow 200ms ease-out, background 200ms ease-out;
    letter-spacing: 0.02em;
}

.nav-tab:hover {
    transform: translateY(-3px);
    animation: tab-bounce 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes tab-bounce {
    0% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
    70% { transform: translateY(-2px); }
    100% { transform: translateY(-3px); }
}

.nav-tab.active {
    background: rgba(255, 251, 245, 0.8);
    box-shadow:
        0 0 12px rgba(196, 167, 215, 0.3),
        0 0 24px rgba(196, 167, 215, 0.15);
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(196, 167, 215, 0.3), 0 0 24px rgba(196, 167, 215, 0.15); }
    50% { box-shadow: 0 0 18px rgba(196, 167, 215, 0.5), 0 0 36px rgba(196, 167, 215, 0.25); }
}

/* --- Room Transition Effects --- */
.archetype-room {
    transition: filter 400ms ease-out, opacity 400ms ease-out;
}

.archetype-room.blur-out {
    filter: blur(8px);
    opacity: 0.3;
}

.archetype-room.focus-in {
    animation: room-focus-in 500ms ease-out forwards;
}

@keyframes room-focus-in {
    0% { filter: blur(8px); transform: scale(0.95); opacity: 0.5; }
    100% { filter: blur(0px); transform: scale(1); opacity: 1; }
}

/* --- Ribbon Connectors between rooms (decorative) --- */
.archetype-room::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 2px;
    height: 40%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 300ms ease-out;
}

[data-archetype="genki"]::after {
    background: linear-gradient(to bottom, transparent, #f2a5b7, transparent);
}

[data-archetype="tsundere"]::after {
    background: linear-gradient(to bottom, transparent, #f5d08e, transparent);
}

[data-archetype="yandere"]::after {
    background: linear-gradient(to bottom, transparent, #c4a7d7, transparent);
}

[data-archetype="ojousama"]::after {
    background: linear-gradient(to bottom, transparent, #c4a7d7, transparent);
}

[data-archetype="megane"]::after {
    background: linear-gradient(to bottom, transparent, #9db4d4, transparent);
}

[data-archetype="kuudere"]::after {
    background: linear-gradient(to bottom, transparent, #f0e6f6, transparent);
}

.archetype-room.ribbon-visible::after {
    opacity: 0.4;
}

/* --- Responsive adjustments --- */
@media (max-width: 900px) {
    .room-content {
        flex-direction: column;
        padding: 10% 5%;
        gap: 1rem;
    }

    .silhouette-area {
        flex: 0 0 auto;
        height: 25vh;
        width: 100%;
    }

    .center-area {
        flex: 0 0 auto;
    }

    .traits-area {
        flex: 0 0 auto;
        height: 25vh;
        width: 100%;
    }

    .archetype-title {
        font-size: clamp(2.5rem, 8vw, 5rem);
    }

    .gradient-silhouette {
        width: 40%;
        height: 100%;
    }

    .kanji-waterfall {
        width: 100%;
    }

    .nav-tab {
        font-size: 0.7rem;
        padding: 6px 10px;
    }

    #ribbon-nav {
        bottom: 12px;
        gap: 2px;
        padding: 4px 8px;
    }

    .vertical-kanji {
        font-size: 2rem;
    }
}

@media (max-width: 600px) {
    .description-card {
        padding: 1.2rem 1.4rem;
    }

    .description-card p {
        font-size: 0.9rem;
    }

    .nav-tab {
        font-size: 0.65rem;
        padding: 5px 8px;
    }

    .trait-orbit {
        display: none;
    }

    .orbit-center-motif {
        display: none;
    }

    .traits-area {
        display: none;
    }

    .room-content {
        gap: 0.5rem;
    }
}
