/* ========================================================================
   MAIN.CSS - Core styles for Kvasir card-based layouts
   ======================================================================== */

/* ========================================================================
   1. BASE & LAYOUT STYLES
   ======================================================================== */

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden !important;
  }
}

/* ========================================================================
   2. SECTION STRUCTURE
   ======================================================================== */

/* Section wrapper with max-width constraint */
.section-section {
  max-width: 1600px;
  margin: 0 30px;
}

@media (max-width: 768px) {
  .section-section {
    margin: 0;
  }
}

/* Section title styling */
.section-title {
  color: #10245e;
  font-family: 'Merriweather', serif;
  font-weight: 400;
  text-align: center;
  letter-spacing: 0.03em;
}

.section-title h1 {
  margin-bottom: 2px !important;
}

.section-title h3 {
  margin-bottom: 0 !important;
}

/* Section title link styles with animated triangles */
.section-title a {
  color: #10245e;
  position: relative;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 0.15em;
  text-decoration-thickness: from-font;
  outline: none;
}

.section-title a:visited,
.section-title a:hover,
.section-title a:active,
.section-title a:focus {
  color: #10245e;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 0.15em;
  text-decoration-thickness: from-font;
}

/* Animated triangle indicators */
.section-title a::before,
.section-title a::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 0.9em solid transparent;
  border-bottom: 0.9em solid transparent;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

/* Left triangle → points right */
.section-title a::before {
  left: -80%;
  border-left: 1em solid currentColor;
  transform: translate(-0.2em, -50%);
}

/* Right triangle → points left */
.section-title a::after {
  right: 20%;
  border-right: 1em solid currentColor;
  transform: translate(0.2em, -50%);
}

@media (max-width: 768px) {
  .section-title a::before {
    left: -98%;
  }
  .section-title a::after {
    right: 2%;
  }
}

/* Show triangles on hover/focus */
.section-title a:hover::before,
.section-title a:hover::after,
.section-title a:focus-visible::before,
.section-title a:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%);
}

/* ========================================================================
   3. SCROLL BUTTONS
   ======================================================================== */

.scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ccc;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  color: #666;
  z-index: 10;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  opacity: 0.5;
}

.scroll-btn:hover {
  background: rgba(255, 255, 255, 1);
  color: #333;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  opacity: 1;
}

.scroll-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.scroll-btn.left {
  left: -20px;
}

.scroll-btn.right {
  right: -20px;
}

/* Hide scroll buttons on mobile devices */
@media (max-width: 768px) {
  .scroll-btn {
    display: none;
  }
}

/* ========================================================================
   4. STATUS & DECORATIVE ELEMENTS
   ======================================================================== */

.status-HTML {
  pointer-events: none;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  font-family: "Coiny", sans-serif;
  font-size: 1rem;
  color: rgb(199, 0, 0);
}

.status-HTML-small {
  pointer-events: none;
  position: absolute;
  top: -5px;
  right: 15px;
  z-index: 2;
  font-family: "Coiny", sans-serif;
  font-size: 1rem;
  color: rgb(199, 0, 0);
}

.heart-HTML {
  pointer-events: none;
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 2;
  font-size: 3em;
  color: red;
}

/* ========================================================================
   5. SECTION CONTAINERS
   ======================================================================== */

.section-container {
  position: relative;
  display: none;
  align-items: center;
  width: 100%;
}

/* Hide scrollbars in section containers */
.section-container .d-flex::-webkit-scrollbar {
  display: none;
}

.section-container .d-flex {
  flex: 1;
  user-select: none;
  touch-action: pan-x;
  scrollbar-width: none;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: none;
  overflow-x: auto;
}

/* ========================================================================
   6. CARD WRAPPER CONTAINERS
   ======================================================================== */

/* Main horizontal scrolling card wrapper */
.cards-main-wrapper {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0 !important;
  padding: 5px;
  scroll-behavior: smooth;
  justify-content: flex-start;
  align-items: stretch;
  scrollbar-width: none;
}

.cards-main-wrapper::-webkit-scrollbar {
  display: none;
}

/* Small card wrapper variant */
.cards-main-wrapper-small {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0 !important;
  padding: 0 5px;
  scroll-behavior: smooth;
  justify-content: flex-start;
  align-items: stretch;
  scrollbar-width: none;
}

.cards-main-wrapper-small::-webkit-scrollbar {
  display: none;
}

/* ========================================================================
   7. CARD COMPONENTS
   ======================================================================== */

/* Base card styling */
.card-main {
  border-radius: 1rem;
  border: 0;
  background-color: transparent;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  padding: 0.5rem;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: transform 0.2s ease-in-out;
}

/* Card size variants */
.card-main-small {
  width: 250px;
  height: 150px;
  padding: 0;
  font-family: "Onest", system-ui;
  font-weight: 400;
  font-size: 2rem;
}

.card-main-echo {
  width: 300px;
  height: 400px;
  font-family: "Onest", system-ui;
  font-weight: 400;
  font-size: 2rem;
}

.card-main-search {
  width: 400px;
  height: 400px;
}

/* Responsive card sizes */
@media (min-width: 769px) {
  .card-main-course {
    width: 500px;
    height: 500px;
  }
  
  .card-main-readings {
    width: 400px;
    height: 400px;
  }
  
  .card-main-superhit {
    width: 600px;
    height: 400px;
  }
}

@media (max-width: 768px) {
  .card-main-course {
    width: 400px;
    height: 600px;
  }
  
  .card-main-superhit {
    width: 400px;
    height: 400px;
  }
  
  .card-main-readings {
    width: 400px;
    height: 400px;
  }
}

/* Card internal structure */
.card-main-inner {
  padding: 0.5rem;
  background-color: #ecf0f2;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.card-main-upper-row {
  background-color: rgba(236, 240, 242, 0.6);
  border-radius: 1rem 1rem 0 0;
  padding: 0.5rem;
  height: 85%;
  width: 100%;
  min-height: 75%;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
}

.card-main-upper-row-small {
  background-color: rgba(236, 240, 242, 0.6);
  height: 100%;
  width: 96%;
  border-radius: 1rem;
}

.card-main-bottom-row {
  border-radius: 0 0 1rem 1rem;
  padding: 0.5rem;
  background-color: rgba(236, 240, 242, 0.6);
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
}

/* Card content elements */
.card-main-img-desc {
  border-radius: 0.5rem;
  background-color: #ecf0f2;
  overflow: hidden;
  margin: 0 6px;
  overflow-y: auto;
  scrollbar-width: none;
  flex: 1;
  height: 100%;
}

.card-main-img {
  border-radius: 1rem;
  max-height: 200px;
  max-width: 133px;
  object-fit: cover;
  object-position: center;
  float: left;
  margin-right: 6px;
}

.card-main-img2 {
  border-radius: 20px;
  max-height: 250px;
  max-width: 250px;
  object-fit: cover;
  object-position: center;
  float: right;
  margin-left: 6px;
}

.card-main-img-larger {
  border-radius: 20px;
  max-height: 350px;
  max-width: 250px;
  object-fit: cover;
  float: left;
  margin-right: 6px;
}

.card-main-img-small {
  border-radius: 20px;
  max-height: 133px;
  max-width: 133px;
  object-fit: cover;
  object-position: center;
  float: left;
  margin-right: 6px;
}

.card-main-desc {
  font-size: 12px;
  border-radius: 0.5rem;
  color: #222;
  margin: 0;
  text-overflow: ellipsis;
}

/* Card text elements */
.card-main-author {
  font-family: 'Merriweather', serif; 
  font-size: 15px;
  min-height: 1.5rem;
  color: #000;
  margin-left: 5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.card-main-author-heart {
  margin-left: 40px;
  min-width: 230px;
}


.card-main-echo .card-main-author {
  font-size: 16px;
}

.card-main-promotion {
  font-family: 'Merriweather', serif!important;
  font-size: 18px;
  color: #204aac;
  margin: 5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Card button */
.card-main-btn {
  padding: 0.6rem 1.4rem;
  letter-spacing: 0.02em;
  background: #2563eb !important;
  border: 0;
  color: #f4f4f4 !important;
  min-width: 200px;
  min-height: 50px;
  font-size: 16px;
  border-radius: 2rem;
  font-family: "Inter", sans-serif;
  font-optical-sizing: auto;
  font-weight: 700;
  cursor: pointer;
  margin: 5px;
  transition: background 0.2s;
}

.card-main-btn:hover {
  background: #1e40af !important;
}

@media (max-width: 768px) {
  .card-main-btn {
    width: 100% !important;
    min-height: 46px !important;
    font-size: 15px !important;
    border-radius: 2rem !important;
  }
}

/* Card hover effects for specific sections */
#superhitSection .card-main-inner,
#librarySection .card-main-inner,
#echoChatSection .card-main-inner,
#coursesSection .card-main-inner {
  transition: transform 0.25s ease;
}

#superhitSection .card-main-inner:hover,
#librarySection .card-main-inner:hover,
#echoChatSection .card-main-inner:hover,
#coursesSection .card-main-inner:hover {
  transform: scale(1.02);
}

/* ========================================================================
   8. SEARCH FUNCTIONALITY
   ======================================================================== */

.search-input {
  display: block;
}

@media (max-width: 768px) {
  .search-input {
    display: none;
    top: 7vh;
    left: 5vw;
    position: absolute;
    z-index: 99;
  }
}

.search-results {
  position: fixed;
  top: 100px;
  left: 20px;
  width: 80%;
  height: auto;
  overflow: auto;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 60%, #eef3f9 100%);
  border-radius: 20px;
  z-index: 1000;
  resize: none;
  pointer-events: auto;
}

.search-results-blur {
  position: fixed;
  top: 45px;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(10px);
  z-index: 999;
  pointer-events: none;
}

@media (max-width: 768px) {
  .search-results {
    width: 100%;
    top: 10px;
    left: 0;
  }
}




.close-search-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 1100;
  background: transparent;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
}

/* ========================================================================
   9. GRID LAYOUT (Desktop Solo Pages)
   ======================================================================== */

/* Desktop grid layout for books/courses/echoes pages */
@media (min-width: 769px) {
  .section-solo-container .cards-grid-wrapper {
    display: grid !important;
    grid-template-rows: repeat(3, 1fr);
    gap: 20px;
    overflow-x: visible !important;
    overflow-y: auto !important;
    max-height: calc(100vh - 140px);
    flex-wrap: unset !important;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 10px;
    scroll-behavior: smooth;
    scrollbar-width: auto;
    scrollbar-color: rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.1) !important;
  }
  
  /* 3-column grid layout */
  .section-solo-3 .cards-grid-wrapper {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* 5-column grid layout */
  .section-solo-5 .cards-grid-wrapper {
    grid-template-columns: repeat(5, 1fr);
  }

  /* Ensure cards maintain proper sizing in grid */
  .section-solo-container .card-main-readings {
    width: 100% !important;
    max-width: 400px;
    height: 400px;
    margin: 0;
  }
  
  /* Custom scrollbar styling for grid */
  .section-solo-container .cards-grid-wrapper::-webkit-scrollbar {
    background: rgba(0, 0, 0, 0.1);
  }

  .section-solo-container .cards-grid-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1) !important;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
  }

  .section-solo-container .cards-grid-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.4) !important;
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: content-box;
  }

  .section-solo-container .cards-grid-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.6) !important;
    background-clip: content-box;
  }
}

/* Keep mobile layout as horizontal scroll */
@media (max-width: 768px) {
  .section-solo-container .cards-grid-wrapper {
    display: flex !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    flex-wrap: nowrap !important;
  }
}
