/* ===== Theme Variables ===== */
:root {
    --theme-bg: #ffffff;
    --theme-text: #111111;
    --theme-card: #f5f5f5;
    --theme-border: #ddd;
}

/* Dark Theme (Default) */
[data-theme="dark"] {
    --theme-bg: #000000;
    --theme-text: #e8e8e8;
    --theme-card: #1e1e1e;
    --theme-border: #333;
}

/* ===== Theme Global ===== */

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

body {
    font-family:
        "Pretendard Variable",
        "Pretendard",
        system-ui,
        -apple-system,        /* macOS / iOS */
        BlinkMacSystemFont,   /* Chrome on macOS */
        "Segoe UI",           /* Windows */
        Roboto,               /* Android */
        "Noto Sans KR",
        "Apple SD Gothic Neo",
        Arial,                /* Fallback */
        sans-serif;           /* 최종 대체 */
    background-color: var(--theme-bg);
    color: var(--theme-text);

    line-height: 1.6;
}

/* ===== Theme Header ===== */

.theme-header {
    position: sticky;
    top: 0;
    margin: 0 12px;
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 6px;
    border-bottom: 1px solid var(--theme-border);
}

[data-theme="dark"] .theme-header {
    background: rgba(20, 20, 20, 0.95);
}

.theme-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;   /* 핵심 */
    gap: 8px;                 /* 줄 간격 */
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.theme-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.theme-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--theme-text);
}

.theme-desc {
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.5;
    color: #888;
}

.theme-guide {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.theme-buttons button {
    border: 1px solid var(--theme-border);
    background: var(--theme-card);
    color: var(--theme-text);

    padding: 6px 14px;
    margin-left: 8px;

    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;

    transition: all 0.2s;
}

.theme-buttons button:hover {
    opacity: 0.8;
}

.theme-buttons button.active {
    background: #4dd0e1;
    color: #000;
    border-color: #4dd0e1;
}

/* ===== Theme Body ===== */

.container {
    /* max-width: 1400px; */
    margin: 4rem 0 auto;
    padding: 0 20px 80px 20px;
}

h1 {
    color: var(--theme-text);
    margin-bottom: 10px;
    font-size: 2.5rem;
}

.subtitle {
    color: var(--theme-text);
    margin-bottom: 40px;
    font-size: 1.1rem;
}

.section {
    margin-bottom: 50px;
}

.section-title {
    color: #005AA3;
    font-size: 1.8rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #333;
    display: flex;
    align-items: center;
}
[data-theme="dark"] .section-title {
    color: #4dd0e1;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.color-card {
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    transition: transform 0.2s, box-shadow 0.2s;
}

.color-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.7);
}

.color-swatch {
    position: relative;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 0.8rem;
    text-shadow: 0 1px 2px rgba(255,255,255,0.3);
}
[data-theme="dark"] .color-swatch {
    color: #000;
}

/* 대비 실패 시 */
.color-swatch.contrast-fail::before,
.color-swatch.contrast-fail::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 3px;
    background-color: var(--contrast-x-color, #000);
}
.color-swatch.contrast-fail::before {
    transform: translateY(-50%) rotate(30deg);
}
.color-swatch.contrast-fail::after {
    transform: translateY(-50%) rotate(-30deg);
}
.color-swatch.contrast-fixed {
outline: 2px dashed #ff9800;
outline-offset: 2px;
}

.color-info {
    padding: 10px;
    background: var(--theme-card);
}

.color-name {
    font-weight: 600;
    margin-bottom: 3px;
    font-size: 0.85rem;
    color: var(--theme-text);
}

.color-code {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--gray-aaa-5);
    margin-bottom: 3px;
}
.color-contrast {
    font-size: 0.75rem;
    color: var(--gray-aaa-5);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

.badge-aaa {
    background: #66bb6a;
    color: #fff;
}

[data-theme="dark"] .badge-aaa {
    color: #000;
}

.badge-aa {
    background: #42a5f5;
    color: #fff;
}

[data-theme="dark"] .badge-aa {
    color: #000;
}

h3 {
    color: #595959;
    margin: 25px 0 15px;
    font-size: 1.2rem;
}
[data-theme="dark"] h3 {
    color: #d0d0d0;
}