/* MOOSSin magazine header (plan MOOSSIN_MAGAZINE_PLAN.md 4.4, batch 3, 2026-11-03): the brand, the blog's
 * channels as plain text, a "更多" menu, search and the language link in one row; below 900px the same
 * header is two rows -- brand, 更多 and search on top, the channels in one swipeable row beneath.
 * Shared verbatim by all four sections (www, blog, trade, life); every rule is scoped to .mooss-bar and
 * resets what a section stylesheet could leak in. Light colours are the portal's palette (ink 14.6:1,
 * muted 7.7:1, moss 6.1:1 on white); dark colours follow prefers-color-scheme, and an explicit
 * <html data-theme="light|dark"> (the blog's reading setting) wins over the system. Change it in every
 * section at once, never in one. */
.mooss-bar {
  --mb-bg: #ffffff;
  --mb-line: #dfe5dc;
  --mb-ink: #1c221d;
  --mb-muted: #4a544b;
  --mb-faint: #6b756b;
  --mb-hover: #f1f4ef;
  --mb-field: #f1f4ef;
  --mb-accent: #2f6b3f;
  --mb-pop: #ffffff;
  --mb-pop-line: #cfd6cc;
  --mb-shadow: 0 10px 28px rgba(28, 34, 29, 0.12);
  --mb-ch: #2f6b3f;
  --mb-ch-light: #f1f4ef;
  position: relative;
  z-index: 40;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--mb-line);
  background: var(--mb-bg);
  color: var(--mb-ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  text-align: left;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mooss-bar {
    --mb-bg: #121815;
    --mb-line: #2c372f;
    --mb-ink: #e8eee8;
    --mb-muted: #b3beb4;
    --mb-faint: #8d998f;
    --mb-hover: #1e2721;
    --mb-field: #1b231d;
    --mb-accent: #86d29a;
    --mb-pop: #19211b;
    --mb-pop-line: #3a463c;
    --mb-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] .mooss-bar {
  --mb-bg: #121815;
  --mb-line: #2c372f;
  --mb-ink: #e8eee8;
  --mb-muted: #b3beb4;
  --mb-faint: #8d998f;
  --mb-hover: #1e2721;
  --mb-field: #1b231d;
  --mb-accent: #86d29a;
  --mb-pop: #19211b;
  --mb-pop-line: #3a463c;
  --mb-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.mooss-bar *,
.mooss-bar *::before,
.mooss-bar *::after {
  box-sizing: border-box;
}

.mooss-bar a {
  color: inherit;
  text-decoration: none;
}

.mooss-bar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mooss-bar li {
  margin: 0;
  padding: 0;
}

.mooss-bar summary {
  list-style: none;
  cursor: pointer;
}

.mooss-bar summary::-webkit-details-marker {
  display: none;
}

.mooss-bar__inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1160px;
  min-height: 64px;
  margin: 0 auto;
  padding: 0 20px;
}

.mooss-bar__brand {
  flex: none;
  margin-right: 24px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.mooss-bar__channels {
  flex: 0 1 auto;
  min-width: 0;
}

.mooss-bar__channel-list {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mooss-bar__channels a,
.mooss-bar__more > summary,
.mooss-bar__lang {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--mb-ink);
  white-space: nowrap;
}

.mooss-bar__channels a:hover,
.mooss-bar__more > summary:hover,
.mooss-bar__lang:hover {
  background: var(--mb-hover);
}

.mooss-bar__channels a[aria-current="page"] {
  border-radius: 6px 6px 0 0;
  box-shadow: inset 0 -3px 0 var(--mb-ch);
  font-weight: 700;
}

.mooss-bar [data-channel="ai"] { --mb-ch: #5b45c2; --mb-ch-light: #ece8fb; }
.mooss-bar [data-channel="security"] { --mb-ch: #b43528; --mb-ch-light: #fbe7e4; }
.mooss-bar [data-channel="dev"] { --mb-ch: #1c66a3; --mb-ch-light: #e3eefa; }
.mooss-bar [data-channel="living"] { --mb-ch: #9b4e14; --mb-ch-light: #fbecdc; }
.mooss-bar [data-channel="science"] { --mb-ch: #0f7066; --mb-ch-light: #dcf2ee; }
.mooss-bar [data-channel="student"] { --mb-ch: #ac3668; --mb-ch-light: #fbe5ee; }
.mooss-bar [data-channel="money"] { --mb-ch: #38701c; --mb-ch-light: #e6f2db; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mooss-bar [data-channel="ai"] { --mb-ch: #a99bf3; --mb-ch-light: #2a2547; }
  :root:not([data-theme="light"]) .mooss-bar [data-channel="security"] { --mb-ch: #f28f84; --mb-ch-light: #3d2321; }
  :root:not([data-theme="light"]) .mooss-bar [data-channel="dev"] { --mb-ch: #78b8f0; --mb-ch-light: #1c3047; }
  :root:not([data-theme="light"]) .mooss-bar [data-channel="living"] { --mb-ch: #efa86b; --mb-ch-light: #3b2a19; }
  :root:not([data-theme="light"]) .mooss-bar [data-channel="science"] { --mb-ch: #52c8b8; --mb-ch-light: #163732; }
  :root:not([data-theme="light"]) .mooss-bar [data-channel="student"] { --mb-ch: #f089b4; --mb-ch-light: #3d2130; }
  :root:not([data-theme="light"]) .mooss-bar [data-channel="money"] { --mb-ch: #8fce70; --mb-ch-light: #253719; }
}

:root[data-theme="dark"] .mooss-bar [data-channel="ai"] { --mb-ch: #a99bf3; --mb-ch-light: #2a2547; }
:root[data-theme="dark"] .mooss-bar [data-channel="security"] { --mb-ch: #f28f84; --mb-ch-light: #3d2321; }
:root[data-theme="dark"] .mooss-bar [data-channel="dev"] { --mb-ch: #78b8f0; --mb-ch-light: #1c3047; }
:root[data-theme="dark"] .mooss-bar [data-channel="living"] { --mb-ch: #efa86b; --mb-ch-light: #3b2a19; }
:root[data-theme="dark"] .mooss-bar [data-channel="science"] { --mb-ch: #52c8b8; --mb-ch-light: #163732; }
:root[data-theme="dark"] .mooss-bar [data-channel="student"] { --mb-ch: #f089b4; --mb-ch-light: #3d2130; }
:root[data-theme="dark"] .mooss-bar [data-channel="money"] { --mb-ch: #8fce70; --mb-ch-light: #253719; }

/* 更多 -------------------------------------------------------------- */
.mooss-bar__more {
  position: relative;
  flex: none;
}

.mooss-bar__more > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.mooss-bar__more[open] > summary {
  background: var(--mb-hover);
  font-weight: 700;
}

.mooss-bar__more[open] > summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.mooss-bar__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 2;
  width: 270px;
  padding: 8px 0;
  border: 1px solid var(--mb-pop-line);
  border-radius: 10px;
  background: var(--mb-pop);
  box-shadow: var(--mb-shadow);
}

.mooss-bar__menu a {
  display: block;
  padding: 8px 20px;
  color: var(--mb-ink);
}

.mooss-bar__menu a:hover {
  background: var(--mb-hover);
}

.mooss-bar__menu a[aria-current="page"] .mooss-bar__item {
  color: var(--mb-accent);
}

.mooss-bar__item {
  display: block;
  font-weight: 700;
}

.mooss-bar__hint {
  display: block;
  color: var(--mb-faint);
  font-size: 12px;
}

.mooss-bar__menu .mooss-bar__menu-end {
  display: flex;
  flex-wrap: wrap;
  column-gap: 16px;
  margin-top: 8px;
  padding: 0 20px;
  border-top: 1px solid var(--mb-line);
}

.mooss-bar__menu .mooss-bar__menu-end a {
  flex: none;
  padding: 8px 0;
}

.mooss-bar__menu-lang {
  display: none;
}

/* search and language ----------------------------------------------- */
/* A link, not a form: the sections' content policies allow no form submission. */
.mooss-bar__search {
  display: flex;
  flex: 0 1 220px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 36px;
  margin: 0 0 0 auto;
  padding: 0 16px 0 12px;
  border-radius: 18px;
  background: var(--mb-field);
  color: var(--mb-faint);
  font-size: 14px;
  white-space: nowrap;
}

.mooss-bar__search:hover {
  background: var(--mb-hover);
  color: var(--mb-ink);
}

.mooss-bar__search svg {
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--mb-muted);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.mooss-bar__lang {
  flex: none;
  color: var(--mb-muted);
  font-size: 14px;
}

.mooss-bar a:focus-visible,
.mooss-bar summary:focus-visible {
  outline: 2px solid var(--mb-accent);
  outline-offset: -2px;
}

/* below 900px: two rows -------------------------------------------- */
@media (max-width: 899px) {
  .mooss-bar__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand more search"
      "channels channels channels";
    column-gap: 4px;
    row-gap: 0;
    min-height: 0;
    padding: 0 16px;
  }

  .mooss-bar__brand {
    grid-area: brand;
    margin: 0;
    padding: 10px 0;
    font-size: 20px;
  }

  .mooss-bar__more {
    grid-area: more;
  }

  .mooss-bar__more > summary {
    min-height: 44px;
  }

  .mooss-bar__menu {
    top: 52px;
    right: 12px;
    left: auto;
    position: absolute;
    width: min(270px, calc(100vw - 24px));
  }

  /* the dropdown is positioned against the bar, not the small button */
  .mooss-bar__more {
    position: static;
  }

  .mooss-bar__search {
    grid-area: search;
    flex: none;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 22px;
    background: none;
  }

  .mooss-bar__search span,
  .mooss-bar__lang {
    display: none;
  }

  .mooss-bar__menu-lang {
    display: block;
  }

  .mooss-bar__channels {
    grid-area: channels;
    margin: 0 -16px;
    padding: 2px 16px 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mooss-bar__channels::-webkit-scrollbar {
    display: none;
  }

  .mooss-bar__channel-list {
    gap: 8px;
    width: max-content;
    padding-right: 16px;
  }

  .mooss-bar__channels a {
    min-height: 36px;
    padding: 0 16px;
    border-radius: 18px;
    background: var(--mb-field);
    font-size: 15px;
  }

  .mooss-bar__channels a[aria-current="page"] {
    border-radius: 18px;
    background: var(--mb-ch-light);
    box-shadow: none;
    color: var(--mb-ch);
  }
}
