/* ==========================================================================
   Lanview :: Studio — Header, navigation, mobile menu, footer
   ========================================================================== */

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 500;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: var(--header-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand img { height: 26px; width: auto; }
.brand .brand-dark { display: none; }
html[data-theme="dark"] .brand .brand-light { display: none; }
html[data-theme="dark"] .brand .brand-dark { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .brand .brand-light { display: none; }
  html:not([data-theme]) .brand .brand-dark { display: block; }
}

/* Desktop nav */
.nav-desktop { display: flex; align-items: center; gap: 4px; }
.nav-desktop > ul { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav-desktop a {
  color: var(--text);
  font-weight: 550;
  font-size: .96rem;
  padding: 10px 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-desktop a:hover { color: var(--accent-500); background: var(--surface-alt); }
.nav-desktop li.current > a { color: var(--accent-500); }
.nav-desktop li.external a::after {
  content: "";
  width: 11px; height: 11px;
  margin-left: 2px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14 3h7v7h-2V6.4l-9.3 9.3-1.4-1.4L17.6 5H14V3z'/%3E%3Cpath d='M5 5h6v2H7v10h10v-4h2v6H5V5z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14 3h7v7h-2V6.4l-9.3 9.3-1.4-1.4L17.6 5H14V3z'/%3E%3Cpath d='M5 5h6v2H7v10h10v-4h2v6H5V5z'/%3E%3C/svg%3E") no-repeat center / contain;
  opacity: .55;
}

.nav-item-has-children { position: relative; }
.nav-caret { width: 9px; height: 9px; margin-left: -2px; opacity: .6; transition: transform var(--speed-fast) var(--ease); }
.nav-item-has-children:hover .nav-caret,
.nav-item-has-children:focus-within .nav-caret { transform: rotate(180deg); }

.submenu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity var(--speed-fast) var(--ease), transform var(--speed-fast) var(--ease), visibility var(--speed-fast);
}
.nav-item-has-children:hover .submenu,
.nav-item-has-children:focus-within .submenu {
  opacity: 1; visibility: visible; transform: translateY(4px);
}
.submenu a { display: block; padding: 9px 12px; border-radius: 8px; }

/* Header right controls */
.header-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Theme switch — Light / System / Dark segmented control (icon based) */
.theme-switch {
  --step: 28px; /* button width (26px) + gap (2px) — must match exactly or the thumb drifts out from under the icon as it moves right */
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  flex-shrink: 0;
}
.theme-switch__opt {
  position: relative;
  z-index: 1;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--speed-fast) var(--ease);
}
.theme-switch__opt svg { width: 14px; height: 14px; }
.theme-switch__opt[aria-pressed="true"] { color: #fff; }
.theme-switch__thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-400), var(--accent-600));
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  transition: transform var(--speed-med) var(--ease);
  z-index: 0;
  pointer-events: none;
}
.theme-switch[data-active="light"] .theme-switch__thumb { transform: translateX(0); }
.theme-switch[data-active="system"] .theme-switch__thumb { transform: translateX(var(--step)); }
.theme-switch[data-active="dark"] .theme-switch__thumb { transform: translateX(calc(var(--step) * 2)); }

/* Mobile menu trigger */
.menu-trigger {
  display: none;
  width: 42px; height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
/* Fixed-size icon box with absolutely-positioned bars at integer offsets —
   avoids the sub-pixel rounding that flex+gap can introduce, which was
   making the middle bar render thinner than the outer two in some browsers. */
.menu-trigger-icon {
  position: relative;
  width: 20px;
  height: 14px;
  flex-shrink: 0;
}
.menu-trigger-icon span {
  position: absolute;
  left: 0;
  width: 20px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--speed-fast) var(--ease), opacity var(--speed-fast) var(--ease), top var(--speed-fast) var(--ease);
}
.menu-trigger-icon span:nth-child(1) { top: 0; }
.menu-trigger-icon span:nth-child(2) { top: 6px; }
.menu-trigger-icon span:nth-child(3) { top: 12px; }
html.menu-open .menu-trigger-icon span:nth-child(1) { top: 6px; transform: rotate(45deg); }
html.menu-open .menu-trigger-icon span:nth-child(2) { opacity: 0; }
html.menu-open .menu-trigger-icon span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

@media (max-width: 900px) {
  .nav-desktop { display: none; }
  .menu-trigger { display: flex; }
}

/* ---------- Full-screen mobile menu ---------- */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateY(-100%);
  transition: transform var(--speed-slow) var(--ease);
  overflow-y: auto;
}
html.menu-open .mobile-menu { transform: translateY(0); }
.mobile-menu-top {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mobile-menu-close {
  width: 42px; height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.mobile-menu-close svg { width: 18px; height: 18px; color: var(--text); }

.mobile-nav { padding: 20px 24px 12px; list-style: none; margin: 0; flex: 1; }
.mobile-nav li { border-bottom: 1px solid var(--border); }
.mobile-nav > li > a, .mobile-nav-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 18px 4px;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  background: none; border: none; text-align: left; cursor: pointer;
  font-family: inherit;
}
.mobile-nav .nav-caret { width: 13px; height: 13px; opacity: .5; transition: transform var(--speed-fast) var(--ease); }
.mobile-nav li.open > .mobile-nav-toggle .nav-caret { transform: rotate(180deg); }
.mobile-submenu {
  list-style: none; margin: 0 0 12px; padding: 0 0 0 6px;
  max-height: 0; overflow: hidden;
  transition: max-height var(--speed-med) var(--ease);
}
.mobile-nav li.open .mobile-submenu { max-height: 400px; }
.mobile-submenu a {
  display: block; padding: 12px 4px; font-size: 1.05rem; color: var(--text-secondary);
}
.mobile-nav .external-label { font-size: .95rem; font-weight: 600; color: var(--text-muted); }

.mobile-menu-foot {
  padding: 20px 24px 32px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.mobile-menu-foot .btn { width: 100%; justify-content: center; margin-bottom: 22px; }

/* Font size control (mobile menu only) */
.font-size-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.font-size-label { font-size: .85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.font-size-buttons { display: flex; align-items: center; gap: 6px; }
.font-size-buttons button {
  font-family: inherit;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-secondary);
  cursor: pointer;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--speed-fast) var(--ease), color var(--speed-fast) var(--ease), border-color var(--speed-fast) var(--ease);
}
.font-size-buttons button[data-size="sm"] { font-size: .75rem; }
.font-size-buttons button[data-size="md"] { font-size: .95rem; }
.font-size-buttons button[data-size="lg"] { font-size: 1.15rem; }
.font-size-buttons button.active { background: var(--accent-500); border-color: var(--accent-500); color: #fff; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 56px 0 36px;
  background: var(--bg-alt);
}
.footer-top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 24px;
  padding-bottom: 32px; margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.footer-logo img { height: 24px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 22px; list-style: none; margin: 0; padding: 0; }
.footer-nav a { color: var(--text-secondary); font-size: .95rem; font-weight: 550; }
.footer-nav a:hover { color: var(--accent-500); }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.footer-copy { font-size: .85rem; color: var(--text-muted); }
.footer-partner { display: flex; align-items: center; gap: 8px; }
.footer-partner img { height: 20px; opacity: .85; }
