.rko-gallery {
  --rko-accent: var(--pifoxen-base, #e8283a);
  position: relative;
  margin: 0 0 24px;
  max-width: 100%;
}

.rko-gallery__stage {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 8px;
  background: #16181b;
  perspective: 1600px;
  outline: none;
  touch-action: pan-y;
  user-select: none;
}
.rko-gallery__stage:focus-visible {
  box-shadow: 0 0 0 3px var(--rko-accent);
}

.rko-gallery__slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  cursor: zoom-in;
  backface-visibility: hidden;
  -webkit-user-drag: none;
}
.rko-gallery__slide.is-link { cursor: pointer; }
.rko-gallery__slide,
.rko-viewer__img { image-rendering: auto; -ms-interpolation-mode: bicubic; }
.rko-gallery__slide.is-active {
  opacity: 1;
  z-index: 1;
}

/* Blurred copy of the current photo filling the letterbox bars. */
.rko-gallery__backdrop {
  position: absolute;
  inset: -30px;
  background-size: cover;
  background-position: center;
  filter: blur(24px) brightness(0.55);
  transition: background-image 0.6s ease;
}

.rko-gallery__nav,
.rko-gallery__tool {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}
.rko-gallery__nav:hover,
.rko-gallery__tool:hover {
  background: var(--rko-accent);
}
.rko-gallery__nav {
  top: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  font-size: 22px;
  line-height: 1;
}
.rko-gallery__nav--prev { left: 12px; }
.rko-gallery__nav--next { right: 12px; }

.rko-gallery__tools {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 8px;
}
.rko-gallery__tool {
  position: static;
  width: 36px;
  height: 36px;
  font-size: 15px;
}

.rko-gallery__counter {
  position: absolute;
  left: 12px;
  bottom: 14px;
  z-index: 3;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 12px;
  line-height: 1.6;
}

.rko-gallery__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  height: 3px;
  width: 0;
  background: var(--rko-accent);
}

.rko-gallery__thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-bottom: 4px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.rko-gallery__thumb {
  flex: 0 0 auto;
  width: 84px;
  height: 60px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  background: #ddd;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.rko-gallery__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rko-gallery__thumb:hover { opacity: 0.9; }
.rko-gallery__thumb.is-active {
  opacity: 1;
  border-color: var(--rko-accent);
}

/* Post title over the bottom of a post slideshow. */
.rko-gallery__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 36px 14px 26px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none !important;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rko-gallery__caption:hover { text-decoration: underline !important; }
.rko-gallery.has-caption .rko-gallery__counter { bottom: auto; top: 12px; }

/* Home page rotator above the post list. */
.rko-home-rotator { margin-bottom: 40px; }
.rko-home-rotator .rko-gallery__caption { font-size: 20px; padding: 60px 20px 30px; }
@media (max-width: 767px) {
  .rko-home-rotator .rko-gallery__caption { font-size: 15px; padding: 30px 12px 22px; }
}

/* ---------- Photo Gallery page intro (above [rko_albums]) ---------- */
.rko-albums-intro { max-width: 820px; margin: 0 auto 32px; text-align: center; }
.rko-albums-intro__title { margin: 0 0 4px; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.25; }
.rko-albums-intro__title-km { margin: 0 0 16px; font-size: 20px; color: var(--pifoxen-primary, #f37a21); }
.rko-albums-intro__text { margin: 0 0 12px; font-size: 16px; line-height: 1.75; color: #555; }
.rko-albums-intro__text[lang=km] { font-size: 16.5px; line-height: 1.9; }
.rko-albums-intro__tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.rko-albums-intro__tags li { margin: 0; padding: 6px 14px; border-radius: 999px; background: #f5f6fb; font-size: 14px; color: #3a3f68; }
.rko-albums-intro__tags li span { color: #888; }
.rko-albums-intro__cta { margin: 18px 0 0; font-weight: 600; }
.rko-albums-intro__cta a { white-space: nowrap; }

/* ---------- Album covers ([rko_albums]) ---------- */
.rko-albums {
  display: grid;
  grid-template-columns: repeat(var(--rko-albums-cols, 3), minmax(0, 1fr));
  gap: 20px;
  margin: 0 0 24px;
}
.rko-albums__card {
  display: block;
  color: inherit !important;
  text-decoration: none !important;
}
.rko-albums__cover {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: #eee;
}
.rko-albums__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.rko-albums__card:hover .rko-albums__cover img { transform: scale(1.05); }
.rko-albums__name {
  display: block;
  margin-top: 10px;
  font-weight: 600;
}
.rko-albums__card:hover .rko-albums__name { color: var(--pifoxen-base, #e8283a); }
.rko-albums__count {
  display: block;
  font-size: 13px;
  opacity: 0.65;
}
.rko-albums__back { text-decoration: none; }
.rko-albums__title { margin: 0 0 14px; }
@media (max-width: 767px) {
  .rko-albums { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}
@media (max-width: 420px) {
  .rko-albums { grid-template-columns: 1fr; }
}

/* ---------- Post archive (by category / year / month) ---------- */
.rko-archive h4 {
  margin: 0 0 10px;
  font-size: 18px;
}
.rko-archive ul {
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}
.rko-archive li {
  margin: 0;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.rko-archive li:last-child { border-bottom: 0; }
.rko-archive a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.rko-archive a:hover { color: var(--pifoxen-base, #e8283a); }
.rko-archive__count { opacity: 0.6; }
/* The theme draws a \203A arrow on every sidebar link; here it would sit on top of the counts. */
.rko-archive li a::after,
.rko-archive li a::before { content: none !important; display: none !important; }
.rko-archive details > summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
.rko-archive details > summary::-webkit-details-marker { display: none; }
.rko-archive details > summary::before {
  content: "+";
  display: inline-block;
  width: 1em;
  color: var(--pifoxen-base, #e8283a);
}
.rko-archive details[open] > summary::before { content: "\2212"; }
.rko-archive summary span:first-child { flex: 1; }
.rko-archive details ul { margin: 6px 0 0 1em; }

/* Narrow spots such as the sidebar. */
.rko-gallery.is-compact .rko-gallery__nav { width: 34px; height: 34px; margin-top: -17px; font-size: 18px; }
.rko-gallery.is-compact .rko-gallery__thumb { width: 60px; height: 44px; }
.rko-gallery.is-compact .rko-gallery__tool { width: 30px; height: 30px; font-size: 13px; }
.rko-gallery.is-compact .rko-gallery__caption { padding: 22px 10px 10px; font-size: 12.5px; -webkit-line-clamp: 2; }

/* ---------- Full-screen viewer ---------- */
.rko-viewer {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 12, 0.95);
  overflow: hidden;
  touch-action: none;
}
.rko-viewer__img {
  max-width: 94vw;
  max-height: 88vh;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  transition: transform 0.15s ease-out;
  cursor: zoom-in;
}
.rko-viewer__img.is-zoomed { cursor: grab; }
.rko-viewer__img.is-panning { cursor: grabbing; transition: none; }
.rko-viewer__bar {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
}
.rko-viewer button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.rko-viewer button:hover { background: var(--pifoxen-base, #e8283a); }
.rko-viewer__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px !important;
  height: 52px !important;
  font-size: 26px !important;
}
.rko-viewer__nav--prev { left: 16px; }
.rko-viewer__nav--next { right: 16px; }
.rko-viewer__counter {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .rko-gallery__thumbs { scroll-behavior: auto; }
  .rko-viewer__img { transition: none; }
}
