/* ==========================================================================
   首页品牌头部（v9.3.2）：左侧 logo 撑满蓝板 + 右栏三行
     行 1 导航 / 行 2 登录注册 + 搜索 / 行 3 供需动态滚动
   独立模块；复用 css/marketplace.css 的 .mk-search 与 css/style.css 的
   .navbar / .nav-menu / .nav-actions / .sr-only，仅在 .mk-mast 作用域内覆盖，
   不改全站枢纽（js/main.js、js/marketplace.js、css/style.css 零改动）。
   ========================================================================== */

.mk-mast {
  padding: 18px 0 16px;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
}
.mk-mast-grid {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  gap: 22px;
  align-items: stretch;
}

/* --- 左栏：唯一品牌字标 ----------------------------------------------------
   宽高比锁定为 logo 原始比例 600:277，由左栏自身撑起 grid 行高；
   logo 按宽度 100% 缩放后高度正好等于板高，四周不再出现大片空白。 */
.mk-mast-brand {
  position: relative;
  overflow: hidden;
  min-width: 0;
  align-self: start;
  aspect-ratio: 600 / 277;
  display: flex;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #17205e 0%, #1a237e 45%, #2962ff 100%);
}
.mk-mast-brand::after {
  content: '';
  position: absolute;
  z-index: 0;
  right: -70px;
  bottom: -90px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .13), transparent 70%);
  pointer-events: none;
}
.mk-mast-logo { display: block; width: 100%; position: relative; z-index: 1; }
.mk-mast-logo img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .16));
}

/* --- 右栏：三行，与左栏等高、上中下均匀分布 ------------------------------- */
.mk-mast-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}
.mk-mast-row { min-width: 0; }

/* 行 1：导航（复用全站 navbar DOM，首页不输出小 logo） */
.mk-mast-navrow { position: relative; }
.mk-mast .navbar {
  position: relative;
  top: auto;
  left: auto;
  height: auto;
  padding: 4px 0 8px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  border-bottom: 1px solid var(--color-border);
  z-index: 5;
}
.mk-mast .navbar.scrolled { height: auto; background: transparent; box-shadow: none; }
.mk-mast .navbar .container { max-width: none; margin: 0; padding: 0; gap: 8px; }
/* 全站 @1180px 会隐藏 .nav-menu/.nav-actions，首页三行布局要求它们常显 */
.mk-mast .nav-menu { display: flex; justify-content: flex-start; }
.mk-mast .nav-menu a { padding: 5px 6px; font-size: .78rem; }
.mk-mast .nav-actions { display: flex; gap: 5px; }
.mk-mast .nav-actions .nav-search-btn,
.mk-mast .nav-actions .nav-theme-toggle,
.mk-mast .nav-actions .nav-cart { width: 32px; height: 32px; }
/* 全站移动端 tap-target 块用 !important 把 button 设为 inline-flex，隐藏需同等优先级 */
.mk-mast .nav-toggle { display: none !important; }
.mk-nav-placeholder { display: none; height: 46px; }

/* 行 2：登录注册 + 站内挂牌搜索 */
.mk-mast-accountrow { display: flex; align-items: center; gap: 10px; }
.mk-mast .mk-search { flex: 1 1 auto; min-width: 0; }
.mk-mast .mk-search input { padding: 11px 16px; }
.mk-mast .mk-search button { min-height: 44px; padding: 0 20px; white-space: nowrap; }
.mk-account-actions { display: flex; flex-shrink: 0; gap: 8px; }
.mk-acct-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
}
.mk-mast .mk-nav-login {
  background: transparent;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
}
.mk-mast .mk-nav-register { background: var(--gradient-primary); color: #fff; border: 1.5px solid transparent; }

/* 行 3：站内供需动态滚动（真实数据，非编造成交） */
.mk-mast-tickerrow {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}
.mk-ticker-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: .76rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}
.mk-ticker-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .16);
}
.mk-ticker {
  flex: 1 1 auto;
  min-width: 0;
  height: var(--mk-ticker-row-h, 34px);
  overflow: hidden;
}
.mk-ticker-track {
  margin: 0;
  padding: 0;
  list-style: none;
  animation: mk-ticker-roll 30s linear infinite;
  will-change: transform;
}
.mk-ticker-ready .mk-ticker-track { animation-play-state: running; }
.mk-ticker:hover .mk-ticker-track,
.mk-ticker:focus-within .mk-ticker-track { animation-play-state: paused; }
@keyframes mk-ticker-roll {
  from { transform: translateY(0); }
  to   { transform: translateY(-50%); }
}
.mk-ticker-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: var(--mk-ticker-row-h, 34px);
  font-size: .78rem;
  white-space: nowrap;
}
.mk-ticker-item .mk-tk-kind {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(41, 98, 255, .1);
  color: var(--color-accent);
  font-size: .68rem;
  font-weight: 700;
}
.mk-ticker-item a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
  text-decoration: none;
}
.mk-ticker-item a:hover { color: var(--color-accent); text-decoration: underline; }
.mk-ticker-item .mk-tk-meta { flex-shrink: 0; color: var(--color-text-light); font-size: .72rem; }
.mk-ticker-actions { display: flex; flex-shrink: 0; gap: 12px; }
.mk-ticker-actions a { font-size: .76rem; font-weight: 600; color: var(--color-accent); white-space: nowrap; }
.mk-ticker-actions a:hover { text-decoration: underline; }

/* --- 滚动后：导航行吸顶（由 js/masthead.js 切 body.mk-nav-fixed） --------- */
body.mk-nav-fixed .mk-nav-placeholder { display: block; }
body.mk-nav-fixed .mk-mast .navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 52px;
  padding: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  border-bottom: 1px solid var(--color-border);
}
[data-theme="dark"] body.mk-nav-fixed .mk-mast .navbar { background: rgba(15, 18, 34, .96); }
body.mk-nav-fixed .mk-mast .navbar.scrolled { height: 52px; }
body.mk-nav-fixed .mk-mast .navbar .container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 24px;
  flex-wrap: nowrap;
}
body.mk-nav-fixed .mk-mast .nav-menu {
  order: 0;
  width: auto;
  flex: 1 1 auto;
  padding-top: 0;
  justify-content: flex-start;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
body.mk-nav-fixed .mk-mast .nav-menu::-webkit-scrollbar { display: none; }
body.mk-nav-fixed .mk-mast .nav-actions { order: 0; margin-left: 0; }

/* 首页锚点：滚动后仅有 52px 吸顶导航，避免沿用过大的全站顶距 */
.mk-mast ~ section[id] { scroll-margin-top: 68px; }

/* --- 响应式 -------------------------------------------------------------- */
@media (max-width: 1180px) {
  .mk-mast-grid { gap: 16px; }
  .mk-mast .nav-menu a { padding: 5px 5px; font-size: .74rem; }
  .mk-ticker-actions { gap: 8px; }
}
@media (max-width: 1000px) {
  .mk-mast-grid { grid-template-columns: 1fr; gap: 14px; }
  /* 单列时取消固定比例，避免板子过高压住首屏；logo 居中且仅留少量呼吸边距 */
  .mk-mast-brand { aspect-ratio: auto; padding: 14px 18px; }
  .mk-mast-logo { max-width: 420px; margin: 0 auto; }
  .mk-mast-right { justify-content: flex-start; gap: 12px; }
  /* 导航区：工具与账户在上、菜单横向可滑在下，仍属「导航一行」区块 */
  .mk-mast .navbar .container { flex-wrap: wrap; }
  .mk-mast .nav-menu {
    display: flex;
    order: 2;
    width: 100%;
    flex: 1 1 100%;
    padding-top: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .mk-mast .nav-menu::-webkit-scrollbar { display: none; }
  .mk-mast .nav-actions { order: 1; margin-left: auto; }
  .mk-mast .nav-toggle { display: none; }
  .mk-ticker-actions a:last-child { display: none; }
}
@media (max-width: 560px) {
  .mk-mast { padding: 10px 0; }
  .mk-mast-grid { gap: 10px; }
  .mk-mast-brand { padding: 10px 12px; }
  .mk-mast-logo { max-width: 280px; }
  .mk-mast-right { gap: 9px; }
  .mk-mast .navbar { padding: 2px 0 6px; }
  .mk-mast .nav-menu { padding-top: 4px; }
  .mk-mast-accountrow { flex-wrap: wrap; gap: 8px; }
  .mk-mast .mk-search { flex: 1 1 100%; }
  .mk-mast .mk-search input { padding: 9px 14px; }
  .mk-mast .mk-search button { min-height: 42px; padding: 0 16px; }
  .mk-account-actions { width: 100%; }
  .mk-acct-btn { flex: 1 1 0; height: 40px; }
  .mk-mast-tickerrow { gap: 8px; padding: 0 9px; }
  .mk-ticker-label { font-size: .7rem; }
  .mk-ticker-actions { display: none; }
  body.mk-nav-fixed .mk-mast .nav-actions .nav-btn { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .mk-ticker-track { animation: none; }
}
