/* ============================================
   hwagryul.com - Neomorphic Probability Calculator
   Colors: #E8E4E0, #D4D0CC, #FAFAF8, #3D3D4A, #5A5A6E, #1A1A24, #6BCC8A, #E8E8F0
   Fonts: DM Sans (display), Lexend (body), JetBrains Mono (readouts)
   ============================================ */

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

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

body {
    font-family: 'Lexend', sans-serif;
    font-weight: 400;
    color: #3D3D4A;
    background-color: #E8E4E0;
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Surface Grain Texture --- */
#surface-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Device Frame --- */
#device-frame {
    max-width: 640px;
    margin: 0 auto;
    padding: 48px 24px 80px;
    opacity: 0;
    animation: fadeInDevice 0.8s ease-out 0.5s forwards;
}

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

/* --- Device Panels --- */
.device-panel {
    background: #E8E4E0;
    border-radius: 24px;
    box-shadow:
        8px 8px 16px rgba(0, 0, 0, 0.1),
        -8px -8px 16px rgba(255, 255, 255, 0.8);
    margin-bottom: 48px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.device-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.panel-inner {
    padding: 40px 32px;
}

/* --- Panel Headings --- */
.panel-heading {
    font-family: 'DM Sans', sans-serif;
    font-size: 36px;
    font-weight: 700;
    line-height: 1.15;
    color: #3D3D4A;
    margin-bottom: 28px;
}

.spec-heading {
    font-size: 22px;
}

/* --- Brand Plate --- */
#brand-plate {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#brand-plate .panel-inner {
    width: 100%;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.embossed-text {
    font-family: 'DM Sans', sans-serif;
    font-size: 48px;
    font-weight: 700;
    color: #3D3D4A;
    text-shadow:
        1px 1px 2px rgba(255, 255, 255, 0.8),
        -1px -1px 2px rgba(0, 0, 0, 0.1);
    opacity: 0;
    animation: fadeInBrand 0.6s ease-out 1.3s forwards;
}

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

#brand-subtitle {
    font-family: 'Lexend', sans-serif;
    font-size: 16px;
    color: #5A5A6E;
    opacity: 0;
    animation: fadeInBrand 0.6s ease-out 1.6s forwards;
}

/* --- Indicator Light --- */
.indicator-light {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle, #6BCC8A 0%, transparent 70%);
    box-shadow: 0 0 4px rgba(107, 204, 138, 0.5);
    opacity: 0;
    animation: fadeInBrand 0.4s ease-out 1.9s forwards, pulseLight 2s ease-in-out 2.3s infinite;
}

@keyframes pulseLight {
    0%, 100% {
        box-shadow: 0 0 4px rgba(107, 204, 138, 0.5);
    }
    50% {
        box-shadow: 0 0 12px rgba(107, 204, 138, 0.7);
    }
}

/* --- Inset Displays --- */
.inset-display {
    background: #1A1A24;
    border-radius: 12px;
    box-shadow:
        inset 4px 4px 12px rgba(0, 0, 0, 0.15),
        inset -4px -4px 12px rgba(255, 255, 255, 0.3);
    padding: 16px 20px;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inset-display.large {
    min-height: 80px;
    padding: 24px 20px;
}

.inset-display.small {
    min-height: 40px;
    padding: 10px 14px;
}

.readout {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 500;
    line-height: 1.2;
    color: #E8E8F0;
    text-shadow: 0 0 8px rgba(107, 204, 138, 0.3);
    letter-spacing: 0.02em;
}

.inset-display.small .readout {
    font-size: 18px;
}

.inset-display.large .readout {
    font-size: 28px;
}

/* --- Display Groups --- */
.display-group {
    margin-bottom: 24px;
}

.display-group:last-child {
    margin-bottom: 0;
}

.display-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #5A5A6E;
    display: block;
    margin-bottom: 8px;
    line-height: 1.3;
}

/* --- Neomorphic Buttons --- */
.neo-button {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    color: #3D3D4A;
    background: #E8E4E0;
    border: none;
    border-radius: 12px;
    padding: 14px 28px;
    cursor: pointer;
    box-shadow:
        4px 4px 8px rgba(0, 0, 0, 0.12),
        -4px -4px 8px rgba(255, 255, 255, 0.9);
    transition:
        box-shadow 0.15s ease,
        transform 0.15s ease;
    user-select: none;
}

.neo-button:hover {
    box-shadow:
        2px 2px 4px rgba(0, 0, 0, 0.12),
        -2px -2px 4px rgba(255, 255, 255, 0.9);
    transform: translate(1px, 1px);
}

.neo-button:active {
    box-shadow:
        inset 4px 4px 8px rgba(0, 0, 0, 0.12),
        inset -4px -4px 8px rgba(255, 255, 255, 0.5);
    transform: translate(2px, 2px);
}

.neo-button.secondary {
    font-size: 13px;
    padding: 12px 20px;
    color: #5A5A6E;
}

.neo-button.settling {
    animation: settleButton 0.3s ease-out forwards;
}

@keyframes settleButton {
    from {
        box-shadow:
            12px 12px 20px rgba(0, 0, 0, 0.12),
            -12px -12px 20px rgba(255, 255, 255, 0.9);
    }
    to {
        box-shadow:
            4px 4px 8px rgba(0, 0, 0, 0.12),
            -4px -4px 8px rgba(255, 255, 255, 0.9);
    }
}

/* --- Button Row --- */
.button-row {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* --- Control Groups --- */
.control-group {
    margin-bottom: 40px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #3D3D4A;
    display: block;
    margin-bottom: 6px;
}

.control-description {
    font-family: 'Lexend', sans-serif;
    font-size: 14px;
    color: #5A5A6E;
    line-height: 1.5;
    margin-bottom: 4px;
}

/* --- Slider --- */
.slider-container {
    padding: 20px 0 8px;
}

.slider-track {
    position: relative;
    height: 8px;
    border-radius: 4px;
    background: #D4D0CC;
    box-shadow:
        inset 2px 2px 4px rgba(0, 0, 0, 0.1),
        inset -2px -2px 4px rgba(255, 255, 255, 0.5);
    cursor: pointer;
}

.slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #6BCC8A, #E8E4E0);
    width: 50%;
    pointer-events: none;
    transition: width 0.05s linear;
}

.slider-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #E8E4E0;
    box-shadow:
        4px 4px 8px rgba(0, 0, 0, 0.12),
        -4px -4px 8px rgba(255, 255, 255, 0.9);
    transform: translate(-50%, -50%);
    cursor: grab;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
    z-index: 2;
}

.slider-thumb:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow:
        6px 6px 12px rgba(0, 0, 0, 0.12),
        -6px -6px 12px rgba(255, 255, 255, 0.9);
}

.slider-thumb.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: #5A5A6E;
}

/* --- Compound Events --- */
.compound-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.compound-input {
    flex: 1;
    min-width: 80px;
}

.compound-operator {
    font-family: 'DM Sans', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #5A5A6E;
    padding-bottom: 10px;
}

.compound-result {
    flex: 1;
    min-width: 90px;
}

.input-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #5A5A6E;
    display: block;
    margin-bottom: 6px;
}

.neo-input-wrap {
    display: flex;
    align-items: center;
    background: #E8E4E0;
    border-radius: 10px;
    box-shadow:
        inset 3px 3px 6px rgba(0, 0, 0, 0.1),
        inset -3px -3px 6px rgba(255, 255, 255, 0.7);
    padding: 8px 12px;
}

.neo-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: #3D3D4A;
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    -moz-appearance: textfield;
}

.neo-input::-webkit-outer-spin-button,
.neo-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-unit {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    color: #5A5A6E;
    margin-left: 4px;
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.stat-cell {
    text-align: center;
}

.stat-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #5A5A6E;
    display: block;
    margin-top: 8px;
}

/* --- Specification Plate --- */
.spec-grid {
    margin-bottom: 28px;
}

.spec-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(90, 90, 110, 0.1);
}

.spec-row:last-child {
    border-bottom: none;
}

.spec-key {
    font-family: 'Lexend', sans-serif;
    font-size: 13px;
    color: #5A5A6E;
    line-height: 1.5;
}

.spec-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #3D3D4A;
    line-height: 1.5;
}

.spec-footer {
    font-family: 'Lexend', sans-serif;
    font-size: 13px;
    color: #5A5A6E;
    text-align: center;
    line-height: 1.6;
    padding-top: 16px;
    border-top: 1px solid rgba(90, 90, 110, 0.1);
}

/* --- Scramble animation class --- */
.readout.scrambling {
    animation: scrambleGlow 0.3s ease-in-out;
}

@keyframes scrambleGlow {
    0% { text-shadow: 0 0 8px rgba(107, 204, 138, 0.3); }
    50% { text-shadow: 0 0 16px rgba(107, 204, 138, 0.6); }
    100% { text-shadow: 0 0 8px rgba(107, 204, 138, 0.3); }
}

/* --- Responsive --- */
@media (max-width: 600px) {
    #device-frame {
        padding: 24px 12px 60px;
    }

    .panel-inner {
        padding: 28px 20px;
    }

    .embossed-text {
        font-size: 36px;
    }

    .panel-heading {
        font-size: 28px;
    }

    .readout {
        font-size: 18px;
    }

    .inset-display.large .readout {
        font-size: 22px;
    }

    .compound-row {
        flex-direction: column;
        align-items: stretch;
    }

    .compound-operator {
        text-align: center;
        padding-bottom: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .button-row {
        flex-direction: column;
    }

    .neo-button {
        width: 100%;
        text-align: center;
    }
}
