/* ==========================================================================
   Navbar UDLAP (sticky, dark mode, search, mobile, scroll-to-top)
   ========================================================================== */

:root {
  --udlap-color-bg: #ffffff;
  --udlap-color-bg-card: #fff;
  --udlap-color-text: #0f172a;
  --udlap-color-dark: #1a2f28;
  --udlap-color-accent: #d27961;
  --udlap-color-accent-primary: #88b04b;
  --udlap-color-accent-orange: #ff6b35;
  --udlap-color-accent-orange-hover: #e55a2b;
  --udlap-color-border: rgba(0, 0, 0, 0.08);
  --udlap-color-border-input: #e2e8f0;
  --udlap-color-shadow: rgba(0, 0, 0, 0.08);
  --udlap-color-overlay: rgba(0, 0, 0, 0.5);
  --udlap-color-navbar-bg: rgba(255, 255, 255, 0.75);
  --udlap-touch-target-min: 44px;
  --udlap-navbar-height: 5.5rem;
}

body {
  padding-top: var(--udlap-navbar-height);
}

/* ----- Navbar ----- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: transparent;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 1rem 0;
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
}

.navbar.visible {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.navbar.at-top {
  background: var(--udlap-color-navbar-bg);
  backdrop-filter: blur(10px);
}

.navbar.at-top .navbar-container {
  justify-content: space-between;
}

.navbar.at-top .navbar-menu {
  background: var(--udlap-color-bg-card);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
}

.navbar.scrolled {
  background: var(--udlap-color-navbar-bg);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px var(--udlap-color-shadow);
}

.navbar.scrolled .navbar-container {
  justify-content: center;
  position: relative;
}

.navbar.scrolled .navbar-logo-link {
  position: absolute;
  left: 1.5rem;
}

.navbar.scrolled .navbar-menu {
  background: transparent;
  padding: 0;
  border-radius: 0;
  backdrop-filter: none;
  margin: 0 auto;
}

.navbar-container {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-logo-link {
  display: inline-flex;
  text-decoration: none;
}

.navbar-logo {
  height: 3.5rem;
  width: auto;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.navbar-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.8);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  backdrop-filter: blur(10px);
  list-style: none;
  margin: 0;
}

.navbar-menu-item {
  position: relative;
  margin: 0;
}

.navbar-menu-link {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--udlap-color-text);
  transition: color 0.3s ease;
  border-radius: 1rem;
  text-decoration: none;
}

.navbar-menu-link:hover {
  color: var(--udlap-color-accent-orange);
  text-decoration: none;
}

@media (min-width: 1025px) {
  .navbar-menu {
    background: rgba(26, 47, 40, 0.05);
    padding: 0.25rem;
    border-radius: 20px;
    backdrop-filter: none;
    gap: 0;
  }

  .navbar-menu-link {
    font-family: "Poppins", "Source Sans 3", sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 18px;
    color: #1a2f28;
    border-radius: 20px;
    transition: all 0.3s ease;
    white-space: nowrap;
  }

  .navbar-menu-link:hover {
    background-color: rgba(26, 47, 40, 0.1);
    color: #1a2f28;
  }

  .navbar.at-top .navbar-menu {
    background: #fff;
    padding: 0.25rem;
    border-radius: 20px;
  }

  .navbar.at-top .navbar-menu-link {
    font-family: "Poppins", "Source Sans 3", sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 18px;
    color: #1a2f28;
    border-radius: 20px;
  }

  .navbar.at-top .navbar-menu-link:hover {
    background-color: rgba(26, 47, 40, 0.1);
    color: #1a2f28;
  }

  .navbar.scrolled .navbar-menu {
    background: rgba(26, 47, 40, 0.05);
    padding: 0.25rem;
    border-radius: 20px;
    gap: 0;
  }

  .navbar.scrolled .navbar-menu-link {
    font-family: "Poppins", "Source Sans 3", sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 18px;
    color: #1a2f28;
    border-radius: 20px;
    background: transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
  }

  .navbar.scrolled .navbar-menu-link:hover {
    background-color: rgba(26, 47, 40, 0.1);
    color: #1a2f28;
  }
}

/* ----- Hamburger ----- */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  background: none;
  border: 0;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 1.5rem;
  height: 2px;
  background: var(--udlap-color-text);
  transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* ----- Mobile menu ----- */
.mobile-menu {
  display: none;
  position: fixed;
  top: 5.5rem;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ff6b35;
  z-index: 998;
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 2rem 1.5rem 4rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  height: calc(100vh - 5.5rem);
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.mobile-menu.active {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.mobile-menu > ul {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.mobile-menu-item {
  margin-bottom: 0.75rem;
  width: 100%;
  display: block;
  flex-shrink: 0;
}

.mobile-menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  color: white;
  font-family: "Poppins", "Source Sans 3", sans-serif;
  font-size: 1.25rem;
  line-height: 1.5;
  border-radius: 0.5rem;
  transition: background 0.3s ease;
  width: 100%;
  text-decoration: none;
}

.mobile-menu-link:hover,
.mobile-menu-link.active {
  background: rgba(255, 255, 255, 0.2);
  text-decoration: none;
  color: white;
}

.mobile-search {
  margin-top: auto;
  padding-top: 2rem;
  padding-bottom: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-search-icon {
  background: none;
  border: none;
  padding: 0;
  width: 2rem;
  height: 2rem;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
  outline: none;
}

.mobile-search-icon svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mobile-search-icon:hover {
  opacity: 0.8;
}

@media (max-width: 1024px) {
  .navbar,
  .navbar.scrolled,
  .navbar.at-top {
    background: var(--udlap-color-navbar-bg);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px var(--udlap-color-shadow);
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .navbar .navbar-container,
  .navbar.scrolled .navbar-container {
    justify-content: space-between;
    position: static;
  }

  .navbar .navbar-logo-link,
  .navbar.scrolled .navbar-logo-link {
    position: static;
  }

  .navbar .navbar-right,
  .navbar.scrolled .navbar-right {
    margin-left: auto;
  }

  .navbar-menu {
    display: none;
  }

  .menu-toggle {
    display: flex;
  }

  .mobile-menu {
    display: flex;
  }

  .mobile-menu-link {
    font-size: calc(1.25rem - 2px);
  }
}

/* ----- Search icon + modal ----- */
.search-icon {
  background: none;
  border: none;
  padding: 0;
  width: 1.5rem;
  height: 1.5rem;
  cursor: pointer;
  color: var(--udlap-color-text);
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  outline: none;
}

.search-icon svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.search-icon:hover {
  color: var(--udlap-color-accent-orange);
}

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.search-modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.search-modal-overlay {
  position: absolute;
  inset: 0;
  background: var(--udlap-color-overlay);
  backdrop-filter: blur(4px);
}

.search-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--udlap-color-bg-card);
  border-radius: 1rem;
  padding: 2.5rem;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.search-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 2rem;
  color: var(--udlap-color-text);
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
  line-height: 1;
  background: none;
  border: 0;
  cursor: pointer;
}

.search-modal-close:hover {
  background: var(--udlap-color-bg);
  color: var(--udlap-color-accent-orange);
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.search-label {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--udlap-color-text);
}

.search-input {
  width: 100%;
  padding: 1rem 1.25rem;
  border: 2px solid var(--udlap-color-border-input);
  border-radius: 0.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--udlap-color-text);
  background: var(--udlap-color-bg-card);
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: var(--udlap-color-accent-orange);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.search-submit {
  background-color: var(--udlap-color-accent-orange);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  align-self: flex-start;
}

.search-submit:hover {
  background-color: var(--udlap-color-accent-orange-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

@media (max-width: 1024px) {
  .search-icon {
    display: none;
  }
}

@media (max-width: 768px) {
  .search-modal-content {
    padding: 2rem 1.5rem;
    width: 95%;
  }

  .search-label {
    font-size: 1.125rem;
  }

  .search-input {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
  }

  .search-submit {
    width: 100%;
    padding: 0.875rem 1.5rem;
  }
}

/* ----- Scroll to top ----- */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 3rem;
  height: 3rem;
  background: var(--udlap-color-accent-orange);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 0;
  padding: 0;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background: var(--udlap-color-accent-orange-hover);
  transform: translateY(-5px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.scroll-to-top svg {
  width: 1.5rem;
  height: 1.5rem;
}

@media (max-width: 1024px) {
  .scroll-to-top {
    width: 2.5rem;
    height: 2.5rem;
    bottom: 1.5rem;
    right: 1.5rem;
  }

  .scroll-to-top svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}

/* ----- Theme toggle ----- */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--udlap-touch-target-min);
  height: var(--udlap-touch-target-min);
  border-radius: 50%;
  color: var(--udlap-color-text);
  transition: background 0.3s ease, color 0.3s ease;
  flex-shrink: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--udlap-color-border);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--udlap-color-accent-orange);
  outline-offset: 2px;
}

.theme-toggle__icon {
  width: 1.25rem;
  height: 1.25rem;
}

.theme-toggle__sun {
  display: none;
}

.theme-toggle__moon {
  display: block;
}

[data-theme="dark"] .theme-toggle__sun {
  display: block;
}

[data-theme="dark"] .theme-toggle__moon {
  display: none;
}

.mobile-theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  color: white;
  font-family: "Poppins", "Source Sans 3", sans-serif;
  font-size: 1.25rem;
  line-height: 1.5;
  border-radius: 0.5rem;
  transition: background 0.3s ease;
  width: 100%;
  background: none;
  border: 0;
  cursor: pointer;
}

.mobile-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.mobile-theme-toggle:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.mobile-theme-toggle__icon {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.mobile-theme-toggle__sun {
  display: none;
}

.mobile-theme-toggle__moon {
  display: block;
}

[data-theme="dark"] .mobile-theme-toggle__sun {
  display: block;
}

[data-theme="dark"] .mobile-theme-toggle__moon {
  display: none;
}

[data-theme="dark"] .mobile-theme-toggle {
  color: var(--udlap-color-text);
}

[data-theme="dark"] .mobile-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

@media (min-width: 1025px) {
  .mobile-theme-toggle {
    display: none;
  }
}

@media (max-width: 1024px) {
  .theme-toggle {
    display: flex;
  }

  .mobile-theme-toggle {
    font-size: calc(1.25rem - 2px);
  }
}

/* ----- Dark theme (navbar + page tokens) ----- */
[data-theme="dark"] {
  color-scheme: dark;

  --udlap-color-bg: #18191d;
  --udlap-color-bg-card: #23262d;
  --udlap-color-text: #e8e6e3;
  --udlap-color-dark: #c8d0c5;
  --udlap-color-accent: #e8a090;
  --udlap-color-accent-primary: #a3c86a;
  --udlap-color-accent-orange: #ff8a5c;
  --udlap-color-accent-orange-hover: #ff6b35;
  --udlap-color-border: rgba(255, 255, 255, 0.12);
  --udlap-color-border-input: #3a3d44;
  --udlap-color-shadow: rgba(0, 0, 0, 0.3);
  --udlap-color-overlay: rgba(0, 0, 0, 0.7);
  --udlap-color-navbar-bg: rgba(27, 29, 33, 0.88);

  --surface: #18191d;
  --surface-soft: #23262d;
  --ink: #e8e6e3;
  --muted: #918e88;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 0.75rem 2.5rem rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
  color: var(--ink);
}

[data-theme="dark"] .navbar-menu {
  background: rgba(37, 40, 48, 0.8);
}

[data-theme="dark"] .navbar.at-top .navbar-menu {
  background: var(--udlap-color-bg-card);
}

@media (min-width: 1025px) {
  [data-theme="dark"] .navbar-menu {
    background: rgba(255, 255, 255, 0.07);
  }

  [data-theme="dark"] .navbar-menu-link {
    color: var(--udlap-color-dark);
  }

  [data-theme="dark"] .navbar-menu-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--udlap-color-dark);
  }

  [data-theme="dark"] .navbar.at-top .navbar-menu {
    background: var(--udlap-color-bg-card);
  }

  [data-theme="dark"] .navbar.at-top .navbar-menu-link {
    color: var(--udlap-color-dark);
  }

  [data-theme="dark"] .navbar.at-top .navbar-menu-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--udlap-color-dark);
  }

  [data-theme="dark"] .navbar.scrolled .navbar-menu {
    background: rgba(255, 255, 255, 0.07);
  }

  [data-theme="dark"] .navbar.scrolled .navbar-menu-link {
    color: var(--udlap-color-dark);
  }

  [data-theme="dark"] .navbar.scrolled .navbar-menu-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--udlap-color-dark);
  }
}

[data-theme="dark"] .mobile-menu {
  background: var(--udlap-color-bg-card);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .mobile-menu-link {
  color: var(--udlap-color-text);
}

[data-theme="dark"] .mobile-menu-link:hover,
[data-theme="dark"] .mobile-menu-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--udlap-color-text);
}

[data-theme="dark"] .mobile-search {
  border-top-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .mobile-search-icon {
  color: var(--udlap-color-text);
}

[data-theme="dark"] .search-modal-content {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .search-input {
  background: var(--udlap-color-bg);
}

[data-theme="dark"] .search-input:focus {
  box-shadow: 0 0 0 3px rgba(255, 138, 92, 0.15);
}
