/* hwakryul.com — neubrutalism probability workshop
   palette: paper #f2ede6, sticky #faf0c8, ink #1a1a1a, red #d43d2e,
            blue #2a5caa, graphite #6a6a6a, shadow #c4baa8
   type:    Nanum Pen Script (display KO), Syne (display roman),
            Work Sans (body), Courier Prime (mono)
*/

:root {
    --paper: #f2ede6;
    --sticky: #faf0c8;
    --ink: #1a1a1a;
    --red: #d43d2e;
    --blue: #2a5caa;
    --graphite: #6a6a6a;
    --shadow: #c4baa8;

    --border-w: 3px;
    --shadow-x: 4px;
    --shadow-y: 4px;

    --font-ko: "Nanum Pen Script", cursive;
    --font-display: "Syne", sans-serif;
    --font-body: "Work Sans", sans-serif;
    --font-mono: "Courier Prime", "Courier New", monospace;
}

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

html, body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
}

body {
    background-image:
        radial-gradient(circle at 12% 18%, rgba(212,61,46,0.04) 0, transparent 40%),
        radial-gradient(circle at 88% 72%, rgba(42,92,170,0.04) 0, transparent 45%),
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 31px,
            rgba(106,106,106,0.05) 31px,
            rgba(106,106,106,0.05) 32px
        );
    padding: 28px 24px 0;
}

/* ---------- board layout ---------- */
.board {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 28px;
    align-items: start;
}

/* ---------- sidebar / index card ---------- */
.sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
}

.sidebar-card {
    position: relative;
    background: var(--sticky);
    border: var(--border-w) solid var(--ink);
    border-radius: 4px;
    box-shadow: var(--shadow-x) var(--shadow-y) 0 var(--shadow);
    padding: 24px 22px 22px;
    transform: rotate(-1.2deg);
    overflow: hidden;
}

.folded-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 38px;
    height: 38px;
    background:
        linear-gradient(225deg, var(--paper) 0 50%, transparent 50%);
    border-left: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    box-shadow: -2px 2px 0 rgba(26,26,26,0.18);
}

.sidebar .hanja {
    font-family: var(--font-ko);
    font-size: clamp(3.4rem, 5vw, 4.6rem);
    line-height: 0.95;
    color: var(--ink);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.sidebar .reading {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--graphite);
    letter-spacing: 0.06em;
    text-transform: lowercase;
    border-bottom: 1.5px dashed var(--ink);
    padding-bottom: 10px;
    margin-bottom: 14px;
}

.sidebar .definition {
    font-family: var(--font-body);
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--ink);
    margin-bottom: 18px;
}

.sidebar .definition strong {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--red);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    margin-right: 4px;
}

.sidebar-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--ink);
    margin: 14px 0 8px;
    border-top: 1.5px solid var(--ink);
    padding-top: 8px;
}

.related-list {
    list-style: none;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--ink);
    line-height: 1.7;
}

.related-list li {
    padding-left: 2px;
}

.related-list.mono li {
    color: var(--blue);
}

.sidebar-stamp {
    margin-top: 18px;
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--red);
    border: 2px solid var(--red);
    padding: 4px 8px;
    transform: rotate(-3deg);
}

/* ---------- main column ---------- */
.main {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-bottom: 80px;
}

/* ---------- hero ---------- */
.hero {
    background: var(--paper);
    border: var(--border-w) solid var(--ink);
    border-radius: 4px;
    box-shadow: var(--shadow-x) var(--shadow-y) 0 var(--shadow);
    padding: 36px 36px 30px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1.5px dashed var(--ink);
    border-radius: 2px;
    pointer-events: none;
    opacity: 0.35;
}

.hero-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border: 2px solid var(--ink);
    background: var(--paper);
    padding: 3px 9px;
    color: var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
}

.tag-red {
    background: var(--red);
    color: var(--paper);
}

.tag-blue {
    background: var(--blue);
    color: var(--paper);
}

.domain-mono {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: var(--ink);
    border-bottom: 1.5px solid var(--ink);
    display: inline-block;
    padding-bottom: 2px;
    margin-bottom: 4px;
}

.korean-display {
    font-family: var(--font-ko);
    font-weight: 400;
    font-size: clamp(4.5rem, 12vw, 9rem);
    line-height: 0.9;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin: 4px 0 12px;
    position: relative;
    display: inline-block;
}

.korean-display::after {
    content: "확률";
    position: absolute;
    left: 6px;
    top: 6px;
    color: var(--red);
    z-index: -1;
    opacity: 0.18;
    pointer-events: none;
}

.hero-sub {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.05rem, 1.7vw, 1.35rem);
    line-height: 1.45;
    color: var(--ink);
    max-width: 56ch;
    margin-bottom: 22px;
}

.hero-sub em {
    color: var(--red);
    font-style: italic;
    font-weight: 700;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--graphite);
    border-top: 1.5px solid var(--ink);
    padding-top: 14px;
}

.meta-item {
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.meta-divider {
    color: var(--red);
    font-weight: 700;
}

/* ---------- generic card ---------- */
.card {
    background: var(--paper);
    border: var(--border-w) solid var(--ink);
    border-radius: 4px;
    box-shadow: var(--shadow-x) var(--shadow-y) 0 var(--shadow);
    padding: 0;
    position: relative;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.25s ease;
}

.card:hover {
    box-shadow: 6px 6px 0 var(--shadow);
}

.card-label {
    display: flex;
    align-items: baseline;
    gap: 14px;
    background: var(--ink);
    color: var(--paper);
    padding: 10px 18px;
    border-bottom: var(--border-w) solid var(--ink);
    font-family: var(--font-mono);
}

.card-num {
    font-size: 0.95rem;
    color: var(--sticky);
    font-weight: 700;
    letter-spacing: 0.1em;
}

.card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.card-body {
    padding: 26px 30px 30px;
}

.card-prose {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--ink);
    margin-bottom: 18px;
    max-width: 64ch;
}

.card-prose em {
    color: var(--blue);
    font-style: italic;
    font-weight: 500;
}

.card-prose strong {
    background: var(--sticky);
    border-bottom: 2px solid var(--ink);
    padding: 0 3px;
}

.ink-red { color: var(--red); font-weight: 600; font-family: var(--font-mono); }
.ink-blue { color: var(--blue); font-weight: 600; font-family: var(--font-mono); }

/* ---------- card 01 — coin ---------- */
.card-coin .card-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 30px;
    align-items: start;
}

.coin-stage {
    perspective: 600px;
    width: 200px;
    height: 200px;
    display: grid;
    place-items: center;
    background:
        repeating-linear-gradient(
            45deg,
            transparent 0 8px,
            rgba(196,186,168,0.18) 8px 9px
        );
    border: 2px dashed var(--ink);
    border-radius: 50%;
    margin-top: 4px;
    position: relative;
}

.coin-stage::after {
    content: "P( ½ , ½ )";
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--graphite);
    letter-spacing: 0.1em;
}

.coin {
    width: 140px;
    height: 140px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: rotateY(0deg);
}

.coin.flipping {
    will-change: transform;
}

.coin-face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 4px solid var(--ink);
    background: var(--sticky);
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 4rem;
    color: var(--ink);
    backface-visibility: hidden;
    box-shadow:
        inset 0 0 0 6px var(--paper),
        inset 0 0 0 8px var(--ink);
}

.coin-front {
    background: var(--sticky);
}

.coin-back {
    transform: rotateY(180deg);
    background: var(--red);
    color: var(--paper);
}

.coin-prose p {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--ink);
    margin-bottom: 14px;
    max-width: 56ch;
}

.btn-flip {
    display: inline-block;
    margin-top: 6px;
    padding: 12px 24px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--ink);
    background: var(--sticky);
    border: var(--border-w) solid var(--ink);
    border-radius: 0;
    box-shadow: 4px 4px 0 var(--ink);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
}

.btn-flip:hover {
    background: var(--red);
    color: var(--paper);
}

.btn-flip:active,
.btn-flip.is-pressed {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink);
}

.flip-log {
    margin-top: 16px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--graphite);
    border-top: 1.5px dashed var(--ink);
    padding-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.log-label {
    color: var(--red);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.log-stream {
    color: var(--ink);
    word-break: break-all;
}

.log-stream .h-mark {
    color: var(--blue);
    font-weight: 700;
    margin: 0 1px;
}

.log-stream .t-mark {
    color: var(--red);
    font-weight: 700;
    margin: 0 1px;
}

/* ---------- card 02 — chart ---------- */
.chart-figure {
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 2px;
    padding: 14px 14px 10px;
    margin: 10px 0 16px;
    box-shadow: 3px 3px 0 var(--shadow);
}

.chart-svg {
    width: 100%;
    height: auto;
    display: block;
    background: var(--paper);
}

.chart-svg .chart-label {
    font-family: "Courier Prime", monospace;
    font-size: 14px;
    fill: var(--ink);
    font-weight: 700;
}

.chart-svg .chart-axis {
    font-family: "Courier Prime", monospace;
    font-size: 12px;
    fill: var(--graphite);
    letter-spacing: 0.08em;
}

.bar-group rect {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                fill 0.2s ease;
    transform-origin: bottom center;
    transform-box: fill-box;
}

.bar-group:hover rect {
    transform: translateY(-3px);
}

.bar-group.is-pulse rect {
    animation: barPulse 0.6s ease;
}

@keyframes barPulse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.chart-caption {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--graphite);
    margin-top: 6px;
    line-height: 1.5;
}

.cap-num {
    color: var(--red);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.chart-caption strong {
    background: var(--sticky);
    border-bottom: 2px solid var(--ink);
    padding: 0 3px;
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--ink);
    flex-wrap: wrap;
}

.legend-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--ink);
    margin-right: 4px;
    vertical-align: middle;
}

.sw-red { background: var(--red); }
.sw-blue { background: var(--blue); }

.legend-text {
    margin-right: 14px;
}

/* ---------- card 03 — etymology ---------- */
.hanja-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 22px;
    align-items: center;
    margin: 8px 0 22px;
}

.hanja-entry {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 18px;
    align-items: start;
    padding: 14px;
    border: 2px solid var(--ink);
    background: var(--sticky);
    box-shadow: 3px 3px 0 var(--shadow);
}

.hanja-char {
    font-family: var(--font-ko);
    font-size: clamp(3.5rem, 6vw, 5rem);
    line-height: 1;
    color: var(--ink);
    text-align: center;
    border-right: 2px solid var(--ink);
    padding-right: 16px;
}

.hanja-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.hanja-reading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--ink);
}

.mono-tag {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--red);
    border: 1.5px solid var(--red);
    padding: 1px 6px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    vertical-align: middle;
}

.hanja-gloss {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--ink);
    line-height: 1.4;
}

.hanja-radical {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--graphite);
    line-height: 1.3;
    border-top: 1.5px dashed var(--ink);
    padding-top: 4px;
    margin-top: 4px;
}

.hanja-divider {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2.5rem;
    color: var(--red);
    text-align: center;
}

.hanja-equation {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 1rem;
    background: var(--paper);
    border: 2px dashed var(--ink);
    padding: 12px 16px;
    margin-bottom: 18px;
}

.eq-left {
    color: var(--ink);
    font-weight: 700;
}

.eq-arrow {
    color: var(--red);
    font-weight: 700;
    font-size: 1.2rem;
}

.eq-right {
    color: var(--blue);
    font-weight: 700;
}

.eq-right em {
    color: var(--graphite);
    font-style: italic;
    font-weight: 400;
    font-family: var(--font-body);
    font-size: 0.92rem;
}

/* ---------- card 04 — bayes ---------- */
.bayes-formula {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.4rem, 2.3vw, 1.8rem);
    color: var(--ink);
    background: var(--sticky);
    border: 2px solid var(--ink);
    box-shadow: 3px 3px 0 var(--shadow);
    padding: 16px 22px;
    margin-bottom: 18px;
}

.bayes-line {
    color: var(--red);
}

.bayes-frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
}

.bayes-num,
.bayes-den {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--ink);
    padding: 0 6px;
}

.bayes-num {
    border-bottom: 2.5px solid var(--ink);
    padding-bottom: 4px;
}

.bayes-den {
    color: var(--blue);
    padding-top: 4px;
}

.mono-prose {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    color: var(--graphite);
    line-height: 1.7;
    background: var(--paper);
    border-left: 4px solid var(--red);
    padding: 8px 12px;
    margin-bottom: 18px;
}

.checklist {
    list-style: none;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    color: var(--ink);
    line-height: 1.85;
}

.checklist li {
    border-bottom: 1.5px dashed var(--shadow);
    padding: 4px 0;
}

.checklist li:last-child {
    border-bottom: none;
}

.chk {
    color: var(--red);
    font-weight: 700;
    margin-right: 8px;
}

/* ---------- footer (torn edge) ---------- */
.torn-footer {
    margin-top: 60px;
    background: #e8dfd1;
    border-top: var(--border-w) solid var(--ink);
    padding: 60px 24px 36px;
    clip-path: polygon(
        0% 14px,
        5% 4px, 10% 18px, 15% 6px, 20% 14px,
        25% 2px, 30% 16px, 35% 8px, 40% 20px,
        45% 4px, 50% 14px, 55% 6px, 60% 18px,
        65% 2px, 70% 16px, 75% 8px, 80% 20px,
        85% 4px, 90% 14px, 95% 6px, 100% 18px,
        100% 100%, 0% 100%
    );
    position: relative;
}

.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    color: var(--ink);
}

.footer-eq {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--red);
    letter-spacing: 0.05em;
}

.footer-mark {
    color: var(--graphite);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.78rem;
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
    .board {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .sidebar {
        position: static;
    }

    .sidebar-card {
        transform: rotate(-0.4deg);
    }

    .card-coin .card-body {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .coin-prose {
        width: 100%;
    }

    .hanja-grid {
        grid-template-columns: 1fr;
    }

    .hanja-divider {
        font-size: 1.6rem;
    }
}

@media (max-width: 640px) {
    body {
        padding: 16px 12px 0;
    }

    .hero {
        padding: 24px 20px 22px;
    }

    .card-body {
        padding: 20px 18px 22px;
    }

    .coin-stage {
        width: 170px;
        height: 170px;
    }

    .coin {
        width: 120px;
        height: 120px;
    }

    .coin-face {
        font-size: 3rem;
    }

    .hanja-entry {
        grid-template-columns: 1fr;
    }

    .hanja-char {
        border-right: none;
        border-bottom: 2px solid var(--ink);
        padding-right: 0;
        padding-bottom: 8px;
    }

    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ---------- small flourishes ---------- */
.card[data-rotate]:not(.no-rotate) {
    transform-origin: center;
}

::selection {
    background: var(--red);
    color: var(--paper);
}
