/* START CSS */

/* Variables */
:root {
  --pink: #ffc3d8;
  --white: #ffffff;

  --polka-bg-color: #ffe1ed;

  --text-color: #ff91bd;
  --box-bg-color: #ffe6f0ff;
  --box-border-color: #ffc3d8;
  --box-shadow-color: #fff8fc;
}

/* Body */
body {
  background-color: var(--polka-bg-color);

  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 21px;
  padding: 25px 10px;
  text-align: center;
  color: var(--text-color);
}

/* Shared pink box */
.pink-box {
  display: inline-block;
  vertical-align: top;
  position: relative;

  background-color: var(--box-bg-color);
  border: 6px solid var(--box-border-color);
  border-radius: 57px;
  padding: 20px;
  box-sizing: border-box;

  box-shadow: 0 0 0 10px var(--box-shadow-color);
  color: var(--text-color);
  text-align: center;

  margin-right: 20px;
}

/* END CSS */

/* ---- page-specific styles ---- */

* {
  box-sizing: border-box;
}

/* header row: title box + dark mode toggle side by side */
.header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 35px;
}

.site-header {
  margin: 0;
  max-width: 700px;
  width: 100%;
}

.site-header.pink-box {
  padding-left: 55px;
  padding-right: 55px;
}

.site-header h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
  color: var(--text-color);
}

.site-header p {
  margin: 8px 0 0;
  font-size: 17px;
  opacity: 0.85;
}

/* grid of comics, built from pink-box so cards match the rest of the site */
.comic-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px 0; /* horizontal gap handled by pink-box margin-right */
  max-width: 1100px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.comic-card,
.comic-card:visited {
  display: block;
  width: 220px;
  margin-right: 0; /* override pink-box's inline-flow margin, gap handles spacing */
  color: var(--text-color);
}

/* images are supplied at higher resolution than they're displayed at
   (retina-sharp), so width:100% + height:auto scales them down cleanly
   with no cropping or distortion */
.comic-cover {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 32px;
  border: 4px solid var(--box-border-color);
  background-color: var(--white);
  cursor: pointer;
}

.comic-cover:focus-visible {
  outline: 3px solid var(--text-color);
  outline-offset: 4px;
}

.comic-title {
  display: block;
  margin: 14px 0 0;
  font-size: 19px;
  font-weight: 600;
  color: var(--text-color);
  line-height: 1.3;
}

/* "Read" button under each title */
.read-btn,
.read-btn:visited {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 26px;
  background-color: var(--text-color);
  color: var(--white);
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  border-radius: 20px;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.read-btn:hover,
.read-btn:focus-visible {
  background-color: #ff7aad;
  transform: translateY(-2px);
}

.read-btn:focus-visible {
  outline: 3px solid var(--box-shadow-color);
  outline-offset: 3px;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background-color: rgba(48, 20, 33, 0.75);
  z-index: 1000;
}

.lightbox.is-open {
  display: flex;
}

.lightbox-content {
  position: relative;
  display: inline-block;
  max-width: min(90vw, 600px);
  max-height: 85vh;
}

.lightbox-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(90vw, 600px);
  max-height: 85vh;
  border-radius: 24px;
  border: 6px solid var(--box-border-color);
  box-shadow: 0 0 0 10px var(--box-shadow-color);
}

.lightbox-close {
  position: absolute;
  top: -22px;
  right: -60px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background-color: var(--white);
  color: var(--text-color);
  font-family: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0 0 4px var(--box-shadow-color);
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  background-color: var(--box-bg-color);
}

/* keep things comfortable on small screens */
@media (max-width: 480px) {
  body {
    font-size: 18px;
    padding: 20px 8px;
  }

  .site-header h1 {
    font-size: 27px;
  }

  .comic-card {
    width: 42vw;
    max-width: 220px;
  }

  .comic-grid {
    gap: 16px 0;
  }

  /* pin to the screen corner instead of the image corner -- on a tall
     phone the image can reach close to the screen edge, which pushes an
     image-relative button off screen entirely */
  .lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .comic-card {
    transition: none;
  }
}

/* Dark mode toggle button -- sits right next to the header, not pinned to
   a page corner */
.theme-toggle {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid var(--box-border-color);
  border-radius: 50%;
  background-color: var(--box-bg-color);
  color: var(--text-color);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 0 0 6px var(--box-shadow-color);
  transition: transform 0.15s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: translateY(-2px);
}

/* Dark mode palette -- blacks and greys only, no color */
body.dark-mode {
  --polka-bg-color: #141414;
  --text-color: #d9d9d9;
  --box-bg-color: #1e1e1e;
  --box-border-color: #4a4a4a;
  --box-shadow-color: #000000;
  --white: #2a2a2a;
}

body.dark-mode .lightbox {
  background-color: rgba(0, 0, 0, 0.8);
}

/* ---- comic reader page (e.g. TMNT-NIGHTTIDE) ---- */
/* no pink boxes here -- just the polka-dot bg + dark mode toggle from
   above, scoped under body.reader-page so the homepage is unaffected */

body.reader-page {
  padding: 0;
}

/* controls bar: dark mode toggle + season/episode dropdowns, stacked
   vertically at the top of the page (not sticky -- the whole page scrolls
   normally, controls included) */
.page-controls {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 10px;
  background-color: var(--polka-bg-color);
}

/* wraps the info dropdown + episode dropdown so they stack and share a
   width, sitting next to the theme toggle */
.dropdowns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* info dropdown: title, maturity rating, season/episode count, format,
   credits, synopsis -- a native <details> element, no JS needed.
   The episode dropdown below reuses this exact class so both dropdowns
   are guaranteed to match in width, text size, icon size, and hover
   color -- a native <select> can't be styled consistently with this. */
.info-dropdown {
  width: clamp(320px, 80vw, 560px);
  text-align: left;
  border: 3px solid var(--box-border-color);
  border-radius: 20px;
  background-color: var(--box-bg-color);
  color: var(--text-color);
  overflow: hidden;
}

.info-dropdown summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  font-family: inherit;
  font-weight: 600;
  font-size: 19px;
  cursor: pointer;
  list-style: none;
}

.info-dropdown summary::-webkit-details-marker {
  display: none;
}

.info-dropdown summary i {
  font-size: 18px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.info-dropdown[open] summary i {
  transform: rotate(180deg);
}

.info-dropdown summary:hover,
.info-dropdown summary:focus-visible {
  background-color: var(--polka-bg-color);
}

.info-dropdown summary:focus-visible {
  outline: 3px solid var(--text-color);
  outline-offset: -3px;
}

.info-panel {
  padding: 4px 18px 18px;
  font-size: 17px;
  font-weight: 500;
  border-top: 3px solid var(--box-border-color);
}

.info-panel dt {
  font-weight: 600;
  margin-top: 12px;
}

.info-panel dt:first-child {
  margin-top: 12px;
}

.info-panel dd {
  margin: 2px 0 0;
  opacity: 0.9;
}

/* episode dropdown's option list -- fully custom, so hover/active states
   use the site's pink palette instead of the browser's default blue */
.episode-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.episode-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 17px;
  color: var(--text-color);
  padding: 12px 18px;
  cursor: pointer;
}

.episode-option:hover:not(:disabled),
.episode-option:focus-visible:not(:disabled) {
  background-color: var(--polka-bg-color);
}

.episode-option:focus-visible:not(:disabled) {
  outline: 3px solid var(--text-color);
  outline-offset: -3px;
}

.episode-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.episode-option.is-active {
  color: var(--white);
  background-color: var(--text-color);
}

.episode-option.is-active:hover,
.episode-option.is-active:focus-visible {
  background-color: var(--text-color);
}

/* prev/next episode nav, shown above and below the comic pages */
.episode-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 10px;
}

.episode-nav-top {
  margin-top: 20px;
}

.episode-nav-bottom {
  margin: 24px auto 40px;
}

.episode-nav-arrow,
.episode-nav-arrow:visited {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background-color: var(--box-bg-color);
  border: 3px solid var(--box-border-color);
  border-radius: 20px;
  color: var(--text-color);
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.episode-nav-arrow:hover,
.episode-nav-arrow:focus-visible {
  background-color: var(--polka-bg-color);
  transform: translateY(-2px);
}

.episode-nav-arrow:focus-visible {
  outline: 3px solid var(--text-color);
  outline-offset: 3px;
}

.episode-nav-arrow[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* comic pages: a comfortable reading width on desktop so people can zoom
   in without the page getting absurdly wide */
.comic-pages {
  max-width: 800px;
  margin: 30px auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 0 10px 40px;
}

.comic-page {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 20px;
  border: 4px solid var(--box-border-color);
  background-color: var(--white);
}

/* full-bleed on mobile -- controls bar above stays sticky/opaque so pages
   scroll under it, never over it */
@media (max-width: 480px) {
  .comic-pages {
    max-width: 100%;
    margin-top: 0;
    gap: 0;
    padding: 0;
  }

  .comic-page {
    border-radius: 0;
    border: none;
    border-bottom: 2px solid var(--box-border-color);
  }

  .page-controls {
    padding: 12px 8px;
  }

  .episode-nav {
    padding: 0 12px;
  }

  .episode-nav-arrow {
    padding: 8px 14px;
    font-size: 14px;
  }
}