@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-main: #090d16;
    --bg-card: #111726;
    --bg-border: #1e293b;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-border: #0284c7;
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.app-layout {
    display: flex;
    max-width: 1280px;
    margin: 0 auto;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--bg-border);
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: 2.5rem;
}

.brand-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: block;
    margin-bottom: 0.75rem;
}

.lang-switch {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-card);
    padding: 0.25rem;
    border-radius: 6px;
    border: 1px solid var(--bg-border);
}

.lang-btn {
    flex: 1;
    text-align: center;
    padding: 0.2rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 4px;
}

.lang-btn.active {
    background: var(--accent-border);
    color: var(--text-primary);
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toc-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.toc-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Content Area */
.content-area {
    flex-grow: 1;
    padding: 3rem 4rem;
    max-width: 900px;
}

.doc-header {
    border-bottom: 1px solid var(--bg-border);
    padding-bottom: 2rem;
    margin-bottom: 3rem;
}

.doc-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.doc-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0.75rem 0;
}

.lead {
    color: var(--text-muted);
    font-size: 1.05rem;
}

.doc-section {
    margin-bottom: 3.5rem;
}

.doc-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.section-subtitle {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 1.5rem 0 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.spec-list {
    list-style: none;
    margin-top: 1rem;
}

.spec-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--bg-border);
    font-size: 0.95rem;
}

/* Code Banner & Highlighting */
.code-banner pre, pre code {
    font-family: var(--font-mono) !important;
    font-size: 0.85rem !important;
    border-radius: 6px;
}

pre {
    background: var(--bg-card) !important;
    border: 1px solid var(--bg-border);
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
}

code:not(pre code) {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-card);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--bg-border);
    color: var(--accent-blue);
}

/* Technical Table */
.table-container {
    border: 1px solid var(--bg-border);
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem 0;
}

.tech-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
    min-width: 500px;
}

.tech-table th {
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--bg-border);
}

.tech-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bg-border);
    color: var(--text-muted);
}

.tech-table tr:last-child td {
    border-bottom: none;
}

/* Workflow Steps */
.workflow-steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.workflow-steps li {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    padding: 1rem;
    border-radius: 6px;
}

.step-num {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-blue);
    font-weight: 700;
}

.step-content {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.step-content strong {
    font-size: 0.95rem;
}

/* Content-area variant for pages with no sidebar (e.g. interactive labs).
   The 900px cap on .content-area exists because it normally sits next
   to a 280px sidebar inside the same 1280px .app-layout frame. Drop the
   cap here so a sidebar-less page fills that same frame instead of
   leaving the sidebar's space empty. .app-layout itself is untouched,
   so the outer frame always matches starter-en.php exactly. */
.content-area--full {
    flex: 1 1 0;
    max-width: 100% !important;
    padding: 2rem 1.5rem !important;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* 1. Laptop / Small Desktop (Max-width: 1024px) */
/* 1. Laptop / Small Desktop (Max-width: 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
        padding: 1.5rem 1rem;
    }

    .content-area {
        padding: 2.5rem 2.5rem;
    }
}

/* 2. Tablet & Mobile Layout Switch (Max-width: 868px) */
@media (max-width: 868px) {
    html, body {
        overflow-x: hidden; /* 전체 페이지 좌우 스크롤 금지 */
    }

    .app-layout { 
        flex-direction: column; 
        width: 100%;
        max-width: 100vw;
    }

    .sidebar { 
        width: 100%; 
        height: auto; 
        position: relative; 
        border-right: none;
        border-bottom: 1px solid var(--bg-border);
        padding: 1.25rem;
    }

    .sidebar-header {
        margin-bottom: 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .brand-title {
        margin-bottom: 0;
    }

    .lang-switch {
        width: 110px;
    }

    .toc-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .toc-nav a {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
        background: var(--bg-card);
        border: 1px solid var(--bg-border);
    }

    .content-area { 
        padding: 1.5rem 1rem; 
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .doc-header {
        margin-bottom: 2rem;
        padding-bottom: 1.5rem;
    }

    .doc-header h1 {
        font-size: 1.6rem;
        word-break: keep-all; /* 제목 단어 단위 줄바꿈 */
    }

    .lead {
        font-size: 0.95rem;
    }

    .doc-section {
        margin-bottom: 2.5rem;
    }

    /* 코드 블록 스크롤 방지 및 안전 처리 */
    pre {
        max-width: 100%;
        overflow-x: auto;
        white-space: pre-wrap; /* 긴 모바일 화면에서 자동 줄바꿈 */
        word-break: break-all;
    }

    /* 테이블 영역 화면 벗어남 방지 */
    .table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tech-table {
        min-width: 100%;
    }
}

/* 3. Small Mobile Devices (Max-width: 480px) */
@media (max-width: 480px) {
    .sidebar {
        padding: 1rem;
    }

    .content-area {
        padding: 1.25rem 0.75rem;
    }

    .doc-header h1 {
        font-size: 1.35rem;
    }

    .workflow-steps li {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.85rem;
    }

    .tech-table th, 
    .tech-table td {
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }

    pre {
        padding: 0.75rem;
        font-size: 0.8rem !important;
    }
}

