/* ============================================
   hwaglyul.com - Probability & Statistics
   Scandinavian / Z-pattern / Border-animate
   ============================================ */

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

:root {
    --white-base: #FAFAF8;
    --sand: #E8E0D0;
    --grid-gray: #D0D0C8;
    --nordic-teal: #3A6A7A;
    --complement-orange: #D07040;
    --dark-text: #2A2A28;
    --muted-text: #7A7A70;
    --nature-green: #5A7A50;
    --font-display: 'Sora', sans-serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'DM Mono', monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(15px, 1.05vw, 17px);
    line-height: 1.8;
    color: var(--dark-text);
    background-color: var(--white-base);
    overflow-x: hidden;
    position: relative;
}

/* --- Grid Background Pattern --- */
#grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right, rgba(208, 208, 200, 0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(208, 208, 200, 0.1) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* --- Logotype --- */
.logotype {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 4.5vw, 52px);
    color: var(--dark-text);
    text-decoration: none;
    transition: font-weight 300ms ease;
    display: inline-block;
}

.logotype:hover {
    font-weight: 400;
}

/* --- Section: Hero (Z Top Bar) --- */
.section-hero {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 80px clamp(24px, 5vw, 80px);
    background-color: var(--white-base);
}

.hero-inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 60px;
}

.hero-left {
    flex: 1;
    max-width: 600px;
    opacity: 0;
    animation: fadeIn 500ms ease forwards;
    animation-delay: 200ms;
}

.hero-subtitle {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--muted-text);
    margin-top: 16px;
    letter-spacing: 0.05em;
}

.hero-headline {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 3.5vw, 48px);
    color: var(--dark-text);
    line-height: 1.2;
    margin-top: 24px;
}

.hero-description {
    font-size: clamp(16px, 1.2vw, 19px);
    color: var(--muted-text);
    margin-top: 20px;
    max-width: 480px;
    line-height: 1.7;
}

.hero-right {
    flex: 1;
    max-width: 550px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

#bell-curve-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: drawBellCurve 1500ms ease-out forwards;
    animation-delay: 400ms;
}

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

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

/* --- Section: Diagonal Transition Band --- */
.section-diagonal {
    position: relative;
    z-index: 1;
    background-color: var(--sand);
    padding: 100px clamp(24px, 5vw, 80px);
    clip-path: polygon(0 8%, 100% 0, 100% 92%, 0 100%);
    margin-top: -60px;
    margin-bottom: -60px;
}

.diagonal-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 60px;
    padding: 40px 0;
}

.diagonal-illustration {
    flex: 1;
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 600ms ease, transform 600ms ease;
}

.diagonal-illustration.visible {
    opacity: 1;
    transform: translateX(0);
}

.dice-illustration,
.coin-illustration,
.tree-illustration {
    width: 120px;
    height: auto;
}

.dice-illustration *,
.coin-illustration *,
.tree-illustration * {
    vector-effect: non-scaling-stroke;
}

.diagonal-text {
    flex: 1;
    max-width: 500px;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 600ms ease, transform 600ms ease;
}

.diagonal-text.visible {
    opacity: 1;
    transform: translateX(0);
}

.diagonal-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(24px, 3vw, 40px);
    color: var(--dark-text);
    line-height: 1.2;
}

.diagonal-body {
    font-size: clamp(15px, 1.1vw, 18px);
    color: var(--muted-text);
    margin-top: 16px;
    line-height: 1.8;
}

/* --- Section: Calculator (Z Second Bar) --- */
.section-calculator {
    position: relative;
    z-index: 1;
    padding: 120px clamp(24px, 5vw, 80px) 100px;
    background-color: var(--white-base);
}

.calculator-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 60px;
    align-items: flex-start;
}

.calculator-left {
    flex: 1;
    max-width: 480px;
}

.calculator-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(24px, 2.8vw, 38px);
    color: var(--dark-text);
    line-height: 1.2;
}

.calculator-description {
    color: var(--muted-text);
    margin-top: 12px;
    font-size: clamp(15px, 1.05vw, 17px);
}

.calc-field-group {
    margin-top: 28px;
}

.calc-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--muted-text);
    margin-bottom: 8px;
    letter-spacing: 0.03em;
}

/* --- Border-Animate Input Wrap --- */
.border-animate-wrap {
    position: relative;
    display: block;
}

.calc-input {
    width: 100%;
    padding: 14px 18px;
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--dark-text);
    background: var(--white-base);
    border: 1.5px solid var(--grid-gray);
    border-radius: 4px;
    outline: none;
    transition: border-color 400ms ease;
    position: relative;
    z-index: 1;
}

.calc-input:focus {
    border-color: transparent;
}

.border-draw {
    position: absolute;
    top: -1.5px;
    left: -1.5px;
    right: -1.5px;
    bottom: -1.5px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 2;
}

.border-draw::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100% + 3px);
    height: calc(100% + 3px);
    border: 1.5px solid var(--nordic-teal);
    border-radius: 4px;
    clip-path: inset(0 100% 100% 0);
    transition: clip-path 400ms ease;
}

.calc-input:focus ~ .border-draw::before {
    clip-path: inset(0 0 0 0);
}

/* --- Calculator Results --- */
.calc-results {
    margin-top: 36px;
    padding: 24px;
    background: var(--white-base);
    border: 1px solid var(--grid-gray);
    border-radius: 6px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.result-row + .result-row {
    border-top: 1px solid rgba(208, 208, 200, 0.3);
}

.result-label {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--muted-text);
}

.result-value {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--complement-orange);
    font-weight: 400;
    transition: transform 200ms ease;
}

.result-value.pulse {
    animation: pulseValue 200ms ease;
}

@keyframes pulseValue {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* --- Visualization / Bar Chart --- */
.calculator-right {
    flex: 1.2;
    min-width: 0;
}

.viz-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    color: var(--dark-text);
    margin-bottom: 16px;
}

.viz-container {
    position: relative;
}

.bar-chart {
    width: 100%;
    height: auto;
    display: block;
}

.viz-x-label {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted-text);
    text-align: center;
    margin-top: 8px;
}

/* --- Section: Concept Cards --- */
.section-concepts {
    position: relative;
    z-index: 1;
    padding: 100px clamp(24px, 5vw, 80px);
    background-color: var(--white-base);
}

.concepts-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(24px, 3vw, 40px);
    color: var(--dark-text);
    text-align: center;
    margin-bottom: 60px;
}

.concepts-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
}

.concept-card {
    background: var(--white-base);
    border: 1px solid var(--grid-gray);
    border-radius: 6px;
    padding: 32px 28px;
    transition: border-color 300ms ease, box-shadow 300ms ease;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 500ms ease, transform 500ms ease, border-color 300ms ease, box-shadow 300ms ease;
}

.concept-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.concept-card:hover {
    border-color: var(--nordic-teal);
    box-shadow: 0 4px 20px rgba(42, 42, 40, 0.06);
}

.card-illustration {
    margin-bottom: 20px;
}

.card-svg {
    width: 100%;
    max-width: 200px;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Stroke-draw animation for card SVGs */
.card-svg line,
.card-svg circle,
.card-svg rect,
.card-svg path,
.card-svg polyline,
.card-svg polygon {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1000ms ease;
}

.concept-card.visible .card-svg line,
.concept-card.visible .card-svg circle,
.concept-card.visible .card-svg rect,
.concept-card.visible .card-svg path,
.concept-card.visible .card-svg polyline,
.concept-card.visible .card-svg polygon {
    stroke-dashoffset: 0;
}

.card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    color: var(--nordic-teal);
    margin-bottom: 10px;
}

.card-body {
    font-size: 15px;
    color: var(--muted-text);
    line-height: 1.7;
    margin-bottom: 16px;
}

.card-formula {
    display: block;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--complement-orange);
    padding: 10px 14px;
    background: rgba(208, 208, 200, 0.12);
    border-radius: 4px;
    text-align: center;
}

/* --- Section: Footer --- */
.section-footer {
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--grid-gray);
    padding: 48px clamp(24px, 5vw, 80px);
    background-color: var(--white-base);
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 24px;
}

.footer-logotype {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--dark-text);
    text-decoration: none;
    transition: font-weight 300ms ease;
}

.footer-logotype:hover {
    font-weight: 400;
}

.footer-nav {
    display: flex;
    gap: 28px;
}

.footer-link {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--muted-text);
    text-decoration: none;
    transition: color 200ms ease;
}

.footer-link:hover {
    color: var(--nordic-teal);
}

.footer-copy {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted-text);
}

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

    .hero-left {
        max-width: 100%;
    }

    .hero-description {
        margin-left: auto;
        margin-right: auto;
    }

    .hero-right {
        max-width: 400px;
    }

    .diagonal-inner {
        flex-direction: column;
        text-align: center;
    }

    .diagonal-text {
        max-width: 100%;
    }

    .calculator-inner {
        flex-direction: column;
    }

    .calculator-left {
        max-width: 100%;
    }

    .concepts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .section-diagonal {
        clip-path: polygon(0 4%, 100% 0, 100% 96%, 0 100%);
    }

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

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .diagonal-illustration {
        flex-direction: column;
    }
}
