/* 위쪽 가로 메뉴 (2026-10 리뉴얼) — body.topnav 화면에만 걸린다.
   왼쪽 레일은 모든 폭에서 '전체 메뉴' 서랍이 된다. [[home-topnav]] */

body.topnav { padding-left: 0 !important; overflow-x: clip; }
body.topnav > .rail-toggle { display: none !important; }

/* ── 레일 → 서랍 (style.css 의 모바일 서랍 규칙을 모든 폭으로) ── */
body.topnav .rail,
body.topnav .rail:hover {
    width: 264px; max-width: 82vw;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: none; overflow-y: auto; z-index: 60;
}
body.topnav .rail.open,
body.topnav .rail.open:hover { transform: none; box-shadow: 2px 0 24px rgba(0, 0, 0, .25); }
body.topnav .rail .rail-label { opacity: 1; }
body.topnav .rail .rail-sub { max-height: 320px; }
body.topnav .rail .rail-group { height: auto; padding: 14px 11px 6px; }
body.topnav .rail-backdrop.on { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 59; }
body.topnav.rail-locked { overflow: hidden; }

/* ── 머리줄 ── */
.tn { position: sticky; top: 0; z-index: 40; background: var(--card); border-bottom: 1px solid var(--border); }
.tn-in { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 18px; }
.tn-burger { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 38px; height: 38px; margin-left: -8px;
             padding: 0 9px; border: 0; border-radius: 8px; background: none; cursor: pointer; flex-shrink: 0; }
.tn-burger:hover { background: var(--muted-bg); }
.tn-burger span { display: block; height: 2px; background: var(--text); border-radius: 2px; }
.tn-logo { display: flex; align-items: center; gap: 8px; color: var(--text); flex-shrink: 0; margin-right: 10px; }
.tn-logo b { font-size: 19px; font-weight: 800; letter-spacing: -.03em; }
.tn-menu { display: flex; gap: 2px; flex: 1; min-width: 0; }
.tn-menu a { padding: 8px 11px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: 15.5px; letter-spacing: -.02em; white-space: nowrap; }
.tn-menu a:hover { background: var(--muted-bg); }
.tn-menu a.on { color: var(--primary); }
.tn-side { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }
.tn-my { color: var(--text-light); font-size: 14px; padding: 6px 8px; }
.tn-my.on { color: var(--primary); }
.tn-login { background: var(--ink); color: var(--card) !important; font-weight: 700; font-size: 14px; padding: 8px 16px; border-radius: 999px; }
:root[data-theme="dark"] .tn-login { background: var(--primary); color: var(--on-primary) !important; }

@media (max-width: 1080px) { .tn-in { gap: 10px; } .tn-menu a { padding: 8px 7px; font-size: 14.5px; } .tn-logo { margin-right: 0; } }

/* 좁은 화면 — 메뉴는 둘째 줄에 옆으로 밀어 보기. 시험 화면의 고정 칸과 겹치지 않게 고정하지 않는다 */
@media (max-width: 860px) {
    .tn { position: relative; }
    .tn-in { height: auto; flex-wrap: wrap; padding: 8px 12px 0; gap: 4px 8px; }
    .tn-burger { margin-left: -4px; }
    .tn-menu { order: 3; flex: 0 0 calc(100% + 24px); margin: 4px -12px 0; padding: 0 8px; overflow-x: auto; scrollbar-width: none;
               border-top: 1px solid var(--line-soft); }
    .tn-menu::-webkit-scrollbar { display: none; }
    .tn-menu a { padding: 11px 9px; border-radius: 0; font-size: 14.5px; }
    .tn-menu a.on { box-shadow: inset 0 -2px 0 var(--primary); }
    .tn-menu a:hover { background: none; }
}

/* 위 메뉴가 생겨 본문 첫 칸이 너무 붙지 않게 */
body.topnav main.container { padding-top: 8px; }

/* 문제 푸는 화면은 메뉴를 고정하지 않는다 (header.php 가 tn-static 을 붙인다) */
body.tn-static .tn { position: relative; }

/* 위 메뉴(64px)가 고정되므로, 그 아래 붙는 칸들을 내려 준다 */
@media (min-width: 861px) {
    body.topnav:not(.tn-static) .exam-ads { top: 80px; }
    body.topnav .pd-tabs { top: 64px; }
    body.topnav .pd-aside { top: 84px; }
}
