/* ================================================================
   FONTS
   ================================================================ */
@font-face {
  font-family: 'Zapfino';
  src: url('Zapfino.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ================================================================
   RESET & BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:      #e8b4b8;
  --accent-dark: #c0717a;
  --bg:          #0a0a0a;
  --panel-bg:    rgba(10, 10, 10, 0.95);
  --text:        #f0e8e8;
  --muted:       #888;
  --radius:      12px;
  --trans-speed: 1000ms;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ================================================================
   STAGE
   ================================================================ */
#stage {
  position: fixed;
  inset: 0;
  background: #000;
  cursor: none; /* hidden; shown on move */
}
#stage.cursor-visible { cursor: default; }

/* ----------------------------------------------------------------
   Slide layers
   ---------------------------------------------------------------- */
.slide-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  opacity: 0;
  will-change: transform, opacity, filter;
}
.slide-layer.active   { opacity: 1; z-index: 2; }
.slide-layer.inactive { opacity: 0; z-index: 1; }

/* --- Fit: contain ---- */
body.fit-contain .slide-layer {
  background-size: contain;
}

/* ================================================================
   TRANSITIONS
   ================================================================ */

/* Cross-fade (default) */
body.trans-crossfade .slide-layer {
  transition: opacity var(--trans-speed) ease-in-out;
}

/* Blur dissolve */
body.trans-blur .slide-layer.inactive-to-active {
  animation: blurIn var(--trans-speed) ease-in-out forwards;
}
body.trans-blur .slide-layer.active-to-inactive {
  animation: blurOut var(--trans-speed) ease-in-out forwards;
}
@keyframes blurIn  { from { opacity:0; filter:blur(30px); } to { opacity:1; filter:blur(0); } }
@keyframes blurOut { from { opacity:1; filter:blur(0);    } to { opacity:0; filter:blur(30px); } }

/* Slide left */
body.trans-slide-left .slide-layer.inactive-to-active {
  animation: slideInLeft var(--trans-speed) ease-in-out forwards;
}
body.trans-slide-left .slide-layer.active-to-inactive {
  animation: slideOutLeft var(--trans-speed) ease-in-out forwards;
}
@keyframes slideInLeft  { from { transform:translateX(100%); opacity:1; } to { transform:translateX(0); opacity:1; } }
@keyframes slideOutLeft { from { transform:translateX(0);    opacity:1; } to { transform:translateX(-100%); opacity:0; } }

/* Slide up */
body.trans-slide-up .slide-layer.inactive-to-active {
  animation: slideInUp var(--trans-speed) ease-in-out forwards;
}
body.trans-slide-up .slide-layer.active-to-inactive {
  animation: slideOutUp var(--trans-speed) ease-in-out forwards;
}
@keyframes slideInUp  { from { transform:translateY(100%); opacity:1; } to { transform:translateY(0); opacity:1; } }
@keyframes slideOutUp { from { transform:translateY(0);    opacity:1; } to { transform:translateY(-100%); opacity:0; } }

/* Flip */
body.trans-flip .slide-layer.inactive-to-active {
  animation: flipIn var(--trans-speed) ease-in-out forwards;
  transform-origin: center;
}
body.trans-flip .slide-layer.active-to-inactive {
  animation: flipOut var(--trans-speed) ease-in-out forwards;
  transform-origin: center;
}
@keyframes flipIn  { from { transform:rotateY(90deg); opacity:0; } to { transform:rotateY(0deg); opacity:1; } }
@keyframes flipOut { from { transform:rotateY(0deg);  opacity:1; } to { transform:rotateY(-90deg); opacity:0; } }

/* Zoom-in */
body.trans-zoom-in .slide-layer.inactive-to-active {
  animation: zoomIn var(--trans-speed) ease-in-out forwards;
}
body.trans-zoom-in .slide-layer.active-to-inactive {
  animation: fadeOut var(--trans-speed) ease-in-out forwards;
}
@keyframes zoomIn   { from { transform:scale(1.3); opacity:0; } to { transform:scale(1); opacity:1; } }
@keyframes fadeOut  { from { opacity:1; } to { opacity:0; } }

/* Ken Burns — applied per-layer on activation; JS also moves the bg */
body.trans-kenburns .slide-layer.active {
  animation: kenburns calc(var(--trans-speed) + var(--display-duration, 7000ms)) linear forwards;
}
@keyframes kenburns {
  0%   { transform: scale(1.0) translate(0%,   0%);   }
  25%  { transform: scale(1.06) translate(1%,  0.5%); }
  50%  { transform: scale(1.1) translate(-1%,  1%);   }
  75%  { transform: scale(1.08) translate(0.5%,-1%);  }
  100% { transform: scale(1.04) translate(-0.5%, 0%); }
}
body.trans-kenburns .slide-layer {
  transition: opacity var(--trans-speed) ease-in-out;
}

/* None */
body.trans-none .slide-layer {
  transition: none;
}

/* ================================================================
   LOADING SCREEN
   ================================================================ */
#loading-screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  transition: opacity 0.6s ease;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }

.loading-heart {
  font-size: 5rem;
  color: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.2); opacity: 0.7; }
}
#loading-text { color: var(--muted); font-size: 1rem; letter-spacing: 0.05em; }

/* ================================================================
   HUD (counter + progress bar)
   ================================================================ */
#hud {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#stage.cursor-visible #hud { opacity: 1; }

#hud-counter {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.05em;
  text-shadow: 0 1px 4px #000;
  white-space: nowrap;
}

#progress-bar-wrap {
  width: 120px;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* ================================================================
   BOTTOM CONTROLS
   ================================================================ */
#controls {
  position: absolute;
  bottom: 1.8rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity 0.3s;
}
#stage.cursor-visible #controls { opacity: 1; }

#controls button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 1.1rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
#controls button:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  transform: scale(1.1);
}
#controls button:active { transform: scale(0.95); }

#btn-settings { color: var(--accent); }
#btn-settings:hover { color: #fff; background: var(--accent-dark) !important; }

/* ================================================================
   CAPTION  (filename · date — centred above controls)
   ================================================================ */
#caption {
  position: absolute;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  padding: 0.3rem 1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
#caption.visible { opacity: 1; }

/* ================================================================
   ALBUM LABEL  (bottom-right, Zapfino)
   ================================================================ */
#album-label {
  position: absolute;
  bottom: 2.5rem;
  right: 4rem;
  z-index: 20;
  font-family: 'Zapfino', cursive;
  font-size: 2rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.82);
  text-shadow:
    0 2px 12px rgba(0,0,0,0.7),
    0 1px 3px  rgba(0,0,0,0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  max-width: 45vw;
  text-align: right;
  word-break: break-word;
}
#album-label.visible { opacity: 1; }

/* ================================================================
   LIVE PHOTO VIDEO OVERLAY
   ================================================================ */
#live-photo-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;    /* matches the default 'cover' fit */
  z-index: 3;           /* above both slide layers */
  opacity: 0;
  transition: opacity 0.4s ease;
  background: #000;
}
#live-photo-video.playing {
  opacity: 1;
}
/* When fit=contain, match the image fit */
body.fit-contain #live-photo-video {
  object-fit: contain;
}

/* Live photo badge — small indicator bottom-left */
#live-photo-badge {
  position: absolute;
  bottom: 5.5rem;
  left: 1.2rem;
  z-index: 20;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  letter-spacing: 0.05em;
}
#live-photo-badge.visible { opacity: 1; }


#settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  transition: opacity 0.25s;
}
#settings-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Panel is flex-column so footer stays at bottom */
#settings-panel {
  background: var(--panel-bg);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden; /* children handle their own scroll */
}

/* Scrollable body */
#settings-body {
  padding: 1.8rem 2rem 1rem;
  overflow-y: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dark) transparent;
}

#settings-panel h2 {
  font-size: 1.4rem;
  margin-bottom: 1.6rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

#settings-close {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  transition: color 0.15s;
  z-index: 2;
}
#settings-close:hover { color: #fff; }

#settings-panel section {
  margin-bottom: 1.8rem;
  padding-bottom: 1.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
#settings-panel section:last-of-type { border-bottom: none; margin-bottom: 0; }

#settings-panel h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 0.8rem;
}
.hint code {
  background: rgba(255,255,255,0.08);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.82rem;
}

/* Album entries */
#album-list { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 0.8rem; }

.album-entry {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}

.album-entry-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.album-entry input[type="text"] {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.album-entry input[type="text"]:focus { border-color: var(--accent); }
.album-entry input[type="text"]::placeholder { color: var(--muted); }

.album-entry .album-label {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 65px;
}

/* Weight row — only visible when weightMode = album */
.album-weight-row {
  display: none;
  align-items: center;
  gap: 0.6rem;
}
body.weight-album .album-weight-row { display: flex; }

.album-weight-row label {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}
.album-weight-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}
.album-weight-value {
  font-size: 0.9rem;
  color: var(--accent);
  min-width: 3rem;
  text-align: right;
}

/* Weight total indicator */
#weight-total-wrap {
  display: none;
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 0.4rem;
}
body.weight-album #weight-total-wrap { display: block; }
#weight-total-wrap span { color: var(--accent); font-weight: 600; }
#weight-total-wrap.over span { color: #e07070; }

/* Inline hint in radio label */
.hint-inline {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 0.3rem;
  font-style: italic;
}

.btn-remove-album {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem;
  transition: color 0.15s;
  flex-shrink: 0;
}
.btn-remove-album:hover { color: #e07070; }

/* Inputs */
input[type="url"], input[type="text"] {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  color: var(--text);
  font-size: 0.96rem;
  outline: none;
  transition: border-color 0.15s;
}
input[type="url"]:focus, input[type="text"]:focus { border-color: var(--accent); }
input[type="url"]::placeholder { color: var(--muted); }

/* Radio groups */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.96rem;
  cursor: pointer;
  padding: 0.45rem 0.6rem;
  border-radius: 7px;
  transition: background 0.12s;
}
.radio-group label:hover { background: rgba(255,255,255,0.05); }
.radio-group input[type="radio"] { accent-color: var(--accent); width: 1rem; height: 1rem; }
.t-icon { font-size: 1.05rem; width: 1.6rem; text-align: center; }

/* Range */
.range-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}
.range-wrap span {
  font-size: 0.96rem;
  color: var(--accent);
  min-width: 3.8rem;
  text-align: right;
  font-weight: 500;
}

/* Checkbox / toggle */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.96rem;
  cursor: pointer;
}
.toggle-label input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

/* Buttons */
button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.96rem;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
button:active { transform: scale(0.97); }

/* Sticky footer that's always visible */
#settings-footer {
  flex: 0 0 auto;
  padding: 1rem 2rem 1.2rem;
  background: var(--panel-bg);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.settings-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#btn-apply {
  background: var(--accent-dark);
  color: #fff;
  border: none;
  padding: 0.7rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 1;
}
#btn-apply:hover { background: var(--accent); color: #111; }

button.secondary {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  color: var(--text);
  padding: 0.6rem 1.1rem;
}
button.secondary:hover { background: rgba(255,255,255,0.13); }

#btn-add-album {
  font-size: 0.88rem;
  padding: 0.4rem 0.9rem;
}

#url-output {
  font-size: 0.78rem;
  color: var(--accent);
  word-break: break-all;
  background: rgba(255,255,255,0.04);
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
}
#url-output.hidden { display: none; }

/* ================================================================
   UTILITY
   ================================================================ */
.hidden { display: none !important; }

/* ================================================================
   KEYBOARD SHORTCUT TOAST
   ================================================================ */
#toast {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#toast.visible { opacity: 1; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 500px) {
  #controls { gap: 0.2rem; padding: 0.4rem 0.6rem; }
  #controls button { font-size: 0.9rem; width: 2rem; height: 2rem; }
  #settings-panel { padding: 1.2rem; }
}
