/* ============================================
   LAYOUT — Nav, page system, sections, footer
   ============================================ */

/* --- NAV --- */
#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 900;
  height: var(--nav-h); padding: 0 48px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid transparent;
  transition: background .3s, border-color .3s, backdrop-filter .3s;
}
#nav.scrolled {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(20px); border-color: var(--border);
}
.nav-logo {
  font-family: var(--ff-display); font-size: 1.25rem; font-weight: 800;
  letter-spacing: -0.02em; color: var(--text); cursor: pointer; user-select: none;
  display: flex; align-items: center; height: var(--nav-h); overflow: hidden;
}
.nav-logo-mark {
  width: 28px; height: 28px; background: var(--accent); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800; color: #fff; flex-shrink: 0;
}
.brand-logo { width: auto; display: block; user-select: none; pointer-events: none; }
.nav-logo .brand-logo { height: 140px; width: auto; object-fit: contain; }
.brand-logo-light { display: none }
[data-theme="light"] .brand-logo-dark { display: none }
[data-theme="light"] .brand-logo-light { display: block }
.nav-links { display: flex; align-items: center; gap: 6px; list-style: none; }
.nav-links a {
  font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.01em;
  color: var(--text-2); padding: 6px 12px; border-radius: 6px;
  transition: color .2s, background .2s;
}
.nav-links a:hover { color: var(--text); background: var(--surface) }
.nav-links a.active { color: var(--text) }
.nav-right { display: flex; align-items: center; gap: 10px }
.nav-theme-btn {
  width: 36px; height: 36px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: border-color .2s, color .2s, background .2s;
}
.nav-theme-btn:hover { border-color: var(--border-hi); color: var(--text) }
.nav-ham {
  display: none; flex-direction: column; gap: 5px;
  width: 36px; height: 36px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 8px;
  align-items: center; justify-content: center;
}
.nav-ham span { width: 16px; height: 1px; background: var(--text); transition: .2s }
.nav-ham.open span:nth-child(1) { transform: translateY(6px) rotate(45deg) }
.nav-ham.open span:nth-child(2) { opacity: 0 }
.nav-ham.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg) }

/* Mobile overlay */
.mob-overlay[hidden] { display: none }
.mob-overlay {
  position: fixed; inset: 0; z-index: 800;
  padding: calc(var(--nav-h) + 16px) 20px 20px;
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  backdrop-filter: blur(24px); opacity: 0; pointer-events: none; transition: opacity .22s;
}
.mob-overlay.open { opacity: 1; pointer-events: auto }
.mob-panel {
  border: 1px solid var(--border); background: var(--bg2); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.mob-link {
  font-size: 0.9rem; font-weight: 500; color: var(--text-2);
  padding: 12px 14px; border-radius: 8px; transition: background .2s, color .2s; display: block;
}
.mob-link:hover { background: var(--surface); color: var(--text) }
.mob-cta {
  margin-top: 8px; font-family: var(--ff-display); font-size: 0.85rem; font-weight: 700;
  color: #fff; background: var(--accent); padding: 12px 16px;
  text-align: center; border-radius: 8px; display: block;
}

/* --- PAGE SYSTEM --- */
.page { display: none; min-height: 100vh; padding-top: var(--nav-h) }
.page.active { display: block }

/* --- SCROLL PROGRESS --- */
.scroll-bar {
  position: fixed; top: 0; left: 0; width: 100%; height: 2px; z-index: 1000;
  background: var(--accent); transform-origin: left; transform: scaleX(0);
  pointer-events: none; will-change: transform;
}

/* --- SECTION COMMONS --- */
.section { max-width: 1160px; margin: 0 auto; padding: 96px 48px; }
.section-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--accent-2);
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
}
.section-label::before {
  content: ''; width: 18px; height: 1px; background: var(--accent-2); opacity: 0.6;
}

/* --- FOOTER --- */
footer {
  --footer-pad: 48px; background: var(--bg);
  border-top: 1px solid var(--border); width: 100%;
  padding: 48px var(--footer-pad) 0; box-sizing: border-box; position: relative;
}
footer::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 1px; background: var(--border);
}
.footer-top {
  position: relative; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 64px; width: 100%; align-items: flex-start;
}
.footer-logo-wrap {
  font-family: var(--ff-display); font-size: 1.2rem; font-weight: 800;
  letter-spacing: -0.02em; color: var(--text); display: flex; align-items: center;
}
.footer-logo-wrap .brand-logo { height: auto; width: auto; object-fit: contain; }
.footer-tagline {
  font-size: 0.875rem; color: var(--text-3); font-style: italic;
  max-width: 280px; line-height: 1.6; padding-top: 4px;
}
.footer-brand-social { margin-top: 20px; display: flex; gap: 10px; }
.footer-nav { display: flex; flex-direction: column; }
.footer-nav a {
  display: block; font-size: 13px; color: var(--text-3);
  line-height: 2.2; transition: color .2s; letter-spacing: 0.02em;
}
.footer-nav a:hover { color: var(--text-2) }
.footer-nav-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 16px;
}
.footer-bottom {
  width: auto; padding: 24px var(--footer-pad);
  margin: 40px calc(var(--footer-pad) * -1) 0;
  border-top: 1px solid rgba(255,255,255,0.06); box-sizing: border-box;
  display: flex; justify-content: space-between; align-items: center;
}
.footer-copy { font-size: 0.8rem; color: var(--text-3) }
.footer-social { display: flex; gap: 10px }
.social-link {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  color: var(--text-3); transition: border-color .2s, color .2s;
}
.social-link:hover { border-color: var(--border-hi); color: var(--text) }
.social-link svg { width: 14px; height: 14px; fill: currentColor }
.footer-contact-text { font-size: 0.85rem; color: var(--text-3); line-height: 1.7; }
.footer-demo-btn {
  margin-top: 14px; align-self: flex-start; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 0.82rem; font-weight: 700; cursor: pointer;
}
.footer-brand-logo { width: 190px; height: 44px; margin-bottom: 18px; overflow: hidden; position: relative; }
.footer-brand-logo .brand-logo {
  position: absolute; left: -18px; top: -79px; width: 220px; height: 220px;
  max-width: none; object-fit: contain;
}
#site-footer .brand-logo-light { display: none !important; }
[data-theme="light"] #site-footer .brand-logo-dark { display: none !important; }
[data-theme="light"] #site-footer .brand-logo-light { display: block !important; }

/* --- BACK TO TOP --- */
.back-to-top {
  position: fixed; bottom: 28px; right: 28px; z-index: 800;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .3s, transform .3s, border-color .2s, color .2s;
}
.back-to-top.visible { opacity: 1; transform: none; pointer-events: auto }
.back-to-top:hover { border-color: var(--border-hi); color: var(--text) }
.back-to-top svg {
  width: 16px; height: 16px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round
}

/* --- RESPONSIVE --- */
@media(max-width:960px) {
  #nav {
    height: 64px; padding: 0 14px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(18px); border-color: var(--border);
  }
  .page { padding-top: 64px; }
  .nav-logo { height: 64px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
  .nav-logo .brand-logo { height: 104px; flex: 0 0 auto; }
  .nav-right { flex: 0 0 auto; gap: 8px; }
  .nav-theme-btn { display: flex !important; width: 36px; height: 36px; flex: 0 0 36px; }
  .nav-links, .nav-right .btn-cta, .nav-right .btn-outline { display: none }
  .nav-ham { display: flex !important; width: 36px; height: 36px; flex: 0 0 36px; }
  .section { padding: 64px 20px }
  footer { --footer-pad: 20px; padding: 40px var(--footer-pad) 0 }
  .footer-top { grid-template-columns: 1fr; gap: 32px }
  .footer-col { justify-self: stretch !important; min-width: 0 !important; }
  .footer-bottom {
    flex-direction: column; align-items: flex-start;
    padding: 24px var(--footer-pad); margin: 40px calc(var(--footer-pad) * -1) 0; gap: 12px
  }
}
@media(max-width:640px) {
  #nav { height: 60px; padding: 0 12px; }
  .page { padding-top: 60px; }
  .nav-logo { height: 60px; }
  .nav-logo .brand-logo { height: 96px; }
  .nav-theme-btn, .nav-ham { width: 34px; height: 34px; flex-basis: 34px; }
  .section { padding: 52px 16px; }
  footer { --footer-pad: 16px; }
  .footer-top { gap: 28px; }
  .footer-bottom { align-items: stretch; }
  .footer-social { justify-content: flex-start; }
}
