/* ========================================
   UNIFIED NAVIGATION STYLES
   ======================================== */

/* Theme Toggle - Fixed top right, HIGHEST z-index */
.theme-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  transition: all 0.3s;
  box-shadow: var(--shadow);
}
.theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

/* Menu Toggle - Fixed top left, HIGHEST z-index */
.menu-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9999;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.3rem;
  backdrop-filter: blur(10px);
  transition: all 0.3s;
  box-shadow: var(--shadow);
  display: none; /* Hidden on desktop */
}
.menu-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

/* Nav - Desktop: Sticky at top */
#main-nav {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  justify-content: center;
  padding-top: 52px; /* Push tiles below fixed toggles */
}

#main-nav .nav-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 0;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  justify-items: center;
}

.nav-empty {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 56px;
  grid-column: 1;
  grid-row: 3;
}

#main-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 16px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 400;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  transition: background 0.2s, color 0.2s;
  border-bottom: 3px solid transparent;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-align: center;
  width: 100%;
  min-height: 56px;
}

#main-nav a:hover,
#main-nav a.active {
  background: var(--primary);
  color: white;
  border-bottom-color: var(--primary);
}

/* ========================================
   TABLE STYLES (all screens)
   ======================================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-weight: 600;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

tbody tr:hover {
  background: var(--bg-alt);
}

/* ========================================
   LIST STYLES (all screens)
   ======================================== */
ul, ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

li {
  margin: 0.5rem 0;
  line-height: 1.7;
  padding-left: 0.25rem;
}

li::marker {
  color: var(--primary);
}

/* Nested lists */
li > ul, li > ol {
  margin: 0.25rem 0;
}

/* Emoji-prefixed list items (used extensively in Compendium) */
li img:first-child, li .bullet:first-child {
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* ========================================
   MOBILE STYLES (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {
  /* Show menu toggle on mobile */
  .menu-toggle {
    display: block;
  }
  
  /* Nav: Fixed at top, slides down when active */
  #main-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transform: translateY(-100%); /* Hidden by default */
    transition: transform 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
  }
  
  #main-nav.open {
    transform: translateY(0); /* Visible when open */
  }
  
  #main-nav .nav-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    justify-items: center;
    box-sizing: border-box;
  }
  
  #main-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 4px;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
    width: 100%;
    min-height: 48px;
    box-sizing: border-box;
  }
  
  #main-nav a:last-of-type {
    border-bottom: none;
  }
  
  /* Add padding to body for fixed nav */
  body {
    padding-top: 60px;
  }
  
  /* Prevent hero from being blocked by toggles */
  .hero {
    margin-top: 0;
    padding-top: 80px;
  }
  
  /* Tables responsive on mobile */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    font-size: 0.9rem;
    table-layout: auto;
    border-collapse: collapse;
    white-space: normal;
  }
  
  thead, tbody, tr {
    display: table;
    width: 100%;
  }
  
  th, td {
    display: table-cell;
    padding: 10px 12px;
    min-width: 100px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: left;
  }
  
  th {
    font-weight: 600;
    border-bottom: 2px solid var(--border);
  }
  
  td {
    border-bottom: 1px solid var(--border);
  }
}
