/* ====================================
   Variables & Base Settings
   ==================================== */
:root {
  --primary-color: #328195;
  --primary-hover: #256170;
  --bg-color: #f4f6f8;
  --text-main: #2c3e50;
  --text-muted: #6c757d;
  --card-bg: #ffffff;
}

body {
  font-family: "Inter", "Noto Sans JP", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

.text-primary-custom {
  color: var(--primary-color) !important;
}
.bg-primary-custom {
  background-color: var(--primary-color) !important;
}

/* Global Animations */
.col {
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ====================================
   Header & Search Panel
   ==================================== */
.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  color: #adb5bd;
}
.breadcrumb-item a {
  transition: opacity 0.2s;
}
.breadcrumb-item a:hover {
  opacity: 0.7;
}

.search-panel {
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.search-input-group {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  transition: all 0.2s;
  background: white;
}
.search-input-group:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(50, 129, 149, 0.15);
}
.search-input-group .input-group-text,
.search-input-group .form-control {
  border: none;
  outline: none;
  box-shadow: none;
}

/* Native Dropdown Override */
.selectFilter {
  position: relative;
}
.selectFilter select {
  width: 100%;
  padding: 0.8rem 2.5rem 0.8rem 1.25rem;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  appearance: none;
  cursor: pointer;
  transition: all 0.2s;
}
.selectFilter select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(50, 129, 149, 0.15);
  background-color: #fff;
}
.selectFilter::after {
  content: "\f078";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #adb5bd;
  font-size: 0.8rem;
}

/* Category Pills */
.categories a.badge {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1.1rem;
  border-radius: 50rem;
  border: 1px solid #e0e6ed;
  color: var(--text-muted);
  background: white;
  text-transform: capitalize;
  transition: all 0.2s ease-in-out;
}
.categories a.badge.active,
.categories a.badge:hover {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

/* ====================================
   Standard Card (Unexpanded)
   ==================================== */
/* We target the class JS creates and forcefully override bootstrap bg-transparent */
.readerCard.bg-transparent {
  background-color: var(--card-bg) !important;
  border-radius: 12px;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.04),
    0 1px 3px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  cursor: pointer;
}
.readerCard:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.coverImg {
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: center 20%; /* Biases the crop towards the top of the cover where titles are */
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  background-color: #f8f9fa;
}

.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.card-body h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  line-height: 1.4;
}
.card-body p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-body p b {
  color: var(--text-main);
  font-weight: 600;
}
.card-body p:last-child {
  margin-bottom: 0;
  margin-top: auto; /* Pushes bottom stats to bottom of card uniformly */
}

/* Progress Overlay */
.bubble.date {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: rgba(50, 129, 149, 0.95) !important;
  color: white;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 10;
  backdrop-filter: blur(4px);
  border: none !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ====================================
   Expanded Card View 
   ==================================== */
.col.expanded {
  width: 100%;
  flex: 0 0 100%;
  max-width: 100%;
}
.expanded .readerCard {
  flex-direction: row;
  cursor: default;
  padding: 2.5rem;
  gap: 2.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.expanded .readerCard:hover {
  transform: none; /* Disable hover float on expanded */
}
.expanded .main-card-image {
  width: 280px;
  height: auto;
  max-height: 400px;
  object-fit: contain; /* Full un-cropped book cover */
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  background-color: #f8f9fa;
}

.expanded .card-body {
  padding: 0;
  display: block;
}
.expanded .card-body h2 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
  padding-right: 2.5rem; /* Space for the absolute positioned 'X' button */
}
.expanded .card-body p {
  display: block;
  -webkit-line-clamp: unset;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}
.expanded .card-body p a {
  color: var(--primary-color);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.expanded .card-body p a:hover {
  color: var(--primary-hover);
}

.expanded .close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 1.75rem;
  color: #ced4da;
  cursor: pointer;
  z-index: 10;
  transition: color 0.2s;
}
.expanded .close:hover {
  color: #495057;
}

/* Start Reading Button */
.readBtn {
  display: inline-block;
  background: var(--primary-color);
  color: white !important;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0;
  transition:
    background 0.2s,
    transform 0.1s;
  box-shadow: 0 4px 10px rgba(50, 129, 149, 0.3);
}
.readBtn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}
.readBtn:active {
  transform: translateY(0);
}
.readBtn .element {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ====================================
   Expanded Stats Dashboard
   ==================================== */
.stats-container {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1rem 0 1.5rem 0;
  border: 1px solid #e9ecef;
}
.stats-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.stats-pills .badge {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.6rem;
  background: #fff !important;
  border: 1px solid #dee2e6 !important;
  color: var(--text-main) !important;
}
.stats-pills .badge i {
  color: var(--primary-color);
  margin-right: 0.35rem;
}
.stats-table {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  overflow: hidden;
}
.stats-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  background-color: #f1f3f5;
  border-bottom: 2px solid #dee2e6;
  padding: 0.6rem;
  vertical-align: middle;
}
.stats-table td {
  font-size: 0.85rem;
  vertical-align: middle;
  padding: 0.5rem;
  border-bottom: 1px solid #e9ecef;
}
.stats-table tbody tr:last-child td {
  border-bottom: none;
}

/* ====================================
   Similar Cards Scroller 
   ==================================== */
.similarTitle {
  font-weight: 600;
  color: var(--text-main) !important;
  margin-top: 2rem;
  margin-bottom: 1rem !important;
  font-size: 1.1rem !important;
}
.similarCards {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}
.similarCards::-webkit-scrollbar {
  height: 8px;
}
.similarCards::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}
.similarCards::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}
.similarCards::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.similarWrapper {
  flex: 0 0 160px;
}
.similarWrapper a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 0.75rem;
  height: 100%;
  transition: all 0.2s;
}
.similarWrapper a:hover {
  background: #fff;
  border-color: var(--primary-color);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}
.similarWrapper img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}
.similarWrapper h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.similarWrapper p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ====================================
   Mobile Adjustments 
   ==================================== */
@media (max-width: 768px) {
  .expanded .readerCard {
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
  }
  .expanded .main-card-image {
    width: 100%;
    max-height: 350px;
    object-fit: contain;
  }
  .expanded .card-body h2 {
    font-size: 1.5rem;
  }
  .expanded .close {
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    padding: 0.5rem; /* Larger tap target */
  }
  .readBtn {
    width: 100%;
    text-align: center;
    justify-content: center;
    display: flex;
  }
}

/* ====================================
   Pagination 
   ==================================== */
.pagination {
  gap: 0.25rem;
}
.page-item .page-link {
  border: none;
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  background-color: transparent;
}
.page-item .page-link:hover {
  background-color: #e9ecef;
  color: var(--text-main);
}
.page-item.active .page-link {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 8px rgba(50, 129, 149, 0.2);
}
.page-item.disabled .page-link {
  background-color: transparent;
  color: #dee2e6;
}
