/* styles.css */

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-top: 80px;
}

a {
  color: var(--primary);
}

a:hover {
  color: var(--primary-hover);
}

.text-muted {
  color: var(--muted) !important;
}

.app-body {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 247, 214, 0.9), rgba(254, 249, 231, 0.95));
}

.app-surface {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.7;
  mix-blend-mode: screen;
  background: radial-gradient(circle at 20% 20%, rgba(241, 196, 15, 0.18), transparent 35%),
    radial-gradient(circle at 70% 0%, rgba(39, 174, 96, 0.16), transparent 35%),
    radial-gradient(circle at 85% 70%, rgba(231, 76, 60, 0.12), transparent 32%);
  z-index: 0;
}

.page-shell {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}


/* Navbar core styling */
#main-navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background-color: rgba(254, 249, 231, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
  padding: 0.8rem 1rem;
  transition: transform 0.3s ease-in-out, background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Hidden state */
#main-navbar.nav-hidden {
  transform: translateY(-100%);
  box-shadow: none;
}

/* At the very top */
#main-navbar.at-top {
  background-color: transparent;
  box-shadow: none;
  border-bottom: none;
}

#main-navbar .navbar-toggler {
  display: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-md);
}

.header-collection {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: 1rem;
  flex: 1;
}

#navbarContent.show,
#navbarContent.collapsing {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-header .header-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-mark {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: var(--text);
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-md);
  font-weight: 800;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.mobile-shortcut-pill {
  display: none;
  text-decoration: none;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: 1rem;
  flex-wrap: wrap;
}

.nav-pill {
  color: var(--muted);
  text-decoration: none;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
  font-weight: 600;
}

.nav-pill:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-highlight);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-chip {
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  color: var(--text);
  font-weight: 700;
}

.page-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.gap-2 {
  gap: 0.5rem;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 30%, rgba(241, 196, 15, 0.2), transparent 45%);
  pointer-events: none;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.01em;
  margin-bottom: 0.4rem;
}

.hero p {
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(39, 174, 96, 0.16);
  color: var(--primary);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.book-card {
  position: relative;
  padding: 1.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.9));
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.book-card:hover {
  transform: translateY(-4px);
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg-highlight);
}

.book-card h3 {
  margin: 0.4rem 0;
  font-family: var(--font-display);
}

.divider {
  width: 100%;
  height: 1px;
  background: var(--divider);
  margin: 0.75rem 0;
}

.search-panel {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 2fr 1fr auto;
  align-items: end;
}

.input-shell label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

.input-shell input,
.input-shell select,
.input-shell textarea,
.form-control {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.75rem 0.9rem;
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.input-shell input:focus,
.input-shell select:focus,
.input-shell textarea:focus,
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.2);
}

.form-check-input {
  accent-color: var(--primary);
}

.pill-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px dashed var(--border);
  color: var(--muted);
  text-decoration: none;
}

.flash-region {
  min-height: 0;
}

.toast-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.toast-title {
  font-weight: 700;
}

.quiz-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.quiz-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  color: var(--muted);
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.25rem;
}

.question-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.question-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: block;
}

.question-card.is-active {
  display: block;
  animation: pop 200ms ease;
}

.quiz-wizard-active .question-card {
  display: none;
}

.quiz-wizard-active .question-card.is-active {
  display: block;
}

.question-card.post-submit {
  display: block;
}

.question-number {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.question-body select,
.question-body input[type="text"] {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8rem;
  color: var(--text);
}

.question-body select:focus,
.question-body input[type="text"]:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.18);
}

.quiz-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

.quiz-score-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.score-big {
  font-size: 2.6rem;
  font-weight: 800;
  font-family: var(--font-display);
}

.result-card {
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--bg-card);
}

.draggable-tiles {
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--bg-card);
}

.draggable-tiles .tile {
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  margin-bottom: 0.6rem;
  cursor: grab;
}

.draggable-tiles .tile:hover {
  border-color: var(--primary);
}

.app-footer {
  text-align: center;
  padding: 1.5rem 1.25rem 2rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (min-width: 992px) {
  #main-navbar .navbar-toggler {
    display: none;
  }

  #navbarContent {
    display: flex !important;
    position: static !important;
    background: none !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
}

@keyframes pop {
  from {
    transform: scale(0.98);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 960px) {
  .search-panel {
    grid-template-columns: 1fr;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 1.1rem;
  }

  .book-card {
    padding: 1rem;
  }

  .quiz-nav {
    flex-direction: column;
    align-items: stretch;
  }
}

/* --- Mobile Navigation: Floating Top-Left Square --- */
@media (max-width: 991px) {
  /* 1. Reset Navbar Layout to be transparent and non-intrusive */
  #main-navbar {
    background-color: transparent !important; /* No strip background */
    box-shadow: none !important;
    padding: 10px; /* Space from edges */
    pointer-events: none; /* Let clicks pass through empty space */
    align-items: flex-start; /* Align items to top */
  }

  /* 2. Style the Toggler as a visible "Square" */
  #main-navbar .navbar-toggler {
    display: flex;
    pointer-events: auto; /* Re-enable clicks on the button */
    background-color: var(--secondary); /* Yellow background */
    color: var(--text); /* Dark Icon */
    border: 2px solid var(--text); /* Solid border */
    border-radius: 8px; /* Slightly rounded square */
    
    /* Force Square Shape */
    width: 50px;
    height: 50px;
    align-items: center;
    justify-content: center;
    padding: 0;
    
    /* Positioning */
    position: fixed; /* Keep it fixed while scrolling */
    top: 15px;
    left: 15px;
    z-index: 1100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  }

  /* 3. The Icon (Three Dashes) */
  #main-navbar .navbar-toggler-icon {
    width: 24px;
    height: 24px;
    background-image: none !important; /* Remove default Bootstrap SVG if modifying */
    /* Construct 3 dashes using CSS borders or keep default if it looks good.
       If default is used, ensure contrast: */
    filter: brightness(0); /* Force black icon if SVG */
  }
  
  /* Optional: Custom 3 dashes if not using Bootstrap default */
  #main-navbar .navbar-toggler-icon::before {
    content: "☰"; /* Unicode Hamburger */
    font-size: 24px;
    line-height: 24px;
  }

  /* 4. Hide Brand on Mobile (Optional - based on "minimize to a square") */
  /* If the user wants ONLY the square, hide the text: */
  #main-navbar .brand {
    display: none; 
  }

  .mobile-shortcut-pill {
    display: inline-flex;
    pointer-events: auto;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 0 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }

  .mobile-shortcut-pill:hover {
    color: var(--text);
    background: var(--bg-highlight);
    text-decoration: none;
  }

  /* 5. The Menu Content (When Opened) */
  #main-navbar .navbar-collapse {
    display: none;
  }

  #main-navbar .navbar-collapse.show,
  #main-navbar .navbar-collapse.collapsing {
    pointer-events: auto;
    background-color: var(--bg); /* Solid background when open */
    position: absolute;
    top: 70px; /* Below the button */
    left: 10px;
    right: 10px;
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
  }

  #main-navbar .header-inner {
    align-items: flex-start;
  }

  #main-navbar .header-nav {
    flex-direction: column;
    align-items: flex-start;
    margin-left: 0;
    width: 100%;
  }

  #main-navbar .nav-pill {
    width: 100%;
  }

  #main-navbar .header-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}
