/* deoji/categories-bar — horizontal category nav for the header */
.deoji-categories-bar {
    margin: 0;
    padding: 0;
}
.deoji-categories-bar ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
}
.deoji-categories-bar li {
    margin: 0;
}
.deoji-categories-bar a {
    text-decoration: none;
    color: var(--wp--preset--color--text, #1a1a1a);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.15s;
}
.deoji-categories-bar a:hover {
    color: var(--wp--preset--color--primary, #1a4d8c);
}
.deoji-categories-bar li.is-current > a {
    color: var(--wp--preset--color--primary, #1a4d8c);
    font-weight: 600;
}

/* ── Fixed header ── */
.deoji-site-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 9999;
    background-color: var(--wp--preset--color--background);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

/* 관리자 바가 있을 때 (로그인 상태) */
.admin-bar .deoji-site-header {
    top: 32px !important;
}
@media screen and (max-width: 782px) {
    .admin-bar .deoji-site-header {
        top: 46px !important;
    }
}

/* ── Dropdown / submenu ── */
.deoji-categories-bar li.has-children {
    position: relative;
}

.deoji-categories-bar .sub-menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 0.2rem;
    font-size: 0.75rem;
    color: var(--wp--preset--color--text, #1a1a1a);
    vertical-align: middle;
    line-height: 1;
    transition: transform 0.15s;
}

.deoji-categories-bar li.has-children.is-open > .sub-menu-toggle {
    transform: rotate(180deg);
}

.deoji-categories-bar .sub-menu {
    list-style: none;
    margin: 0;
    /* padding-top creates visual gap while keeping hover area continuous (no gap = no flicker) */
    padding: 0.5rem 0 0.375rem;
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 130px;
    background-color: var(--wp--preset--color--surface);
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 200;
}

.deoji-categories-bar .sub-menu li {
    margin: 0;
}

.deoji-categories-bar .sub-menu a {
    display: block;
    padding: 0.4rem 1rem;
    font-size: 0.875rem;
    font-weight: 400;
    white-space: nowrap;
}

/* Desktop (hover capable): CSS hover opens submenu, toggle button hidden */
@media (hover: hover) and (pointer: fine) {
    .deoji-categories-bar li.has-children:hover > .sub-menu {
        display: block;
    }
    .deoji-categories-bar .sub-menu-toggle {
        display: none;
    }
}

/* Touch / mobile: JS-toggled via .is-open */
.deoji-categories-bar li.has-children.is-open > .sub-menu {
    display: block;
}

/* ── 다크 모드 (OS / 브라우저 수준) ── */
/*
 * 핵심 원칙: :root 변수 자체를 재정의한다.
 * var(--wp--preset--color--*, fallback) 패턴은 변수가 이미 정의돼 있으면
 * fallback에 절대 도달하지 않는다. 따라서 변수값을 직접 바꿔야 한다.
 * :root 재정의 후 기존 var() 사용 요소는 별도 다크 규칙 없이 자동 적용된다.
 */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --wp--preset--color--background: #18181b;
        --wp--preset--color--surface:    #27272a;
        --wp--preset--color--text:       #e4e4e7;
        --wp--preset--color--text-muted: #a1a1aa;
        --wp--preset--color--border:     #3f3f46;
        --wp--preset--color--primary:    #a5b4fc;
        --wp--preset--color--up:         #f87171;
        --wp--preset--color--down:       #60a5fa;
        /* style.css 표 전용 변수 재정의 */
        --deoji-table-head:   #2e2e32;
        --deoji-table-border: #3f3f46;
    }
    /* rgba 기반 box-shadow는 변수로 표현 불가 — 직접 지정 */
    .deoji-site-header {
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    }
    .deoji-categories-bar .sub-menu {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
}
