/* ============================================
   확률.com - Glitch Probability Engine
   Coastal-Blend Palette + Modular Blocks
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --coastal-white: #F5F8F8;
    --sea-glass: #E8F0F0;
    --deep-tide: #1A2830;
    --ocean-slate: #4A6068;
    --teal-shore: #2A8A80;
    --sandy-coral: #D08868;
    --glitch-cyan: #00C8B8;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.95rem;
    line-height: 1.7;
    font-weight: 400;
    color: var(--ocean-slate);
    background-color: var(--coastal-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Container --- */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
    position: relative;
    width: 100%;
    padding: 4rem 2rem;
    background-color: var(--coastal-white);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.hero-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
    pointer-events: none;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

/* HUD Frame around hero title */
.hud-frame {
    position: relative;
    display: inline-block;
    padding: 1.5rem 3rem;
}

.hud-bracket {
    position: absolute;
    width: 20px;
    height: 20px;
}

.hud-bracket-tl {
    top: 0;
    left: 0;
    border-top: 2px solid var(--teal-shore);
    border-left: 2px solid var(--teal-shore);
}

.hud-bracket-tr {
    top: 0;
    right: 0;
    border-top: 2px solid var(--teal-shore);
    border-right: 2px solid var(--teal-shore);
}

.hud-bracket-bl {
    bottom: 0;
    left: 0;
    border-bottom: 2px solid var(--teal-shore);
    border-left: 2px solid var(--teal-shore);
}

.hud-bracket-br {
    bottom: 0;
    right: 0;
    border-bottom: 2px solid var(--teal-shore);
    border-right: 2px solid var(--teal-shore);
}

.hero-title {
    font-family: 'Albert Sans', sans-serif;
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    font-weight: 600;
    color: var(--deep-tide);
    letter-spacing: 0.01em;
    line-height: 1.1;
}

.hero-probability-display {
    margin-top: 1.5rem;
    font-family: 'IBM Plex Sans', monospace;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--teal-shore);
    font-variant-numeric: tabular-nums;
}

.prob-label {
    font-weight: 500;
    color: var(--ocean-slate);
}

.prob-value {
    font-weight: 600;
    color: var(--teal-shore);
    letter-spacing: 0.05em;
}

.hero-accent-line {
    margin: 1.5rem auto 0;
    width: 60px;
    height: 3px;
    background-color: var(--teal-shore);
}

/* ============================================
   MODULAR GRID SECTIONS
   ============================================ */
.grid-section {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

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

/* ============================================
   MODULE BLOCKS
   ============================================ */
.module-block {
    position: relative;
    background-color: var(--sea-glass);
    border-radius: 2px;
    padding: 0;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, z-index 0s;
    z-index: 1;
}

.module-block:hover {
    transform: scale(1.04);
    z-index: 10;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.module-block:hover .block-noise {
    opacity: 0.12;
}

.span-2 {
    grid-column: span 2;
}

/* --- Block Noise Texture --- */
.block-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    opacity: 0.05;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.block-noise-high {
    opacity: 0.07;
}

.block-noise-low {
    opacity: 0.02;
}

/* --- Scanline Overlay --- */
.scanline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.02) 2px,
        rgba(0, 0, 0, 0.02) 4px
    );
    pointer-events: none;
    z-index: 2;
}

/* --- HUD Header --- */
.block-hud-header {
    position: relative;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(42, 138, 128, 0.15);
    z-index: 3;
}

.block-hud-header.prominent {
    padding: 1rem 1.25rem;
}

/* --- HUD Corner Brackets on Blocks --- */
.hud-corner {
    position: absolute;
    width: 8px;
    height: 8px;
}

.hud-corner-tl {
    top: 4px;
    left: 4px;
    border-top: 1.5px solid rgba(42, 138, 128, 0.4);
    border-left: 1.5px solid rgba(42, 138, 128, 0.4);
}

.hud-corner-tr {
    top: 4px;
    right: 4px;
    border-top: 1.5px solid rgba(42, 138, 128, 0.4);
    border-right: 1.5px solid rgba(42, 138, 128, 0.4);
}

.hud-corner-bl {
    bottom: 4px;
    left: 4px;
    border-bottom: 1.5px solid rgba(42, 138, 128, 0.4);
    border-left: 1.5px solid rgba(42, 138, 128, 0.4);
}

.hud-corner-br {
    bottom: 4px;
    right: 4px;
    border-bottom: 1.5px solid rgba(42, 138, 128, 0.4);
    border-right: 1.5px solid rgba(42, 138, 128, 0.4);
}

/* --- HUD Probability Percent --- */
.hud-prob-percent {
    font-family: 'IBM Plex Sans', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--teal-shore);
    white-space: nowrap;
    min-width: 55px;
}

/* --- HUD Progress Bar --- */
.hud-progress-bar {
    flex: 1;
    height: 3px;
    background-color: rgba(42, 138, 128, 0.15);
    border-radius: 1px;
    overflow: hidden;
}

.hud-progress-fill {
    height: 100%;
    background-color: var(--teal-shore);
    border-radius: 1px;
    transition: width 0.5s ease;
}

.featured-fill {
    background-color: var(--sandy-coral);
}

/* --- Block Content --- */
.block-content {
    position: relative;
    padding: 1rem 1.25rem 1.25rem;
    z-index: 3;
}

.block-title {
    font-family: 'Albert Sans', sans-serif;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    font-weight: 600;
    color: var(--deep-tide);
    letter-spacing: 0.01em;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.block-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--ocean-slate);
    font-weight: 400;
}

/* --- Featured Block (Sandy Coral accent) --- */
.module-block.featured {
    border-left: 3px solid var(--sandy-coral);
}

.module-block.featured .hud-prob-percent {
    color: var(--sandy-coral);
}

/* --- Large Blocks (Section 3) --- */
.large-block .block-content {
    padding: 1.25rem 1.5rem 1.5rem;
}

.large-block .block-title {
    font-size: clamp(1.2rem, 2.8vw, 1.6rem);
}

/* ============================================
   CLOSING SECTION
   ============================================ */
.closing-section {
    margin-bottom: 2rem;
}

.closing-block {
    width: 100%;
}

.closing-content {
    text-align: center;
    padding: 2rem 1.5rem 2.5rem;
}

.closing-title {
    font-family: 'Albert Sans', sans-serif;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--deep-tide);
    letter-spacing: 0.01em;
    margin-bottom: 0.75rem;
}

.closing-probability {
    font-family: 'IBM Plex Sans', monospace;
    font-size: 1.3rem;
    color: var(--teal-shore);
    font-variant-numeric: tabular-nums;
    margin-bottom: 1rem;
}

.prob-value-final {
    font-weight: 600;
    color: var(--teal-shore);
    letter-spacing: 0.05em;
}

.closing-accent-line {
    margin: 0 auto;
    width: 40px;
    height: 2px;
    background-color: var(--teal-shore);
}

/* ============================================
   GLITCH ANIMATION
   ============================================ */
@keyframes glitch-slice {
    0% {
        clip-path: inset(0 0 0 0);
        filter: none;
    }
    20% {
        clip-path: inset(30% 0 40% 0);
        filter: hue-rotate(180deg);
    }
    40% {
        clip-path: inset(60% 0 10% 0);
        filter: hue-rotate(180deg);
    }
    60% {
        clip-path: inset(10% 0 70% 0);
        filter: hue-rotate(0deg);
    }
    80% {
        clip-path: inset(50% 0 20% 0);
        filter: none;
    }
    100% {
        clip-path: inset(0 0 0 0);
        filter: none;
    }
}

.module-block.glitching {
    animation: glitch-slice 100ms steps(4) 1;
}

/* ============================================
   PROBABILITY COUNTER ANIMATION (Hero)
   ============================================ */
@keyframes prob-cycle {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.hero-probability-display .prob-value {
    animation: prob-cycle 2s ease-in-out infinite;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .span-2 {
        grid-column: span 1;
    }

    .grid-section-2x2 {
        grid-template-columns: 1fr;
    }

    .hero {
        padding: 3rem 1.5rem;
    }

    .hud-frame {
        padding: 1rem 2rem;
    }

    .container {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .grid-section {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: clamp(1.8rem, 8vw, 2.5rem);
    }
}
