/* ============================================
   hangul.day — Retro-Futuristic Neomorphic Dashboard
   Colors: #E0D8D0, #B8B0A8, #F8F4F0, #E8734A, #4A8E8C, #3A3530, #D4A060
   Fonts: Noto Sans KR, Chakra Petch, Fira Code
   ============================================ */

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

:root {
    --surface: #E0D8D0;
    --shadow-dark: #B8B0A8;
    --shadow-light: #F8F4F0;
    --accent-orange: #E8734A;
    --accent-teal: #4A8E8C;
    --panel-dark: #3A3530;
    --text-primary: #3A3530;
    --isometric-gold: #D4A060;
    --neo-outer: 6px 6px 14px #B8B0A8, -6px -6px 14px #F8F4F0;
    --neo-inner: inset 4px 4px 10px #B8B0A8, inset -4px -4px 10px #F8F4F0;
    --neo-subtle: 3px 3px 8px #B8B0A8, -3px -3px 8px #F8F4F0;
    --radius: 16px;
    --radius-sm: 10px;
    --transition-fast: 200ms ease;
    --transition-med: 400ms ease;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 400;
    font-size: clamp(13px, 0.9vw, 15px);
    letter-spacing: 0.04em;
    line-height: 1.5;
}

/* ============================================
   STATUS BAR
   ============================================ */

#status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--surface);
    box-shadow: var(--neo-outer);
    opacity: 0;
    animation: fadeSlideDown 600ms ease 200ms forwards;
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#status-logo {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.08em;
    color: var(--accent-orange);
    text-transform: lowercase;
    white-space: nowrap;
}

#status-selector {
    display: flex;
    gap: 4px;
    align-items: center;
}

.selector-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--neo-subtle);
    color: var(--text-primary);
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.selector-btn:hover {
    transform: scale(1.05);
}

.selector-btn.active {
    box-shadow: var(--neo-inner);
    color: var(--accent-orange);
}

#status-mode {
    display: flex;
    align-items: center;
}

#mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    background: var(--surface);
    box-shadow: var(--neo-subtle);
    color: var(--text-primary);
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
}

#mode-toggle:hover {
    box-shadow: var(--neo-inner);
}

.mode-label {
    text-transform: uppercase;
}

/* ============================================
   APP LAYOUT
   ============================================ */

#app-layout {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
}

/* ============================================
   SIDEBAR
   ============================================ */

#sidebar {
    width: 240px;
    min-width: 240px;
    height: 100%;
    overflow-y: auto;
    padding: 16px 12px;
    background: var(--surface);
    box-shadow: 4px 0 14px rgba(184, 176, 168, 0.4);
    display: flex;
    flex-direction: column;
    gap: 20px;
    opacity: 0;
    animation: fadeSlideRight 600ms ease 400ms forwards;
}

@keyframes fadeSlideRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scrollbar styling for sidebar */
#sidebar::-webkit-scrollbar {
    width: 4px;
}
#sidebar::-webkit-scrollbar-track {
    background: transparent;
}
#sidebar::-webkit-scrollbar-thumb {
    background: var(--shadow-dark);
    border-radius: 2px;
}

.sidebar-label {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-teal);
    margin-bottom: 10px;
    padding-left: 4px;
}

.jamo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.jamo-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--neo-outer);
    color: var(--text-primary);
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
    transition: box-shadow var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
    opacity: 0;
    transform: scale(0.8);
}

.jamo-btn.visible {
    opacity: 1;
    transform: scale(1);
}

.jamo-btn:hover {
    transform: scale(1.08);
    color: var(--accent-orange);
}

.jamo-btn.active {
    box-shadow: var(--neo-inner);
    color: var(--accent-orange);
    transform: scale(0.96);
}

.jamo-btn.consonant {
    border-top: 2px solid transparent;
}

.jamo-btn.consonant[data-place="bilabial"] {
    border-top-color: var(--accent-orange);
}
.jamo-btn.consonant[data-place="alveolar"] {
    border-top-color: var(--accent-teal);
}
.jamo-btn.consonant[data-place="palatal"] {
    border-top-color: var(--isometric-gold);
}
.jamo-btn.consonant[data-place="velar"] {
    border-top-color: #9A7BBF;
}
.jamo-btn.consonant[data-place="glottal"] {
    border-top-color: var(--shadow-dark);
}

.jamo-btn.vowel[data-shape="vertical"] {
    border-top: 2px solid var(--accent-teal);
}
.jamo-btn.vowel[data-shape="horizontal"] {
    border-top: 2px solid var(--isometric-gold);
}
.jamo-btn.vowel[data-shape="compound"] {
    border-top: 2px solid var(--accent-orange);
}

/* ============================================
   MAIN PANEL
   ============================================ */

#main-panel {
    flex: 1;
    display: grid;
    grid-template-columns: 60% 40%;
    grid-template-rows: 50% 50%;
    gap: 16px;
    padding: 16px;
    overflow: hidden;
}

/* ============================================
   DASHBOARD MODULE (shared)
   ============================================ */

.dashboard-module {
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--neo-outer);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    animation: moduleAppear 800ms ease forwards;
}

.dashboard-module:nth-child(1) { animation-delay: 600ms; }
.dashboard-module:nth-child(2) { animation-delay: 750ms; }
.dashboard-module:nth-child(3) { animation-delay: 900ms; }
.dashboard-module:nth-child(4) { animation-delay: 1050ms; }

@keyframes moduleAppear {
    0% {
        opacity: 0;
        box-shadow: none;
        transform: scale(0.98);
    }
    50% {
        opacity: 1;
        box-shadow: none;
        transform: scale(1);
    }
    100% {
        opacity: 1;
        box-shadow: 6px 6px 14px #B8B0A8, -6px -6px 14px #F8F4F0;
        transform: scale(1);
    }
}

.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 3px solid var(--accent-orange);
    border-bottom: 1px solid rgba(184, 176, 168, 0.3);
    flex-shrink: 0;
}

.module-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.module-meta {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    color: var(--accent-teal);
}

.module-body {
    flex: 1;
    padding: 16px;
    overflow: hidden;
    position: relative;
}

/* ============================================
   MODULE: Character Display
   ============================================ */

#module-character {
    grid-column: 1;
    grid-row: 1;
}

#char-display-area {
    width: 100%;
    height: calc(100% - 30px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#char-stroke-svg {
    position: absolute;
    width: 60%;
    height: 80%;
    z-index: 2;
    pointer-events: none;
}

#char-stroke-svg path {
    fill: none;
    stroke: var(--accent-orange);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 6px rgba(232, 115, 74, 0.4));
}

#char-large-display {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: clamp(60px, 10vw, 120px);
    color: var(--text-primary);
    opacity: 0.15;
    z-index: 1;
    transition: opacity 150ms ease;
    user-select: none;
}

#char-large-display.faded {
    opacity: 0;
}

#char-info-strip {
    display: flex;
    gap: 10px;
    justify-content: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.info-badge {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--surface);
    box-shadow: var(--neo-subtle);
    color: var(--accent-teal);
    white-space: nowrap;
}

/* ============================================
   MODULE: Composition Panel
   ============================================ */

#module-composition {
    grid-column: 2;
    grid-row: 1;
}

#composition-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    align-items: center;
    height: 100%;
    overflow-y: auto;
}

/* Isometric syllable block */
.iso-block {
    width: 80px;
    height: 90px;
    position: relative;
    perspective: 300px;
    cursor: pointer;
    transition: transform var(--transition-med);
}

.iso-block:hover {
    transform: scale(1.1);
}

.iso-cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-20deg) rotateY(30deg);
    transition: transform var(--transition-med);
}

.iso-face {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    border: 1.5px solid var(--text-primary);
    border-radius: 4px;
}

.iso-face-top {
    width: 60px;
    height: 40px;
    background: var(--isometric-gold);
    font-size: 20px;
    color: var(--panel-dark);
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.iso-face-right {
    width: 60px;
    height: 40px;
    background: rgba(212, 160, 96, 0.7);
    font-size: 18px;
    color: var(--panel-dark);
    top: 44px;
    right: 0;
}

.iso-face-bottom {
    width: 60px;
    height: 26px;
    background: rgba(212, 160, 96, 0.4);
    font-size: 14px;
    color: var(--panel-dark);
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.iso-syllable-label {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    color: var(--accent-teal);
    white-space: nowrap;
}

/* ============================================
   MODULE: Phonetics
   ============================================ */

#module-phonetics {
    grid-column: 1;
    grid-row: 2;
}

#module-phonetics .module-body {
    padding: 12px 16px;
}

#phonetics-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
    height: 100%;
}

#phonetics-ipa-display {
    grid-column: 1;
    grid-row: 1;
}

#phonetics-place {
    grid-column: 2;
    grid-row: 1;
}

#phonetics-manner {
    grid-column: 1;
    grid-row: 2;
}

.phonetics-label {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--shadow-dark);
    margin-bottom: 4px;
}

.phonetics-value {
    font-family: 'Fira Code', monospace;
    font-size: 18px;
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--neo-inner);
    display: inline-block;
}

#mouth-diagram {
    grid-column: 2;
    grid-row: 2 / 4;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mouth-svg {
    width: 100%;
    max-width: 200px;
    height: auto;
}

#waveform-container {
    grid-column: 1;
    grid-row: 3;
}

#waveform-canvas {
    width: 100%;
    height: 50px;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--neo-inner);
}

/* ============================================
   MODULE: History
   ============================================ */

#module-history {
    grid-column: 2;
    grid-row: 2;
}

#history-timeline {
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
    perspective: 600px;
    padding: 10px 20px;
}

#history-timeline::-webkit-scrollbar {
    height: 4px;
}
#history-timeline::-webkit-scrollbar-track {
    background: transparent;
}
#history-timeline::-webkit-scrollbar-thumb {
    background: var(--shadow-dark);
    border-radius: 2px;
}

.history-entry {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    text-align: center;
    transition: transform var(--transition-med), opacity var(--transition-med);
    cursor: default;
}

.history-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 40px;
    color: var(--text-primary);
    transition: font-size var(--transition-med), opacity var(--transition-med), color var(--transition-med);
}

.history-entry.distant .history-char {
    font-size: 24px;
    opacity: 0.35;
    color: var(--shadow-dark);
}

.history-entry.near .history-char {
    font-size: 32px;
    opacity: 0.6;
}

.history-entry.current .history-char {
    font-size: 48px;
    opacity: 1;
    color: var(--accent-orange);
}

.history-year {
    font-family: 'Fira Code', monospace;
    font-size: 10px;
    color: var(--accent-teal);
    margin-top: 6px;
}

.history-label {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 9px;
    letter-spacing: 0.06em;
    color: var(--shadow-dark);
    margin-top: 2px;
    white-space: nowrap;
}

/* ============================================
   TRANSITIONS FOR MODULE UPDATES
   ============================================ */

.module-fade-out {
    opacity: 0;
    transition: opacity 150ms ease;
}

.module-fade-in {
    opacity: 1;
    transition: opacity 150ms ease;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    #sidebar {
        width: 180px;
        min-width: 180px;
    }
    .jamo-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .jamo-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    #main-panel {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 10px;
    }
}

@media (max-width: 768px) {
    #status-selector {
        display: none;
    }
    #sidebar {
        width: 60px;
        min-width: 60px;
        padding: 10px 6px;
    }
    .sidebar-label {
        font-size: 8px;
        letter-spacing: 0.05em;
        text-align: center;
        padding: 0;
    }
    .jamo-grid {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .jamo-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
        margin: 0 auto;
    }
    #main-panel {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }
    #module-character { grid-column: 1; grid-row: 1; }
    #module-composition { grid-column: 1; grid-row: 2; }
    #module-phonetics { grid-column: 1; grid-row: 3; }
    #module-history { grid-column: 1; grid-row: 4; }
}
