*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body.slideshow {
  font-family: "Inter", system-ui, sans-serif;
  background: #0a0a0a;
  color: #fafafa;
  display: flex;
  flex-direction: column;
}

a { color: #34d399; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.slideshow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: rgba(10, 10, 10, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  z-index: 10;
}

.slideshow-logo img {
  height: 32px;
  width: auto;
  display: block;
}

.slideshow-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.slideshow-nav a {
  font-size: 0.85rem;
  font-weight: 500;
  color: #a1a1aa;
}

.slideshow-nav a:hover { color: #fafafa; }

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fafafa;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Main stage */
.slideshow-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  padding: 0.5rem 3.5rem;
  touch-action: pan-y;
}

.slideshow-stage {
  margin: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  max-height: calc(100vh - 140px);
  position: relative;
}

.slideshow-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  user-select: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.slideshow-stage img.is-loaded {
  opacity: 1;
}

.slideshow-loading {
  position: absolute;
  font-size: 0.9rem;
  color: #71717a;
}

.slideshow-loading.is-hidden {
  display: none;
}

/* Arrows */
.slideshow-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 48px;
  height: 72px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fafafa;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.slideshow-arrow:hover {
  background: rgba(255, 255, 255, 0.14);
}

.slideshow-arrow--prev { left: 0.5rem; }
.slideshow-arrow--next { right: 0.5rem; }

.slideshow-arrow:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Footer */
.slideshow-footer {
  flex-shrink: 0;
  padding: 0.65rem 1.25rem 0.85rem;
  background: rgba(10, 10, 10, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.slideshow-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-control {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #a1a1aa;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-control:hover {
  color: #fafafa;
  border-color: rgba(255, 255, 255, 0.3);
}

.slideshow-counter {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e4e4e7;
  min-width: 4.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.slideshow-progress {
  flex: 1;
  min-width: 120px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.slideshow-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #34d399);
  border-radius: 999px;
  width: 0%;
  transition: width 0.25s ease;
}

.btn-thumbs-toggle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #a1a1aa;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.btn-thumbs-toggle:hover,
.btn-thumbs-toggle[aria-expanded="true"] {
  color: #fafafa;
  border-color: rgba(52, 211, 153, 0.4);
}

/* Thumbnails */
.slideshow-thumbs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 28vh;
  background: rgba(10, 10, 10, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.75rem 1rem;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
}

.slideshow-thumbs[hidden] {
  display: none;
}

.slideshow-thumbs__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.slideshow-thumbs__grid button {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s, border-color 0.15s;
}

.slideshow-thumbs__grid button:hover,
.slideshow-thumbs__grid button.is-active {
  opacity: 1;
  border-color: #34d399;
}

.slideshow-thumbs__grid img {
  width: 72px;
  height: 48px;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}

/* Fullscreen */
body.slideshow.is-fullscreen .slideshow-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

body.slideshow.is-fullscreen:hover .slideshow-header,
body.slideshow.is-fullscreen:focus-within .slideshow-header {
  opacity: 1;
  pointer-events: auto;
}

body.slideshow.is-fullscreen .slideshow-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

body.slideshow.is-fullscreen .slideshow-main {
  padding: 0;
}

body.slideshow.is-fullscreen .slideshow-stage {
  max-height: 100vh;
}

@media (max-width: 640px) {
  .slideshow-main {
    padding: 0 2.75rem;
  }

  .slideshow-arrow {
    width: 40px;
    height: 56px;
    font-size: 1.5rem;
  }

  .slideshow-arrow--prev { left: 0.25rem; }
  .slideshow-arrow--next { right: 0.25rem; }

  .slideshow-thumbs__grid img {
    width: 56px;
    height: 40px;
  }
}
