/* ============================================
   Web Novel Reader — Styles (BEM methodology)
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-bg: #faf9f6;
  --color-text: #2c2c2c;
  --color-primary: #1a1a2e;
  --color-accent: #e94560;
  --color-nav-bg: #1a1a2e;
  --color-nav-text: #f0f0f0;
  --color-nav-btn: #e94560;
  --color-nav-btn-hover: #c73852;
  --color-nav-btn-disabled: #555;
  --color-select-bg: #16213e;
  --color-select-text: #f0f0f0;
  --content-max-width: 700px;
  --font-reading: 'Georgia', 'Times New Roman', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-reading);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.75;
  min-height: 100vh;
}

/* --- App Shell --- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  font-family: var(--font-ui);
  font-size: 1.1rem;
  color: #888;
}

/* --- Navigation Bar (BEM Block: nav-bar) --- */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--color-nav-bg);
  position: sticky;
  z-index: 100;
}

.nav-bar--top {
  top: 0;
}

.nav-bar--bottom {
  /* Not sticky, just at bottom */
}

.nav-bar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background-color: var(--color-nav-btn);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.nav-bar__btn:hover:not(:disabled) {
  background-color: var(--color-nav-btn-hover);
}

.nav-bar__btn:active:not(:disabled) {
  transform: scale(0.95);
}

.nav-bar__btn:disabled {
  background-color: var(--color-nav-btn-disabled);
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-bar__btn--prev::before {
  content: '◀';
}

.nav-bar__btn--next::before {
  content: '▶';
}

.nav-bar__select {
  flex: 1;
  max-width: 240px;
  height: 44px;
  padding: 0 1rem;
  border: 2px solid var(--color-accent);
  border-radius: 8px;
  background-color: var(--color-select-bg);
  color: var(--color-select-text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23e94560' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
}

.nav-bar__select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Chapter Content (BEM Block: chapter) --- */
.chapter {
  flex: 1;
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.chapter__title {
  font-family: var(--font-ui);
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--color-primary);
}

.chapter__body {
  font-size: 1rem;
  line-height: 1.75;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chapter__body p {
  margin-bottom: 1.2em;
  text-align: justify;
  hyphens: auto;
}

.chapter__body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 4px;
}

.chapter__body a {
  color: var(--color-accent);
  text-decoration: none;
}

/* Remove any ads / scripts / iframes that might have leaked through */
.chapter__body script,
.chapter__body iframe,
.chapter__body ins,
.chapter__body .ads,
.chapter__body [class*="ad-"],
.chapter__body [id*="ad-"] {
  display: none !important;
}

/* --- Install Banner (BEM Block: install-banner) --- */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background-color: var(--color-nav-bg);
  border-top: 2px solid var(--color-accent);
  z-index: 200;
  animation: install-banner--slide-up 0.3s ease-out;
}

@keyframes install-banner--slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.install-banner__text {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-nav-text);
}

.install-banner__btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 8px;
  background-color: var(--color-accent);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.install-banner__btn:hover {
  background-color: var(--color-nav-btn-hover);
}

.install-banner__btn:active {
  transform: scale(0.96);
}

.install-banner__close {
  background: none;
  border: none;
  color: var(--color-nav-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.6;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.install-banner__close:hover {
  opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  html {
    font-size: 16px;
  }

  .chapter {
    padding: 1.25rem 1rem;
  }

  .chapter__title {
    font-size: 1.2rem;
  }

  .nav-bar {
    gap: 0.35rem;
    padding: 0.6rem 0.5rem;
  }

  .nav-bar__select {
    max-width: 180px;
    font-size: 0.85rem;
  }
}

@media (min-width: 768px) {
  .chapter {
    padding: 3rem 2rem;
  }
}

/* --- Dark mode support (prefers-color-scheme) --- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #121212;
    --color-text: #e0e0e0;
    --color-primary: #e94560;
  }

  .chapter__body a {
    color: #ff6b81;
  }
}
