/*
 * Layout styles define the structural scaffolding of each page. It handles
 * navigation positioning for desktop and mobile, the 3D stage container, and
 * responsive grid behaviours. The layout ensures that the bottom
 * navigation doesn’t obscure content by padding the bottom of the page on
 * small devices.
 */
/* Root application wrapper */
.app {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Fixed sidebar navigation (desktop) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--nav-width-desktop);
  height: 100vh;
  background: var(--color-muted);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
  z-index: 1000;
}

.sidebar .nav-icons {
  list-style: none;
  display: flex;
  flex-direction: column;
  /* Increase spacing between icons on desktop for clearer separation */
  gap: var(--space-7);
  margin: 0;
  padding: 0;
}

.sidebar .nav-icons li {
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  margin-bottom: 4px;
  border-radius: var(--radius-round);
  color: var(--color-silver);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 10px 22px rgba(0,0,0,0.16);
  transition: transform var(--duration-fast) var(--easing), background var(--duration-fast) var(--easing), border-color var(--duration-fast) var(--easing);
}

.sidebar-logo:hover,
.sidebar-logo:focus-visible {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.08);
  border-color: rgba(50,214,240,0.34);
}

.sidebar-logo img {
  width: 40px;
  height: 40px;
  display: block;
}

.sidebar .nav-icons button {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-round);
  background: var(--color-muted-light);
  border: 1px solid var(--color-muted-light);
  color: var(--color-silver);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background var(--duration-fast) var(--easing),
    transform var(--duration-fast) var(--easing);
}

/* Allow anchors (.nav-btn) inside nav to look and behave like buttons */
.sidebar .nav-icons .nav-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-round);
  background: var(--color-muted-light);
  border: 1px solid var(--color-muted-light);
  color: var(--color-silver);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background var(--duration-fast) var(--easing),
    transform var(--duration-fast) var(--easing);
  text-decoration: none;
}

/* Highlight active navigation buttons and links. The active class is
 * applied by initNavState() in app.js. Active items use a neon
 * background and dark text for strong contrast. */
.sidebar .nav-icons .nav-btn.active,
.sidebar .nav-icons button.active {
  background: var(--color-neon-5);
  color: var(--color-anthracite);
  transform: scale(1.05);
}

/* Hover & focus styles for both buttons and anchor nav items */
.sidebar .nav-icons button:hover,
.sidebar .nav-icons button:focus,
.sidebar .nav-icons .nav-btn:hover,
.sidebar .nav-icons .nav-btn:focus {
  background: var(--color-muted);
  color: var(--color-neon-2);
  transform: scale(1.05);
}

/* Top microbar inside content area */
.microbar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.microbar .chip {
  background: var(--color-muted-light);
  color: var(--color-silver);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-round);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* The floating quick actions stack has been removed globally. To ensure no
 * residual styles inadvertently occupy space, the class is defined but
 * hidden. */
.quick-actions {
  display: none !important;
}

/* Content area next to navigation */
.content {
  margin-left: var(--nav-width-desktop);
  width: calc(100% - var(--nav-width-desktop));
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  z-index: 0;
}

/* Stage container with perspective for 3D scenes */


.stage {
  perspective: 1400px;
  transform-style: preserve-3d;
  width: 100%;
  position: relative;
}

/* Scenes inside stage hold actual page content */
.scene {
  transform-style: preserve-3d;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* Bottom navigation bar (mobile). On desktop it remains hidden by default and
 * appears on screens up to 768px wide. The bar is fixed to the bottom of
 * the viewport and contains the same icons as the sidebar. */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height-mobile);
  background: var(--color-muted);
  border-top: 1px solid var(--color-muted-light);
  display: none;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav .nav-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-round);
  background: var(--color-muted-light);
  border: 1px solid var(--color-muted-light);
  color: var(--color-silver);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background var(--duration-fast) var(--easing),
    transform var(--duration-fast) var(--easing);
  text-decoration: none;
}
.bottom-nav .nav-btn.active {
  background: var(--color-neon-5);
  color: var(--color-anthracite);
  transform: scale(1.05);
}
.bottom-nav .nav-btn:hover,
.bottom-nav .nav-btn:focus {
  background: var(--color-muted);
  color: var(--color-neon-2);
  transform: scale(1.05);
}

/* Hide the sections toggle and modal on all viewports. The bottom
 * navigation bar provides the mobile navigation now. */
#sections-toggle,
#sections-modal {
  display: none !important;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .bottom-nav {
    display: flex;
  }
  .content {
    margin-left: 0;
    width: 100%;
    padding: var(--space-5) var(--space-4);
    /* Leave room for the bottom nav */
    padding-bottom: calc(var(--nav-height-mobile) + var(--space-6));
  }
  .microbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .quick-actions {
    display: none;
  }
}

/* ------------------------------------------------------------------ */
/* Sections modal and toggle for mobile navigation                      */
/* The sidebar navigation is hidden on small screens. A single button
 * appears that opens a modal listing each page. This improves
 * accessibility by offering a clear navigation mechanism without
 * obscuring content. */
.sections-toggle {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-round);
  background: var(--color-neon-5);
  color: var(--color-anthracite);
  border: none;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1100;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--easing),
    color var(--duration-fast) var(--easing);
}
.sections-toggle:focus,
.sections-toggle:hover {
  background: var(--color-neon-4);
}
@media (max-width: 768px) {
  .sections-toggle {
    display: flex;
  }
}

.sections-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 1200;
}
.sections-modal.open {
  display: block;
}
.sections-modal .sections-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.sections-modal .sections-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-muted-light);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  color: var(--text-on-dark);
}
.sections-dialog h2 {
  margin: 0 0 var(--space-4) 0;
  color: var(--color-neon-5);
}
.sections-dialog ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.sections-dialog li a {
  text-decoration: none;
  display: block;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-silver);
  background: var(--color-muted);
  transition: background var(--duration-fast) var(--easing),
    color var(--duration-fast) var(--easing);
}
.sections-dialog li a:hover,
.sections-dialog li a:focus {
  background: var(--color-neon-5);
  color: var(--color-anthracite);
}
.sections-close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  background: none;
  border: none;
  color: var(--color-silver);
  font-size: 1.5rem;
  cursor: pointer;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.page-bg canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.page-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(1200px 700px at 50% 45%, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.52) 60%, rgba(0, 0, 0, 0.70) 100%);
}

.page-bg--home::after {
  background: radial-gradient(1200px 700px at 50% 45%, rgba(0, 0, 0, 0.03) 0%, rgba(0, 0, 0, 0.18) 60%, rgba(0, 0, 0, 0.28) 100%);
}

.stage {
  z-index: 1;
}

/* ------------------------------------------------------------------ */
/* Homepage / global navigation refinement                              */
/* Desktop keeps the left rail. Mobile returns to the fixed bottom bar  */
/* requested in the latest feedback while preserving the same palette.   */

.sidebar {
  width: 84px;
  padding: 18px 0;
  background: linear-gradient(180deg, rgba(43,48,56,0.96), rgba(37,42,50,0.98));
  border-right: 1px solid rgba(255,255,255,0.05);
  box-shadow: 14px 0 36px rgba(0,0,0,0.16);
}

.sidebar nav {
  width: 100%;
}

.sidebar .nav-icons {
  gap: 1.9rem;
  width: 100%;
  align-items: center;
}

.sidebar .nav-icons .nav-btn,
.sidebar .nav-icons button {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.05);
  color: var(--color-silver);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.sidebar .nav-icons .nav-btn svg,
.sidebar .nav-icons button svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.9;
}

.sidebar .nav-icons .nav-btn.active,
.sidebar .nav-icons button.active {
  background: var(--color-neon-5);
  color: #111820;
  border-color: transparent;
  box-shadow: 0 12px 22px rgba(51,155,240,0.26);
}

.content {
  margin-left: 84px;
  width: calc(100% - 84px);
  padding-inline: clamp(1rem, 2vw, 1.8rem);
}

.bottom-nav {
  display: none;
  background: linear-gradient(180deg, rgba(43,48,56,0.96), rgba(37,42,50,0.98));
  border-top: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 -12px 28px rgba(0,0,0,0.22);
  backdrop-filter: blur(16px);
  padding: 0.55rem max(0.7rem, env(safe-area-inset-right)) calc(0.55rem + env(safe-area-inset-bottom, 0px)) max(0.7rem, env(safe-area-inset-left));
  height: auto;
}

.bottom-nav .nav-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--color-silver);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.bottom-nav .nav-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.9;
}

.bottom-nav .nav-btn.active {
  background: var(--color-neon-5);
  color: #111820;
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(51,155,240,0.22);
}

.bottom-nav .nav-btn:hover,
.bottom-nav .nav-btn:focus-visible {
  background: rgba(255,255,255,0.11);
  color: var(--color-neon-2);
}

html {
  scrollbar-color: rgba(61, 180, 255, 0.6) rgba(255,255,255,0.06);
  scrollbar-width: thin;
}

body::-webkit-scrollbar,
.home-dialog::-webkit-scrollbar,
.faq-answer::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

body::-webkit-scrollbar-track,
.home-dialog::-webkit-scrollbar-track,
.faq-answer::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}

body::-webkit-scrollbar-thumb,
.home-dialog::-webkit-scrollbar-thumb,
.faq-answer::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(80, 201, 255, 0.82), rgba(49, 122, 207, 0.88));
  border-radius: 999px;
  border: 2px solid rgba(12,16,24,0.7);
}

body::-webkit-scrollbar-thumb:hover,
.home-dialog::-webkit-scrollbar-thumb:hover,
.faq-answer::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(107, 226, 255, 0.95), rgba(60, 146, 236, 0.96));
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
  }

  .content {
    margin-left: 0;
    width: 100%;
    padding: 0.95rem 0.8rem calc(var(--nav-height-mobile) + 2.15rem);
  }
}

@media (max-width: 420px) {
  .bottom-nav {
    gap: 0.35rem;
    padding-inline: 0.45rem;
  }

  .bottom-nav .nav-btn {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 768px) {
  .bottom-nav {
    --mobile-nav-button-size: 48px;
    --mobile-nav-pad-y: 8px;
    box-sizing: border-box;
    left: 0;
    right: 0;
    width: auto !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    height: calc(var(--mobile-nav-button-size) + 16px + env(safe-area-inset-bottom, 0px)) !important;
    min-height: calc(var(--mobile-nav-button-size) + 16px + env(safe-area-inset-bottom, 0px)) !important;
    padding: var(--mobile-nav-pad-y) max(0.65rem, env(safe-area-inset-right)) calc(var(--mobile-nav-pad-y) + env(safe-area-inset-bottom, 0px)) max(0.65rem, env(safe-area-inset-left)) !important;
  }

  .bottom-nav .nav-btn {
    flex: 0 0 var(--mobile-nav-button-size);
    width: var(--mobile-nav-button-size) !important;
    height: var(--mobile-nav-button-size) !important;
    min-width: var(--mobile-nav-button-size) !important;
    min-height: var(--mobile-nav-button-size) !important;
    max-width: var(--mobile-nav-button-size);
    max-height: var(--mobile-nav-button-size);
    transform: none !important;
  }

  .bottom-nav .nav-btn svg {
    width: 22px;
    height: 22px;
  }

  .content {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 1.25rem);
  }
}


/* Final alignment polish */
.sidebar {
  padding-top: 10px;
}
.sidebar .nav-icons {
  justify-content: flex-start;
}
