/* ================================================================
   UniCheatSheet - Site-wide Course Search
   Loaded on every page; the trigger + overlay are injected by
   script.js on pages that do not ship them in their HTML.
   ================================================================ */

:root {
  --accent: #00e5ff;
  --accent-dim: rgba(0, 229, 255, 0.15);
  --accent-glow: rgba(0, 229, 255, 0.35);
  --surface: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(0, 229, 255, 0.4);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --transition-fast: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
/* ============================================
   SEARCH
   ============================================ */

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: rgba(0, 10, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 1000;
}

.search-trigger:hover {
  background-color: rgba(0, 229, 255, 0.08);
  border-color: rgba(0, 229, 255, 0.3);
}

.search-trigger i {
  color: var(--accent);
  font-size: 20px;
}

.search-text {
  color: #fff;
  font-size: 18px;
  font-family: 'Inter', 'Montserrat', system-ui, sans-serif;
  font-weight: 500;
  letter-spacing: 1px;
}

/* Search Overlay — fades in/out instead of popping */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 5, 15, 0.98);
  z-index: 10000;
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
  backdrop-filter: blur(20px);
  overflow-y: auto;
}

.search-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s ease, visibility 0s;
}

.search-container {
  max-width: 850px;
  margin: 60px auto 0;
  padding: 20px 24px 40px;
  transform: translateY(14px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.05s, opacity 0.35s ease 0.05s;
}

.search-overlay.active .search-container {
  transform: translateY(0);
  opacity: 1;
}

.search-header {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
}

#searchInput {
  flex: 1;
  padding: 14px 20px;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #fff;
  font-family: 'Inter', 'Montserrat', system-ui, sans-serif;
  transition: border-color 0.3s ease, background 0.3s ease;
}

#searchInput:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 229, 255, 0.04);
}

#searchInput::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.close-search {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 48px;
}

.close-search:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 229, 255, 0.08);
}

/* Search Results Container */
.search-results {
  color: #fff;
}

/* Semester Group */
.search-semester-group {
  margin-bottom: 28px;
}

.search-sem-heading {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin: 0 0 12px 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 229, 255, 0.15);
  font-family: 'Inter', 'Montserrat', system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.search-sem-count {
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 1px;
  text-transform: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Course List */
.search-course-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Course Card — expandable, with a staggered entrance */
.search-course-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  transition: all 0.25s ease;
  overflow: hidden;
  animation: searchCardIn 0.35s ease both;
}

.search-course-card:nth-child(2) { animation-delay: 0.04s; }
.search-course-card:nth-child(3) { animation-delay: 0.08s; }
.search-course-card:nth-child(4) { animation-delay: 0.12s; }
.search-course-card:nth-child(5) { animation-delay: 0.16s; }
.search-course-card:nth-child(6) { animation-delay: 0.2s; }
.search-course-card:nth-child(7) { animation-delay: 0.24s; }
.search-course-card:nth-child(8) { animation-delay: 0.28s; }
.search-course-card:nth-child(n+9) { animation-delay: 0.32s; }

@keyframes searchCardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-course-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.search-course-card.expanded {
  border-color: rgba(0, 229, 255, 0.3);
  background: rgba(0, 229, 255, 0.04);
}

/* Card Header — the clickable area */
.search-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.search-card-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.search-course-card.expanded .search-card-header {
  background: rgba(0, 229, 255, 0.03);
}

/* Course Name */
.search-course-name {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  flex: 1;
  font-family: 'Inter', 'Montserrat', system-ui, sans-serif;
  line-height: 1.3;
}

/* Semester Badge */
.search-sem-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.2);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: 'Inter', system-ui, sans-serif;
  flex-shrink: 0;
}

/* Chevron */
.search-card-chevron {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.4);
  transition: transform 0.3s ease, color 0.3s ease;
  flex-shrink: 0;
}

.search-course-card.expanded .search-card-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

/* Card Body — hidden by default */
.search-card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-course-card.expanded .search-card-body {
  max-height: 200px;
}

/* Link Rows */
.search-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px 13px 24px;
  text-decoration: none;
  color: #fff;
  transition: all 0.2s ease;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-family: 'Inter', system-ui, sans-serif;
}

.search-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

.search-link-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.search-link-label {
  font-size: 0.92rem;
  font-weight: 500;
  flex: 1;
}

.search-link-arrow {
  font-size: 1.3rem;
  color: rgba(255, 255, 255, 0.3);
  font-weight: 300;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.search-link:hover .search-link-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* Courses whose content isn't uploaded yet */
.search-link-empty {
  cursor: default;
  opacity: 0.55;
  font-style: italic;
}

.search-link-empty:hover {
  background: none;
}

/* Link color accents on hover */
.link-lecture:hover {
  background: rgba(99, 179, 237, 0.08);
}

.link-lecture:hover .search-link-label {
  color: #90cdf4;
}

.link-solutions:hover {
  background: rgba(72, 187, 120, 0.08);
}

.link-solutions:hover .search-link-label {
  color: #68d391;
}

.link-pyqs:hover {
  background: rgba(237, 137, 54, 0.08);
}

.link-pyqs:hover .search-link-label {
  color: #f6ad55;
}

/* No Results */
.search-no-results {
  text-align: center;
  padding: 60px 20px;
}

.search-no-results p {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.7);
}

.search-no-results span {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.4);
}

/* Search responsive */
@media screen and (max-width: 600px) {
  .search-container {
    margin: 30px auto 0;
    padding: 16px 16px 30px;
  }

  #searchInput {
    font-size: 16px;
    padding: 12px 16px;
  }

  .search-card-header {
    padding: 12px 14px;
    gap: 8px;
  }

  .search-course-name {
    font-size: 0.9rem;
  }

  .search-sem-badge {
    font-size: 0.6rem;
    padding: 2px 8px;
  }

  .search-link {
    padding: 12px 16px 12px 20px;
    gap: 10px;
  }

  .search-link-label {
    font-size: 0.85rem;
  }

  .search-sem-heading {
    font-size: 0.75rem;
  }
}

/* ---------- Trigger extras: keyboard hint + livelier icon ---------- */
.search-trigger {
  position: relative;
  z-index: 1000;
}

.search-trigger i {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.3s ease;
}

.search-trigger:hover i {
  transform: scale(1.15) rotate(-8deg);
}

.search-kbd {
  display: flex;
  gap: 3px;
  margin-left: 2px;
}

.search-kbd kbd {
  font: 600 10px/1 'Inter', system-ui, sans-serif;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 3px 5px;
  letter-spacing: 0.5px;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.search-trigger:hover .search-kbd kbd {
  color: var(--accent);
  border-color: rgba(0, 229, 255, 0.35);
}

@media screen and (max-width: 768px) {
  .search-kbd {
    display: none;
  }
}

@media screen and (max-width: 576px) {
  .search-text {
    display: none;
  }

  .search-trigger {
    padding: 12px;
  }
}