/* hangul.name - Memphis meets Sejong */
/* Colors: #F5C542 Gold, #F2735A Coral, #E8467C Pink, #2AABB3 Teal, #1A1E2C Dark, #FDF6EC Cream, #2B2D33 Text, #1B6CA8 Blue */

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

:root {
    --gold: #F5C542;
    --coral: #F2735A;
    --pink: #E8467C;
    --teal: #2AABB3;
    --dark: #1A1E2C;
    --cream: #FDF6EC;
    --text: #2B2D33;
    --blue: #1B6CA8;
    --siot-stroke: #B8960F;
}

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
    font-size: 16px;
}

body {
    font-family: 'Work Sans', sans-serif;
    color: var(--text);
    background: var(--cream);
    overflow-x: hidden;
    line-height: 1.6;
}

/* ======================== LOADING OVERLAY ======================== */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}
#loading-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
#loading-svg {
    margin-bottom: 1.5rem;
}
#hieut-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: drawHieut 1.2s ease-out forwards;
}
@keyframes drawHieut {
    to { stroke-dashoffset: 0; }
}
#loading-hangul {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: 3rem;
    color: var(--cream);
    opacity: 0;
    animation: fadeInHangul 0.6s ease 0.8s forwards;
}
.loading-char {
    display: inline-block;
    animation: charPop 0.3s ease forwards;
    opacity: 0;
}
.loading-char:nth-child(1) { animation-delay: 1s; }
.loading-char:nth-child(2) { animation-delay: 1.2s; }
@keyframes charPop {
    0% { opacity: 0; transform: scale(0.5) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes fadeInHangul {
    to { opacity: 1; }
}
#loading-domain {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--gold);
    opacity: 0;
    animation: fadeInHangul 0.5s ease 1.5s forwards;
    letter-spacing: 0.05em;
}

/* ======================== NAVIGATION ======================== */
#section-nav {
    position: fixed;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.nav-dot {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--cream);
    border: 3px solid var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    cursor: pointer;
}
.nav-dot:hover, .nav-dot.active {
    transform: scale(1.2);
    border-color: var(--teal);
    background: var(--teal);
}
.nav-dot:hover .nav-jamo, .nav-dot.active .nav-jamo {
    color: var(--cream);
}
.nav-dot::before {
    content: attr(data-label);
    position: absolute;
    right: 60px;
    white-space: nowrap;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
    background: var(--cream);
    padding: 4px 10px;
    border-radius: 4px;
    border: 2px solid var(--text);
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.25s ease;
    pointer-events: none;
}
.nav-dot:hover::before {
    opacity: 1;
    transform: translateX(0);
}
.nav-jamo {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: 1.1rem;
    color: var(--text);
    transition: color 0.3s ease;
}

/* ======================== FLOWING CURVE ======================== */
#flowing-curve {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.3;
}
#flow-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.05s linear;
}

/* ======================== PARALLAX SECTIONS ======================== */
.parallax-section {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    scroll-snap-align: start;
}
.parallax-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.parallax-mid {
    position: absolute;
    inset: 0;
    z-index: 1;
}
.parallax-fg {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

/* ======================== TERRAZZO FIELD ======================== */
.terrazzo-field {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
.terrazzo-dot {
    position: absolute;
    border-radius: 50%;
    opacity: 0.4;
}

/* ======================== OPENING SECTION ======================== */
.opening-section {
    background: var(--cream);
}
.opening-content {
    width: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    min-height: 100vh;
    padding-bottom: 8vh;
}
.opening-title-block {
    position: relative;
    z-index: 5;
    background: var(--gold);
    padding: 2rem 3rem;
    clip-path: polygon(0 0, 100% 3%, 98% 100%, 2% 97%);
}
.site-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 7vw, 5.5rem);
    color: var(--dark);
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.title-dot {
    color: var(--coral);
}
.site-subtitle {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--dark);
    margin-top: 0.5rem;
}
.site-tagline {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: var(--text);
    margin-top: 0.25rem;
}

/* Scroll hint */
.scroll-hint {
    margin-top: 3rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0.6;
    animation: pulseHint 2s ease-in-out infinite;
}
@keyframes pulseHint {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 0.8; transform: translateY(5px); }
}
.scroll-arrow {
    width: 20px;
    height: 20px;
    border-right: 2px solid var(--text);
    border-bottom: 2px solid var(--text);
    transform: rotate(45deg);
}
.scroll-text {
    font-family: 'Work Sans', sans-serif;
    font-size: 0.85rem;
    color: var(--text);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Memphis decorative shapes */
.memphis-shape {
    position: absolute;
    z-index: 3;
    pointer-events: none;
}
.memphis-zigzag {
    top: 15%;
    right: 10%;
    width: 120px;
    height: 40px;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px,
        transparent 10px,
        var(--coral) 10px,
        var(--coral) 12px
    );
    clip-path: polygon(0% 50%, 10% 0%, 20% 50%, 30% 0%, 40% 50%, 50% 0%, 60% 50%, 70% 0%, 80% 50%, 90% 0%, 100% 50%, 90% 100%, 80% 50%, 70% 100%, 60% 50%, 50% 100%, 40% 50%, 30% 100%, 20% 50%, 10% 100%);
    animation: floatMemphis 6s ease-in-out infinite;
}
.memphis-circle-deco {
    bottom: 25%;
    right: 20%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 6px solid var(--pink);
    animation: floatMemphis 5s ease-in-out infinite 1s;
}
.memphis-triangle-deco {
    top: 30%;
    left: 15%;
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 52px solid var(--teal);
    opacity: 0.6;
    animation: floatMemphis 7s ease-in-out infinite 0.5s;
}
@keyframes floatMemphis {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(3deg); }
}

/* Floating Jamo Field */
.floating-jamo-field {
    position: absolute;
    inset: 0;
}
.floating-jamo-char {
    position: absolute;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    opacity: 0.15;
    user-select: none;
    animation: bobJamo var(--bob-duration, 5s) ease-in-out infinite;
    animation-delay: var(--bob-delay, 0s);
}
@keyframes bobJamo {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(var(--bob-amount, -12px)); }
}

/* ======================== CONSONANT SECTIONS ======================== */
.consonant-section {
    background: var(--cream);
    transition: background-color 0.5s ease;
}
#section-giyeok { background: linear-gradient(135deg, #e8f2fa 0%, var(--cream) 60%); }
#section-nieun { background: linear-gradient(135deg, #e4f5f6 0%, var(--cream) 60%); }
#section-mieum { background: linear-gradient(135deg, #fde8e3 0%, var(--cream) 60%); }
#section-siot { background: linear-gradient(135deg, #fdf3d7 0%, var(--cream) 60%); }
#section-ieung { background: linear-gradient(135deg, #f8e0eb 0%, var(--cream) 60%); }

.section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 3rem;
    min-height: 100vh;
    align-content: center;
}
.jamo-display-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}
.jamo-large {
    position: relative;
    width: clamp(200px, 30vw, 350px);
    height: clamp(200px, 30vw, 350px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.jamo-large:hover {
    transform: scale(1.15) rotate(-3deg);
}
.jamo-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.jamo-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: clamp(8rem, 20vw, 16rem);
    opacity: 0.08;
    position: absolute;
    pointer-events: none;
}
.related-jamo {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}
.mini-jamo {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: 2.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 0.5rem;
    border-radius: 8px;
}
#section-giyeok .mini-jamo { color: var(--blue); }
#section-nieun .mini-jamo { color: var(--teal); }
#section-mieum .mini-jamo { color: var(--coral); }
#section-siot .mini-jamo { color: var(--siot-stroke); }
#section-ieung .mini-jamo { color: var(--pink); }

.mini-jamo:hover {
    transform: scale(1.15) rotate(3deg);
    background: rgba(0,0,0,0.05);
}
.section-text-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem;
}
.section-label {
    font-family: 'Bungee', cursive;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}
#section-giyeok .section-label { color: var(--blue); }
#section-nieun .section-label { color: var(--teal); }
#section-mieum .section-label { color: var(--coral); }
#section-siot .section-label { color: var(--siot-stroke); }
#section-ieung .section-label { color: var(--pink); }

.section-title {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4.236rem);
    line-height: 1.15;
    margin-bottom: 0.25rem;
}
#section-giyeok .section-title { color: var(--blue); }
#section-nieun .section-title { color: var(--teal); }
#section-mieum .section-title { color: var(--coral); }
#section-siot .section-title { color: var(--siot-stroke); }
#section-ieung .section-title { color: var(--pink); }

.section-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 2.5vw, 1.618rem);
    color: var(--text);
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}
.section-body {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--text);
    margin-bottom: 1rem;
    max-width: 540px;
    line-height: 1.7;
}
.section-body span[lang="ko"] {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
}
.organ-illustration {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
}
.organ-svg {
    width: clamp(150px, 20vw, 250px);
    height: auto;
}

/* Section zigzag borders */
.section-zigzag-border {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    z-index: 5;
}
#section-giyeok .section-zigzag-border {
    background: linear-gradient(135deg, var(--blue) 25%, transparent 25%) -14px 0,
                linear-gradient(225deg, var(--blue) 25%, transparent 25%) -14px 0,
                linear-gradient(315deg, var(--blue) 25%, transparent 25%),
                linear-gradient(45deg, var(--blue) 25%, transparent 25%);
    background-size: 28px 20px;
    opacity: 0.3;
}
#section-nieun .section-zigzag-border {
    background: linear-gradient(135deg, var(--teal) 25%, transparent 25%) -14px 0,
                linear-gradient(225deg, var(--teal) 25%, transparent 25%) -14px 0,
                linear-gradient(315deg, var(--teal) 25%, transparent 25%),
                linear-gradient(45deg, var(--teal) 25%, transparent 25%);
    background-size: 28px 20px;
    opacity: 0.3;
}
#section-mieum .section-zigzag-border {
    background: linear-gradient(135deg, var(--coral) 25%, transparent 25%) -14px 0,
                linear-gradient(225deg, var(--coral) 25%, transparent 25%) -14px 0,
                linear-gradient(315deg, var(--coral) 25%, transparent 25%),
                linear-gradient(45deg, var(--coral) 25%, transparent 25%);
    background-size: 28px 20px;
    opacity: 0.3;
}
#section-siot .section-zigzag-border {
    background: linear-gradient(135deg, var(--gold) 25%, transparent 25%) -14px 0,
                linear-gradient(225deg, var(--gold) 25%, transparent 25%) -14px 0,
                linear-gradient(315deg, var(--gold) 25%, transparent 25%),
                linear-gradient(45deg, var(--gold) 25%, transparent 25%);
    background-size: 28px 20px;
    opacity: 0.3;
}

/* Confetti layer */
.confetti-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    opacity: 0.5;
    animation: confettiFloat var(--confetti-dur, 8s) ease-in-out infinite;
    animation-delay: var(--confetti-delay, 0s);
}
.confetti-piece.circle { border-radius: 50%; }
.confetti-piece.triangle {
    width: 0 !important;
    height: 0 !important;
    border-left: var(--tri-size, 8px) solid transparent;
    border-right: var(--tri-size, 8px) solid transparent;
    border-bottom: calc(var(--tri-size, 8px) * 1.7) solid var(--confetti-color, var(--gold));
    background: none !important;
}
.confetti-piece.square { border-radius: 2px; }
@keyframes confettiFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-20px) rotate(90deg); }
    50% { transform: translateY(10px) rotate(180deg); }
    75% { transform: translateY(-10px) rotate(270deg); }
}

/* Background shapes per section */
.section-bg-shape {
    position: absolute;
    opacity: 0.06;
    pointer-events: none;
}
.giyeok-bg-shape {
    right: -5%;
    top: 10%;
    width: 50vw;
    height: 50vw;
    border-top: 20vw solid var(--blue);
    border-right: 20vw solid var(--blue);
}
.nieun-bg-shape {
    left: -5%;
    bottom: 10%;
    width: 40vw;
    height: 40vw;
    border-bottom: 15vw solid var(--teal);
    border-left: 15vw solid var(--teal);
}
.mieum-bg-shape {
    right: 5%;
    top: 15%;
    width: 35vw;
    height: 35vw;
    border: 12vw solid var(--coral);
}
.siot-bg-shape {
    left: 10%;
    top: 10%;
    width: 0;
    height: 0;
    border-left: 20vw solid transparent;
    border-right: 20vw solid transparent;
    border-bottom: 35vw solid var(--gold);
}
.ieung-bg-shape {
    right: 0;
    top: 5%;
    width: 40vw;
    height: 40vw;
    border-radius: 50%;
    border: 12vw solid var(--pink);
}

/* ======================== CLOSING SECTION ======================== */
.closing-section {
    background: var(--dark);
    color: var(--cream);
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}
.closing-content {
    max-width: 700px;
}
.closing-quote {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--cream);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}
.closing-translation {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: var(--gold);
    margin-bottom: 0.5rem;
    font-style: italic;
}
.closing-attribution {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: 0.9rem;
    color: rgba(253, 246, 236, 0.5);
    margin-bottom: 3rem;
}
.closing-jamo-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}
.closing-jamo-grid span {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    font-size: 1.5rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
}
.closing-jamo-grid span:nth-child(5n+1) { color: var(--blue); border: 2px solid var(--blue); }
.closing-jamo-grid span:nth-child(5n+2) { color: var(--teal); border: 2px solid var(--teal); }
.closing-jamo-grid span:nth-child(5n+3) { color: var(--coral); border: 2px solid var(--coral); }
.closing-jamo-grid span:nth-child(5n+4) { color: var(--gold); border: 2px solid var(--gold); }
.closing-jamo-grid span:nth-child(5n+5) { color: var(--pink); border: 2px solid var(--pink); }
.closing-jamo-grid span:hover {
    transform: scale(1.15) rotate(-3deg);
}
.closing-domain {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--cream);
    letter-spacing: 0.05em;
    opacity: 0.6;
}

/* ======================== TOOLTIP ======================== */
.jamo-tooltip {
    position: fixed;
    z-index: 9999;
    background: var(--cream);
    border: 3px solid var(--text);
    padding: 1rem 1.25rem;
    border-radius: 4px;
    pointer-events: none;
    max-width: 280px;
    box-shadow: 6px 6px 0 var(--text);
    transform: translate(-50%, -110%);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.jamo-tooltip.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -100%);
}
.tooltip-name {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}
.tooltip-sound {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--teal);
    margin-bottom: 0.25rem;
}
.tooltip-origin {
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text);
    opacity: 0.7;
    line-height: 1.4;
}

/* ======================== CONFETTI BURST ======================== */
.confetti-burst {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
}
.burst-particle {
    position: absolute;
    border-radius: 50%;
    animation: burstOut 0.6s ease-out forwards;
}
@keyframes burstOut {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--bx), var(--by)) scale(0); opacity: 0; }
}

/* ======================== SECTION ANIMATIONS ======================== */
.section-grid {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}
.section-grid.visible {
    opacity: 1;
    transform: translateY(0);
}
.jamo-display-area {
    transform: translateX(-30px);
    opacity: 0;
    transition: all 0.6s ease 0.2s;
}
.visible .jamo-display-area {
    transform: translateX(0);
    opacity: 1;
}
.section-text-area {
    transform: translateX(30px);
    opacity: 0;
    transition: all 0.6s ease 0.3s;
}
.visible .section-text-area {
    transform: translateX(0);
    opacity: 1;
}
.organ-illustration {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease 0.5s;
}
.visible .organ-illustration {
    opacity: 1;
    transform: translateY(0);
}

/* ======================== RESPONSIVE ======================== */
@media (max-width: 768px) {
    .section-grid {
        grid-template-columns: 1fr;
        padding: 3rem 1.5rem;
    }
    .jamo-large {
        width: clamp(180px, 60vw, 280px);
        height: clamp(180px, 60vw, 280px);
    }
    #section-nav {
        right: 0.75rem;
    }
    .nav-dot {
        width: 36px;
        height: 36px;
    }
    .nav-jamo { font-size: 0.85rem; }
    .opening-title-block { padding: 1.5rem 2rem; }
    .memphis-zigzag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
