:root {
  /* Dark theme (default) */
  --bg-primary: #0b1622;
  --bg-secondary: #1a2332;
  --bg-tertiary: #151f2e;
  --bg-quaternary: #32445b;
  --text-primary: #8596a5;
  --text-secondary: #a8b5c4;
  --text-tertiary: #cecece;
  --text-light: #edf1f5;
  --border-color: #32445b;
  --hover-bg: #2a3441;
  --table-bg: #1f2a38;
}

[data-theme="light"] {
  --bg-primary: #e7f0f8;
  --bg-secondary: #b7e0f7;
  --bg-tertiary: #b7e0f7;
  --bg-quaternary: #ffffff;
  --text-primary: #0b5f97;
  --text-secondary: #0b5f97;
  --text-tertiary: #97cdec;
  --text-light: #ffffff;
  --border-color: #DCECF8;
  --hover-bg: #cfe8f7;
  --table-bg: #DCECF8;
}

[data-theme="brown"] {
  --bg-primary: #271c19;
  --bg-secondary: #f8f8f8;
  --bg-tertiary: #55423d;
  --bg-quaternary: #af7f76;
  --text-primary: #faeee7;
  --text-secondary: #faeee7;
  --text-tertiary: #af7f76;
  --text-light: #faeee7;
  --border-color: #fffffe;
  --hover-bg: #fffffe;
  --table-bg: #74544d;
}

/* --- Star Rating Overlap Effect --- */
.star-rating {
  display: inline-block;
  position: relative;
  height: 1.1em;
  line-height: 1;
  top: -0.38em;
}

.star-rating .star-icon {
  width: 1.1em;
  height: 1.1em;
  display: inline-block;
  position: relative;
  margin-left: -0.25em;
  /* strong overlap for cool effect */
  z-index: 1;
  vertical-align: middle;
  transition: filter 0.2s;
}

.star-rating .star-icon:first-child {
  margin-left: 0;
}


.star-rating .star-icon.empty {
  opacity: 0.4;
}

body {
  background-color: var(--bg-primary);
  margin: 0;
  padding: 0;
  color: var(--text-primary);
}

html {
  overflow-y: scroll;
}

.status-header {
  margin-top: 50px;
  /* adjust this value as you want */
  margin-bottom: 10px;
  /* adjust this value as you want */
  font-weight: bold;
}

.separator-bar {
  width: 100%;
  height: 45px;
  background-color: var(--bg-tertiary);
  margin-bottom: 1.5rem;
}

/* --- Page Layout --- */
.list-page-container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 10rem 2rem;

}

/* --- Banner Rotator --- */
.banner-rotator {
  position: relative;
  /* Needed to contain the overlay */
  width: 100%;
  height: 330px;
  overflow: hidden;
}

.banner-rotator img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  object-position: center 15%;

  /* Add smooth opacity transition */
  transition: opacity 1s ease-in-out;
  opacity: 1;
}

/* The overlay that covers the whole image */
.banner-overlay {
  position: absolute;
  /* sits over the image */
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, rgba(6, 13, 34, 0) 40%, rgba(6, 13, 34, 0.6) 100%);
  z-index: 1;
  pointer-events: none;
  /* let clicks pass through */
  display: flex;
  justify-content: flex-end;
  /* align quote container to right */
  align-items: stretch;
  padding-right: 2rem;
  box-sizing: border-box;
}

/* The quote container on right side, initially hidden */
.banner-quote {
  display: none;
  /* toggle via JS */
  color: white;
  font-style: italic;
  padding: 1rem 2rem;
  text-align: right;
  max-height: 50%;
  min-height: 10%;
  max-width: 30%;
  min-width: 5%;
  overflow-y: auto;
  white-space: pre-wrap;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  /* allow text selection if needed */
  border-radius: 0 0 0 12px;

  margin-top: auto;
  /* push it down inside flex container */
  margin-bottom: 2rem;
  /* add some space from bottom */

  transition: opacity 1s ease-in-out;

  scrollbar-width: none;
  /* for Firefox */
  -ms-overflow-style: none;
  /* for IE and Edge */
}

.banner-quote::-webkit-scrollbar {
  display: none;
}

/* --- Sidebar --- */
.sidebar {
  width: 15%;
  padding-right: 2.5rem;
  display: flex;
  flex-direction: column;

}

#search-input {
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: none;
  font-size: 1rem;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
}

#search-input:focus {
  outline: none;
  box-shadow: none;
}

#search-input::placeholder {
  color: var(--text-tertiary);
}

.filter-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.view-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dual-toggle {
  display: flex;
  gap: 0.5rem;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-tertiary);
  max-height: 1.9rem;
}

.toggle-half {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background-color 0.3s ease;
}

.toggle-half:hover {
  background-color: var(--bg-quaternary);
}

.toggle-half.active {
  background-color: var(--bg-tertiary);
}

.toggle-text {
  font-size: 0.85rem;
  white-space: nowrap;
}

.filter-btn,
.toggle-btn,
.type-filter-btn,
.sort-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  width: 100%;
}

.btn-count {
  opacity: 0;
  transition: opacity 0.3s ease;
  /* right side */
  font-weight: bold;
  /* optionally add color or spacing */
}

.filter-buttons-wrapper:hover .btn-count {
  opacity: 1;
}

.sidebar h3 {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.filter-btn:hover,
.type-filter-btn:hover,
.sort-btn:hover {
  background-color: var(--bg-quaternary);
}

#check-status-btn:hover {
  background-color: var(--bg-quaternary);
}

.filter-btn.active,
.toggle-btn.active,
.type-filter-btn.active,
.sort-btn.active {
  background-color: var(--bg-tertiary);
}

.sort-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sort-btn {
  flex: 1;
  justify-content: center;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* --- Main List Content --- */
.list-content {
  width: 80%;
  margin-top: -45px;
}

/* --- Card View Grid --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 150px));
  gap: 0.9rem;
}

/* Default card (all media types) */
.card {
  border-radius: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.15s ease-in-out;
  cursor: pointer;
  width: 150px;
  height: 210px;
}

/* Game-specific card height */
body[data-media-type="games"] .card {
  height: 200px;
}

.card-image {
  overflow: hidden;
  border-radius: 3px;
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* ensures image covers container */
  object-position: center top;
  /* default crop */
}

/* Card Image */
.card img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  overflow: hidden;
  border-radius: 3px;
}

.card[data-media-type="music"] {
  width: 150px;
  height: 150px;
}

.card[data-media-type="music"] .card-image {
  width: 270px;
  height: 100%;
  left: -60px;
}

/* Override global .card img rule */
.card[data-media-type="music"] .card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}



.repeat-indicator {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  z-index: 2;
}

.repeat-count {
  position: absolute;
  top: 0;
  left: 25px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 14px;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  min-width: 20px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none
}

.repeat-indicator:hover .repeat-count {
  opacity: 1;
}

.repeat-icon {
  width: 16px;
  height: 16px;
  color: white;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}



/* Title & Rating Overlay */
.card-title-overlay {
  background: rgba(14, 15, 15, .8);
  color: var(--text-light);
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 0.8rem;
  gap: 0.5rem;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  min-height: 48px;
}


.card-title {
  width: 100%;
  flex: 1;
}

.card-rating {
  align-self: flex-end;
  margin-left: auto;
  font-size: 1.1rem;
}

.rating-number {
  font-size: 0.82rem;
  color: var(--text-primary);
  vertical-align: top;
  position: relative;
}

.card-meta-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
}

.card-progress {
  font-size: 0.75rem;
  color: grey;
}


/* Edit Button */
.edit-card-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  display: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 4px;
}

.edit-card-btn::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
}

.card:hover .edit-card-btn {
  display: block;
}

.list-table .edit-card-btn {
  display: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  padding: 4px 8px;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.list-table tr:hover .edit-card-btn {
  display: inline-block;
}

/* Rating Badge */
.face-field {
  background-color: none;
  padding: 4px 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-rating svg {
  width: 1em;
  height: 1em;
  color: grey;
}

/* --- List View Table --- */
.list-table {
  width: 100%;
  overflow-x: auto;
}

.list-table table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  table-layout: fixed;
  overflow: hidden;
}

.list-table th:nth-child(1),
.list-table td:nth-child(1) {
  width: 50%;
}

.list-table th:nth-child(2),
.list-table td:nth-child(2) {
  width: 10%;
  text-align: center;
}

.list-table th:nth-child(3),
.list-table td:nth-child(3) {
  color: var(--text-primary);
  width: 20%;
  text-align: center;
}

.list-table th:nth-child(4),
.list-table td:nth-child(4) {
  color: var(--text-primary);
  width: 10%;
  text-align: center;
}

.list-table th:nth-child(5),
.list-table td:nth-child(5) {
  color: var(--text-primary);
  width: 10%;
  text-align: center;
}

.list-table th,
.list-table td {
  padding: 0.8rem 1rem;
  text-align: left;
}

.list-table td {
  padding: 0.5rem 1rem;
  vertical-align: middle;
  position: relative;
}

.list-table th {
  background-color: var(--table-bg);
  color: var(--text-primary);
}

.list-table td {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

.list-table a {
  color: var(--text-primary);
  text-decoration: none;
}

.list-table a:hover {
  text-decoration: underline;
}


#card-view,
#list-view {
  display: none;
}

.status-dot {
  position: absolute;
  top: -10px;
  /* align to top edge */
  left: -10px;
  /* align to left edge */
  width: 30px;
  height: 30px;
  border-radius: 50%;
  z-index: 10;
  box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.6);
}

#check-status-container {
  display: none;
}

label.music-player-btn {
  cursor: pointer;
}

label.music-player-btn input[type="checkbox"] {
  display: none;
}

label.music-player-btn .music-icon {
  border: 2px solid var(--text-primary);
  border-radius: 20%;
  padding: 4px;
  transition: border-color 0.3s ease;
}

label.music-player-btn .music-icon path {
  fill: var(--text-primary) !important;
  transition: fill 0.3s ease;
}

label.music-player-btn:has(input:checked) .music-icon {
  border-color: var(--activity-high, #c0d0e0);
}

label.music-player-btn:has(input:checked) .music-icon path {
  fill: var(--activity-high, #c0d0e0) !important;
}

label.music-player-btn:hover .music-icon {
  border-color: #c0d0e0;
}

label.music-player-btn:hover .music-icon path {
  fill: #c0d0e0 !important;
}

.status-legend {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-tertiary);
}

.status-legend div {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.music-player-container {
  position: fixed !important;
  bottom: 20px !important;
  left: 20px !important;
  z-index: 9999 !important;
  line-height: 0 !important;
}

.music-player-container iframe {
  display: block !important;
  border: none !important;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: 0 0 6px currentColor;
}

.legend-dot.green {
  background-color: green;
  color: green;
}

.legend-dot.orange {
  background-color: orange;
  color: orange;
}

.legend-dot.red {
  background-color: red;
  color: red;
}

.legend-dot.gray {
  background-color: gray;
  color: gray;
}

.sidebar-toggle-btn {
  display: none;
}

@media(orientation: portrait) {

  .separator-bar {
    margin-bottom: 0.1rem;
    height: 4rem;
  }

  .edit-card-btn {
    padding: 6px 10px;
    font-size: 4rem;
  }

  .sidebar-toggle-btn {
    display: block;
    position: fixed;
    bottom: 40px;
    left: 40px;
    z-index: 1000;
    background: rgb(0 0 0 / 0.8);
    color: #ffffff;
    border: none;
    padding: 0.8rem 1.6rem;
    font-size: 6rem;
    border-radius: 20px;
    cursor: pointer;
    transform-origin: bottom left;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    /* start off-screen */
    bottom: 0;
    /* anchor to bottom-left corner */
    width: 280px;
    background: var(--bg-primary);
    z-index: 999;
    border-radius: 20px;

    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* stack elements from bottom up */
    padding: 2rem;

    max-height: 100vh;
    /* prevent overflow off-screen */
    overflow-y: auto;
    /* scroll if content taller than screen */

    transition: left 0.3s ease;
    padding-bottom: 15rem;

    width: 90%;
    max-width: 90%;
    box-sizing: border-box;
  }

  .sidebar.sidebar-visible {
    left: 0;
  }


  .list-page-container {
    gap: 8rem;
    padding-left: 2.3rem;
    position: relative;
    flex-direction: column;
    padding-right: 0rem;
  }

  .list-content {
    transform-origin: top;
    width: unset;
    margin-top: unset;
  }

  .card {
    width: 293px;
    height: 410px;
  }

  body[data-media-type="games"] .card {
    height: 390px;
  }

  .card-image {
    border-radius: 8px;
  }

  .card[data-media-type="music"] {
    width: 293px;
    height: 293px;
  }

  .card[data-media-type="music"] .card-image {
    width: 528px;
    height: 100%;
    left: -117px;
  }

  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(293px, 293px));
    gap: 0.9rem;

  }

  .card-title {
    font-size: 1.7rem;
  }

  .card-title-overlay {
    min-height: 6.5rem;
  }

  .card-rating svg {
    width: 2.5rem;
    height: 2.5rem;
    margin-right: 0.5rem;
  }

  .card-rating {
    font-size: 2rem;
  }

  .star-rating {
    top: -0.2rem;
  }

  .rating-number {
    font-size: 2rem;
    margin-right: 0.5rem;
  }

  .card-progress {
    font-size: 2rem;
    margin-left: 0.5rem;
  }

  .card-meta-row {
    margin-bottom: 0.8rem;
  }

  .status-dot {
    width: 5rem;
    height: 5rem;
    top: -2rem;
    left: -2rem;
  }

  .repeat-indicator {
    top: 2rem;
    left: 2rem;
  }

  .repeat-count {
    font-size: 2rem;
  }

  .repeat-icon {
    width: 2.2rem;
    height: 2.2rem;
  }

  .list-table table {
    font-size: 2rem;
    table-layout: fixed;
  }

  .list-table th:nth-child(1),
  .list-table td:nth-child(1) {
    width: unset;
  }

  .list-table table td,
  .list-table table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .banner-quote {
    font-size: 2rem;
  }

  .list-table .edit-card-btn {
    font-size: 2rem;
  }

  .status-header {
    font-size: 3.2rem;
  }

  .filter-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .filter-btn {
    justify-content: center;
    font-size: 2.5rem;
  }

  .list-table {
    max-width: 57rem;
  }

  .sort-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .sort-btn {
    font-size: 2.5rem;
  }

  .view-toggle .dual-toggle {
    max-height: none;
  }

  .toggle-text {
    font-size: 2.5rem;
  }

  #search-input {
    font-size: 2.5rem;
    padding: 0.8rem;
  }

  .type-filter-btn {
    font-size: 2.5rem;
  }

  .toggle-btn {
    font-size: 2.5rem;
  }

  .sidebar h3 {
    font-size: 2.5rem;
    margin-top: 2rem;
  }

  .btn-count {
    display: none;
  }

  .status-legend {
    display: none;
  }

  .music-icon {
    height: 2.5rem;
    width: 2.5rem;
  }
}