/* hwaglyul.com — 확률 / 確率 — glassmorphism + minimalist meditation on probability */

:root {
    --bg-start: #e8e4f0;     /* pale lavender */
    --bg-end:   #e0eef4;     /* pale cyan */
    --glass-fill:   rgba(255, 255, 255, 0.25);
    --glass-fill-strong: rgba(255, 255, 255, 0.42);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-border-strong: rgba(255, 255, 255, 0.45);
    --text-primary:   #1a1e2e;
    --text-secondary: #5a6070;
    --accent:    #6a5acd;    /* soft violet, probability */
    --highlight: #d4627a;    /* warm rose, dot highlights */
    --shadow-soft: 0 8px 32px rgba(26, 30, 46, 0.08);
    --shadow-deep: 0 18px 48px rgba(26, 30, 46, 0.12);
    --shadow-rise: 0 4px 18px rgba(26, 30, 46, 0.06);

    --font-hangul: "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
    --font-roman:  "Outfit", "Helvetica Neue", sans-serif;
    --font-mono:   "Space Mono", "SFMono-Regular", monospace;
}

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

html, body {
    min-height: 100%;
}

body {
    font-family: var(--font-roman);
    font-weight: 300;
    color: var(--text-primary);
    line-height: 1.7;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    background-attachment: fixed;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ambient atmospheric layers ---------------------------------------------- */

.ambient-gradient {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(106, 90, 205, 0.10), transparent 55%),
        radial-gradient(ellipse at 80% 20%, rgba(212, 98, 122, 0.06), transparent 50%),
        radial-gradient(ellipse at 50% 90%, rgba(106, 90, 205, 0.08), transparent 55%);
    z-index: 0;
    pointer-events: none;
}

.ambient-blobs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    animation: drift 28s ease-in-out infinite alternate;
}

.blob-violet {
    width: 38vw;
    height: 38vw;
    left: -8vw;
    top: 12vh;
    background: radial-gradient(circle, rgba(106, 90, 205, 0.45), transparent 70%);
    animation-duration: 32s;
}

.blob-cyan {
    width: 32vw;
    height: 32vw;
    right: -6vw;
    top: 30vh;
    background: radial-gradient(circle, rgba(180, 220, 230, 0.55), transparent 70%);
    animation-duration: 24s;
    animation-delay: -6s;
}

.blob-lavender {
    width: 30vw;
    height: 30vw;
    left: 30vw;
    bottom: -10vh;
    background: radial-gradient(circle, rgba(232, 228, 240, 0.7), transparent 70%);
    animation-duration: 36s;
    animation-delay: -12s;
}

@keyframes drift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(2vw, 3vh, 0) scale(1.06); }
    100% { transform: translate3d(-1vw, -2vh, 0) scale(0.98); }
}

/* Stage / grid ------------------------------------------------------------ */

.stage {
    position: relative;
    z-index: 1;
    padding: 8vh 6vw 10vh;
    min-height: 100vh;
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(120px, auto);
    gap: clamp(16px, 2.2vw, 32px);
    max-width: 1480px;
    margin: 0 auto;
}

/* Glass panel base -------------------------------------------------------- */

.panel {
    position: relative;
    background: var(--glass-fill);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: clamp(20px, 2.4vw, 36px);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    transition: transform 0.8s ease-in-out, box-shadow 0.8s ease-in-out;
}

@supports not (backdrop-filter: blur(1px)) {
    .panel {
        background: rgba(255, 255, 255, 0.62);
    }
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 60%);
    pointer-events: none;
    opacity: 0.7;
}

.panel[data-depth="3"] {
    box-shadow: var(--shadow-deep);
    background: var(--glass-fill-strong);
    border-color: var(--glass-border-strong);
    backdrop-filter: blur(28px) saturate(1.3);
    -webkit-backdrop-filter: blur(28px) saturate(1.3);
}

.panel[data-depth="2"] {
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.panel[data-depth="1"] {
    box-shadow: var(--shadow-rise);
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(12px) saturate(1.15);
    -webkit-backdrop-filter: blur(12px) saturate(1.15);
}

.panel-label {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
}

/* Hero panel -------------------------------------------------------------- */

.panel-hero {
    grid-column: 1 / span 8;
    grid-row: span 4;
    min-height: 56vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(32px, 4vw, 64px);
    isolation: isolate;
}

.hero-marker {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: clamp(20px, 3vh, 40px);
}

.marker-line {
    height: 1px;
    width: clamp(40px, 6vw, 80px);
    background: var(--accent);
    opacity: 0.6;
}

.marker-label {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.hangul {
    font-family: var(--font-hangul);
    font-weight: 100;
    font-size: clamp(4rem, 10vw, 10rem);
    line-height: 1;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    text-shadow: 0 2px 24px rgba(255, 255, 255, 0.6);
}

.hero-meaning {
    font-family: var(--font-roman);
    font-weight: 300;
    font-size: clamp(1.2rem, 1.6vw, 1.6rem);
    color: var(--text-secondary);
    margin-top: 0.5rem;
    letter-spacing: 0.04em;
}

.hero-sub {
    font-family: var(--font-roman);
    font-weight: 300;
    font-size: 1rem;
    color: var(--text-secondary);
    opacity: 0.85;
    margin-top: 0.4rem;
    font-style: italic;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(18px, 3vw, 40px);
    margin-top: clamp(28px, 4vh, 56px);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.meta-cell em {
    font-style: normal;
    color: var(--accent);
    margin-right: 0.35em;
}

/* Hanja panel ------------------------------------------------------------- */

.panel-hanja {
    grid-column: 9 / span 4;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 28vh;
}

.hanja-display {
    font-family: var(--font-hangul);
    font-weight: 300;
    font-size: clamp(3.2rem, 6vw, 5.6rem);
    color: var(--text-primary);
    letter-spacing: 0.02em;
    line-height: 1;
    text-shadow:
        0 0 18px rgba(106, 90, 205, 0.25),
        0 2px 6px rgba(255, 255, 255, 0.6);
    margin: 0.5rem 0;
}

.hanja-translit {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.16em;
}

/* Dot grid panel ---------------------------------------------------------- */

.panel-dots {
    grid-column: 9 / span 4;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 28vh;
}

.dot-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: clamp(6px, 1vw, 14px);
    align-self: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 240px;
    margin: 0.6rem auto;
}

.dot {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 8px;
    max-height: 8px;
    margin: auto;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.3;
    transition: background-color 0.6s ease-in-out, opacity 0.6s ease-in-out, transform 0.6s ease-in-out;
}

.dot.is-on {
    background: var(--highlight);
    opacity: 1;
    transform: scale(1.05);
}

.dot-readout {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-family: var(--font-mono);
    margin-top: 0.6rem;
}

.readout-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.12em;
    text-transform: lowercase;
}

.readout-value {
    font-size: 1.2rem;
    color: var(--accent);
    transition: color 0.6s ease-in-out;
}

/* Bell curve panel -------------------------------------------------------- */

.panel-curve {
    grid-column: 1 / span 5;
    grid-row: span 2;
    min-height: 26vh;
    display: flex;
    flex-direction: column;
}

.bell-curve {
    width: 100%;
    height: clamp(140px, 18vh, 200px);
    margin-top: 0.3rem;
}

.bell-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    stroke-linecap: round;
    transition: stroke-dashoffset 2.4s ease-in-out;
}

.bell-path.is-drawn {
    stroke-dashoffset: 0;
}

.bell-fill {
    opacity: 0;
    transition: opacity 1.4s ease-in-out 1.4s;
}

.bell-fill.is-drawn {
    opacity: 1;
}

.curve-stats {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(106, 90, 205, 0.15);
}

.curve-stat {
    display: flex;
    flex-direction: column;
    font-family: var(--font-mono);
}

.curve-stat em {
    font-style: normal;
    font-size: 0.72rem;
    color: var(--text-secondary);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.curve-stat span {
    font-size: 1rem;
    color: var(--accent);
    margin-top: 4px;
}

/* Counter panel ----------------------------------------------------------- */

.panel-counter {
    grid-column: 6 / span 3;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 26vh;
}

.counter-value {
    font-family: var(--font-mono);
    font-size: clamp(1.6rem, 2.4vw, 2.4rem);
    color: var(--text-primary);
    letter-spacing: 0.04em;
    margin-top: auto;
    transition: color 0.6s ease-in-out;
}

.counter-caption {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.12em;
    margin-top: 0.4rem;
}

/* Sequence panel ---------------------------------------------------------- */

.panel-sequence {
    grid-column: 1 / span 5;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 22vh;
}

.sequence {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0.6rem 0;
}

.seq-cell {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(106, 90, 205, 0.18);
    transition: background-color 0.6s ease-in-out, color 0.6s ease-in-out, transform 0.6s ease-in-out;
}

.seq-cell.is-h {
    color: var(--accent);
    border-color: rgba(106, 90, 205, 0.4);
}

.seq-cell.is-t {
    color: var(--highlight);
    border-color: rgba(212, 98, 122, 0.35);
}

.sequence-caption {
    font-family: var(--font-roman);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
}

/* Whisper panel ----------------------------------------------------------- */

.panel-whisper {
    grid-column: 6 / span 7;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    min-height: 22vh;
}

.whisper {
    font-family: var(--font-roman);
    font-weight: 300;
    font-size: clamp(1.4rem, 2.6vw, 2.4rem);
    color: var(--text-primary);
    letter-spacing: 0.02em;
    line-height: 1.3;
    margin-top: 0.4rem;
}

.whisper-em {
    color: var(--accent);
    font-style: italic;
}

/* Meditation section ------------------------------------------------------ */

.meditation {
    position: relative;
    z-index: 1;
    padding: 12vh max(25vw, 24px) 12vh;
    color: var(--text-primary);
}

.meditation-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin-bottom: 2.4rem;
}

.meditation-paragraph {
    font-family: var(--font-roman);
    font-weight: 300;
    font-size: clamp(1.05rem, 1.3vw, 1.25rem);
    line-height: 1.85;
    margin: 1.4rem 0;
    color: var(--text-primary);
}

.meditation-final {
    font-style: italic;
    color: var(--text-secondary);
}

.rand-line {
    display: block;
    height: 1px;
    background: var(--accent);
    opacity: 0.4;
    width: 50%;
    margin: 3.2rem 0;
    transition: width 1.6s ease-in-out;
}

/* Footer / RNG ------------------------------------------------------------ */

.rng-footer {
    position: relative;
    z-index: 1;
    background: linear-gradient(180deg, rgba(26, 30, 46, 0.92), rgba(26, 30, 46, 0.98));
    color: #e8e4f0;
    padding: 6vh 6vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.rng-label {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(232, 228, 240, 0.6);
}

.rng-display {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    letter-spacing: 0.06em;
    color: #e8e4f0;
    text-shadow: 0 0 24px rgba(106, 90, 205, 0.3);
    transition: color 0.4s ease-in-out;
}

.rng-display.is-scrambling {
    color: var(--highlight);
}

.rng-meta {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    color: rgba(232, 228, 240, 0.5);
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1024px) {
    .panel-hero { grid-column: 1 / span 12; }
    .panel-hanja { grid-column: 1 / span 6; }
    .panel-dots { grid-column: 7 / span 6; }
    .panel-curve { grid-column: 1 / span 7; }
    .panel-counter { grid-column: 8 / span 5; }
    .panel-sequence { grid-column: 1 / span 6; }
    .panel-whisper { grid-column: 7 / span 6; }
    .meditation { padding-left: 12vw; padding-right: 12vw; }
}

@media (max-width: 720px) {
    .stage { padding: 6vh 5vw 8vh; }
    .grid { grid-template-columns: repeat(6, 1fr); gap: 16px; }
    .panel-hero,
    .panel-hanja,
    .panel-dots,
    .panel-curve,
    .panel-counter,
    .panel-sequence,
    .panel-whisper { grid-column: 1 / -1; }
    .meditation { padding-left: 6vw; padding-right: 6vw; }
    .hero-meta { gap: 14px; }
    .seq-cell { width: 32px; height: 32px; font-size: 0.9rem; }
}
