/* ====================================================================
   APPBAR - shared fixed-bottom navigation
   Used on every sub-page that wants the landing-style nav. The landing
   index.html still has the inline copy (for now) - when this proves
   itself we'll switch the landing over too.
   ==================================================================== */

.appbar {
  /* Hardened so no page-level rule (e.g. global `nav { display: none }`
     at narrow breakpoints, or sticky-positioned overflow ancestors)
     can knock it loose. Stays glued to the bottom on every viewport. */
  display: block !important;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100% !important;
  z-index: 60;
  background: rgba(8, 8, 12, .82);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-top: 1px solid rgba(255, 255, 255, .10);
  color: #f3ecdf;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  box-shadow: 0 -14px 44px rgba(0, 0, 0, .45);
  /* Lift content above the home-indicator on notched iPhones / Androids */
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.appbar-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 18px;
  max-width: 1400px; margin: 0 auto;
  /* Row height matched to the toggle pill so icons + pill share the
     same vertical mid-line. */
  min-height: 52px;
}
.appbar-side {
  /* Icons spread evenly inside each half so they don't hug the edges. */
  display: flex; align-items: center; gap: 4px;
  justify-content: space-around;
  min-height: 40px;
}
.appbar-side-left, .appbar-side-right { /* sides identical now */ }

.appbar-icon {
  display: inline-flex; flex-direction: column; align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 12px;
  color: rgba(255, 255, 255, .62);
  text-decoration: none;
  border-radius: 10px;
  border: 0;
  transition: color .2s, background .2s, transform .15s;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  /* Match the toggle pill height so glyph+label sit on the same
     mid-line as the Dis/Sol pill. */
  min-height: 40px;
}
.appbar-icon::after { display: none !important; }
.appbar-icon svg { width: 20px; height: 20px; flex: 0 0 20px; }
.appbar-icon span {
  font-size: 8.5px; letter-spacing: .2em; text-transform: uppercase;
  line-height: 1;
}
.appbar-icon:hover { color: #f3ecdf; background: rgba(255, 255, 255, .07); transform: translateY(-1px); }
.appbar-icon:focus-visible { outline: 2px solid #ff3b81; outline-offset: 2px; }
.appbar-icon-cta { color: #ff3b81; }
.appbar-icon-cta:hover { color: #0b0b10; background: #ff3b81; }
/* Bigger tap target on touch devices - the visible glyph stays the
   same size but the hit area grows to the WCAG-recommended 44×44. */
@media (hover: none) and (pointer: coarse) {
  .appbar-icon { min-width: 44px; min-height: 44px; }
}
/* Respect users who've opted out of motion - no nudge animation. */
@media (prefers-reduced-motion: reduce) {
  .appbar-icon, .appbar-icon:hover { transform: none; transition: none; }
}

/* Segmented Dis/Sol toggle */
.appbar-toggle {
  position: relative;
  display: inline-flex; align-items: stretch;
  padding: 4px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .20);
  border-radius: 999px;
  color: #f3ecdf; cursor: pointer;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  transition: border-color .2s, background .2s;
  min-height: 40px;
  overflow: hidden;
  isolation: isolate;
}
.appbar-toggle:hover { border-color: rgba(255, 255, 255, .32); }
.appbar-toggle:focus-visible { outline: 2px solid #ff3b81; outline-offset: 3px; }
.appbar-toggle::before {
  content: '';
  position: absolute;
  top: 4px; bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  background: #ff3b81;
  border-radius: 999px;
  box-shadow: 0 0 14px #ff3b81;
  transition: transform .35s cubic-bezier(.7, 0, .3, 1), background .6s ease, box-shadow .6s ease;
  z-index: 0;
}
html[data-state="dissolved"] .appbar-toggle::before { transform: translateX(0); }
html[data-state="soluble"]   .appbar-toggle::before { transform: translateX(100%); background: #c8862e; box-shadow: 0 0 14px #c8862e; }
.appbar-toggle .seg {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 16px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
  transition: color .25s ease;
  z-index: 1;
  min-width: 48px;
  min-height: 32px;
}
html[data-state="dissolved"] .appbar-toggle .seg[data-target="dissolved"],
html[data-state="soluble"]   .appbar-toggle .seg[data-target="soluble"] {
  color: #0b0b10 !important;
}

/* Ticker */
.appbar-ticker {
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .025);
  padding: 7px 0;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
  position: relative;
}
.appbar-ticker::before,
.appbar-ticker::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 60px;
  pointer-events: none; z-index: 2;
}
.appbar-ticker::before { left: 0;  background: linear-gradient(to right, rgba(8, 8, 12, .95), transparent); }
.appbar-ticker::after  { right: 0; background: linear-gradient(to left,  rgba(8, 8, 12, .95), transparent); }
.appbar-ticker-track {
  display: inline-flex; align-items: center;
  white-space: nowrap;
  animation: appbar-ticker-scroll 38s linear infinite;
  will-change: transform;
}
.appbar-ticker .ticker-group {
  display: inline-flex; align-items: center; gap: 36px;
  padding-right: 36px;
  flex-shrink: 0;
}
.appbar-ticker .ticker-group .ti { display: inline-flex; align-items: center; gap: 8px; }
.appbar-ticker .ticker-group .ti b { color: #ff3b81; font-weight: 500; transition: color .6s ease; }
html[data-state="soluble"] .appbar-ticker .ticker-group .ti b { color: #c8862e; }
.appbar-ticker .ticker-group .ti i { font-style: normal; color: #f3ecdf; font-weight: 400; }
@keyframes appbar-ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* Body padding so content clears the fixed bar. calc() adds the
   home-indicator safe-area on notched iPhones / Androids on top of
   the base appbar height. */
body { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 640px) {
  body { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
  .appbar-top { padding: 6px 8px; gap: 0; }
  .appbar-icon { padding: 6px 8px; }
  .appbar-icon svg { width: 20px; height: 20px; flex: 0 0 20px; }
  .appbar-icon span { font-size: 8.5px; letter-spacing: .14em; }
  .appbar-toggle { min-height: 36px; padding: 3px; }
  .appbar-toggle .seg { font-size: 10px; padding: 0 12px; min-width: 40px; min-height: 28px; letter-spacing: .14em; }
  .appbar-ticker { padding: 5px 0; font-size: 9px; letter-spacing: .16em; }
  .appbar-ticker .ticker-group { gap: 24px; padding-right: 24px; }
}
@media (max-width: 420px) {
  body { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
  .appbar-icon { padding: 5px 5px; }
  .appbar-icon span { font-size: 8px; letter-spacing: .1em; }
}

/* ─── Language toggle (top-left, pill, 2-segment EN/中) ───────────
   Active language is highlighted; the other is a clickable link.
   Subtle until hover so it doesn't compete with the wordmark. */
.lang-toggle {
  position: fixed;
  /* Top-right corner. The .home-fab orange circle lives top-left on
     sub-pages, so the right side stays clear for the language pill. */
  top: 22px; right: 14px;
  z-index: 9999;
  display: inline-flex; align-items: stretch;
  padding: 3px;
  background: rgba(8, 8, 12, .55);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  letter-spacing: .14em;
  line-height: 1;
  user-select: none;
}
.lang-toggle .lang-seg {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  color: rgba(255, 255, 255, .55);
  text-decoration: none;
  transition: color .2s, background .2s;
}
.lang-toggle .lang-seg:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.lang-toggle .lang-seg-active {
  color: #0b0b10;
  background: #f3ecdf;
  font-weight: 600;
}
.lang-toggle .lang-seg-active:hover { background: #f3ecdf; color: #0b0b10; }
@media (max-width: 640px) {
  .lang-toggle { top: 18px; right: 10px; font-size: 10px; }
  .lang-toggle .lang-seg { min-width: 26px; padding: 5px 8px; }
}
@media print { .lang-toggle { display: none; } }
