@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@700&family=M+PLUS+Rounded+1c:wght@500&family=Nunito:wght@400&family=Shippori+Mincho:wght@400&display=swap');

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sakura: #FFB7C5;
    --lavender: #C8A2E8;
    --cyan: #A8E6E2;
    --cream: #FFF5EB;
    --gold: #F5C76B;
    --plum: #2D1B3D;
    --coral: #FF8FA4;
    --midnight: #1A0E2E;
}

body {
    background-color: var(--cream);
    color: var(--plum);
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.75;
    overflow-x: hidden;
}

/* ============================================
   SPARKLE FIELD
   ============================================ */
#sparkle-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    background: var(--gold);
    transform: rotate(45deg);
    animation: sparkleFloat ease-in-out infinite;
}

@keyframes sparkleFloat {
    0%, 100% {
        opacity: 0;
        transform: rotate(45deg) translateY(0) translateX(0);
    }
    20% {
        opacity: var(--sparkle-opacity, 0.2);
    }
    50% {
        opacity: var(--sparkle-opacity, 0.2);
        transform: rotate(45deg) translateY(-40px) translateX(20px);
    }
    80% {
        opacity: var(--sparkle-opacity, 0.2);
    }
}

/* ============================================
   HERO ZONE
   ============================================ */
#hero {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--cream) 0%, rgba(200, 162, 232, 0.05) 50%, var(--cream) 100%);
}

.hero-cartouche {
    text-align: center;
    z-index: 10;
    position: relative;
}

.hero-cartouche-border {
    position: relative;
    padding: 2.5rem 3.5rem;
    border: 1px solid rgba(200, 162, 232, 0.3);
    border-radius: 20px;
    background: rgba(255, 245, 235, 0.7);
}

.cartouche-ornament {
    position: absolute;
}
.cartouche-ornament-tl { top: -4px; left: -4px; }
.cartouche-ornament-tr { top: -4px; right: -4px; }
.cartouche-ornament-bl { bottom: -4px; left: -4px; }
.cartouche-ornament-br { bottom: -4px; right: -4px; }

.hero-title {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    letter-spacing: 0.03em;
    color: var(--plum);
    min-height: 1.3em;
}

.hero-epithet {
    font-family: 'Shippori Mincho', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: var(--lavender);
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.hero-epithet.visible {
    opacity: 1;
}

/* Hero Silhouettes */
.hero-silhouettes {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.hero-silhouette {
    position: absolute;
    bottom: 8%;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hero-silhouette.visible {
    opacity: 1;
    transform: translateY(0);
}

.silhouette-anima {
    left: 8%;
}

.silhouette-shadow {
    right: 8%;
}

/* ============================================
   DIALOGUE BOX
   ============================================ */
.dialogue-section {
    padding: 60px 20px;
    display: flex;
    justify-content: center;
}

.dialogue-box {
    max-width: 600px;
    background: rgba(255, 245, 235, 0.95);
    border: 1px solid var(--sakura);
    border-radius: 16px;
    padding: 32px 40px;
    position: relative;
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.5s ease, transform 0.5s ease-out;
}

.dialogue-box.visible {
    opacity: 1;
    transform: translateX(0);
}

.dialogue-box::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid var(--sakura);
}

.dialogue-box p {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--plum);
}

.dialogue-box em {
    font-style: italic;
    color: var(--lavender);
}

/* ============================================
   GALLERY
   ============================================ */
#archetype-gallery {
    padding: 40px 20px 60px;
}

.gallery-title {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 500;
    font-size: clamp(1rem, 2vw, 1.4rem);
    letter-spacing: 0.05em;
    text-align: center;
    color: var(--lavender);
    margin-bottom: 40px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, min(280px, 80vw));
    gap: 24px;
    justify-content: center;
}

/* ============================================
   ARCHETYPE CARD
   ============================================ */
.archetype-card {
    aspect-ratio: 2 / 3;
    perspective: 1000px;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.archetype-card.visible {
    opacity: 1;
    transform: scale(1);
}

.archetype-card:not(.flipped):hover {
    transform: translateY(-8px) scale(1);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
}

.archetype-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
}

.card-front {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(180deg, var(--cream) 0%, rgba(255, 245, 235, 0.95) 100%);
    border: 1px solid rgba(200, 162, 232, 0.3);
    box-shadow: 0 8px 32px rgba(180, 130, 200, 0.2);
    transition: box-shadow 0.3s ease, border-color 0.3s ease, border-width 0.3s ease;
}

.archetype-card:not(.flipped):hover .card-front {
    box-shadow: 0 16px 48px rgba(180, 130, 200, 0.35);
    border-color: var(--sakura);
    border-width: 2px;
}

.archetype-card:not(.flipped):hover .card-silhouette svg path {
    opacity: 1;
}

.card-back {
    background: var(--midnight);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transform: rotateY(180deg);
    border: 1px solid rgba(200, 162, 232, 0.2);
}

.card-back-border {
    position: relative;
    padding: 20px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(200, 162, 232, 0.15);
    border-radius: 8px;
}

.card-description {
    font-family: 'Shippori Mincho', serif;
    font-weight: 400;
    font-size: 0.95rem;
    line-height: 1.7;
    letter-spacing: 0.04em;
    color: var(--cream);
}

/* Card ornaments */
.card-ornament {
    position: absolute;
    z-index: 5;
}
.card-ornament-tl { top: 8px; left: 8px; }
.card-ornament-tr { top: 8px; right: 8px; }
.card-ornament-bl { bottom: 8px; left: 8px; }
.card-ornament-br { bottom: 8px; right: 8px; }

.card-top-arc {
    margin-bottom: 12px;
}

.card-silhouette {
    margin-bottom: 16px;
    transition: opacity 0.3s ease;
}

.card-silhouette svg path {
    transition: opacity 0.3s ease;
}

.card-name {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    letter-spacing: 0.03em;
    color: var(--plum);
    margin-bottom: 6px;
    text-align: center;
}

.card-epithet {
    font-family: 'Shippori Mincho', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--lavender);
    text-align: center;
}

.card-bottom-moon {
    font-size: 1rem;
    color: var(--lavender);
    opacity: 0.4;
    margin-top: 14px;
}

/* Card aura per archetype */
.archetype-card[data-archetype="shadow"] .card-front {
    box-shadow: 0 8px 32px rgba(200, 162, 232, 0.25);
}
.archetype-card[data-archetype="anima"] .card-front {
    box-shadow: 0 8px 32px rgba(255, 183, 197, 0.25);
}
.archetype-card[data-archetype="trickster"] .card-front {
    box-shadow: 0 8px 32px rgba(245, 199, 107, 0.25);
}
.archetype-card[data-archetype="sage"] .card-front {
    box-shadow: 0 8px 32px rgba(168, 230, 226, 0.25);
}
.archetype-card[data-archetype="hero"] .card-front {
    box-shadow: 0 8px 32px rgba(255, 143, 164, 0.25);
}

/* ============================================
   FOOTER SHRINE
   ============================================ */
#footer-shrine {
    background: var(--midnight);
    padding: 80px 20px;
    text-align: center;
}

.shrine-inner {
    max-width: 400px;
    margin: 0 auto;
}

.shrine-icons {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
}

.shrine-icon {
    font-size: 1.4rem;
    opacity: 0.6;
}

.shrine-title {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--cream);
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.shrine-subtitle {
    font-family: 'Shippori Mincho', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--lavender);
    letter-spacing: 0.04em;
    opacity: 0.6;
}

/* ============================================
   INTERACTIVE LINKS
   ============================================ */
a {
    color: var(--coral);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--sakura);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 940px) {
    .card-grid {
        grid-template-columns: repeat(2, min(280px, 80vw));
    }
}

@media (max-width: 620px) {
    .card-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
        margin: 0 auto;
    }
    .hero-silhouette {
        bottom: 5%;
    }
    .silhouette-anima { left: 2%; }
    .silhouette-shadow { right: 2%; }
    .hero-cartouche-border {
        padding: 1.5rem 2rem;
    }
    .dialogue-box {
        padding: 24px 28px;
    }
}
