/* ===== SayShow Navigation Styles ===== */

/* --- CSS Custom Properties --- */
:root {
  --nav-bg: var(--bg, #0D0D0D);
  --nav-text: var(--text, #fff);
  --nav-text-dim: var(--text2, rgba(255, 255, 255, 0.6));
  --nav-green: #00d478;
  --nav-overlay-bg: var(--bg, #0D0D0D);
  --nav-separator: rgba(255, 255, 255, 0.08);
}

/* Light theme overrides */
[data-theme="light"] {
  --nav-bg: #ffffff;
  --nav-text: #1a1a1a;
  --nav-text-dim: rgba(0, 0, 0, 0.5);
  --nav-overlay-bg: #ffffff;
  --nav-separator: rgba(0, 0, 0, 0.08);
}

/* ===== Hidden Checkbox ===== */
.nav__toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* ===== Nav Bar ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 64px;
  background: var(--nav-bg);
}

.nav__inner {
  display: flex;
  align-items: center;
  height: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Logo ===== */
.nav__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 48px;
}

.nav__logo-img {
  width: 28px;
  height: 28px;
  display: block;
}

.nav__logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--nav-text);
  letter-spacing: -0.02em;
  line-height: 1;
}

/* ===== Desktop Links ===== */
.nav__links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav__link {
  font-size: 15px;
  font-weight: 450;
  color: var(--nav-text-dim);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
  line-height: 1;
}

.nav__link:hover {
  color: var(--nav-text);
  background: rgba(128, 128, 128, 0.08);
}

/* ===== Desktop Actions ===== */
.nav__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Theme Toggle Button */
.nav__theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--nav-text-dim);
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease;
  position: relative;
}

.nav__theme-btn:hover {
  color: var(--nav-text);
  background: rgba(128, 128, 128, 0.08);
}

.nav__theme-icon {
  display: block;
  position: absolute;
  transition: opacity 0.2s ease, transform 0.3s ease;
}

/* Default (dark theme): show moon, hide sun */
.nav__theme-icon--sun {
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
}

.nav__theme-icon--moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Light theme: show sun, hide moon */
[data-theme="light"] .nav__theme-icon--sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

[data-theme="light"] .nav__theme-icon--moon {
  opacity: 0;
  transform: scale(0.5) rotate(90deg);
}

/* Login Button */
.nav__login {
  font-size: 14px;
  font-weight: 550;
  color: #ffffff;
  background: var(--nav-green);
  text-decoration: none;
  padding: 8px 20px;
  border-radius: 8px;
  line-height: 1;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.nav__login:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.nav__login:active {
  transform: translateY(0);
}

/* ===== Hamburger (Mobile) ===== */
.nav__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 8px;
  background: transparent;
  margin-left: auto;
  flex-shrink: 0;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.nav__hamburger:hover {
  background: rgba(128, 128, 128, 0.08);
}

.nav__hamburger-line {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--nav-text);
  border-radius: 2px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.15s ease;
  transform-origin: center;
}

/* Hamburger to X animation */
#nav-toggle:checked ~ .nav .nav__hamburger-line--top {
  transform: translateY(6.5px) rotate(45deg);
}

#nav-toggle:checked ~ .nav .nav__hamburger-line--mid {
  opacity: 0;
  transform: scaleX(0);
}

#nav-toggle:checked ~ .nav .nav__hamburger-line--bot {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* ===== Mobile Overlay ===== */
.nav__overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  background: var(--nav-overlay-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#nav-toggle:checked ~ .nav__overlay {
  opacity: 1;
  pointer-events: auto;
}

/* Backdrop: clicking outside the menu closes it */
.nav__overlay-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav__overlay-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 80px 24px 40px;
  pointer-events: none;
}

.nav__overlay-inner > * {
  pointer-events: auto;
}

/* ===== Mobile Menu ===== */
.nav__menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  max-width: 360px;
}

.nav__menu-link {
  font-size: 28px;
  font-weight: 550;
  color: var(--nav-text);
  text-decoration: none;
  padding: 12px 20px;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease;
  letter-spacing: -0.02em;
  line-height: 1.2;
  width: 100%;
  text-align: center;
}

.nav__menu-link:hover {
  background: rgba(128, 128, 128, 0.06);
}

/* Separator */
.nav__menu-separator {
  width: 100%;
  height: 1px;
  background: var(--nav-separator);
  margin: 16px 0;
}

/* Mobile Theme Toggle */
.nav__menu-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: var(--nav-text-dim);
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
  position: relative;
}

.nav__menu-theme-btn:hover {
  background: rgba(128, 128, 128, 0.06);
  color: var(--nav-text);
}

.nav__menu-theme-btn .nav__theme-icon {
  position: relative;
  flex-shrink: 0;
}

/* Mobile Login Button */
.nav__menu-login {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 16px;
  font-weight: 550;
  color: #ffffff;
  background: var(--nav-green);
  text-decoration: none;
  padding: 14px 20px;
  border-radius: 10px;
  margin-top: 8px;
  transition: opacity 0.15s ease;
  line-height: 1;
}

.nav__menu-login:hover {
  opacity: 0.88;
}

/* ===== Responsive Breakpoint ===== */

/* Desktop: hide hamburger, hide overlay menu */
@media (min-width: 769px) {
  .nav__hamburger {
    display: none;
  }

  .nav__links {
    display: flex;
  }

  .nav__actions {
    display: flex;
  }

  .nav__overlay {
    display: none;
  }
}

/* Mobile: 56px nav, show hamburger, hide desktop links/actions */
@media (max-width: 768px) {
  .nav {
    height: 56px;
  }

  .nav__inner {
    padding: 0 16px;
  }

  .nav__logo {
    margin-right: 0;
    gap: 8px;
  }

  .nav__logo-text {
    font-size: 17px;
  }

  .nav__links {
    display: none;
  }

  .nav__actions {
    display: none;
  }

  .nav__hamburger {
    display: flex;
  }
}

/* ===== Prevent scroll when menu open ===== */
body:has(#nav-toggle:checked) {
  overflow: hidden;
}

/* ===== Reset inherited box-sizing within nav ===== */
.nav *,
.nav *::before,
.nav *::after,
.nav__overlay *,
.nav__overlay *::before,
.nav__overlay *::after {
  box-sizing: border-box;
}

/* ===== Font normalization ===== */
.nav,
.nav__overlay {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Legacy <nav> element support (nav.html uses bare <nav> tag) ===== */
body > nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: 64px; background: var(--nav-bg);
  display: flex; align-items: center;
  padding: 0 24px; gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
body > nav a {
  color: var(--nav-text-dim); text-decoration: none;
  font-size: 14px; font-weight: 450;
  padding: 8px 12px; border-radius: 8px;
  transition: color .15s ease, background .15s ease;
  white-space: nowrap;
}
body > nav a:hover { color: var(--nav-text); background: rgba(128, 128, 128, 0.08); }
body > nav a.logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 17px; font-weight: 600; color: var(--nav-text);
  margin-right: 32px; padding: 4px 8px;
  text-decoration: none;
}
body > nav a.logo:hover { background: transparent; }
@media (max-width: 768px) {
  body > nav { height: 56px; padding: 0 16px; }
  body > nav a { font-size: 13px; padding: 6px 8px; }
  body > nav a.logo { margin-right: 0; font-size: 15px; }
}
