/* VL2 Navigation - base styles: variables, glass, topbar, footer, dropdowns */

:root {
  --font:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto,
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC',
    'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --content-width: 1180px;
  --transition: 0.22s cubic-bezier(0.25, 0.1, 0.25, 1);
}

html[data-theme='light'] {
  --text: #1d2530;
  --text-secondary: rgba(29, 37, 48, 0.6);
  --text-tertiary: rgba(29, 37, 48, 0.42);
  --accent: #2f76c4;
  --accent-soft: rgba(47, 118, 196, 0.12);
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px rgba(31, 45, 61, 0.14);
  --item-bg: rgba(255, 255, 255, 0.35);
  --item-bg-hover: rgba(255, 255, 255, 0.85);
  --scenery: url('/static/img/scenery.svg');
  --overlay-bg: rgba(240, 244, 248, 0.72);
}

html[data-theme='dark'] {
  --text: #e8edf5;
  --text-secondary: rgba(232, 237, 245, 0.62);
  --text-tertiary: rgba(232, 237, 245, 0.4);
  --accent: #5aa2f0;
  --accent-soft: rgba(90, 162, 240, 0.16);
  --glass-bg: rgba(24, 30, 44, 0.55);
  --glass-bg-strong: rgba(24, 30, 44, 0.8);
  --glass-border: rgba(255, 255, 255, 0.13);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --item-bg: rgba(255, 255, 255, 0.07);
  --item-bg-hover: rgba(255, 255, 255, 0.16);
  --scenery: url('/static/img/scenery-dark.svg');
  --overlay-bg: rgba(10, 14, 24, 0.82);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme='light']):not([data-theme='dark']) {
    --text: #e8edf5;
    --text-secondary: rgba(232, 237, 245, 0.62);
    --text-tertiary: rgba(232, 237, 245, 0.4);
    --accent: #5aa2f0;
    --accent-soft: rgba(90, 162, 240, 0.16);
    --glass-bg: rgba(24, 30, 44, 0.55);
    --glass-bg-strong: rgba(24, 30, 44, 0.8);
    --glass-border: rgba(255, 255, 255, 0.13);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --item-bg: rgba(255, 255, 255, 0.07);
    --item-bg-hover: rgba(255, 255, 255, 0.16);
    --scenery: url('/static/img/scenery-dark.svg');
    --overlay-bg: rgba(10, 14, 24, 0.82);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: #1c2431;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: var(--scenery);
  background-size: cover;
  background-position: center;
  filter: blur(8px) saturate(1.15);
  transform: scale(1.04);
  transition: opacity 0.4s ease;
}

.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(120, 130, 150, 0.18) 55%, rgba(60, 70, 90, 0.32) 100%);
}

html[data-theme='dark'] .bg-overlay {
  background: linear-gradient(180deg, rgba(8, 12, 22, 0.25) 0%, rgba(8, 12, 22, 0.45) 100%);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  padding: 8px 16px;
  background: var(--glass-bg-strong);
  border-radius: var(--radius-sm);
  z-index: 100;
}

.skip-link:focus {
  left: 8px;
}

/* ---------- glass ---------- */

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--content-width);
  margin: 12px auto 0;
  padding: 10px 18px;
  border-radius: var(--radius);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 650;
  font-size: 17px;
  letter-spacing: 0.01em;
}

.brand-logo {
  border-radius: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.icon-btn:hover {
  background: var(--item-bg-hover);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.accent {
  background: var(--accent);
  color: #fff;
}

.icon-btn.accent:hover {
  filter: brightness(1.08);
  background: var(--accent);
}

/* theme icon per state */
html[data-theme='dark'] .ico-theme-light { display: none; }
html[data-theme='dark'] .ico-theme-dark { display: inline; }
html[data-theme='light'] .ico-theme-light { display: inline; }
html[data-theme='light'] .ico-theme-dark { display: none; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme='light']):not([data-theme='dark']) .ico-theme-light { display: none; }
  html:not([data-theme='light']):not([data-theme='dark']) .ico-theme-dark { display: inline; }
}

/* region icon per state */
body[data-region='cn'] .ico-region-global { display: none; }
body[data-region='cn'] .ico-region-cn { display: inline; }
body[data-region='global'] .ico-region-cn { display: none; }
body[data-region='global'] .ico-region-global { display: inline; }

/* ---------- dropdowns ---------- */

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 150px;
  padding: 6px;
  background: var(--glass-bg-strong);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 60;
}

/* display:flex would override the [hidden] UA style - restore it explicitly */
.dropdown-menu[hidden] {
  display: none;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  text-align: left;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
}

.dropdown-menu button:hover {
  background: var(--item-bg-hover);
}

.dropdown-menu button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- footer ---------- */

.footer {
  max-width: var(--content-width);
  margin: 48px auto 24px;
  padding: 28px 32px 20px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.footer-col h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 650;
}

.footer-col p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.footer-link {
  color: var(--accent);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.copyright {
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
  font-size: 12.5px;
  color: var(--text-tertiary);
  text-align: center;
}

/* ---------- fallback icon colors ---------- */

.site-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  user-select: none;
}

.fb-0 { background: linear-gradient(135deg, #6fa8dc, #4a7fb5); }
.fb-1 { background: linear-gradient(135deg, #7fb069, #557d4a); }
.fb-2 { background: linear-gradient(135deg, #e0a458, #b97c3c); }
.fb-3 { background: linear-gradient(135deg, #c97b84, #96565f); }
.fb-4 { background: linear-gradient(135deg, #9b8cc2, #6f6197); }
.fb-5 { background: linear-gradient(135deg, #64a8a0, #437a74); }

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- base responsive ---------- */

@media (max-width: 640px) {
  .topbar {
    margin: 8px 8px 0;
    padding: 8px 12px;
  }
  .brand-name {
    font-size: 15px;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}
