/* ── Palette & globals ──────────────────────────────────────────────── */
:root {
  --brand:       #4f46e5;
  --brand-light: #6366f1;
  --brand-dark:  #3730a3;
  --star-color:  #f59e0b;
  --star-empty:  #d1d5db;
  --bg-hero:     linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f8f9fa;
  -webkit-text-size-adjust: 100%;
}

/* ── Navbar ────────────────────────────────────────────────────────── */
.navbar {
  background: var(--brand);
  padding-top: .4rem;
  padding-bottom: .4rem;
}
.navbar .navbar-brand,
.navbar .nav-link {
  color: #fff !important;
}
.navbar .nav-link:hover {
  color: #e0e7ff !important;
}
.brand-icon {
  font-size: 1.3rem;
}
.search-form {
  max-width: 700px;
  width: 100%;
}
/* (search-cat-select removed — category picker is now a modal) */
.search-form .form-control {
  border: none;
  border-radius: 2rem;
  padding-left: 1rem;
}
.search-form .btn {
  border-radius: 2rem;
}

/* ── Hero ──────────────────────────────────────────────────────────── */
.hero-section {
  background: var(--bg-hero);
  color: #fff;
}
.hero-section .btn-outline-light:hover {
  color: var(--brand);
}
.stat-pill {
  background: rgba(255,255,255,.15);
  padding: .35rem 1rem;
  border-radius: 2rem;
  font-size: .9rem;
}
.stat-number {
  font-weight: 700;
}

/* ── Sidebar (desktop) ─────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  font-size: .88rem;
}
.sidebar-heading {
  font-size: .75rem;
  color: #6b7280;
  letter-spacing: .05em;
}

/* Category tree (sidebar + offcanvas) */
.cat-tree {
  list-style: none !important;
  padding-left: 1.2rem !important;
  margin: 0 !important;
  border-left: 2px solid #e5e7eb;
}
.cat-tree-root {
  padding-left: 0 !important;
  border-left: none !important;
}
.cat-row {
  display: flex;
  align-items: center;
}
.cat-link {
  display: block;
  flex: 1;
  padding: .25rem .5rem;
  color: #374151;
  text-decoration: none;
  border-radius: .25rem;
  transition: background .15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-link:hover {
  background: #e5e7eb;
  color: var(--brand);
}
.cat-link.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.cat-all-link {
  font-weight: 600;
  margin-bottom: .3rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: .4rem;
}

/* Collapse toggle arrow */
.cat-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
  cursor: pointer;
  color: #6b7280;
  font-size: .7rem;
  transition: transform .15s;
  user-select: none;
  border-radius: .2rem;
}
.cat-toggle::before {
  content: "\25b6";  /* ▶ right-pointing triangle = collapsed */
}
.cat-toggle.open::before {
  content: "\25bc";  /* ▼ down-pointing triangle = expanded */
}
.cat-toggle:hover {
  color: var(--brand);
  background: #e5e7eb;
}
.cat-leaf-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
  color: #6b7280;
  font-size: .7rem;
  font-weight: 700;
}
.cat-leaf-marker::before {
  content: "\2014";  /* — em dash */
}

/* Collapsible subtree (visibility controlled by inline style) */
.cat-subtree {
  /* display toggled by inline style + JS */
}

/* ── Offcanvas category drawer (mobile) ────────────────────────────── */
#catDrawer {
  max-width: 280px;
}
#catDrawer .cat-link {
  padding: .45rem .6rem;             /* bigger touch targets */
  font-size: .92rem;
}
#catDrawer .cat-toggle {
  width: 1.5rem;
  height: 1.5rem;
  font-size: .75rem;
}

/* ── Idea cards ────────────────────────────────────────────────────── */
.idea-card {
  border: 1px solid #e5e7eb;
  transition: box-shadow .15s, border-color .15s;
  cursor: pointer;
}
.idea-card:hover {
  border-color: var(--brand-light);
  box-shadow: 0 2px 8px rgba(79,70,229,.12);
}
/* stretched-link makes the whole card clickable; keep the overlay invisible */
.idea-card .stretched-link::after {
  z-index: 1;
}
.idea-card-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
}
.idea-card-stats {
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}
.idea-link {
  color: #111827;
  text-decoration: none;
  font-weight: 600;
}
.idea-link:hover {
  color: var(--brand);
}
.idea-meta {
  font-size: .8rem;
  color: #6b7280;
}
.idea-meta a {
  color: #6b7280;
  text-decoration: underline dotted;
}
.idea-meta a:hover {
  color: var(--brand);
}
/* Tall description textarea — fills available screen space */
.description-tall {
  height: calc(100vh - 520px);
  min-height: 200px;
}
@media (max-width: 575.98px) {
  .description-tall {
    height: calc(100vh - 480px);
    min-height: 150px;
  }
}

/* Category picker button */
.cat-picker-btn {
  background: #fff;
  border: 1px solid #dee2e6;
  color: #495057;
  cursor: pointer;
}
.cat-picker-btn:hover {
  border-color: var(--brand-light);
}
.cat-pick-item.active {
  background: var(--brand) !important;
  color: #fff !important;
}

.author-link {
  color: #6b7280 !important;
  text-decoration: none !important;
}
.author-link:hover {
  color: var(--brand) !important;
  text-decoration: underline !important;
}
.min-width-0 {
  min-width: 0;
}

/* Fork badge */
.fork-badge {
  color: #7c3aed;
  font-weight: 500;
}
.fork-badge a {
  color: #7c3aed !important;
}

/* Fork expand button */
.fork-expand-btn {
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 1rem;
  margin-top: .25rem;
}

/* Inline fork rows (loaded by JS) */
.fork-container {
  border-top: 1px dashed #e5e7eb;
  background: #fafafa;
}
.fork-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .4rem .75rem .4rem 2rem;
  border-bottom: 1px solid #f3f4f6;
  font-size: .85rem;
}
.fork-row:last-child {
  border-bottom: none;
}
.fork-row a {
  color: #4b5563;
  text-decoration: none;
  font-weight: 500;
}
.fork-row a:hover {
  color: var(--brand);
}

/* ── Stars ─────────────────────────────────────────────────────────── */
.stars-display {
  color: var(--star-color);
  font-size: .95rem;
  letter-spacing: 1px;
}
.rating-count {
  font-size: .75rem;
  color: #9ca3af;
}

/* Star rating input (reverse-order trick) */
.star-rating {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: .1em;
}
.star-rating input {
  display: none;
}
.star-rating label {
  cursor: pointer;
  font-size: 1.8rem;
  color: var(--star-empty);
  transition: color .12s;
}
.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
  color: var(--star-color);
}

/* ── Idea detail ───────────────────────────────────────────────────── */
.idea-description {
  white-space: pre-wrap;
  line-height: 1.7;
}
.fork-breadcrumb a {
  color: var(--brand);
  text-decoration: none;
}
.fork-breadcrumb a:hover {
  text-decoration: underline;
}

/* ── Search highlights ─────────────────────────────────────────────── */
mark {
  background: #fef08a;
  padding: 0 .1em;
  border-radius: 2px;
}

/* ── Pagination ────────────────────────────────────────────────────── */
.page-item.active .page-link {
  background-color: var(--brand);
  border-color: var(--brand);
}
.page-link {
  color: var(--brand);
}
.page-link:hover {
  color: var(--brand-dark);
}

/* ── Footer ────────────────────────────────────────────────────────── */
footer {
  color: #9ca3af;
}


/* ==================================================================
   MOBILE  (< 992px — below Bootstrap lg breakpoint)
   ================================================================== */
@media (max-width: 991.98px) {
  /* Hero: compact */
  .hero-section {
    border-radius: 0 !important;
    margin: -1rem -8px 1rem;
    padding: 1.5rem 1rem !important;
  }
  .hero-section .display-5 {
    font-size: 1.5rem;
  }
  .hero-section .lead {
    font-size: .95rem;
  }
  .hero-section .btn-lg {
    font-size: .9rem;
    padding: .4rem 1rem;
  }
  .stats-row {
    gap: .75rem !important;
  }
  .stat-pill {
    font-size: .8rem;
    padding: .25rem .75rem;
  }

  /* Cards: stacked layout on narrow screens */
  .idea-card-inner {
    flex-direction: column;
    gap: .25rem;
  }
  .idea-card-stats {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-align: left;
  }
  .idea-card .card-title {
    white-space: normal;       /* allow wrapping on mobile */
    font-size: .95rem;
  }

  /* Star rating: bigger touch targets */
  .star-rating label {
    font-size: 2.4rem;
    padding: 0 .15rem;
  }

  /* Search form: full width */
  .search-form {
    max-width: 100%;
  }

  /* Pagination: compact */
  .pagination .page-link {
    padding: .3rem .6rem;
    font-size: .85rem;
  }

  /* Sort toggle */
  .btn-group-sm > .btn {
    font-size: .8rem;
  }

  /* Forms: bigger inputs for touch */
  .form-control, .form-select {
    font-size: 1rem;
    padding: .5rem .75rem;
  }

  /* Fork rows: less indent */
  .fork-row {
    padding-left: 1rem;
    font-size: .8rem;
  }

  /* Flash alerts: compact */
  .alert {
    font-size: .85rem;
  }

  /* Profile cards */
  .card-body .row .col-sm-4 {
    font-size: .85rem;
  }
}

/* ==================================================================
   SMALL MOBILE  (< 576px — below Bootstrap sm breakpoint)
   ================================================================== */
@media (max-width: 575.98px) {
  body {
    font-size: .92rem;
  }

  .hero-section .display-5 {
    font-size: 1.25rem;
  }
  .hero-section .lead {
    font-size: .85rem;
    margin-bottom: 1rem !important;
  }
  .hero-section .btn-lg {
    font-size: .85rem;
    padding: .35rem .8rem;
  }

  /* Two-column home: stack to single column */
  .col-md-6 {
    margin-bottom: 1rem;
  }

  /* Card: even more compact */
  .idea-card .card-body {
    padding: .4rem .6rem;
  }
  .idea-card .card-title {
    font-size: .9rem;
  }
  .idea-meta {
    font-size: .72rem;
  }
  .stars-display {
    font-size: .85rem;
  }
  .rating-count {
    font-size: .65rem;
  }
  .fork-expand-btn {
    font-size: .68rem;
    padding: .1rem .4rem;
  }

  /* Idea detail: compact */
  .idea-detail-header h2 {
    font-size: 1.3rem;
  }
  .idea-description .card-body {
    padding: .75rem;
    font-size: .9rem;
    line-height: 1.6;
  }

  /* Pagination: compact on small screens */
  .pagination .page-link {
    padding: .2rem .5rem;
    font-size: .8rem;
  }
}
