/* ================= THEME VARIABLES ================= */
:root {
  --bg: #ffffff;
  --text: #111111;
  --accent: #facc15;
}

[data-theme="dark"] {
  --bg: #111111;
  --text: #ffffff;
  --accent: #facc15;
}

/* รองรับ dark mode ตามระบบ (ถ้ายังไม่ตั้ง theme เอง) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #121212;
    --text: #e0e0e0;
  }
}

/* ================= BASE ================= */
body {
  background-color: var(--bg);
  color: var(--text);
}

a:hover {
  color: var(--accent);
}

/* ================= GEAR POPUP ================= */
#gearPopup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  width: 320px;
  max-width: 90vw;
  display: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

@media (min-width: 768px) {
  #gearPopup {
    position: absolute;
    transform: none;
    top: auto;
    left: auto;
    display: flex;
  }
}

@media (max-width: 767px) {
  #gearPopup {
    width: 80%;
    max-width: 320px;
  }

  #gearMenu[open] summary {
    display: none;
  }
}

@media (max-width: 768px) {
  #gearButton {
    display: none;
  }
}

/* ================= NOVEL CONTENT ================= */
#novelContent {
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
}

#novelContent.dark {
  color: #ffffff;
  background-color: #1a1a1a;
}

/* prose + justify */
.prose.justify-text {
  text-align: justify;
  text-justify: inter-word;
  line-height: 1.6;
  word-break: break-word;
}

.prose.justify-text p {
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  #novelContent.prose {
    text-align: justify;
    text-justify: inter-word;
    word-break: break-word;
    line-height: 1.5;
  }

  #novelContent.prose p {
    margin-bottom: 1rem;
  }
}

/* ================= THEME TEXT HELPERS ================= */
.theme-dark-text p,
.theme-dark-text span {
  color: #ffffff;
}

.theme-light-text p,
.theme-light-text span {
  color: #000000;
}

/* ================= NOVEL COVER ================= */
#novel-cover {
  width: 160px;
  height: 224px;
  object-fit: cover;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px rgba(0,0,0,0.1);
  flex-shrink: 0;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

#novel-cover:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 25px rgba(0,0,0,0.3);
}

#novel-cover:active {
  transform: scale(0.95);
  box-shadow: 0 5px 10px rgba(0,0,0,0.2);
}

@media (max-width: 640px) {
  #novel-cover {
    width: 128px;
    height: 176px;
  }
}

@media (max-width: 480px) {
  #novel-cover {
    width: 100%;
    height: auto;
    max-height: 300px;
  }
}

/* ================= IMAGE EFFECT ================= */
img.glow-hover {
  transition: box-shadow 0.3s ease-in-out;
}

img.glow-hover:hover {
  box-shadow: 0 0 15px 5px rgba(59, 130, 246, 0.7);
}

.novel-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: box-shadow 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.novel-cover:hover {
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.7);
  transform: scale(1.03);
  z-index: 1;
}

/* ================= PAGINATION ================= */
@media (max-width: 640px) {
  .pagination a,
  .pagination span {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    min-width: 30px;
    text-align: center;
  }
}

/* ================= DIALOG ================= */
dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.3);
}

dialog {
  transition: transform 0.3s ease-in-out;
  transform: translateY(100%);
}

dialog.show-dialog {
  transform: translateY(0%);
}
