:root {
  /* Dark theme (default) */
  --bg-primary: #0b1622;
  --bg-secondary: #1a2332;
  --bg-tertiary: #151f2e;
  --bg-quaternary: #32445b;
  --text-primary: #8596a5;
  --text-secondary: #a8b5c4;
  --text-search: #9FADBD;
  --text-search-link: #728AA1;
  --text-search-hover: #8897AA;
  --text-light: #f8f8f8;
  --border-color: #32445b;
  --hover-bg: #2a3441;
  --search-bg: #151F2E;
  --search-hover-bg: #1f2a38;
  --search-border-active: #475A6D;
  --scrollbar-thumb: #ebebeb;
}

[data-theme="light"] {
  --bg-primary: #e7f0f8;
  --bg-secondary: #b7e0f7;
  --bg-tertiary: #DCECF8;
  --bg-quaternary: #ffffff;
  --text-primary: #0b5f97;
  --text-secondary: #0b5f97;
  --text-search: #0b5f97;
  --text-search-link: #97cdec;
  --text-search-hover: #0b5f97;
  --text-light: #0b5f97;
  --border-color: #DCECF8;
  --hover-bg: #cfe8f7;
  --search-bg: #e7f0f8;
  --search-hover-bg: #cfe8f7;
  --search-border-active: #97cdec;
  --scrollbar-thumb: #DCECF8;
}

[data-theme="brown"] {
  --bg-primary: #271c19;
  --bg-secondary: #f8f8f8;
  --bg-tertiary: #55423d;
  --bg-quaternary: #af7f76;
  --text-primary: #faeee7;
  --text-secondary: #faeee7;
  --text-search: #faeee7;
  --text-search-link: #af7f76;
  --text-search-hover: #faeee7;
  --text-light: #faeee7;
  --border-color: #fffffe;
  --hover-bg: #fffffe;
  --search-bg: #271c19;
  --search-hover-bg: #3b2b27;
  --search-border-active: #af7f76;
  --scrollbar-thumb: #74544d;
}

/* Overlay dims the page */
#search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem;
  z-index: 9999;
  overflow-y: auto;
  box-sizing: border-box;
}
#search-overlay {
  transition: opacity 0.5s ease;
  opacity: 1;
}

#search-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
/* The results panel */


/* Scrollbar styling for panel */
#search-results-panel::-webkit-scrollbar {
  width: 8px;
}

#search-results-panel::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 4px;
}

/* Search cards grid inside panel */
.search-card-grid {
  width: 100%;
  max-width: 800px;
  max-height: 70vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  overflow-y: auto;
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body[data-media-type="music"] .search-card-grid {
  grid-template-columns: repeat(2, 1fr);
}

.search-card-grid::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}


/* Individual search card */
.search-card {
  background:none;
  padding: 0.5rem;
}

.search-card:hover {
  transform: scale(1.05);
  background-color: var(--search-hover-bg);
  border-radius: 4px;
}

body[data-media-type="music"] .search-card:hover {
  transform: none;
  background-color: inherit;
}

.search-card img {
  display: block;
  width: 120px;
  height: 180px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  margin-bottom: 0.6rem;
  object-fit: cover;
  margin-left: auto;
  margin-right: auto;
}

body[data-media-type="music"] .search-card img {
  display: none;
}

.search-card-title {
  color: var(--text-search);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  min-height: 2.6em;
  user-select: none;
  padding: 0 0.4rem;
}

body[data-media-type="music"] .search-card-title {
  display: flex;
  justify-content: center;  /* horizontal */
  align-items: center;      /* vertical */
  height: 100%;             /* fill the card container */
  min-height: auto;          /* optional: let flex handle sizing */
  padding: 0.2rem;           /* optional tweak */
  text-align: center;        /* keep text centered */
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

body[data-media-type="music"] .search-card:hover .search-card-title {
  transform: scale(1.05);
  background-color: var(--search-hover-bg);
}

.search-card .card-link {
  color: var(--text-search-link);
  text-decoration: none;
  outline: none;
}

.search-card .card-link:hover,
.search-card .card-link:focus {
  text-decoration: none;
  color: var(--text-search);
}

/* Overlay search input styling */
.overlay-search-bar {
  margin-bottom: 1rem;
  text-align: center;
}

.search-input-container {
  position: relative;
  display: inline-block;
}

#overlay-search-input {
  width: 80%;
  min-width: 250px;
  max-width: 400px;
  padding: 0.75rem 0.75rem 0.75rem 2.75rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
  background-color: var(--search-bg);
  color: var(--text-search);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

#overlay-search-input::placeholder {
  color: var(--text-search);
  opacity: 1;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-search);
  pointer-events: none;
}

.overlay-search-bar {
  align-items: center;
  gap: 1rem;
}

.live-search-label {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text-search-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0.5rem;
  background-color: var(--search-bg);
  border: 3px solid transparent;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: background-color 0.2s ease;
  text-align: center;
}

.live-search-label:hover{
  color: var(--text-search);
}

.live-search-label.active {
  border: 3px solid var(--search-border-active);
}

.live-search-label input[type="checkbox"] {
  display: none;
}

.overlay-search-input-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  transform: translateY(-20px);
  opacity: 0;
  animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}


@media (orientation: portrait) {

  #search-overlay{
    padding-top: 8rem;
    transform: scale(1.7);
    transform-origin: top;
  }

  .search-card-grid{
    max-width: 32rem;
    grid-template-columns: repeat(3, 1fr)!important;
    max-height: 40vh;
  }

  #overlay-search-input {
  width: 80%;
  min-width: 250px;
  max-width: 25rem;
  padding: 0.75rem 0.75rem 0.75rem 2.75rem;
  font-size: 1.5rem;
  border: none;
  border-radius: 6px;
  outline: none;
  background-color: var(--search-hover-bg);
  color: var(--text-light);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.search-icon {
  left: 1.3rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
}

.live-search-label {
  font-size: 1.1rem;
}


  .search-card{
    transform: scale(1.1);
  }
  

}