/* ============================================================
   MANGA SEO MONSTER – Main Stylesheet
   All colors use CSS variables set dynamically by the customizer
   ============================================================ */

/* --- CSS Custom Properties (defaults, overridden by PHP) --- */
:root {
  --c-primary:    #c42b38;
  --c-secondary:  #457b9d;
  --c-bg:         #0d0d0d;
  --c-surface:    #1a1a1a;
  --c-surface2:   #252525;
  --c-text:       #e0e0e0;
  --c-text-muted: #888;
  --c-border:     #2e2e2e;
  --c-link:       #e63946;
  --r-sm:         6px;
  --r-md:         10px;
  --r-lg:         16px;
  --transition:   0.2s ease;
  --max-w:        900px;
  --max-w-wide:   1200px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--c-link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--c-primary); }
a:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: 2px; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* --- Accessibility --- */
.screen-reader-text, .skip-link {
  position: absolute !important;
  clip: rect(1px,1px,1px,1px);
  word-wrap: normal;
  width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed !important;
  top: 8px; left: 8px;
  width: auto; height: auto;
  clip: auto;
  background: var(--c-primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  z-index: 9999;
  font-weight: 700;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.site-wrap { max-width: var(--max-w-wide); margin: 0 auto; padding: 0 16px; }
.section-inner { max-width: var(--max-w-wide); margin: 0 auto; }

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,13,13,0.95);
  border-bottom: 1px solid var(--c-border);
  backdrop-filter: blur(8px);
}
.site-header-inner {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
}
.site-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--c-text);
  white-space: nowrap;
}
.site-logo-text:hover { color: var(--c-primary); }
.site-tagline { font-size: 0.7rem; color: var(--c-text-muted); margin-top: 1px; }

/* Nav */
.nav-menu { display: flex; gap: 4px; align-items: center; }
.nav-menu li a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  color: var(--c-text);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav-menu li a:hover { background: var(--c-surface); color: var(--c-primary); }
.nav-menu li.current-menu-item a { color: var(--c-primary); }

/* Search */
.site-search { margin-left: auto; }
.search-form { display: flex; align-items: center; gap: 0; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 24px; overflow: hidden; }
.search-field {
  background: transparent;
  border: none;
  color: var(--c-text);
  padding: 6px 14px;
  font-size: 0.875rem;
  width: 180px;
  outline: none;
}
.search-field::placeholder { color: var(--c-text-muted); }
.search-submit {
  padding: 6px 12px;
  color: var(--c-text-muted);
  display: flex;
  align-items: center;
}
.search-submit:hover { color: var(--c-primary); }

/* ============================================================
   BREADCRUMBS
   ============================================================ */
.manga-breadcrumbs {
  padding: 10px 0;
  font-size: 0.8rem;
  color: var(--c-text-muted);
}
.manga-breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.manga-breadcrumbs li { display: flex; align-items: center; }
.manga-breadcrumbs a { color: var(--c-text-muted); }
.manga-breadcrumbs a:hover { color: var(--c-primary); }
.bc-sep { color: var(--c-border); margin: 0 2px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 700;
  transition: all var(--transition);
  white-space: nowrap;
}
/* Darken primary 22% so white text meets WCAG AA 4.5:1 contrast */
.btn-primary { background: color-mix(in srgb, var(--c-primary) 78%, #000); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--c-primary) 62%, #000); color: #fff; transform: translateY(-1px); }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); }
.btn-secondary:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn-outline { background: transparent; color: var(--c-primary); border: 1px solid var(--c-primary); }
.btn-outline:hover { background: var(--c-primary); color: #fff; }

/* ============================================================
   HOMEPAGE – HERO
   ============================================================ */
.hero-section {
  padding: 48px 16px;
  max-width: var(--max-w-wide);
  margin: 0 auto;
}
.hero-inner {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}
.hero-cover {
  flex-shrink: 0;
  width: 200px;
}
.hero-cover img {
  width: 200px;
  height: auto;
  border-radius: var(--r-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.hero-content { flex: 1; min-width: 0; }
.hero-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  color: var(--c-text);
}
.hero-description {
  color: var(--c-text-muted);
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.7;
}
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.hero-stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label { color: var(--c-text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-weight: 700; }
.status-ongoing { color: #4caf50; }
.status-completed { color: var(--c-secondary); }
.status-hiatus { color: #ff9800; }

.hero-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.genre-tag {
  /* Solid dark background so contrast is predictable; lighter text for WCAG AA */
  background: color-mix(in srgb, var(--c-primary) 18%, #111);
  color: color-mix(in srgb, var(--c-primary) 55%, #fff);
  border: 1px solid color-mix(in srgb, var(--c-primary) 40%, #111);
  padding: 3px 10px;
  border-radius: 24px;
  font-size: 0.78rem;
  font-weight: 600;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

/* ============================================================
   SECTION STYLES
   ============================================================ */
.section-inner { padding: 40px 16px; }
.section-title {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 800;
  margin-bottom: 24px;
  color: var(--c-text);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.chapter-count { font-size: 0.85rem; color: var(--c-text-muted); font-weight: 400; }

/* ============================================================
   LATEST CHAPTERS GRID (Cards)
   ============================================================ */
.chapter-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.chapter-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); overflow: hidden; transition: border-color var(--transition), transform var(--transition); position: relative; }
.chapter-card:hover { border-color: var(--c-primary); transform: translateY(-2px); }
.chapter-card-link {
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 6px;
  color: var(--c-text);
}
.chapter-card-num { font-size: 0.75rem; color: var(--c-text-muted); }
.chapter-card-title { font-weight: 700; font-size: 0.9rem; }
.chapter-card-date { font-size: 0.75rem; color: var(--c-text-muted); margin-top: auto; }
.chapter-card-new {
  position: absolute;
  top: 8px;
  right: 8px;
  background: color-mix(in srgb, var(--c-primary) 78%, #000);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  display: none;
}
.chapter-card:nth-child(-n+3) .chapter-card-new { display: block; }

/* ============================================================
   CHAPTER LIST
   ============================================================ */
.chapter-list-section { background: var(--c-surface); border-radius: var(--r-lg); margin: 0 16px 40px; }
.chapter-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 20px 0;
}
.chapter-list-sort { display: flex; gap: 6px; }
.sort-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-text-muted);
  border: 1px solid var(--c-border);
  background: transparent;
  transition: all var(--transition);
}
.sort-btn.active, .sort-btn:hover {
  background: color-mix(in srgb, var(--c-primary) 78%, #000);
  color: #fff;
  border-color: var(--c-primary);
}
.chapter-list { padding: 8px 0 16px; }
.chapter-list-item { border-bottom: 1px solid var(--c-border); }
.chapter-list-item:last-child { border-bottom: none; }
.cli-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--c-text);
  transition: background var(--transition);
}
.cli-link:hover { background: var(--c-surface2); color: var(--c-text); }
.cli-number { font-weight: 700; font-size: 0.9rem; flex-shrink: 0; min-width: 90px; }
.cli-title { flex: 1; font-size: 0.875rem; color: var(--c-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cli-date { font-size: 0.78rem; color: var(--c-text-muted); flex-shrink: 0; }

/* ============================================================
   MANGA INFO CARD
   ============================================================ */
.manga-info-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.mic-cover img { width: 100%; height: auto; max-height: 320px; object-fit: cover; }
.mic-body { padding: 16px; }
.mic-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.mic-alt { color: var(--c-text-muted); font-size: 0.85rem; margin-bottom: 12px; }
.mic-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.mic-table th, .mic-table td { padding: 5px 0; text-align: left; }
.mic-table th { color: var(--c-text-muted); width: 90px; }
.mic-table td { font-weight: 600; }
.mic-genres { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.mic-genre {
  background: var(--c-surface2);
  color: #aaa; /* #888 on #252525 = 4.35:1 (fails); #aaa = 6.4:1 (passes) */
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* ============================================================
   ABOUT + FAQ SECTIONS
   ============================================================ */
.manga-about-section { padding: 0 0 40px; }
.manga-about-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
}
.manga-about-text { font-size: 0.95rem; color: var(--c-text-muted); line-height: 1.8; }
.manga-about-text p { margin-bottom: 14px; }

.faq-section { background: var(--c-surface); border-radius: var(--r-lg); margin: 0 16px 40px; }
.faq-list { padding: 0 20px 16px; }
.faq-item { border-bottom: 1px solid var(--c-border); }
.faq-item:last-child { border-bottom: none; }
.faq-question {
  width: 100%;
  text-align: left;
  padding: 16px 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--c-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: color var(--transition);
}
.faq-question:hover, .faq-question[aria-expanded="true"] { color: var(--c-primary); }
.faq-icon { font-size: 1.2rem; flex-shrink: 0; transition: transform var(--transition); color: var(--c-primary); }
.faq-question[aria-expanded="true"] .faq-icon { transform: rotate(45deg); }
.faq-answer {
  display: none;
  padding: 0 0 16px;
  color: var(--c-text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}
.faq-answer.open { display: block; }
.faq-answer p { margin-bottom: 10px; }

/* ============================================================
   CHAPTER READER
   ============================================================ */
.chapter-article { max-width: 860px; margin: 0 auto; padding: 0 0 60px; }

.chapter-header { padding: 24px 16px 20px; }
.chapter-series-link { font-size: 0.8rem; color: var(--c-text-muted); margin-bottom: 8px; }
.chapter-series-link a { color: var(--c-primary); }
.chapter-title { font-size: clamp(1.2rem, 3.5vw, 2rem); font-weight: 800; margin-bottom: 12px; line-height: 1.3; }
.chapter-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.82rem; color: var(--c-text-muted); margin-bottom: 10px; }
.chapter-meta-item { display: flex; align-items: center; gap: 4px; }
.chapter-description { font-size: 0.9rem; color: var(--c-text-muted); margin-top: 8px; }

/* Chapter Nav */
.chapter-nav {
  position: sticky;
  top: 60px;
  z-index: 90;
  background: rgba(13,13,13,0.9);
  border-top: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  backdrop-filter: blur(6px);
  padding: 8px 16px;
}
.chapter-nav-inner { display: flex; align-items: center; gap: 8px; max-width: 860px; margin: 0 auto; }
.chapter-nav-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  transition: all var(--transition);
  white-space: nowrap;
}
.chapter-nav-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.chapter-nav-btn.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.chapter-nav-select-wrap { flex: 1; min-width: 0; }
.chapter-nav-select {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.chapter-nav-select:focus { outline: 2px solid var(--c-primary); }

/* Reader Pages */
.chapter-reader { padding: 16px 0; }
.reader-pages { display: flex; flex-direction: column; align-items: center; gap: 0; }
.reader-page {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}
.reader-img {
  width: 100%;
  height: auto;
  display: block;
  background: var(--c-surface);
  min-height: 100px;
}
.reader-img.lazy { opacity: 0; transition: opacity 0.3s ease; }
.reader-img.loaded { opacity: 1; }

/* Chapter Footer */
.chapter-footer {
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: 20px;
  margin: 24px 16px;
}
.chapter-footer-title { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.chapter-footer p { font-size: 0.875rem; color: var(--c-text-muted); line-height: 1.7; }
.chapter-footer a { color: var(--c-primary); }

/* Related Chapters */
.related-chapters {
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: 20px;
  margin: 0 16px;
}
.related-title { font-size: 1rem; font-weight: 800; margin-bottom: 14px; }
.related-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.related-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--c-text);
  font-size: 0.875rem;
  transition: background var(--transition);
}
.related-list a:hover { background: var(--c-surface2); color: var(--c-primary); }
.rel-ch-num { font-weight: 700; }
.rel-ch-date { font-size: 0.78rem; color: var(--c-text-muted); }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  margin-top: 60px;
}
.footer-inner {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 40px 16px 24px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 32px;
  align-items: start;
}
.footer-manga-title { font-size: 1rem; font-weight: 800; margin-bottom: 8px; }
.footer-desc { font-size: 0.85rem; color: var(--c-text-muted); max-width: 360px; line-height: 1.6; margin-bottom: 10px; }
.footer-genres { display: flex; flex-wrap: wrap; gap: 4px; }
.footer-genre { background: var(--c-surface2); color: #aaa; padding: 2px 7px; border-radius: 4px; font-size: 0.72rem; }
.footer-menu { display: flex; flex-direction: column; gap: 6px; }
.footer-menu a { font-size: 0.85rem; color: var(--c-text-muted); }
.footer-menu a:hover { color: var(--c-primary); }
.footer-social { display: flex; gap: 10px; align-items: center; }
.social-link { color: var(--c-text-muted); transition: color var(--transition); }
.social-link:hover { color: var(--c-primary); }
.footer-bottom { grid-column: 1 / -1; border-top: 1px solid var(--c-border); padding-top: 16px; }
.footer-copyright { font-size: 0.78rem; color: var(--c-text-muted); }
.footer-copyright a { color: var(--c-text-muted); }
.footer-copyright a:hover { color: var(--c-primary); }

/* ============================================================
   ARCHIVE PAGE
   ============================================================ */
.archive-page { max-width: var(--max-w-wide); margin: 0 auto; padding: 0 16px 60px; }
.archive-header { padding: 32px 0 24px; }
.archive-title { font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 800; margin-bottom: 8px; }
.archive-desc { color: var(--c-text-muted); font-size: 0.9rem; }
.archive-pagination { margin-top: 32px; }
.archive-pagination .nav-links { display: flex; gap: 8px; justify-content: center; }
.archive-pagination a, .archive-pagination span {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--c-border);
  font-size: 0.875rem;
  color: var(--c-text);
  background: var(--c-surface);
}
.archive-pagination a:hover { border-color: var(--c-primary); color: var(--c-primary); }
.archive-pagination .current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* ============================================================
   STATIC PAGES
   ============================================================ */
.static-page { max-width: 780px; margin: 0 auto; padding: 32px 16px 60px; }
.page-title { font-size: 2rem; font-weight: 800; margin-bottom: 24px; }
.page-content { font-size: 0.95rem; color: var(--c-text-muted); line-height: 1.8; }
.page-content h2 { font-size: 1.3rem; color: var(--c-text); font-weight: 700; margin: 28px 0 12px; }
.page-content h3 { font-size: 1.1rem; color: var(--c-text); font-weight: 700; margin: 20px 0 8px; }
.page-content p { margin-bottom: 14px; }
.page-content a { color: var(--c-primary); }
.page-content ul, .page-content ol { padding-left: 20px; margin-bottom: 14px; }
.page-content li { margin-bottom: 6px; }
.page-content li { list-style: disc; }
.page-content ol li { list-style: decimal; }

/* ============================================================
   ERROR 404
   ============================================================ */
.error-404 { max-width: 600px; margin: 80px auto; padding: 0 16px; text-align: center; }
.error-title { font-size: 3rem; font-weight: 800; color: var(--c-primary); margin-bottom: 16px; }
.error-404 p { color: var(--c-text-muted); margin-bottom: 20px; }
.error-404 .search-form { justify-content: center; margin-bottom: 20px; }

/* ============================================================
   ADMIN META BOX (just in head)
   ============================================================ */
.manga-meta-row.half { vertical-align: top; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media ( max-width: 768px ) {
  .hero-inner { flex-direction: column; }
  .hero-cover { width: 100%; max-width: 200px; margin: 0 auto; }
  .manga-about-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
  .site-search .search-field { width: 130px; }
  .chapter-nav-btn { padding: 7px 10px; font-size: 0.8rem; }
  .chapter-cards-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .cli-title { display: none; }
}

@media ( max-width: 480px ) {
  .site-header-inner { gap: 12px; }

  /* Nav hides by default on mobile — JS toggles it open */
  .site-nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    padding: 8px 0;
    z-index: 99;
  }
  .site-nav.is-open { display: block; }
  .site-nav .nav-menu {
    flex-direction: column;
    gap: 0;
    padding: 0 8px;
  }
  .site-nav .nav-menu li a {
    padding: 10px 14px;
    border-radius: var(--r-sm);
    display: block;
    font-size: 1rem;
  }

  /* Hamburger button */
  .mobile-nav-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    color: var(--c-text);
    padding: 6px;
    border-radius: var(--r-sm);
    flex-shrink: 0;
  }
  .mobile-nav-toggle:hover { color: var(--c-primary); }

  /* Hide search on very small screens to save space */
  .site-search { display: none; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .site-header, .chapter-nav, .site-footer, .related-chapters, .chapter-footer { display: none; }
  .reader-img { max-width: 100%; }
  body { background: #fff; color: #000; }
}
