/* ============================================
   hwakryul.com -- Victorian-Ornate Probability
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Serif KR', serif;
    font-weight: 400;
    font-size: clamp(15px, 1.05vw, 17px);
    line-height: 1.85;
    color: #2A2018;
    background-color: #F0E4D8;
    overflow-x: hidden;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Abril Fatface', serif;
    font-weight: 400;
    line-height: 1.2;
}

.hero-korean {
    font-family: 'Black Han Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(60px, 20vw, 200px);
    color: #5A4030;
    line-height: 1;
    letter-spacing: 0.02em;
}

.hero-dotcom {
    font-family: 'Abril Fatface', serif;
    font-weight: 400;
    font-size: clamp(24px, 5vw, 60px);
    color: #8A6A4A;
    margin-top: -0.5em;
}

.hero-subtitle {
    font-family: 'Noto Serif KR', serif;
    font-size: clamp(14px, 1.2vw, 18px);
    color: #8A6A4A;
    margin-top: 1em;
    opacity: 0;
    animation: fadeInUp 600ms ease-out 1200ms forwards;
}

.section-heading {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(36px, 6vw, 72px);
    color: #5A4030;
    text-align: center;
    margin-bottom: 2rem;
    line-height: 1.3;
}

.section-heading span {
    display: block;
    font-family: 'Abril Fatface', serif;
    font-size: clamp(18px, 2.5vw, 32px);
    color: #8A6A4A;
    margin-top: 0.2em;
}

/* --- Hero Section --- */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: #F0E4D8;
    overflow: hidden;
}

.hero-pattern {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 50%, #8A6A4A 0.5px, transparent 0.5px),
        radial-gradient(circle at 80% 30%, #8A6A4A 0.3px, transparent 0.3px);
    background-size: 40px 40px, 60px 60px;
    opacity: 0.05;
    pointer-events: none;
}

.hero-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 5vw;
    gap: 2rem;
}

.hero-text {
    flex: 0 0 auto;
    position: relative;
    padding-top: 10vh;
}

.hero-korean {
    transform: scale(0.5);
    opacity: 0;
    animation: scaleIn 800ms ease-out forwards;
}

.hero-dotcom {
    transform: translateX(30px);
    opacity: 0;
    animation: slideInRight 400ms ease-out 800ms forwards;
    text-align: right;
}

.hero-illustration {
    flex: 1 1 50%;
    max-width: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bell-curve-svg {
    width: 100%;
    height: auto;
}

.bell-curve-main {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: drawCurve 1500ms ease-out 200ms forwards;
}

.curve-flourish {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    opacity: 0;
    animation: drawFlourish 600ms ease-out forwards;
}

.flourish-left {
    animation-delay: 1700ms;
}

.flourish-right {
    animation-delay: 1900ms;
}

.flourish-top {
    animation-delay: 2100ms;
}

.frame-ornaments .ornament-path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawOrnament 1000ms ease-out 500ms forwards;
}

.frame-ornaments .ornament-rosette {
    opacity: 0;
    animation: fadeIn 400ms ease-out 1500ms forwards;
}

.frame-ornaments .frame-border {
    stroke-dasharray: 1700;
    stroke-dashoffset: 1700;
    animation: drawFrame 2000ms ease-out 300ms forwards;
}

.frame-ornaments .frame-inner-border {
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
    animation: drawFrame 2000ms ease-out 500ms forwards;
}

.scroll-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    animation: fadeIn 600ms ease-out 2500ms forwards;
}

.scroll-hint span {
    font-family: 'Noto Serif KR', serif;
    font-size: 12px;
    color: #8A6A4A;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.scroll-hint svg {
    animation: bounceDown 1.5s ease-in-out infinite;
}

/* --- Concepts Section --- */
#concepts {
    padding: 6rem 5vw;
    max-width: 1400px;
    margin: 0 auto;
}

.concepts-grid {
    display: grid;
    grid-template-columns: 60% 35%;
    gap: 5%;
    align-items: start;
}

.concepts-left {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.concepts-right {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    margin-top: 40px;
}

.concept-card {
    background: rgba(240, 228, 216, 0.6);
    border: 1px solid rgba(138, 106, 74, 0.2);
    padding: 2rem;
    position: relative;
}

.concept-frame {
    margin-bottom: 1.5rem;
}

.concept-diagram {
    width: 100%;
    height: auto;
    max-height: 260px;
}

.concept-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(20px, 2.5vw, 28px);
    color: #5A4030;
    margin-bottom: 0.8rem;
    line-height: 1.4;
}

.concept-title span {
    display: block;
    font-family: 'Abril Fatface', serif;
    font-size: clamp(16px, 1.5vw, 20px);
    color: #8A6A4A;
}

.concept-text {
    color: #2A2018;
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.85;
}

/* --- Widget Cards --- */
.widget-card {
    background: #F0E4D8;
    border: 1.5px solid #8A6A4A;
    padding: 2rem;
    position: relative;
}

.widget-card::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 0.5px solid rgba(138, 106, 74, 0.3);
    pointer-events: none;
}

.widget-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(18px, 2vw, 24px);
    color: #5A4030;
    margin-bottom: 1.5rem;
    text-align: center;
    line-height: 1.4;
}

.widget-title span {
    display: block;
    font-family: 'Abril Fatface', serif;
    font-size: clamp(14px, 1.2vw, 18px);
    color: #8A6A4A;
}

.widget-body {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    align-items: center;
}

/* Coin Widget */
.coin-display {
    width: 80px;
    height: 80px;
    perspective: 600px;
    margin: 0 auto;
}

.coin {
    width: 80px;
    height: 80px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 600ms ease-out;
}

.coin-face {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Abril Fatface', serif;
    font-size: 28px;
    backface-visibility: hidden;
    border: 2px solid #8A6A4A;
}

.coin-heads {
    background: linear-gradient(135deg, #C4A060, #8A6A4A);
    color: #F0E4D8;
}

.coin-tails {
    background: linear-gradient(135deg, #5A4030, #8A6A4A);
    color: #F0E4D8;
    transform: rotateY(180deg);
}

.coin.flip-heads {
    transform: rotateY(720deg);
}

.coin.flip-tails {
    transform: rotateY(900deg);
}

/* Dice Widget */
.dice-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.dice {
    width: 48px;
    height: 48px;
    border: 1.5px solid #8A6A4A;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Abril Fatface', serif;
    font-size: 22px;
    color: #5A4030;
    background: #F0E4D8;
    transition: transform 300ms ease;
}

.dice-plus, .dice-equals {
    font-family: 'Abril Fatface', serif;
    font-size: 18px;
    color: #8A6A4A;
}

.dice-sum {
    font-family: 'Abril Fatface', serif;
    font-size: 26px;
    color: #408080;
    min-width: 36px;
    text-align: center;
    position: relative;
}

/* Widget Controls */
.widget-controls {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-flip {
    font-family: 'Abril Fatface', serif;
    font-size: 14px;
    padding: 0.6em 1.6em;
    background: #5A4030;
    color: #F0E4D8;
    border: 1px solid #8A6A4A;
    cursor: pointer;
    transition: all 300ms ease;
    letter-spacing: 0.05em;
}

.btn-flip:hover {
    background: #8A6A4A;
    color: #F0E4D8;
}

.btn-flip.btn-secondary {
    background: transparent;
    color: #5A4030;
    border: 1px solid #8A6A4A;
}

.btn-flip.btn-secondary:hover {
    background: rgba(138, 106, 74, 0.1);
}

/* Widget Results */
.widget-results {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.result-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #8A6A4A;
}

.result-value {
    font-family: 'Abril Fatface', serif;
    font-size: 22px;
    color: #5A4030;
    position: relative;
}

.result-teal {
    color: #408080;
}

/* Histogram */
.dice-histogram {
    width: 100%;
    padding: 0.5rem 0;
}

.histogram-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 100px;
    gap: 3px;
    padding: 0 0.5rem;
}

.hist-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
    justify-content: flex-end;
}

.hist-bar {
    width: 100%;
    min-height: 2px;
    background: #408080;
    transition: height 300ms ease;
    border-radius: 1px 1px 0 0;
}

.hist-bar-wrapper span {
    font-size: 10px;
    color: #8A6A4A;
    margin-top: 4px;
    font-family: 'Noto Serif KR', serif;
}

/* --- Quiz Section --- */
#quiz {
    position: relative;
    padding: 6rem 5vw;
    background-color: #F0E4D8;
    overflow: hidden;
}

.quiz-pattern {
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 40px,
            rgba(138, 106, 74, 0.03) 40px,
            rgba(138, 106, 74, 0.03) 41px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 40px,
            rgba(138, 106, 74, 0.03) 40px,
            rgba(138, 106, 74, 0.03) 41px
        );
    opacity: 0.08;
    pointer-events: none;
}

.quiz-content {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
}

.quiz-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.quiz-card {
    position: relative;
    background: #F0E4D8;
    padding: 2rem;
    border: 1.5px solid #8A6A4A;
    transition: transform 300ms ease, box-shadow 300ms ease;
    cursor: default;
}

.quiz-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 24px rgba(90, 64, 48, 0.1);
}

.quiz-card:hover .card-border-svg path,
.quiz-card:hover .card-border-svg line,
.quiz-card:hover .card-border-svg rect:first-child {
    stroke: #C4A060;
    transition: stroke 300ms ease;
}

.card-ornament {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.card-border-svg {
    width: 100%;
    height: 100%;
}

.card-border-svg path,
.card-border-svg line,
.card-border-svg rect,
.card-border-svg circle,
.card-border-svg polygon {
    transition: stroke 300ms ease;
}

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

.card-question {
    font-family: 'Noto Serif KR', serif;
    font-size: clamp(14px, 1vw, 16px);
    color: #2A2018;
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.card-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.quiz-option {
    font-family: 'Noto Serif KR', serif;
    font-size: 14px;
    padding: 0.7em 1.2em;
    background: transparent;
    border: 1px solid rgba(138, 106, 74, 0.4);
    color: #2A2018;
    cursor: pointer;
    text-align: left;
    transition: all 300ms ease;
    position: relative;
    overflow: hidden;
}

.quiz-option:hover {
    border-color: #8A6A4A;
    background: rgba(138, 106, 74, 0.05);
}

.quiz-option.correct {
    border-color: #C4A060;
    background: rgba(196, 160, 96, 0.1);
    box-shadow: 0 0 15px rgba(196, 160, 96, 0.3);
}

.quiz-option.incorrect {
    border-color: #C07070;
    background: rgba(192, 112, 112, 0.05);
    animation: shake 200ms ease;
}

.quiz-option.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.card-explanation {
    font-family: 'Noto Serif KR', serif;
    font-size: 13px;
    color: #8A6A4A;
    line-height: 1.7;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 400ms ease, max-height 400ms ease;
}

.card-explanation.visible {
    opacity: 1;
    max-height: 200px;
}

/* --- Applications Section --- */
#applications {
    padding: 6rem 5vw;
    max-width: 1400px;
    margin: 0 auto;
}

.app-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 3rem;
}

.app-card {
    background: #F0E4D8;
    border: 1px solid rgba(138, 106, 74, 0.3);
    padding: 2.5rem;
    position: relative;
    transition: transform 300ms ease, box-shadow 300ms ease;
}

.app-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(90, 64, 48, 0.08);
}

.app-card-large {
    grid-row: span 2;
}

.app-card-small {
    padding: 1.8rem;
}

.app-icon {
    margin-bottom: 1.2rem;
}

.app-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(18px, 2vw, 24px);
    color: #5A4030;
    margin-bottom: 0.8rem;
    line-height: 1.4;
}

.app-title span {
    display: block;
    font-family: 'Abril Fatface', serif;
    font-size: clamp(14px, 1.2vw, 18px);
    color: #8A6A4A;
}

.app-text {
    font-size: clamp(13px, 0.95vw, 15px);
    color: #2A2018;
    line-height: 1.85;
}

/* --- Footer --- */
#footer {
    background: #2A2018;
    color: #F0E4D8;
    padding: 0;
    margin-top: 4rem;
}

.footer-ornament {
    overflow: hidden;
    height: 20px;
    background: #F0E4D8;
}

.footer-border-svg {
    width: 100%;
    height: 20px;
    display: block;
}

.footer-content {
    padding: 3rem 5vw;
    text-align: center;
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.footer-link {
    font-family: 'Abril Fatface', serif;
    font-size: 14px;
    color: #C4A060;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-variant: small-caps;
    transition: color 300ms ease;
}

.footer-link:hover {
    color: #F0E4D8;
}

.footer-tagline {
    font-family: 'Noto Serif KR', serif;
    font-size: 14px;
    color: rgba(240, 228, 216, 0.6);
    margin-bottom: 0.5rem;
}

.footer-copy {
    font-family: 'Abril Fatface', serif;
    font-size: 12px;
    color: rgba(240, 228, 216, 0.4);
    letter-spacing: 0.1em;
}

/* --- Ripple Effect --- */
.ripple-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(64, 128, 128, 0.2) 0%, transparent 70%);
    transform: scale(0);
    animation: rippleExpand 800ms ease-out forwards;
    pointer-events: none;
}

/* --- Scroll Reveal --- */
.reveal-left {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.reveal-right {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 400ms ease, transform 400ms ease;
    transition-delay: 200ms;
}

.reveal-left.revealed,
.reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* --- Animations --- */
@keyframes scaleIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(30px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes drawCurve {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes drawFlourish {
    0% {
        stroke-dashoffset: 200;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

@keyframes drawOrnament {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes drawFrame {
    to {
        stroke-dashoffset: 0;
    }
}

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

@keyframes rippleExpand {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(1);
        opacity: 0;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@keyframes goldenGlow {
    0% { box-shadow: 0 0 0 rgba(196, 160, 96, 0); }
    50% { box-shadow: 0 0 20px rgba(196, 160, 96, 0.4); }
    100% { box-shadow: 0 0 15px rgba(196, 160, 96, 0.3); }
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .hero-content {
        flex-direction: column;
        text-align: center;
    }

    .hero-text {
        padding-top: 5vh;
    }

    .hero-dotcom {
        text-align: center;
    }

    .hero-illustration {
        max-width: 340px;
    }

    .concepts-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .concepts-right {
        margin-top: 0;
    }

    .app-gallery {
        grid-template-columns: 1fr;
    }

    .app-card-large {
        grid-row: auto;
    }

    .quiz-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .hero-korean {
        font-size: clamp(50px, 18vw, 120px);
    }

    .widget-results {
        gap: 1rem;
    }

    .footer-nav {
        gap: 1.5rem;
    }
}
