/* ---------------------------------------------------------------------------
   Solo Leveling Manga Reader — Premium Dark Theme
   --------------------------------------------------------------------------- */

@font-face {
  font-family: "Outfit";
  src: url("/public/fonts/outfit-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Outfit";
  src: url("/public/fonts/outfit-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02C6, U+02C8, U+02CC, U+02D0-02D1, U+02E0-02E4, U+0300-036F, U+0374, U+0394, U+061C, U+2010-2011, U+2018-201F, U+2039-203A, U+2044, U+2052, U+20A0-20CF, U+2122, U+212A-212B, U+2134, U+2153-2188, U+215B-215E, U+2190-21FF, U+2212, U+2215, U+F020, U+FEFF, U+FFFD;
}

@keyframes floatPulse {
  0% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

:root {
  --bg: #060a10;
  --bg-card: rgba(12, 18, 28, 0.88);
  --bg-elevated: #0d1420;
  --text: #e2e8f0;
  --text-muted: #7c8a9e;
  --accent: #0ea5e9;
  --accent-dim: rgba(14, 165, 233, 0.13);
  --accent-2: #10b981;
  --border: rgba(148, 163, 184, 0.1);
  --border-hover: rgba(14, 165, 233, 0.35);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --glow: 0 0 24px rgba(14, 165, 233, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --max: 1100px;
  --font: "Outfit", "Segoe UI", system-ui, sans-serif;
  --display: "Impact", "Haettenschweiler", "Arial Narrow", sans-serif;
}

/* ── reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* subtle ambient glow behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse 1400px 700px at 15% -15%,
      rgba(14, 165, 233, 0.07) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 900px 900px at 85% 110%,
      rgba(16, 185, 129, 0.05) 0%,
      transparent 70%
    );
  pointer-events: none;
  z-index: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ── layout helpers ── */
.container {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

main {
  position: relative;
  z-index: 1;
}

/* ── nav ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 10, 16, 0.8);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.3px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  border: 1px solid var(--border);
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.25);
  transform: scale(1.12);
}

/* ── buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 100px;
  border: 1px solid var(--border);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-hover);
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  box-shadow: var(--glow);
  transform: translateY(-1px);
}

/* ── hero ── */
.hero {
  position: relative;
  min-height: 420px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  filter: blur(2px) saturate(1.1);
  transform: scale(1.05);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(6, 10, 16, 0.5) 0%,
    rgba(6, 10, 16, 0.85) 60%,
    var(--bg) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: 80px 0 60px;
  max-width: 600px;
}

.tag {
  display: inline-flex;
  align-items: center;
  background: rgba(14, 165, 233, 0.2);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
}

.hero-content h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -1px;
  margin: 0 0 16px;
  line-height: 1.1;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.hero-desc {
  color: rgba(255, 255, 255, 0.75);
  margin: 0 0 28px;
  font-size: 1.05rem;
  line-height: 1.6;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 0.95rem;
}

/* ── resume banner ── */
.resume-banner {
  margin: 24px 0;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(16, 185, 129, 0.08));
  border: 1px solid rgba(14, 165, 233, 0.25);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.resume-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.resume-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.resume-info strong {
  color: var(--text);
  font-size: 0.95rem;
}

/* ── section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 40px 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.3px;
}

.select-minimal {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}

.select-minimal:focus {
  border-color: var(--accent);
}

/* ── chapter grid (home) ── */
.chapter-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.chapter-item:hover {
  background: rgba(14, 165, 233, 0.08);
  padding-left: 24px;
}

.chapter-title {
  font-weight: 500;
  font-size: 0.95rem;
}

.chapter-arrow {
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: transform 0.15s ease, color 0.15s ease;
}

.chapter-item:hover .chapter-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

.skeleton-row {
  height: 54px;
  border-radius: var(--radius-sm);
}

.empty-state {
  color: var(--text-muted);
  padding: 48px 0;
  text-align: center;
}

.view-all {
  margin-top: 24px;
  text-align: center;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.feature-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ── section headers ── */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 44px 0 20px;
}

.section-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.3px;
}

.badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 100px;
}

.latest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(30, 41, 59, 0.6), rgba(51, 65, 85, 0.6), rgba(30, 41, 59, 0.6));
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-card {
  height: 80px;
}

.chapter-badge {
  background: rgba(14, 165, 233, 0.15);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.latest-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
}

.latest-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--glow);
}

.latest-title {
  font-weight: 600;
}

.latest-cta {
  color: var(--text-muted);
  font-size: 0.85rem;
}
/* ── chapter list ── */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: all 0.2s ease;
}

.chapter-row:hover {
  border-color: var(--border-hover);
  border-left-color: var(--accent);
  background: rgba(14, 165, 233, 0.04);
  padding-left: 24px;
}

.chapter-name {
  font-weight: 500;
  font-size: 0.95rem;
}

.chapter-row .read-arrow {
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: color 0.15s, transform 0.15s;
}

.chapter-row:hover .read-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

/* ── search ── */
.search {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 18px;
  color: var(--text);
  width: 100%;
  font-size: 0.92rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 4px;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search::placeholder {
  color: var(--text-muted);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.sort-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 18, 28, 0.9);
  box-shadow: var(--shadow);
}

.sort-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.select {
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
}

.select:focus {
  box-shadow: none;
}

.continue-card {
  margin-top: 14px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.continue-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ── reader ── */
.reader-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(6, 10, 16, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.reader-page .reader-bar {
  top: 72px;
}

.reader-bar.hidden {
  transform: translateY(-110%);
  opacity: 0;
}

.reader-page .nav.hidden {
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 640px) {
  .reader-bar.hidden {
    transform: translateY(110%);
    opacity: 0;
  }
}

.reader-bar .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.reader-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.reader-title .chapter-badge {
  align-self: flex-start;
}

.reader-title strong {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-title span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.jump-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 6px 3px 10px;
}

.slider-wrap {
  display: inline-flex;
  align-items: center;
  min-width: 140px;
}

.slider-wrap input[type="range"] {
  width: 140px;
  accent-color: var(--accent);
}

.jump-wrap input {
  width: 72px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
}

.jump-wrap input::placeholder {
  color: var(--text-muted);
}

/* live page counter pill */
.page-counter {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.page-counter em {
  color: var(--accent);
  font-weight: 600;
  font-style: normal;
}

.reader-progress {
  position: relative;
  height: 3px;
  background: rgba(148, 163, 184, 0.1);
  overflow: hidden;
}

#reader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

.reader-shell {
  padding: 0 0 80px;
}

#reader-status {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-height: 24px;
}

/* rendered pages grid */
.reader-pages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 20px;
}

.page {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  transition: border-color 0.3s;
  aspect-ratio: 1 / var(--page-ratio, 1.35);
  overflow: hidden;
}

.page:hover {
  border-color: rgba(14, 165, 233, 0.2);
}

.page canvas {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.compact .reader-pages {
  gap: 2px;
}

.compact .page {
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.compact .page:hover {
  border-color: transparent;
}

.compact .page canvas {
  border-radius: 0;
}

.compact .reader-shell {
  padding-bottom: 24px;
}

.mobile-fit .reader-pages {
  gap: 0;
  padding-top: 0;
}

.mobile-fit .page {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: 0;
}

.mobile-fit .page:hover {
  border-color: transparent;
}

.mobile-fit .page canvas {
  border-radius: 0;
}

.mobile-fit .reader-shell {
  padding: 0 0 60px 0;
}

.mobile-fit .container.reader-shell {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.mobile-fit .floating-actions {
  bottom: 8px;
  right: 8px;
}

.mobile-fit .floating-actions .btn {
  padding: 8px 12px;
  font-size: 0.8rem;
}

/* skeleton loader inside each page shell */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(14, 165, 233, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── scroll-to-top ── */
.scroll-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 60;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(6, 10, 16, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* hidden by default */
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s ease, transform 0.25s ease, border-color 0.2s, background 0.2s;
  pointer-events: none;
}

.floating-actions {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 70;
}

.floating-actions .btn {
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(6, 10, 16, 0.85);
  border: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.floating-actions .btn:hover {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-top:hover {
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.12);
  box-shadow: var(--glow);
}

/* ── footer ── */
.footer {
  margin: 48px 0 28px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.reader-page .footer {
  opacity: 0;
  height: 0;
  overflow: hidden;
  margin: 0;
}

.reader-page.reader-ready .footer {
  opacity: 1;
  height: auto;
  overflow: visible;
  margin: 48px 0 28px;
  transition: opacity 0.2s ease;
}

/* ── 404 ── */
.error-number {
  font-size: 7rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.error-msg {
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto 28px;
}

/* ── responsive ── */
@media (max-width: 900px) {
  .hero {
    min-height: 360px;
  }
  .hero-content {
    padding: 60px 0 48px;
  }
  .feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .nav-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .brand {
    gap: 8px;
    font-size: 1rem;
  }
  .brand-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    transform: scale(1);
  }
  .nav-inner > div {
    width: 100%;
    justify-content: space-between;
  }
  .search-row {
    grid-template-columns: 1fr;
  }
  .hero {
    min-height: 320px;
  }
  .hero-content {
    padding: 48px 0 40px;
  }
  .hero-content h1 {
    font-size: 1.8rem;
  }
  .hero-desc {
    font-size: 0.95rem;
  }
  .btn-lg {
    padding: 12px 20px;
    font-size: 0.9rem;
  }
  .resume-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 12px;
  }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .chapter-item {
    padding: 14px 16px;
  }
  .btn {
    font-size: 0.84rem;
    padding: 9px 16px;
  }
  .reader-bar .inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .reader-actions {
    width: 100%;
  }
  .reader-actions .btn {
    flex: 1;
    justify-content: center;
  }
  .reader-bar {
    position: sticky;
    top: 0;
    bottom: auto;
    left: auto;
    right: auto;
    z-index: 60;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    border-top: none;
    transform: translateY(0);
  }
  .reader-page .reader-bar {
    top: 0;
  }
  .reader-bar .reader-actions {
    gap: 6px;
  }
  .reader-shell {
    padding-bottom: 80px;
  }
  .floating-actions {
    right: 12px;
    bottom: 80px;
  }
  .floating-actions .btn {
    padding: 12px 14px;
    font-size: 0.85rem;
  }
  .slider-wrap {
    width: 100%;
  }
  .slider-wrap input[type="range"] {
    width: 100%;
  }
  .floating-actions {
    right: 14px;
    bottom: 14px;
  }
  .scroll-top {
    bottom: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
  }
  .error-number {
    font-size: 5rem;
  }
}
