/* ipjosim.com - Speech Monitoring Station */
/* Mid-century instrument dashboard with playful-rounded typography */

/* === CSS Custom Properties === */
:root {
    --buttercream: #FFF8E8;
    --teak-brown: #8B6914;
    --deep-navy: #1A2A44;
    --signal-red: #D94032;
    --retro-teal: #2A8F82;
    --warm-gray: #C4B59A;
    --gauge-amber: #E8A834;
    --soft-umber: #3D2E1A;
    --grid-light: rgba(26, 42, 68, 0.06);
    --grid-heavy: rgba(26, 42, 68, 0.12);
}

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

html {
    height: 100%;
}

body {
    font-family: 'Quicksand', sans-serif;
    font-weight: 500;
    color: var(--deep-navy);
    background-color: var(--buttercream);
    min-height: 100vh;
    overflow: hidden;
    /* Graph-paper grid background */
    background-image:
        repeating-linear-gradient(
            0deg,
            var(--grid-light) 0px,
            var(--grid-light) 1px,
            transparent 1px,
            transparent 48px
        ),
        repeating-linear-gradient(
            90deg,
            var(--grid-light) 0px,
            var(--grid-light) 1px,
            transparent 1px,
            transparent 48px
        ),
        repeating-linear-gradient(
            0deg,
            var(--grid-heavy) 0px,
            var(--grid-heavy) 1px,
            transparent 1px,
            transparent 192px
        ),
        repeating-linear-gradient(
            90deg,
            var(--grid-heavy) 0px,
            var(--grid-heavy) 1px,
            transparent 1px,
            transparent 192px
        );
}

/* === Mobile Status Bar === */
.mobile-status-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(255, 248, 232, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-bottom: 1px solid var(--warm-gray);
}

.mobile-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.mobile-dot-green {
    background: var(--retro-teal);
    animation: pulse-green 3s ease-in-out infinite;
}

.mobile-dot-amber {
    background: var(--gauge-amber);
    animation: pulse-amber 1.8s ease-in-out infinite;
}

.mobile-dot-red {
    background: var(--signal-red);
    animation: pulse-red 0.9s ease-in-out infinite;
}

.mobile-status-label {
    font-family: 'Noto Sans KR', 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--deep-navy);
    margin-left: 6px;
}

/* === Dashboard Grid === */
.dashboard {
    display: grid;
    grid-template-columns: 7fr 5fr;
    grid-template-rows: 45vh 55vh;
    gap: 12px;
    padding: 12px;
    height: 100vh;
    width: 100vw;
    opacity: 0;
    animation: dashboard-fadein 400ms ease-out forwards;
}

@keyframes dashboard-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === Panel Base === */
.panel {
    background: var(--buttercream);
    border: 1px solid var(--warm-gray);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 12px rgba(61, 46, 26, 0.08);
    opacity: 0;
    animation: panel-appear 500ms ease-out forwards;
}

.panel-speech-meter {
    grid-column: 1;
    grid-row: 1;
    animation-delay: 400ms;
}

.panel-tone-dial {
    grid-column: 2;
    grid-row: 1;
    animation-delay: 500ms;
}

.panel-word-cabinet {
    grid-column: 1;
    grid-row: 2;
    animation-delay: 600ms;
}

.panel-broadcast {
    grid-column: 2;
    grid-row: 2;
    animation-delay: 700ms;
}

@keyframes panel-appear {
    from {
        opacity: 0;
        clip-path: inset(50% 50% 50% 50% round 16px);
    }
    to {
        opacity: 1;
        clip-path: inset(0% 0% 0% 0% round 16px);
    }
}

/* === Panel Header === */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--teak-brown);
    border-bottom: 1px solid var(--warm-gray);
}

.panel-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--buttercream);
}

.panel-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--retro-teal);
    box-shadow: 0 0 6px rgba(42, 143, 130, 0.5);
    animation: indicator-pulse 2s ease-in-out infinite;
}

@keyframes indicator-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* === Speech Meter (Top-Left) === */
.gauge-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(100% - 42px);
    padding: 16px;
}

.gauge-svg {
    width: min(70%, 280px);
    height: auto;
    max-height: calc(100% - 20px);
}

.gauge-ring {
    opacity: 0;
    animation: ring-draw 600ms ease-out 800ms forwards;
}

@keyframes ring-draw {
    from {
        stroke-dasharray: 817;
        stroke-dashoffset: 817;
        opacity: 1;
    }
    to {
        stroke-dasharray: 817;
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

.gauge-tick {
    stroke: var(--warm-gray);
    stroke-width: 2;
    opacity: 0;
    animation: tick-appear 100ms ease-out forwards;
}

.gauge-tick:nth-child(1) { animation-delay: 800ms; }
.gauge-tick:nth-child(2) { animation-delay: 830ms; }
.gauge-tick:nth-child(3) { animation-delay: 860ms; }
.gauge-tick:nth-child(4) { animation-delay: 890ms; }
.gauge-tick:nth-child(5) { animation-delay: 920ms; }
.gauge-tick:nth-child(6) { animation-delay: 950ms; }
.gauge-tick:nth-child(7) { animation-delay: 980ms; }
.gauge-tick:nth-child(8) { animation-delay: 1010ms; }
.gauge-tick:nth-child(9) { animation-delay: 1040ms; }
.gauge-tick:nth-child(10) { animation-delay: 1070ms; }
.gauge-tick:nth-child(11) { animation-delay: 1100ms; }
.gauge-tick:nth-child(12) { animation-delay: 1130ms; }

@keyframes tick-appear {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gauge-fill {
    animation: gauge-fill-draw 1200ms ease-out 1200ms forwards;
}

@keyframes gauge-fill-draw {
    to {
        stroke-dashoffset: 188;
    }
}

.gauge-flare, .gauge-flare-secondary {
    transition: opacity 400ms ease-out;
    pointer-events: none;
}

.gauge-container:hover .gauge-flare {
    opacity: 1;
}

.gauge-container:hover .gauge-flare-secondary {
    opacity: 1;
}

.gauge-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.gauge-korean {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--deep-navy);
    opacity: 0;
    transform: translateY(20px);
    animation: text-fadeup 500ms ease-out 1200ms forwards;
}

.gauge-subtitle {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(0.7rem, 1.2vw, 0.95rem);
    color: var(--teak-brown);
    letter-spacing: 0.05em;
    opacity: 0;
    transform: translateY(10px);
    animation: text-fadeup 500ms ease-out 1400ms forwards;
}

@keyframes text-fadeup {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Tone Dial (Top-Right) === */
.tone-indicators {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    height: calc(100% - 42px);
}

.tone-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--buttercream);
    border: 1px solid rgba(196, 181, 154, 0.5);
    border-radius: 12px;
    transition: box-shadow 300ms ease;
}

.tone-card:hover {
    box-shadow: 0 2px 16px rgba(61, 46, 26, 0.12);
}

/* Status Dots */
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-green {
    background: var(--retro-teal);
    animation: pulse-green 3s ease-in-out infinite;
}

.dot-amber {
    background: var(--gauge-amber);
    animation: pulse-amber 1.8s ease-in-out infinite;
}

.dot-red {
    background: var(--signal-red);
    animation: pulse-red 0.9s ease-in-out infinite;
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(42, 143, 130, 0.3);
        transform: scale(1);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 0 6px rgba(42, 143, 130, 0.3);
        transform: scale(1.3);
        opacity: 0.6;
    }
}

@keyframes pulse-amber {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(232, 168, 52, 0.3);
        transform: scale(1);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 0 6px rgba(232, 168, 52, 0.3);
        transform: scale(1.3);
        opacity: 0.6;
    }
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(217, 64, 50, 0.3);
        transform: scale(1);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 0 6px rgba(217, 64, 50, 0.3);
        transform: scale(1.3);
        opacity: 0.6;
    }
}

.tone-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tone-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(0.8rem, 1.3vw, 1rem);
    color: var(--deep-navy);
    letter-spacing: 0.02em;
}

.tone-desc {
    font-family: 'Quicksand', sans-serif;
    font-weight: 500;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    color: var(--warm-gray);
    line-height: 1.4;
}

.tone-gauge-mini {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.tone-gauge-mini svg {
    width: 100%;
    height: 100%;
}

.mini-fill-safe {
    animation: mini-fill-safe-anim 1000ms ease-out 1600ms forwards;
}

.mini-fill-amber {
    animation: mini-fill-amber-anim 1000ms ease-out 1700ms forwards;
}

.mini-fill-red {
    animation: mini-fill-red-anim 1000ms ease-out 1800ms forwards;
}

@keyframes mini-fill-safe-anim {
    to { stroke-dashoffset: 27.1; }
}

@keyframes mini-fill-amber-anim {
    to { stroke-dashoffset: 105.6; }
}

@keyframes mini-fill-red-anim {
    to { stroke-dashoffset: 132.7; }
}

/* === Word Cabinet (Bottom-Left) === */
.cabinet-controls {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px dotted rgba(196, 181, 154, 0.5);
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    width: 48px;
    height: 24px;
    border-radius: 12px;
    background: var(--warm-gray);
    position: relative;
    transition: background-color 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--buttercream);
    box-shadow: 0 1px 3px rgba(61, 46, 26, 0.15);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch input:checked + .toggle-track {
    background: var(--retro-teal);
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(24px);
}

.toggle-label {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--deep-navy);
    letter-spacing: 0.02em;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px 16px;
    height: calc(100% - 42px - 50px);
    align-content: start;
    overflow-y: auto;
    /* Ruled-line background within grid */
    background-image: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 27px,
        rgba(196, 181, 154, 0.3) 27px,
        rgba(196, 181, 154, 0.3) 28px
    );
}

.pill-btn {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    padding: 8px 12px;
    border: none;
    border-radius: 50vh;
    cursor: pointer;
    background: var(--buttercream);
    color: var(--deep-navy);
    border: 1px solid var(--warm-gray);
    box-shadow: 0 1px 4px rgba(61, 46, 26, 0.08);
    transition: transform 250ms ease, box-shadow 250ms ease, background-color 250ms ease;
    opacity: 0;
    animation: pill-fadein 200ms ease-out forwards;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pill-btn:nth-child(1) { animation-delay: 1600ms; }
.pill-btn:nth-child(2) { animation-delay: 1640ms; }
.pill-btn:nth-child(3) { animation-delay: 1680ms; }
.pill-btn:nth-child(4) { animation-delay: 1720ms; }
.pill-btn:nth-child(5) { animation-delay: 1760ms; }
.pill-btn:nth-child(6) { animation-delay: 1800ms; }
.pill-btn:nth-child(7) { animation-delay: 1840ms; }
.pill-btn:nth-child(8) { animation-delay: 1880ms; }
.pill-btn:nth-child(9) { animation-delay: 1920ms; }
.pill-btn:nth-child(10) { animation-delay: 1960ms; }
.pill-btn:nth-child(11) { animation-delay: 2000ms; }
.pill-btn:nth-child(12) { animation-delay: 2040ms; }
.pill-btn:nth-child(13) { animation-delay: 2080ms; }
.pill-btn:nth-child(14) { animation-delay: 2120ms; }
.pill-btn:nth-child(15) { animation-delay: 2160ms; }
.pill-btn:nth-child(16) { animation-delay: 2200ms; }

@keyframes pill-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.pill-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(61, 46, 26, 0.15);
    background-color: var(--gauge-amber);
    color: var(--deep-navy);
}

.pill-safe {
    border-left: 3px solid var(--retro-teal);
}

.pill-caution {
    border-left: 3px solid var(--gauge-amber);
}

.pill-danger {
    border-left: 3px solid var(--signal-red);
}

/* === Broadcast Window (Bottom-Right) === */
.crt-viewport {
    position: relative;
    height: calc(100% - 42px);
    margin: 12px;
    border-radius: 24px;
    background: var(--deep-navy);
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    animation: crt-flicker 200ms ease-out 2000ms forwards;
}

@keyframes crt-flicker {
    0% { opacity: 0; }
    25% { opacity: 0.8; }
    50% { opacity: 1; }
    75% { opacity: 0.8; }
    100% { opacity: 1; }
}

.crt-scanline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.05) 2px,
        rgba(0, 0, 0, 0.05) 4px
    );
    pointer-events: none;
    z-index: 2;
    border-radius: 24px;
}

.broadcast-text {
    padding: 20px 24px;
    height: 100%;
    overflow: hidden;
    position: relative;
    /* Ruled-line background */
    background-image: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 27px,
        rgba(196, 181, 154, 0.08) 27px,
        rgba(196, 181, 154, 0.08) 28px
    );
}

.broadcast-text p {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    line-height: 1.6;
    color: var(--gauge-amber);
    margin: 0;
    padding: 2px 0;
    white-space: nowrap;
}

/* Scrolling animation for broadcast */
.broadcast-text {
    animation: broadcast-scroll 40s linear 2200ms infinite;
}

@keyframes broadcast-scroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

/* === Gauge Breathing Animation (idle) === */
@keyframes gauge-breathe {
    0%, 100% { stroke-dashoffset: 188; }
    50% { stroke-dashoffset: 203; }
}

.gauge-fill.breathing {
    animation: gauge-breathe 6s ease-in-out infinite;
}

/* === Responsive: Mobile === */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
        background-image:
            repeating-linear-gradient(
                0deg,
                var(--grid-light) 0px,
                var(--grid-light) 1px,
                transparent 1px,
                transparent 32px
            ),
            repeating-linear-gradient(
                90deg,
                var(--grid-light) 0px,
                var(--grid-light) 1px,
                transparent 1px,
                transparent 32px
            ),
            repeating-linear-gradient(
                0deg,
                var(--grid-heavy) 0px,
                var(--grid-heavy) 1px,
                transparent 1px,
                transparent 128px
            ),
            repeating-linear-gradient(
                90deg,
                var(--grid-heavy) 0px,
                var(--grid-heavy) 1px,
                transparent 1px,
                transparent 128px
            );
    }

    .mobile-status-bar {
        display: flex;
    }

    .dashboard {
        display: flex;
        flex-direction: column;
        height: auto;
        padding: 52px 16px 16px;
        gap: 12px;
    }

    .panel {
        min-height: 85vh;
    }

    .panel-speech-meter {
        min-height: 70vh;
    }

    .gauge-svg {
        width: 70vw;
        max-width: 300px;
    }

    .word-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .cabinet-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .tone-card {
        padding: 10px 12px;
    }
}