/* =====================================================================
   hall-nav.css — 顶栏视觉 token（唯一来源）
   基准 = 档案馆首页顶栏 .hall-top（archive-0901-90dd4a70.css）；
   全站 GlobalHeader（.gh-top，global-header.html 内联片段）消费同一组变量。
   两处均以 var(--hn-*, 原值) 方式引用：文件缺失时回退到内联原值，不裸奔。
   共享图标 SVG（馆徽/首页/月历/留言板/目录齿轮）与路径已逐字一致，改图标请两处同改。
   首页与内页共用布局、断点和按钮尺寸，防止切页时导航位置跳动。
   ===================================================================== */
:root{
  /* 颜色 */
  --hn-blue:#3f5f9e;                    /* 主强调：图标 hover / 馆徽（首页 --blue） */
  --hn-blue-soft:#567ace;               /* 亮蓝辅助（首页 --blue-2） */
  --hn-ink:#2f3a52;                     /* 品牌文字主色（首页 --ink） */
  --hn-ink-deep:#26324c;                /* 品牌标题深色（首页 --ink-deep） */
  --hn-sub:#5a6a86;                     /* 副标题英文 */
  --hn-icon-color:#33415c;              /* 图标默认色 */
  --hn-hover-bg:rgba(255,253,248,.8);   /* 圆图标 hover/focus 底 */
  --hn-active-bg:rgba(86,122,206,.14);  /* 当前页/激活底 */
  --hn-ring:0 0 0 1px rgba(63,95,158,.2);       /* hover 细环 */
  --hn-ring-strong:0 0 0 1px rgba(63,95,158,.24);/* 激活细环 */
  --hn-status:#53658e;                  /* 首尔时间/天气状态行（白天） */

  /* 尺寸（桌面端连续缩放档） */
  --hn-crest:clamp(34px,3.4vw,52px);    /* 馆徽 */
  --hn-brand-b:clamp(15px,1.45vw,23px); /* 「0901号档案馆」 */
  --hn-brand-s:clamp(8px,.76vw,11px);   /* YUJIN ARCHIVE */
  --hn-brand-s-ls:.36em;                /* 副标题字距 */
  --hn-brand-gap:clamp(8px,1vw,14px);   /* 馆徽↔文字 */
  --hn-icon:clamp(32px,2.9vw,42px);     /* 圆图标按钮 */
  --hn-icon-svg:clamp(18px,1.55vw,22px);/* 圆图标内 SVG */
  --hn-icons-gap:clamp(1px,.9vw,14px);  /* 图标间距 */

  /* 共享移动端紧凑档 */
  --hn-crest-m:30px;
  --hn-brand-b-m:14px;
  --hn-icon-m:33px;
  --hn-icon-svg-m:18px;

  /* 安全区（Toast / 贴底控件统一消费，未支持 env() 的旧机回退 0） */
  --popo-pg-safe-bottom:env(safe-area-inset-bottom,0px);
}

/* 桌面视觉校准（对齐首页 1672 参考稿，archive css 的 @media(min-width:821px) 同源）：
   ≥901px 时 gh 顶栏与首页顶栏同步放大——馆徽 68、标题 26、图标 46 / SVG 25 / 间距 22。 */
@media(min-width:821px){
  :root{
    --hn-crest:68px;
    --hn-brand-b:26px;
    --hn-brand-s:11.5px;
    --hn-brand-s-ls:.32em;
    --hn-icons-gap:22px;
    --hn-icon:46px;
    --hn-icon-svg:25px;
  }
}

/* Shared header geometry. Scoped selectors beat page-local legacy header rules,
   regardless of stylesheet order during full loads or PJAX navigation. */
:root{
  --hn-top-x:clamp(16px,3vw,52px);
  --hn-top-y:30px;
  --hn-top-bottom:clamp(14px,2.6vh,30px);
  --hn-layout-gap:10px;
  --hn-serif:"Times New Roman",Georgia,"Songti SC","Noto Serif SC",serif;
  --hn-sans:"Segoe UI","PingFang SC","Microsoft YaHei","Hiragino Sans",sans-serif;
}
html :is(.hall-top,.gh-top){
  box-sizing:border-box;display:flex;align-items:flex-start;justify-content:space-between;
  width:100%;height:auto;gap:var(--hn-layout-gap);
  padding:var(--hn-top-y) var(--hn-top-x) var(--hn-top-bottom);
}
html :is(.hall-top,.gh-top) :is(.hall-brand,.gh-brand){
  display:flex;align-items:center;gap:var(--hn-brand-gap);min-width:0;min-height:0;
}
html :is(.hall-top,.gh-top) .crest{
  flex:none;width:var(--hn-crest);height:var(--hn-crest);
}
html :is(.hall-top,.gh-top) .brand-text{
  display:flex;flex-direction:column;min-width:0;gap:0;line-height:1.18;
}
html :is(.hall-top,.gh-top) .brand-text b{
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  font:600 var(--hn-brand-b)/1.2 var(--hn-serif);letter-spacing:.03em;
}
html :is(.hall-top,.gh-top) .brand-text small{
  display:block;margin-top:3px;white-space:nowrap;
  font:400 var(--hn-brand-s)/1.4 var(--hn-sans);letter-spacing:var(--hn-brand-s-ls);
}
/* 首尔时间/天气状态行：馆名/副标题下方，样式全部走 hall-nav token。
   脚本 updateStatus() 写入文字并去掉 hidden；无有效天气时显示「天气数据不可用」。 */
html :is(.hall-top,.gh-top) .hall-seoul-status{
  display:block;margin:2px 0 0;padding:0 0 0 1px;
  max-width:min(300px,50vw);
  color:var(--hn-status);
  font:700 clamp(9px,.72vw,11px)/1.35 var(--hn-sans);letter-spacing:.02em;
  white-space:normal;overflow-wrap:anywhere;
  text-shadow:0 1px 0 rgba(255,253,248,.7);
}
html :is(.hall-top,.gh-top) .hall-seoul-status[hidden]{display:none}
@media(max-width:820px){
  html :is(.hall-top,.gh-top) .hall-seoul-status{font-size:9px}
}
html :is(.hall-top,.gh-top) :is(.hall-icons,.gh-icons){
  display:flex;flex:none;align-items:center;gap:var(--hn-icons-gap);overflow:visible;
}
html :is(.hall-top,.gh-top) :is(.hicon,.gh-icon){
  box-sizing:border-box;flex:none;min-width:0;min-height:0;padding:0;
  width:var(--hn-icon);height:var(--hn-icon);
}
html :is(.hall-top,.gh-top) :is(.hicon,.gh-icon) svg{
  display:block;width:var(--hn-icon-svg);height:var(--hn-icon-svg);
}
.gh-app .rail-mobile-menu nav{
  top:calc(var(--hn-top-y) + max(var(--hn-crest),var(--hn-icon)) + 8px);
  max-height:calc(100vh - var(--hn-top-y) - max(var(--hn-crest),var(--hn-icon)) - 20px);
  max-height:calc(100dvh - var(--hn-top-y) - max(var(--hn-crest),var(--hn-icon)) - 20px);
}
@media(max-width:820px){
  :root{
    --hn-top-x:14px;--hn-top-y:12px;--hn-top-bottom:12px;--hn-layout-gap:6px;
    --hn-crest:var(--hn-crest-m);--hn-brand-b:var(--hn-brand-b-m);
    --hn-brand-s:7px;--hn-brand-s-ls:.24em;
    /* 图标间距：原为 0（圆形按钮彼此相切，字形显得挤），按「稍微拉宽」放到 6px */
    --hn-icon:var(--hn-icon-m);--hn-icon-svg:var(--hn-icon-svg-m);--hn-icons-gap:6px;
  }
}
/* 381–470：档案馆首页在 archive-0901 css 里早就有一份更紧凑的校准
   （顶栏内边距 12、馆徽 28、馆名 13、图标 30 / SVG 17）。内页此前没有这一档，
   同样 390 宽下首页图标 30px、内页 33px，右侧整排图标横向错开 17px。
   这里补齐同一档，首页与内页在窄屏上位置、尺寸逐像素一致。 */
@media(max-width:470px){
  :root{
    --hn-top-x:12px;--hn-crest-m:28px;--hn-brand-b-m:13px;
    --hn-icon-m:30px;--hn-icon-svg-m:17px;
  }
}
@media(max-width:380px){
  :root{
    --hn-top-x:10px;--hn-top-y:8px;--hn-top-bottom:8px;
    --hn-crest:26px;--hn-brand-b:12px;--hn-brand-s:6px;--hn-brand-s-ls:.18em;
    --hn-icon:28px;--hn-icon-svg:16px;
  }
  html :is(.hall-top,.gh-top) .brand-text small{margin-top:1px}
}

/* =====================================================================
   夜间顶栏调亮（仅配色，不动尺寸/间距/图标布局）
   由氛围脚本在 body 上切换 .atmo-on.atmo-night 驱动；白天这些规则不生效。
   迁移自旧候选的 #hall.hall-night 配色，按整合版实际结构改写：
   整合版顶栏 .gh-top 在 #hall 之外，且全站颜色统一走 --hn-* token，
   因此这里覆盖 token 而非复制旧选择器。首页 .hall-top 与内页 .gh-top 同时受益。
   ===================================================================== */
html[data-archive-light="night"] body.archive-0901{
  --hn-blue:#d3def7;                    /* 图标 hover/focus/active 与描边色 */
  --hn-ink:#f3edde;                     /* 品牌链接主色 */
  --hn-ink-deep:#f7f2e5;                /* 「0901号档案馆」 */
  --hn-sub:#b9c6e2;                     /* YUJIN ARCHIVE 副标题 */
  --hn-icon-color:#edf1fa;              /* 圆图标默认色 */
  --hn-crest-color:#d5dff4;             /* 馆徽（当前图标色） */
  --hn-hover-bg:rgba(22,32,60,.55);     /* 圆图标 hover/focus 底 */
  --hn-active-bg:rgba(125,155,225,.24); /* 当前页/激活底 */
  --hn-ring:0 0 0 1px rgba(211,222,247,.3);
  --hn-ring-strong:0 0 0 1px rgba(211,222,247,.32);
  --hn-status:#b5c5e8;                  /* 状态行夜间色 */
}
/* 顶栏完全透明（白天/夜间一致）：只作用于档案馆首页。
   首页把主视觉、遮罩、氛围层都固定到视口，顶栏后面与馆景同一层，
   不产生任何横向分界；内页顶栏仍是原来的浅色纸面底。 */
body.archive-0901 :is(.hall-top,.gh-top){
  background:transparent;
  border-bottom-color:transparent;
  box-shadow:none;
}
body.archive-0901 :is(.hall-bg,.hall-bg-fill,.hall-veil,.atmo-layer,.atmo-rain,.atmo-stars,.atmo-snow){
  position:fixed;inset:0;
}
html[data-archive-light="night"] body.archive-0901 :is(.hall-top,.gh-top) .crest{color:var(--hn-crest-color)}
html[data-archive-light="night"] body.archive-0901 :is(.hall-top,.gh-top) .brand-text b{
  text-shadow:0 1px 10px rgba(10,18,38,.6);
}
html[data-archive-light="night"] body.archive-0901 :is(.hall-top,.gh-top) :is(.hicon,.gh-icon) svg{
  filter:drop-shadow(0 1px 2px rgba(10,18,38,.45));
}
html[data-archive-light="night"] body.archive-0901 :is(.hall-top,.gh-top) .hall-seoul-status{
  text-shadow:0 1px 0 rgba(10,18,38,.5);
}
/* 激活的氛围入口（保留旧选择器语义，兼容仍带 .atmo-entry 的页面） */
html[data-archive-light="night"] body.archive-0901 :is(.hicon,.gh-icon).atmo-entry[aria-pressed=true] svg{
  filter:drop-shadow(0 0 4px rgba(255,213,137,.75));
}
