:root {
  --bg: #fdf6ec;
  --bg-soft: #fff;
  --ink: #2b1d3a;
  --ink-soft: #6b5b7a;
  --purple: #4b2e83;
  --purple-deep: #2e1a52;
  --amber: #ffb43c;
  --amber-deep: #ff8c1a;
  --pink: #ff6f9c;
  --line: #ece1d2;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(75, 46, 131, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  scroll-behavior: smooth;
}

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

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

.site-header {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-deep) 100%);
  color: #fff;
  padding: 30px 24px 22px;
  text-align: center;
  position: relative;
  overflow: hidden;
  border: 2px solid #000;
}

.site-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 0%, rgba(255, 180, 60, 0.25), transparent 55%);
  pointer-events: none;
}

.site-title {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: 0.04em;
  margin: 0;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ffd98a, var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Logo wordmark replacing the text title in the header */
.site-title:has(.site-logo) {
  background: none;
  line-height: 0;
}

.site-logo {
  width: clamp(240px, 42vw, 430px);
  height: auto;
  /* Matches the SVG's viewBox (964x284). Without this the browser cannot
     reserve the logo's height until the file downloads, so the header
     starts collapsed and everything below jumps when it loads. */
  aspect-ratio: 964 / 284;
  margin: 0 auto;
  /* Keeps the white wordmark readable if a light banner sits behind it */
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.55));
}

.site-tagline {
  margin: 6px 0 0;
  color: #e6dcf7;
  font-size: 1rem;
  letter-spacing: 0.03em;
}

nav.main-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
  position: relative;
  z-index: 1;
}

nav.main-nav a {
  background: var(--purple-deep);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

nav.main-nav a:hover,
nav.main-nav a.active {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--purple-deep);
  transform: translateY(-2px);
}

/* Link out to the Lunarian Database — moon-toned so it reads as a
   separate site rather than another page of the comic. */
nav.main-nav a.nav-db-btn {
  background: #1e1830;
  border-color: #cfd8ff;
  color: #cfd8ff;
}

nav.main-nav a.nav-db-btn:hover {
  background: #cfd8ff;
  border-color: #cfd8ff;
  color: #1e1830;
}

a.nav-login-btn {
  background: var(--purple);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.2s ease, transform 0.2s ease;
  margin-left: auto;
}

a.nav-login-btn:hover {
  background: #6a45ad;
  transform: translateY(-2px);
}

a.nav-logout-btn {
  margin-left: 6px;
  background: #8e3b3b;
  border-color: rgba(255,100,100,0.4);
}

a.nav-logout-btn:hover {
  background: #a84545;
}

/* Admin page */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 28px;
}

.admin-card {
  background: var(--bg-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border-top: 4px solid var(--purple);
}

.admin-card h2 {
  margin: 0 0 20px;
  color: var(--purple-deep);
  font-size: 1.3rem;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group textarea,
.form-group select,
select.field-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  transition: border-color 0.2s;
}

select.field-select {
  width: auto;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--purple);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

.output-box {
  background: var(--ink);
  color: #e8dff7;
  border-radius: 8px;
  padding: 14px;
  font-family: monospace;
  font-size: 0.82rem;
  white-space: pre;
  overflow-x: auto;
  margin-top: 16px;
  display: none;
}

.output-box.visible { display: block; }

.poll-preview {
  background: linear-gradient(135deg, #fff4e0, #ffe6ee);
  border-radius: 10px;
  padding: 18px;
  margin-top: 16px;
  display: none;
}

.poll-preview.visible { display: block; }

.poll-option-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.poll-option-row input { flex: 1; }

.poll-option-row button {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 1rem;
}

.login-card {
  max-width: 400px;
  margin: 60px auto;
  background: var(--bg-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
  text-align: center;
}

.login-card h2 {
  color: var(--purple-deep);
  margin: 0 0 8px;
}

.login-card p {
  color: var(--ink-soft);
  margin: 0 0 24px;
}

.login-error {
  color: #c0392b;
  font-size: 0.9rem;
  margin-top: 10px;
  display: none;
}

.login-error.visible { display: block; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.6rem;
  color: var(--purple-deep);
}

.section-heading .meta {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.welcome-card {
  background: var(--bg-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 40px;
  text-align: center;
}

.welcome-card.showing-latest {
  padding-top: 18px;
}

.welcome-text {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--purple-deep);
  line-height: 1.5;
  white-space: pre-line;
  margin: 0 0 28px;
}

.welcome-latest-img {
  width: 50%;
  margin: 0 auto 18px;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.2s;
}

.welcome-latest-img:hover {
  transform: scale(1.02);
}

.welcome-card .page-caption {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: linear-gradient(90deg, var(--amber), var(--amber-deep));
  color: var(--purple-deep);
  box-shadow: 0 6px 18px rgba(255, 140, 26, 0.4);
}

.btn-secondary {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 6px 18px rgba(75, 46, 131, 0.3);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.2);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 36px;
}

.feature-card {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--amber);
}

a.feature-card {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(75, 46, 131, 0.2);
}

.feature-card h3 {
  margin: 0 0 8px;
  color: var(--purple-deep);
}

.feature-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 22px;
}

.gallery-item {
  background: var(--bg-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(75, 46, 131, 0.2);
}

.gallery-img-wrap {
  position: relative;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--line);
}

.gallery-item .info {
  padding: 12px 14px;
}

.gallery-item .info .chapter {
  color: var(--amber-deep);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gallery-item .info .title {
  font-weight: 700;
  color: var(--purple-deep);
  margin: 2px 0 4px;
}

.gallery-item .info .date {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* Votes */
.vote-card {
  background: var(--bg-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  text-align: center;
}

.vote-card iframe,
.vote-card .embed-placeholder {
  width: 100%;
  min-height: 420px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff4e0, #ffe6ee);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.95rem;
  padding: 20px;
}

.announcement-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #fff4e0, #ffe6ee);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 28px;
  color: var(--purple-deep);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-line;
}

.announcement-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}

.site-footer {
  text-align: center;
  padding: 30px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* Spoiler toggle */
.spoiler-toggle {
  width: 42px;
  height: 24px;
  background: var(--purple);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.spoiler-toggle.off { background: var(--line); }

.spoiler-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.spoiler-toggle:not(.off) .spoiler-knob { transform: translateX(18px); }

/* Spoiler overlay on gallery items */
.gallery-item { position: relative; }

.spoiler-cover {
  position: absolute;
  inset: 0;
  background: rgba(20, 10, 35, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.3s;
  z-index: 3;
}

.spoiler-cover .spoiler-icon { font-size: 1.8rem; }
.spoiler-cover .spoiler-label {
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.spoiler-cover .spoiler-hint {
  color: rgba(255,255,255,0.55);
  font-size: 0.76rem;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 35, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 30px;
  z-index: 100;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 32px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  background: none;
  border: none;
}

.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10;
}

.lightbox-arrow svg {
  display: block;
  margin: 0 auto;
}

/* Gallery controls: chapter filter + bookmark jump */
.bookmark-jump-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.bookmark-jump-btn:hover {
  background: var(--purple);
  color: #fff;
}

/* Per-page bookmark icon */
.info { position: relative; }

.bookmark-icon-btn {
  position: absolute;
  top: -14px;
  right: 14px;
  width: 30px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--line);
  cursor: pointer;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
  transition: color 0.2s, transform 0.15s;
}

.bookmark-icon-btn:hover { transform: translateY(-2px); }
.bookmark-icon-btn svg { width: 100%; height: 100%; fill: currentColor; }
.bookmark-icon-btn.active { color: var(--amber); }

@keyframes bookmark-flash-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 180, 60, 0); }
  30% { box-shadow: 0 0 0 6px rgba(255, 180, 60, 0.6); }
}

.bookmark-flash {
  animation: bookmark-flash-pulse 1.2s ease;
  border-radius: var(--radius);
}

.lightbox-arrow:hover { background: rgba(255,255,255,0.3); }
.lightbox-arrow[hidden] { display: none; }
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }

/* ============================================================
   Gallery lightbox: zoom & pan
   Scoped to .lightbox-stage so the home page's plain lightbox
   (which has no stage wrapper) keeps its original behaviour.
   ============================================================ */
.lightbox-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 10px;
  touch-action: none;   /* we handle dragging ourselves */
}

.lightbox-stage img {
  position: absolute;
  top: 0;
  left: 0;
  /* Undo the global img caps — size is driven entirely by transform */
  max-width: none;
  max-height: none;
  transform-origin: 0 0;
  will-change: transform;
  cursor: zoom-in;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* Animate deliberate steps, but never while dragging or wheeling */
.lightbox-stage img.smooth { transition: transform 0.22s ease; }

.lightbox-stage.zoomed img          { cursor: grab; }
.lightbox-stage.zoomed.dragging img { cursor: grabbing; transition: none; }

/* ---- Zoom strength panel (left edge, only while zoomed) ---- */
.zoom-panel {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  width: 140px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(30, 24, 48, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.8rem;
}

.zoom-panel[hidden] { display: none; }

.zoom-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
  margin-bottom: 10px;
}

.zoom-panel .zoom-value {
  color: var(--amber);
  font-size: 0.85rem;
  text-transform: none;
}

.zoom-panel input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
  cursor: pointer;
}

.zoom-reset {
  width: 100%;
  margin-top: 12px;
  padding: 7px 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.zoom-reset:hover { background: var(--amber); color: var(--purple-deep); border-color: var(--amber); }

/* ---- Hint strip ---- */
.zoom-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(20, 10, 35, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
}

.zoom-hint kbd {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.74rem;
  color: #fff;
}

@media only screen and (max-width: 768px) {
  .zoom-panel {
    left: 12px;
    width: 116px;
    padding: 11px 12px;
  }
  /* Ctrl+scroll is meaningless on touch, so keep the hint short */
  .zoom-hint {
    font-size: 0.72rem;
    white-space: normal;
    max-width: 78vw;
    text-align: center;
  }
}

/* Mobile overrides */
@media only screen and (max-width: 768px) {
  /* Hide every admin control on phones. All three (Admin Login, Admin Panel,
     Log Out) carry .nav-login-btn, so this one rule covers them and keeps the
     nav to a single tidy row. The panel is still reachable via /admin.html. */
  .main-nav .nav-login-btn { display: none; }

  /* Tighten the remaining links so Home/Gallery/Vote/Socials fit one line */
  nav.main-nav {
    gap: 7px;
    margin-top: 16px;
  }

  nav.main-nav a {
    padding: 8px 15px;
    font-size: 0.85rem;
  }

  .site-header { padding: 22px 14px 18px; }
  .site-tagline { font-size: 0.88rem; }
}

/* Very narrow phones — let the nav wrap into two neat centred rows */
@media only screen and (max-width: 400px) {
  nav.main-nav a {
    padding: 7px 13px;
    font-size: 0.8rem;
  }
}

/* Device-specific mobile overrides */
@media only screen and (width: 360px) and (height: 800px) { }
@media only screen and (width: 414px) and (height: 896px) { }
@media only screen and (width: 390px) and (height: 844px) { }
@media only screen and (width: 393px) and (height: 873px) { }
@media only screen and (width: 375px) and (height: 812px) { }
@media only screen and (width: 384px) and (height: 832px) { }
@media only screen and (width: 412px) and (height: 915px) { }
@media only screen and (width: 360px) and (height: 780px) { }
@media only screen and (width: 393px) and (height: 852px) { }
@media only screen and (width: 385px) and (height: 854px) { }
@media only screen and (width: 360px) and (height: 806px) { }
@media only screen and (width: 430px) and (height: 932px) { }
@media only screen and (width: 412px) and (height: 892px) { }
@media only screen and (width: 360px) and (height: 804px) { }
@media only screen and (width: 375px) and (height: 667px) { }
@media only screen and (width: 428px) and (height: 926px) { }
@media only screen and (width: 384px) and (height: 854px) { }
@media only screen and (width: 384px) and (height: 857px) { }
@media only screen and (width: 360px) and (height: 760px) { }
@media only screen and (width: 393px) and (height: 851px) { }

/* Other — fallback for anything not matched above */
@media only screen and (max-width: 768px) { }
