/* You Won't Break Me — dark webtoon reader
   Shared styles for the chapter index and the chapter reader. */

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

:root {
  --bg: #0b0d10;
  --surface: #14181d;
  --elevated: #1d232b;
  --hairline: #2a323c;
  --hairline-strong: #3b4654;
  --text: #f2f4f7;
  --muted: #9aa4b2;
  --accent: #e8b84b;
  --accent-strong: #f0c65e;
  --accent-soft: rgba(232, 184, 75, 0.12);
  --accent-line: rgba(232, 184, 75, 0.3);
  --radius: 12px;
  --radius-pill: 999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --reader-width: 820px;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body.index {
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(232, 184, 75, 0.07), transparent 62%),
    var(--bg);
}

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

a {
  color: inherit;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[id] {
  scroll-margin-top: 72px;
}

.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Index: shell and top bar ---------- */

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 16px 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  text-decoration: none;
  color: var(--text);
  border-radius: var(--radius);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
}

.brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.topbar-action:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--elevated);
}

/* ---------- Index: hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  margin-top: 18px;
  padding: clamp(20px, 4.5vw, 38px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
}

.hero::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -60px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 184, 75, 0.13), transparent 68%);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 46%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line));
  pointer-events: none;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.kicker-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.hero-title {
  max-width: 18ch;
  margin-top: 12px;
  font-size: clamp(1.85rem, 6vw, 3.4rem);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.hero-sub {
  max-width: 54ch;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.stats-strip {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  text-align: center;
}

.stat-val {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.stat-lbl {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-divider {
  width: 1px;
  height: 30px;
  background: var(--hairline);
}

/* ---------- Index: chapter grid ---------- */

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 30px 0 14px;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 2px 9px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
}

.section-note {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chapter-grid > li {
  min-width: 0;
}

.chapter-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.chapter-card:hover {
  border-color: var(--hairline-strong);
  background: var(--elevated);
  transform: translateY(-2px);
}

.chapter-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.chapter-card.is-first {
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, rgba(232, 184, 75, 0.07), var(--surface) 52%);
}

.chapter-card.is-last {
  border-right: 3px solid var(--accent);
  background: linear-gradient(270deg, rgba(232, 184, 75, 0.07), var(--surface) 52%);
}

.card-thumb {
  display: block;
  height: 58px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--elevated);
}

.card-thumb svg {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.78;
  transition: opacity 0.15s ease;
}

.chapter-card:hover .card-thumb svg {
  opacity: 1;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 18px;
}

.mono-num {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.card-badge {
  padding: 1px 7px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.card-title {
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-caption {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.card-caption .icon {
  width: 14px;
  height: 14px;
}

/* ---------- Shared footer ---------- */

.site-footer {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.6;
  text-align: center;
}

.site-footer strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Reader: shell ---------- */

body.reader {
  background: var(--bg);
}

.reader-shell {
  width: 100%;
  max-width: var(--reader-width);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}

.reader-top {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 56px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(11, 13, 16, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  color: var(--text);
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.back-link:hover {
  background: var(--elevated);
}

.reader-title-link {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  text-decoration: none;
  border-radius: 8px;
}

.reader-title {
  display: block;
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-pill {
  flex-shrink: 0;
  padding: 5px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--elevated);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.chapter-pill b {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Reader: chapter header ---------- */

.chapter-head {
  padding: 20px 16px 22px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}

.chapter-head h1 {
  margin-top: 8px;
  font-size: clamp(1.55rem, 4.5vw, 2.1rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.chapter-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.8rem;
}

.chapter-caption .icon {
  width: 15px;
  height: 15px;
}

/* ---------- Reader: prev / next ---------- */

.chapter-nav {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg);
}

.chapter-nav.is-top {
  border-bottom: 1px solid var(--hairline);
}

.chapter-nav.is-bottom {
  border-top: 1px solid var(--hairline);
  padding-bottom: 26px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-link.prev {
  justify-content: flex-start;
}

.nav-link.next {
  justify-content: flex-end;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
  text-align: right;
}

.nav-link.prev:hover {
  border-color: var(--hairline-strong);
  background: var(--elevated);
  color: var(--text);
}

.nav-link.next:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.nav-link .icon {
  width: 18px;
  height: 18px;
}

.nav-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  line-height: 1.2;
}

.nav-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-target {
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link.next .nav-label {
  color: rgba(11, 13, 16, 0.66);
}

.nav-link.next .nav-target {
  color: var(--bg);
}

/* ---------- Reader: stacked pages ---------- */

.pages {
  display: block;
  background: var(--bg);
}

.pages img {
  margin: 0;
  background: var(--surface);
}

.pages img.end-panel {
  background: var(--bg);
}

/* ---------- Reader: end of chapter ---------- */

.chapter-end {
  padding: 34px 16px 26px;
  background: var(--bg);
}

.end-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.end-divider .line {
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

.end-divider .label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.end-divider .label::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}

.end-card {
  margin-top: 20px;
  padding: 22px 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.end-kicker {
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.end-title {
  margin-top: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.end-desc {
  max-width: 44ch;
  margin: 8px auto 18px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.end-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.end-link:hover {
  border-color: var(--accent);
  background: rgba(232, 184, 75, 0.2);
}

.reader-footer {
  padding: 4px 16px 40px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.6;
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (min-width: 560px) {
  .chapter-grid {
    gap: 12px;
  }

  .card-thumb {
    height: 64px;
  }

  .card-title {
    font-size: 0.98rem;
  }
}

@media (min-width: 640px) {
  .wrap {
    padding: 24px 24px 52px;
  }

  .chapter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  .hero {
    margin-top: 22px;
  }

  .section-head {
    margin-top: 36px;
  }

  .chapter-head {
    padding: 26px 30px 28px;
  }

  .chapter-nav {
    padding: 18px 30px;
  }

  .chapter-nav.is-bottom {
    padding-bottom: 30px;
  }

  .chapter-end {
    padding: 40px 30px 30px;
  }

  .reader-footer {
    padding-bottom: 48px;
  }
}

@media (min-width: 768px) {
  .reader-shell {
    border-left: 1px solid var(--hairline);
    border-right: 1px solid var(--hairline);
  }
}

@media (min-width: 900px) {
  .chapter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hero-title {
    max-width: 20ch;
  }

  .chapter-card {
    padding: 12px;
  }
}

@media (min-width: 1200px) {
  .chapter-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 359px) {
  .chapter-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-link.next {
    justify-content: space-between;
  }

  .section-note {
    display: none;
  }
}

@media (hover: none) {
  .chapter-card:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
