/* ============================================
   Sky Relics — Media Viewer Styles
   ============================================ */

/* --- Viewer Container --- */
.sky-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  color: #e0e0e0;
  user-select: none;
  -webkit-user-select: none;
}

.sky-viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

/* --- Loading Overlay --- */
.sky-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #111;
  z-index: 10;
  transition: opacity 0.4s ease;
}

.sky-viewer-loading.hidden {
  display: none;
}

/* Survey-particle loading visualiser (fills the overlay, fades out on load) */
.sky-viewer-loading-viz {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;   /* a loading overlay must never steal clicks from the viewer */
  transition: opacity var(--sr-fade, 700ms) ease;
}
.sky-viewer-loading-viz.is-hidden { opacity: 0; }
/* transparent loader: let whatever sits behind the viewer show through */
.sky-viewer-loading.survey-transparent { background: transparent; }
/* While the survey cloud is up, the whole overlay is click-through so you can
   orbit the streaming asset behind it (the cloud is decoration, not a control). */
.sky-viewer-loading.has-survey { pointer-events: none; }
/* The cloud replaces the spinner, but keep the type label + % + bar over it,
   layered above the canvas and coloured for legibility on the current theme. */
.sky-viewer-loading.has-survey .sky-viewer-spinner { display: none; }
.sky-viewer-loading.has-survey .sky-viewer-progress { z-index: 1; }
.sky-viewer-loading.has-survey .sky-viewer-progress-label,
.sky-viewer-loading.has-survey .sky-viewer-progress-text { position: relative; z-index: 1; }
.sky-viewer-loading.survey-dark .sky-viewer-progress-label,
.sky-viewer-loading.survey-dark .sky-viewer-progress-text {
  color: #e6eef7; text-shadow: 0 1px 8px rgba(0,0,0,0.55);
}
.sky-viewer-loading.survey-light .sky-viewer-progress-label,
.sky-viewer-loading.survey-light .sky-viewer-progress-text {
  color: #16202b; text-shadow: 0 1px 6px rgba(255,255,255,0.6);
}
/* Groups the bar + label + %, and over a photo/transparent bg gives them their
   own small dark rounded box while the overlay stays transparent (particles fill
   the frame behind). */
.sky-viewer-loading-info { display: flex; flex-direction: column; align-items: center; }
.sky-viewer-loading.survey-transparent .sky-viewer-loading-info {
  position: relative;
  z-index: 1;
  gap: 0.45rem;
  padding: 0.85rem 1.4rem 0.9rem;
  min-width: 210px;
  background: rgba(17, 17, 17, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.sky-viewer-loading.survey-transparent .sky-viewer-progress {
  position: static; width: 100%; height: 4px; border-radius: 999px; overflow: hidden;
}
.sky-viewer-loading.survey-transparent .sky-viewer-progress-label,
.sky-viewer-loading.survey-transparent .sky-viewer-progress-text {
  margin-top: 0; color: rgba(255, 255, 255, 0.86); text-shadow: none;
}

.sky-viewer-loading.hud {
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100% - 2rem));
  padding: 0.8rem 0.9rem 0.75rem;
  align-items: stretch;
  justify-content: flex-start;
  text-align: center;
  gap: 0.45rem;
  background: rgba(17, 17, 17, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.sky-viewer-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #333;
  border-top-color: #999;
  border-radius: 50%;
  animation: sky-viewer-spin 0.8s linear infinite;
}

@keyframes sky-viewer-spin {
  to { transform: rotate(360deg); }
}

/* Progress bar */
.sky-viewer-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255,255,255,0.08);
  z-index: 11;
}

.sky-viewer-loading.hud .sky-viewer-progress {
  position: static;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
}

.sky-viewer-progress-bar {
  height: 100%;
  background: #3b82f6;
  width: 0%;
  transition: width 0.2s ease;
}

.sky-viewer-progress-label {
  margin-top: 1rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sky-viewer-loading.hud .sky-viewer-progress-label {
  margin-top: 0;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.58);
}

.sky-viewer-progress-text {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.sky-viewer-loading.hud .sky-viewer-progress-text {
  margin-top: 0;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.78);
}

.sky-viewer-loading.hud .sky-viewer-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
  align-self: center;
  margin: 0;
}

/* --- Error Overlay --- */
.sky-viewer-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #111;
  z-index: 10;
}

.sky-viewer-error-icon {
  width: 48px;
  height: 48px;
  color: #666;
  margin-bottom: 1rem;
}

.sky-viewer-error-msg {
  font-size: 0.85rem;
  color: #888;
  text-align: center;
  max-width: 300px;
  line-height: 1.5;
}

/* --- Controls Toolbar --- */
.sky-viewer-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding: 6px 8px;
  background: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sky-viewer:hover .sky-viewer-controls,
.sky-viewer-controls:focus-within {
  opacity: 1;
}

.sky-viewer-controls button,
.sky-viewer-video-controls button {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  min-width: 32px;
  min-height: 32px;
}

.sky-viewer-controls button:hover,
.sky-viewer-video-controls button:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.sky-viewer-controls button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sky-viewer-quality {
  position: relative;
}

.sky-viewer-quality-toggle {
  min-width: 56px !important;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sky-viewer-quality-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 84px;
  padding: 4px;
  background: rgba(12,12,12,0.92);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
}

.sky-viewer-quality-menu.open {
  display: flex;
}

.sky-viewer-quality-menu button {
  width: 100%;
  justify-content: flex-start;
  padding: 6px 8px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sky-viewer-quality-menu button.active {
  color: #fff;
  background: rgba(255,255,255,0.14);
}

/* --- Modal Overlay --- */
.sky-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sky-viewer-fade-in 0.25s ease;
}

@keyframes sky-viewer-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sky-viewer-modal .sky-viewer {
  width: 94vw;
  height: 88vh;
  max-width: 1600px;
}

.sky-viewer-modal-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  color: #aaa;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  z-index: 1001;
  transition: color 0.2s;
  padding: 0.5rem;
}

.sky-viewer-modal-close:hover { color: #fff; }

/* --- Branding --- */
.sky-viewer-branding {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  mix-blend-mode: exclusion;
  opacity: 0.7;
  transition: opacity 0.3s;
}
.sky-viewer-branding:hover { opacity: 0.4; }
.sky-viewer-branding-fixed { position: fixed; z-index: 100; }
.sky-viewer-branding img {
  height: 30px;
  filter: invert(1);
}
.sky-viewer-branding span {
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: -2px;
  color: #fff;
}
.sky-viewer-branding .fw200 { font-weight: 200; }
.sky-viewer-branding .fw300 { font-weight: 300; }

/* --- Video Controls --- */
.sky-viewer-video-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.sky-viewer-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sky-viewer-video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sky-viewer-video-wrap:hover .sky-viewer-video-controls,
.sky-viewer:hover > .sky-viewer-video-controls {
  opacity: 1;
}

.sky-viewer-video-controls button { padding: 4px; }

.sky-viewer-video-controls button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.sky-viewer-video-progress {
  flex: 1;
  height: 24px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
}
.sky-viewer-video-progress::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.sky-viewer-video-progress-fill {
  height: 4px;
  background: #3b82f6;
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

.sky-viewer-video-time {
  font-size: 0.75rem;
  color: #999;
  white-space: nowrap;
  min-width: 70px;
  text-align: center;
}

.sky-viewer-volume {
  width: 60px;
  height: 24px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
}
.sky-viewer-volume::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.sky-viewer-volume-fill {
  height: 4px;
  background: #ccc;
  border-radius: 2px;
  width: 100%;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

/* --- Touch targets --- */
@media (hover: none) {
  .sky-viewer-controls button,
  .sky-viewer-video-controls button {
    min-width: 44px;
    min-height: 44px;
  }

  .sky-viewer-controls,
  .sky-viewer-video-controls {
    opacity: 1;
  }
}

/* --- Fullscreen adjustments --- */
.sky-viewer:fullscreen,
.sky-viewer:-webkit-full-screen {
  border-radius: 0;
}
