﻿/* =========================================================
   Navigation: desktop mega menu, mobile drawer, mobile dock,
   mobile sheets and reading bar.
   ========================================================= */

/* ---------- desktop secondary menu ---------- */
.nav-item { position: relative; display: flex; align-items: stretch; }
.nav-item > a { gap: 6px; }
.nav-caret { width: 10px; height: 10px; opacity: 0.55; transition: transform 0.25s var(--ease); }
.nav-item:hover .nav-caret,
.nav-item:focus-within .nav-caret { transform: rotate(180deg); opacity: 1; }

.mega-menu {
  position: absolute;
  top: calc(100% - 1px);
  left: 50%;
  z-index: 75;
  display: none;
  width: min(780px, calc(100vw - 48px));
  padding: 26px 28px 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 32px 70px -36px rgba(28, 32, 29, 0.6);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(calc(-50% + var(--mega-shift, 0px)), 10px);
  transition: opacity 0.22s ease, transform 0.3s var(--ease);
}
.mega-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
}
.nav-item:hover .mega-menu,
.nav-item:focus-within .mega-menu { display: block; opacity: 1; visibility: visible; pointer-events: auto; transform: translate(calc(-50% + var(--mega-shift, 0px)), 0); }

.mega-body { display: grid; grid-template-columns: 1fr 220px; gap: 30px; }
.mega-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 36px; }
.mega-col { min-width: 0; }
.mega-col h5 { margin: 0 0 9px; font-size: 12px; font-weight: 600; letter-spacing: 0.15em; color: var(--quiet); text-transform: uppercase; }
.mega-menu .mega-link { display: block; padding: 6px 0; font-size: 14px; line-height: 1.45; color: var(--ink-2); transition: color 0.2s ease, padding-left 0.2s ease; }
.mega-menu .mega-link:hover { color: var(--red); padding-left: 3px; }
.mega-menu .mega-link span { display: block; margin-top: 1px; font-size: 12.5px; color: var(--quiet); line-height: 1.55; }
.mega-link:hover span { color: var(--muted); }

.mega-feature { position: relative; padding: 20px 20px 18px; color: #f3ecdf; background: var(--green); overflow: hidden; }
.mega-feature::after { content: ""; position: absolute; width: 120px; height: 120px; right: -55px; bottom: -60px; border: 1px solid rgba(243, 236, 223, 0.16); border-radius: 50%; }
.mega-feature .mf-label { position: relative; z-index: 1; font-size: 11px; letter-spacing: 0.14em; color: #d6bf99; }
.mega-feature h4 { position: relative; z-index: 1; margin: 12px 0 0; font-size: 20px; font-weight: 600; line-height: 1.55; }
.mega-feature p { position: relative; z-index: 1; margin: 6px 0 0; font-size: 12.5px; line-height: 1.7; color: rgba(243, 236, 223, 0.58); }
.mega-feature a { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 5px; margin-top: 16px; font-size: 12px; color: #e5cfa8; }
.mega-feature a:hover { color: #fff; }
.mega-feature a svg { width: 12px; height: 12px; }

.mega-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding-top: 13px; border-top: 1px solid var(--line); font-size: 12px; color: var(--quiet); }
.mega-foot a { color: var(--red); }

/* ---------- mobile dock ---------- */
.mobile-dock {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 65;
  align-items: stretch;
  justify-content: space-around;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(246, 242, 233, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.mobile-dock a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 56px;
  height: 54px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.mobile-dock a svg { width: 20px; height: 20px; stroke-width: 1.5; }
.mobile-dock a.is-active { color: var(--red); }
.mobile-dock a.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 18px;
  height: 2px;
  background: var(--red);
}

/* ---------- mobile drawer ---------- */
.mobile-nav { overflow-y: auto; padding: 0; }
.mobile-nav-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px 22px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.mobile-search-trigger {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  margin: 18px 0 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14.5px;
  color: var(--quiet);
  text-align: left;
}
.mobile-search-trigger svg { width: 17px; height: 17px; color: var(--red); }
.mobile-nav-scroll { flex: 1; padding: 0 22px; }
.mnav-group { border-bottom: 1px solid var(--line); }
.mnav-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 15px 2px;
  border: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  text-align: left;
  letter-spacing: -0.02em;
}
.mnav-trigger span { margin-left: auto; padding-right: 14px; font-family: var(--sans); font-size: 11.5px; font-weight: 400; letter-spacing: 0.1em; color: var(--quiet); }
.mnav-trigger .mnav-plus { position: relative; width: 12px; height: 12px; flex: 0 0 auto; }
.mnav-trigger .mnav-plus::before,
.mnav-trigger .mnav-plus::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 1px; background: var(--muted); transform: translate(-50%, -50%); transition: transform 0.25s ease; }
.mnav-trigger .mnav-plus::after { transform: translate(-50%, -50%) rotate(90deg); }
.mnav-trigger[aria-expanded="true"] .mnav-plus::after { transform: translate(-50%, -50%) rotate(0); }
.mnav-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.28s var(--ease); }
.mnav-panel > div { overflow: hidden; }
.mnav-panel-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; padding: 0 0 12px 4px; }
.mnav-panel a { display: block; padding: 8px 0; font-size: 14.5px; color: var(--ink-2); border-bottom: 1px dotted var(--line); }
.mnav-panel a:nth-last-child(-n+2) { border-bottom: 0; }
.mnav-group.is-open .mnav-panel { grid-template-rows: 1fr; }
.mnav-simple { display: flex; align-items: center; justify-content: space-between; padding: 17px 2px; border-bottom: 1px solid var(--line); font-size: 20px; font-weight: 600; }
.mnav-simple span { font-size: 12px; font-weight: 400; letter-spacing: 0.08em; color: var(--quiet); }
.mobile-nav-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 18px 22px calc(24px + env(safe-area-inset-bottom)); }
.mobile-nav-foot .btn { flex: 1 1 46%; }
.mobile-theme-row { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 12px; font-size: 12px; color: var(--muted); }
.mobile-theme-row button { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); background: transparent; font-size: 12px; color: var(--ink-2); }
.mobile-theme-row svg { width: 14px; height: 14px; }

/* ---------- mobile sheets ---------- */
.mobile-only { display: none !important; }
.mobile-sheet {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: flex-end;
  background: rgba(18, 27, 22, 0.56);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.mobile-sheet.is-open { opacity: 1; visibility: visible; }
.mobile-sheet-panel {
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding: 22px 22px calc(22px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-radius: 14px 14px 0 0;
  transform: translateY(18px);
  transition: transform 0.3s var(--ease);
}
.mobile-sheet.is-open .mobile-sheet-panel { transform: translateY(0); }
.mobile-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.mobile-sheet-head h3 { font-size: 19px; font-weight: 600; }
.mobile-sheet-close { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.mobile-sheet-close svg { width: 15px; height: 15px; }
.mobile-sheet-body { padding-top: 16px; }
.mobile-sheet-body .filter-groups { display: flex; }
.mobile-sheet-body .filter-chip { height: 38px; font-size: 13px; }
.mobile-sheet-body .filter-chip span { font-size: 11px; }

/* ---------- mobile filter / reading bar ---------- */
.mobile-filter-btn {
  display: none;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 12px;
  color: var(--ink-2);
}
.mobile-filter-btn svg { width: 13px; height: 13px; }
.mobile-reading-bar { display: none; }
.mobile-toc-list { margin-top: 4px; }
.mobile-toc-list a { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.mobile-toc-list a span { font-size: 11px; color: var(--quiet); }

@media (max-width: 820px) {
  .mobile-only { display: flex !important; }
  .mobile-dock { display: flex; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  body[data-page="article"] { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  body[data-page="article"] .mobile-dock { display: none; }
  .mobile-filter-btn { display: inline-flex; }
  .filter-bar .filter-groups { display: none; }
  .mobile-reading-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(246, 242, 233, 0.97);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
  }
  .mobile-reading-bar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 3px; border: 0; background: transparent; font-size: 11px; color: var(--muted); }
  .mobile-reading-bar button svg { width: 18px; height: 18px; }
  .mobile-reading-bar button:active { color: var(--red); }
  .article-tools-top { margin-top: 17px; }
  .reading-layout { padding-top: 26px; }
}

[data-theme="dark"] .mobile-dock,
[data-theme="dark"] .mobile-reading-bar { background: rgba(15, 22, 18, 0.96); }
[data-theme="dark"] .mobile-nav-head { background: var(--paper); }
[data-theme="dark"] .mobile-sheet { background: rgba(0, 0, 0, 0.66); }
[data-theme="dark"] .mobile-sheet-panel { background: var(--paper); }
[data-theme="dark"] .mega-menu { background: var(--surface); box-shadow: 0 32px 70px -30px rgba(0, 0, 0, 0.8); }




@media (max-width: 820px) {
  .subfilter-row { flex-wrap: wrap; row-gap: 6px; }
  .subfilter-row a { white-space: nowrap; }
  .subfilter-row > span:last-child { display: none; }
  .article-tools-top { display: none; }
}











