/* hangul.dev - Swiss Documentation */
/* Palette: Paper White #ffffff, Off-White #fafaf8, Near Black #1a1a1a, Dark Gray #2a2a2a, Signal Blue #2563eb, Warm Code #f0ece4, Dark Surface #1e1e2e, Code Red #c0392b, Soft Rule #e0dcd4 */

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

html {
    scroll-behavior: smooth;
}

body {
    background: #ffffff;
    color: #2a2a2a;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.7;
}

/* ===== TOP BAR ===== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #e0dcd4;
    z-index: 100;
    display: flex;
    align-items: center;
}

.top-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 24px;
}

.site-identity {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 20px;
}

.site-name {
    color: #1a1a1a;
}

.site-tld {
    color: #2563eb;
}

.search-wrapper {
    max-width: 240px;
    width: 100%;
}

.search-input {
    width: 100%;
    height: 32px;
    padding: 0 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    border: 1px solid #e0dcd4;
    border-radius: 4px;
    background: #fafaf8;
    color: #2a2a2a;
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: #2563eb;
}

/* ===== LAYOUT ===== */
.layout {
    display: flex;
    padding-top: 48px;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    width: 280px;
    height: calc(100vh - 48px);
    background: #fafaf8;
    border-right: 1px solid #e0dcd4;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-inner {
    padding: 24px 0;
}

.nav-group {
    margin-bottom: 24px;
}

.nav-category {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #8a8a88;
    padding: 0 24px;
    margin-bottom: 8px;
}

.nav-link {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #2a2a2a;
    text-decoration: none;
    padding: 4px 24px;
    border-left: 3px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover {
    color: #2563eb;
}

.nav-link.active {
    font-weight: 600;
    color: #2563eb;
    border-left-color: #2563eb;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 280px;
    flex: 1;
    opacity: 0;
    animation: fadeInMain 0.3s ease-out forwards;
}

@keyframes fadeInMain {
    to { opacity: 1; }
}

.content-inner {
    max-width: 720px;
    padding: 48px 48px 120px 48px;
    /* Baseline grid watermark */
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(240, 236, 228, 0.2) 0px,
        rgba(240, 236, 228, 0.2) 1px,
        transparent 1px,
        transparent 24px
    );
    background-size: 100% 24px;
}

/* ===== SECTIONS ===== */
.doc-section {
    margin-bottom: 72px;
}

.doc-section h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 28px;
    line-height: 32px;
    color: #1a1a1a;
    letter-spacing: -0.01em;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0dcd4;
}

.doc-section h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 20px;
    line-height: 24px;
    color: #1a1a1a;
    letter-spacing: -0.01em;
    margin-top: 36px;
    margin-bottom: 16px;
}

.doc-section h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 24px;
    color: #1a1a1a;
    margin-top: 24px;
    margin-bottom: 8px;
}

.doc-section p {
    margin-bottom: 16px;
}

/* Inline code */
code {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    background: #f0ece4;
    color: #c0392b;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Info box */
.info-box {
    background: #f0ece4;
    border-left: 3px solid #2563eb;
    padding: 16px 20px;
    margin: 24px 0;
    border-radius: 0 4px 4px 0;
    line-height: 1.6;
}

.info-box strong {
    color: #1a1a1a;
}

/* ===== CHARACTER SPECIMENS ===== */
.char-specimen-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 24px;
}

.char-specimen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 24px;
    width: 48px;
    height: 48px;
    border: 1px solid #e0dcd4;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}

.char-specimen:hover {
    border-color: #2563eb;
}

.char-specimen.copied {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* ===== DATA TABLES ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 24px;
    font-size: 14px;
}

.data-table th {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #8a8a88;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid #e0dcd4;
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e0dcd4;
    vertical-align: top;
}

.data-table tbody tr:nth-child(even) {
    background: #fafaf8;
}

.data-table td code {
    font-size: 13px;
}

/* ===== CODE BLOCKS ===== */
.code-block {
    background: #1e1e2e;
    border-radius: 6px;
    margin: 16px 0 24px;
    overflow: hidden;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.code-lang {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #6c7086;
}

.code-tabs {
    display: flex;
    gap: 0;
}

.code-tab {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #6c7086;
    background: none;
    border: none;
    padding: 4px 12px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.code-tab:hover {
    color: #cdd6f4;
}

.code-tab.active {
    color: #cdd6f4;
    font-weight: 700;
    border-bottom-color: #2563eb;
}

.copy-btn {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 400;
    color: #6c7086;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    padding: 2px 10px;
    height: 28px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    opacity: 0;
    transition: opacity 0.15s;
}

.code-block:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    color: #cdd6f4;
    border-color: rgba(255, 255, 255, 0.2);
}

.copy-btn.copied {
    color: #2563eb;
}

.code-block pre {
    padding: 16px 24px;
    overflow-x: auto;
    margin: 0;
}

.code-block code {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #cdd6f4;
    background: none;
    padding: 0;
    border-radius: 0;
}

.code-panel {
    margin: 0;
}

.code-panel:not(.active) {
    display: none;
}

/* ===== UNICODE GRIDS ===== */
.unicode-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 12px 0 24px;
}

.unicode-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 1px solid #e0dcd4;
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.unicode-cell:hover {
    border-color: #2563eb;
    border-width: 2px;
}

.unicode-cell .cell-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 16px;
    color: #1a1a1a;
}

.unicode-cell .cell-code {
    font-family: 'Fira Code', monospace;
    font-size: 9px;
    color: #8a8a88;
    margin-top: 2px;
}

.unicode-cell.selected {
    border-color: #2563eb;
    border-width: 2px;
    background: rgba(37, 99, 235, 0.05);
}

/* ===== DECOMPOSITION DIAGRAMS ===== */
.decomposition-diagram {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: #fafaf8;
    border: 1px solid #e0dcd4;
    border-radius: 6px;
    margin: 16px 0 24px;
    flex-wrap: wrap;
}

.decomposition-diagram.small {
    padding: 12px;
    margin: 8px 0;
    gap: 8px;
}

.decomp-result,
.decomp-component {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid #e0dcd4;
    border-radius: 4px;
    background: #ffffff;
}

.decomp-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 24px;
    color: #1a1a1a;
}

.decomp-char.large {
    font-size: 36px;
}

.decomp-code {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    color: #8a8a88;
    margin-top: 4px;
}

.decomp-label {
    font-family: 'Fira Code', monospace;
    font-size: 11px;
    color: #6c7086;
    margin-top: 4px;
}

.decomp-arrow {
    font-size: 20px;
    color: #8a8a88;
}

.decomp-plus {
    font-family: 'Fira Code', monospace;
    font-size: 16px;
    color: #8a8a88;
}

/* ===== INTERACTIVE DECOMPOSE ===== */
.interactive-decompose {
    margin: 16px 0 24px;
}

.input-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.decompose-input {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 24px;
    width: 80px;
    height: 48px;
    text-align: center;
    border: 2px solid #e0dcd4;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.15s;
}

.decompose-input:focus {
    border-color: #2563eb;
}

/* ===== UNICODE EXPLORER ===== */
.explorer-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.explorer-search {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 18px;
    width: 80px;
    height: 40px;
    text-align: center;
    border: 2px solid #e0dcd4;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.15s;
}

.explorer-search:focus {
    border-color: #2563eb;
}

.explorer-info {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: #8a8a88;
}

.explorer-grid-container {
    height: 400px;
    overflow-y: auto;
    border: 1px solid #e0dcd4;
    border-radius: 4px;
    margin-bottom: 16px;
    position: relative;
}

.explorer-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    padding: 4px;
}

.explorer-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 16px;
    color: #1a1a1a;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 2px;
    transition: border-color 0.1s, background 0.1s;
}

.explorer-cell:hover {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.05);
}

.explorer-cell.selected {
    border-color: #2563eb;
    border-width: 2px;
    background: rgba(37, 99, 235, 0.08);
}

.explorer-cell.highlight {
    background: rgba(37, 99, 235, 0.15);
    border-color: #2563eb;
}

.explorer-detail {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px;
    background: #fafaf8;
    border: 1px solid #e0dcd4;
    border-radius: 6px;
}

.detail-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 48px;
    color: #1a1a1a;
    line-height: 1;
}

.detail-info {
    flex: 1;
}

.detail-code {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    color: #2563eb;
    display: block;
    margin-bottom: 4px;
}

.detail-name {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #6c7086;
    display: block;
    margin-bottom: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .content-inner {
        padding: 32px 20px 80px;
    }
}

@media (max-width: 600px) {
    .decomposition-diagram {
        padding: 16px;
        gap: 8px;
    }

    .explorer-grid-container {
        height: 300px;
    }

    .explorer-cell {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}
