/*
 * Lunar Cry — Shared Gallery System
 * Shared by the main gallery, cosplay sub-gallery and future galleries.
 * Page-specific accents can be set with --gallery-accent on .gallery-page.
 */

:root {
  color-scheme: dark;
  --gallery-bg: #080b11;
  --gallery-surface: rgba(18, 24, 36, 0.88);
  --gallery-surface-strong: #111824;
  --gallery-border: rgba(160, 190, 220, 0.18);
  --gallery-text: #e8edf5;
  --gallery-muted: #a3afc2;
  --gallery-accent: #8ddcf2;
  --gallery-accent-rgb: 141, 220, 242;
  --gallery-radius: 18px;
  --gallery-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--gallery-bg);
  scroll-behavior: smooth;
}

body.gallery-page {
  min-height: 100vh;
  margin: 0;
  color: var(--gallery-text);
  background:
    radial-gradient(ellipse at 15% 0%, rgba(var(--gallery-accent-rgb), 0.11), transparent 38rem),
    radial-gradient(ellipse at 88% 24%, rgba(100, 87, 180, 0.10), transparent 34rem),
    linear-gradient(155deg, #090d15 0%, #080a10 54%, #0c1019 100%);
  font-family: Inter, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
}

body.gallery-page::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

.gallery-page a {
  color: var(--gallery-accent);
  text-decoration-color: rgba(var(--gallery-accent-rgb), 0.45);
  text-underline-offset: 0.22em;
}

.gallery-page a:hover { text-decoration-color: currentColor; }

.gallery-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 48px));
  margin-inline: auto;
}

.gallery-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 24px;
  border-bottom: 1px solid var(--gallery-border);
}

.gallery-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--gallery-text) !important;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-decoration: none;
  text-transform: uppercase;
}

.gallery-brand .favicon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex: 0 0 auto;
}

.gallery-brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(var(--gallery-accent-rgb), 0.52);
  border-radius: 50%;
  color: var(--gallery-accent);
  box-shadow: inset 0 0 18px rgba(var(--gallery-accent-rgb), 0.08), 0 0 22px rgba(var(--gallery-accent-rgb), 0.09);
  font-size: 1rem;
}

.gallery-backlink {
  color: var(--gallery-muted) !important;
  font-size: 0.88rem;
  text-decoration: none;
  transition: color 160ms ease;
}
.gallery-backlink:hover { color: var(--gallery-text) !important; }

.gallery-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.34fr);
  align-items: end;
  gap: 32px;
  padding-block: clamp(48px, 8vw, 100px) 48px;
}

.gallery-eyebrow {
  margin: 0 0 14px;
  color: var(--gallery-accent);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.gallery-title {
  max-width: 900px;
  margin: 0;
  color: #f4f6fb;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 7.8vw, 6.4rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.99;
  text-wrap: balance;
}

.gallery-title em {
  color: var(--gallery-accent);
  font-weight: 400;
}

.gallery-intro {
  max-width: 690px;
  margin: 24px 0 0;
  color: var(--gallery-muted);
  font-size: clamp(1rem, 1.5vw, 1.12rem);
}

.gallery-hero-note {
  padding: 18px 0 5px 20px;
  border-left: 1px solid rgba(var(--gallery-accent-rgb), 0.46);
  color: var(--gallery-muted);
  font-size: 0.86rem;
}

.gallery-hero-note strong {
  display: block;
  margin-bottom: 7px;
  color: var(--gallery-text);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 22px;
  padding-block: 15px;
  border-top: 1px solid var(--gallery-border);
  border-bottom: 1px solid var(--gallery-border);
}

.gallery-count {
  margin: 0;
  color: var(--gallery-muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.gallery-count strong { color: var(--gallery-text); }

.gallery-grid {
  --gallery-columns: 3;
  display: grid;
  grid-template-columns: repeat(var(--gallery-columns), minmax(0, 1fr));
  align-items: start;
  gap: clamp(14px, 2vw, 26px);
  padding-bottom: 54px;
}

.gallery-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--gallery-border);
  border-radius: var(--gallery-radius);
  background: linear-gradient(145deg, rgba(27, 35, 50, 0.9), rgba(13, 18, 28, 0.94));
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
  transform: translateZ(0);
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
  break-inside: avoid;
}

.gallery-card:nth-child(5n + 2) { margin-top: 34px; }
.gallery-card:nth-child(7n + 4) { margin-top: 12px; }

.gallery-card:hover {
  z-index: 2;
  border-color: rgba(var(--gallery-accent-rgb), 0.58);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.32), 0 0 26px rgba(var(--gallery-accent-rgb), 0.07);
  transform: translateY(-4px);
}

.gallery-card-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: zoom-in;
  text-align: left;
}

.gallery-card-image-wrap {
  position: relative;
  overflow: hidden;
  background: #0b1018;
}

.gallery-card-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 560px;
  object-fit: cover;
  opacity: 0;
  transition: opacity 300ms ease, transform 600ms cubic-bezier(.2,.65,.2,1);
}

.gallery-card-image.is-loaded { opacity: 1; }
.gallery-card-button:hover .gallery-card-image { transform: scale(1.035); }

.gallery-card-image-wrap::after {
  position: absolute;
  inset: 40% 0 0;
  pointer-events: none;
  content: "";
  background: linear-gradient(transparent, rgba(5, 8, 14, 0.45));
  opacity: 0.55;
}

.gallery-card-info { padding: 15px 17px 17px; }

.gallery-card-title {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--gallery-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.5vw, 1.22rem);
  font-weight: 400;
  line-height: 1.3;
}

.gallery-card-date {
  margin: 8px 0 0;
  color: var(--gallery-muted);
  font-size: 0.76rem;
  letter-spacing: 0.035em;
}

.gallery-status {
  grid-column: 1 / -1;
  padding: 34px 22px;
  border: 1px dashed var(--gallery-border);
  border-radius: var(--gallery-radius);
  color: var(--gallery-muted);
  text-align: center;
}

.gallery-status.is-error { color: #ffb6bf; }

.gallery-footer {
  position: relative;
  z-index: 1;
  padding: 26px 24px 34px;
  border-top: 1px solid var(--gallery-border);
  color: #7f8ba0;
  font-size: 0.78rem;
  text-align: center;
}

/* Accessible lightbox */
.gallery-lightbox[hidden] { display: none !important; }

.gallery-lightbox {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(12px, 2.5vw, 30px);
  background: rgba(3, 5, 9, 0.94);
  backdrop-filter: blur(18px);
}

.gallery-lightbox-top,
.gallery-lightbox-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1500px, 100%);
  margin-inline: auto;
}

.gallery-lightbox-top { padding-bottom: 12px; }
.gallery-lightbox-bottom { padding-top: 12px; }

.gallery-lightbox-label {
  overflow: hidden;
  color: var(--gallery-muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-lightbox-title {
  overflow: hidden;
  margin: 0;
  color: var(--gallery-text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 2.4vw, 1.45rem);
  font-weight: 400;
  text-overflow: ellipsis;
}

.gallery-lightbox-stage {
  display: grid;
  min-height: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 2vw, 24px);
}

.gallery-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  justify-self: center;
  object-fit: contain;
  border-radius: 5px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
}

.gallery-lightbox-control {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--gallery-border);
  border-radius: 50%;
  color: var(--gallery-text);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  font: inherit;
  font-size: 1.25rem;
  transition: background 160ms ease, border-color 160ms ease;
}

.gallery-lightbox-control:hover {
  border-color: rgba(var(--gallery-accent-rgb), 0.65);
  background: rgba(var(--gallery-accent-rgb), 0.12);
}
.gallery-lightbox-control:focus-visible,
.gallery-card-button:focus-visible,
.gallery-page a:focus-visible {
  outline: 2px solid var(--gallery-accent);
  outline-offset: 4px;
}

.gallery-lightbox-close { font-size: 1.5rem; }
.gallery-lightbox-date { color: var(--gallery-muted); font-size: 0.82rem; }

body.gallery-lightbox-open { overflow: hidden; }

@media (min-width: 1200px) {
  .gallery-grid { --gallery-columns: 4; }
  .gallery-card:nth-child(5n + 2) { margin-top: 0; }
  .gallery-card:nth-child(9n + 2),
  .gallery-card:nth-child(9n + 6) { margin-top: 32px; }
}

@media (max-width: 900px) {
  .gallery-hero { grid-template-columns: 1fr; gap: 24px; }
  .gallery-hero-note { max-width: 500px; }
  .gallery-grid { --gallery-columns: 2; }
}

@media (max-width: 560px) {
  .gallery-shell { width: min(100% - 28px, 1440px); }
  .gallery-topline { padding-block: 17px; }
  .gallery-brand { font-size: 0.67rem; letter-spacing: 0.12em; }
  .gallery-brand-mark { width: 30px; height: 30px; }
  .gallery-hero { padding-block: 48px 32px; }
  .gallery-title { font-size: clamp(2.65rem, 15vw, 4.4rem); }
  .gallery-toolbar { align-items: flex-start; }
  .gallery-grid { --gallery-columns: 1; gap: 18px; }
  .gallery-card:nth-child(n) { margin-top: 0; }
  .gallery-card-image { max-height: none; }
  .gallery-lightbox { padding: 10px; }
  .gallery-lightbox-stage { grid-template-columns: 34px minmax(0, 1fr) 34px; gap: 5px; }
  .gallery-lightbox-control { width: 34px; height: 34px; font-size: 1rem; }
  .gallery-lightbox-bottom { align-items: flex-start; flex-direction: column; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
