/* beamer2web base layout and controls (theme independent). */
:root {
  --b2w-accent: #2f7bd6;
  --b2w-glass-bg: rgba(255, 255, 255, 0.42);
  --b2w-glass-border: rgba(255, 255, 255, 0.6);
  --b2w-glass-blur: 24px;
  --b2w-hud-fg: #1c1f24;
  --b2w-panel-bg: rgba(250, 252, 255, 0.62);
  --b2w-panel-fg: #1c1f24;
  --b2w-hover: rgba(127, 127, 127, 0.16);
  --b2w-body-bg: linear-gradient(135deg, #eef2f8 0%, #d8e0ec 55%, #c9d6e6 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background: #c7d2e0;
}

body.theme-light {
  background: var(--b2w-body-bg);
  color: var(--b2w-panel-fg);
}
body.theme-dark {
  --b2w-glass-bg: rgba(24, 28, 36, 0.5);
  --b2w-glass-border: rgba(255, 255, 255, 0.14);
  --b2w-hud-fg: #eef0f4;
  --b2w-panel-bg: rgba(22, 26, 34, 0.58);
  --b2w-panel-fg: #eef0f4;
  --b2w-hover: rgba(255, 255, 255, 0.1);
  --b2w-body-bg: radial-gradient(1200px 800px at 20% 10%, #1c2436 0%,
    #0f1420 55%, #0a0d15 100%);
  background: var(--b2w-body-bg);
  color: var(--b2w-panel-fg);
}

/* -------- slide stage -------- */
#viewer {
  position: fixed;
  left: 50%;
  top: 50%;
  transform-origin: 50% 50%;
  will-change: transform;
  box-shadow: none;
}
body.theme-dark #viewer { box-shadow: none; }

.slide { position: absolute; inset: 0; display: none; }
.slide.active { display: block; }

.slide-media { position: absolute; inset: 0; overflow: hidden; }
.slide-media img,
.slide-media object {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* -------- overlays -------- */
.overlay-zone { position: absolute; inset: 0; pointer-events: none; }
.overlay-zone > * { pointer-events: auto; }

.overlay-text {
  color: inherit;
  line-height: 1.25;
}
.overlay-text, .overlay-button, .overlay-zone video,
.overlay-zone audio, .overlay-zone iframe, .overlay-zone img {
  max-width: 100%;
}

.overlay-button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 10px 22px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)),
    var(--b2w-accent);
  box-shadow: 0 4px 14px rgba(30, 60, 120, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: filter 0.15s ease, transform 0.15s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.overlay-button:hover { filter: brightness(1.12); }
.overlay-button:active { transform: translateY(1px); }

/* -------- loader -------- */
#loader {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(60, 70, 90, 0.7);
  font-size: 15px;
  letter-spacing: 0.05em;
}
body.theme-dark #loader { color: rgba(220, 228, 240, 0.6); }

/* -------- HUD: floating glass pill -------- */
#hud {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  background: var(--b2w-glass-bg);
  -webkit-backdrop-filter: blur(var(--b2w-glass-blur)) saturate(180%);
  backdrop-filter: blur(var(--b2w-glass-blur)) saturate(180%);
  border: 1px solid var(--b2w-glass-border);
  border-radius: 999px;
  box-shadow: 0 12px 44px rgba(15, 25, 45, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: var(--b2w-hud-fg);
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
body.hud-hidden #hud {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
}
body.menu-open #hud,
body.refs-open #hud { opacity: 1; pointer-events: auto; }

#hud button {
  border: none;
  background: transparent;
  color: inherit;
  width: 38px;
  height: 38px;
  font-size: 19px;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
#hud button:hover { background: var(--b2w-hover); }

#hud .spacer { flex: 1; }

#slide-counter {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  opacity: 0.85;
  min-width: 76px;
  text-align: center;
  padding: 0 8px;
}

/* -------- progress bar -------- */
#progress {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  z-index: 1001;
}
#progress-fill {
  height: 100%;
  width: 0;
  background: #3a4048;
  transition: width 0.2s ease;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
}

/* -------- panels: slides index (left) & references (right) -------- */
.panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(400px, 92vw);
  background: var(--b2w-panel-bg);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  color: var(--b2w-panel-fg);
  z-index: 1002;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  transition: transform 0.25s ease;
}
#menu {
  left: 0;
  border-right: 1px solid var(--b2w-glass-border);
  box-shadow: 6px 0 32px rgba(15, 25, 45, 0.3);
  transform: translateX(-100%);
}
#refs {
  right: 0;
  border-left: 1px solid var(--b2w-glass-border);
  box-shadow: -6px 0 32px rgba(15, 25, 45, 0.3);
  transform: translateX(100%);
}
body.menu-open #menu,
body.refs-open #refs { transform: translateX(0); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 6px;
}
.panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.6;
  font-weight: 600;
}
.panel-close {
  border: none;
  background: transparent;
  color: inherit;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  padding: 0;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.panel-close:hover { background: var(--b2w-hover); opacity: 1; }

#menu-list,
#refs-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 4px;
}

.menu-item,
.ref-item {
  display: flex;
  gap: 12px;
  text-align: left;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 11px;
  padding: 10px 12px;
  line-height: 1.4;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.menu-item { align-items: center; font-size: 14px; }
.ref-item { align-items: flex-start; font-size: 13px; }
.menu-item:hover,
.ref-item:hover { background: var(--b2w-hover); }
.menu-item.active {
  background: var(--b2w-hover);
  box-shadow: inset 0 0 0 1px var(--b2w-glass-border);
  font-weight: 600;
}
.ref-item.highlight {
  background: var(--b2w-hover);
  box-shadow: inset 0 0 0 1px var(--b2w-accent);
}
.menu-num,
.ref-num {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.5;
  width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.menu-item.active .menu-num { opacity: 0.85; }
.menu-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ref-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.ref-url {
  color: var(--b2w-accent);
  font-size: 11px;
  word-break: break-all;
  text-decoration: none;
}
.ref-url:hover { text-decoration: underline; }
.refs-empty { opacity: 0.6; font-size: 14px; padding: 0 6px; }

/* -------- citation / reference link overlays -------- */
.overlay-link {
  display: block;
  cursor: pointer;
  border-radius: 3px;
}
.overlay-link.cite-link:hover,
.overlay-link.ref-link:hover { background: rgba(47, 123, 214, 0.2); }

/* -------- compact custom video controls -------- */
.video-wrap { overflow: hidden; }
.video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}
.video-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 5px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.7));
  color: #fff;
  font-family: inherit;
  z-index: 2;
  box-sizing: border-box;
}
.video-controls button {
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.9;
}
.video-controls button:hover { opacity: 1; }
.vc-seek {
  flex: 1 1 auto;
  height: 2.5px;
  min-width: 14px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}
.vc-seek .vc-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: #fff;
  border-radius: 2px;
}
.vc-time {
  font-size: 8px;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

/* Video fullscreen: the wrapper (or the video, on iOS) fills the viewport.
   Inline sizing from the aspect-fit is reset so the video is always large.
   Both the standard pseudo-classes AND a JS-set class (.b2w-fullscreen) are
   used, because Safari does not match the fullscreen pseudo-class on
   descendant selectors. */
.video-wrap:fullscreen,
.video-wrap:-webkit-full-screen,
.video-wrap.b2w-fullscreen {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  z-index: 2147483000 !important;
  background: #000;
  display: block !important;
}
.video-wrap:fullscreen video,
.video-wrap:-webkit-full-screen video,
.video-wrap.b2w-fullscreen video {
  position: static !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  margin: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}
.video-wrap video:fullscreen,
.video-wrap video:-webkit-full-screen { object-fit: contain; }
.video-wrap:fullscreen .video-controls,
.video-wrap:-webkit-full-screen .video-controls,
.video-wrap.b2w-fullscreen .video-controls {
  height: 44px;
  padding: 0 16px;
  gap: 8px;
}
.video-wrap:fullscreen .video-controls button,
.video-wrap:-webkit-full-screen .video-controls button,
.video-wrap.b2w-fullscreen .video-controls button {
  width: 44px;
  height: 44px;
}
.video-wrap:fullscreen .video-controls svg,
.video-wrap:-webkit-full-screen .video-controls svg,
.video-wrap.b2w-fullscreen .video-controls svg { width: 20px; height: 20px; }
.video-wrap:fullscreen .vc-time,
.video-wrap:-webkit-full-screen .vc-time,
.video-wrap.b2w-fullscreen .vc-time { font-size: 13px; }
.video-wrap:fullscreen .vc-seek,
.video-wrap:-webkit-full-screen .vc-seek,
.video-wrap.b2w-fullscreen .vc-seek { height: 5px; }

/* Comfortable touch targets on phones / tablets. */
@media (pointer: coarse) {
  .video-controls { height: 26px; gap: 5px; padding: 0 7px; }
  .video-controls button { width: 28px; height: 28px; }
  .video-controls svg { width: 13px; height: 13px; }
  .vc-seek { height: 4px; }
  .vc-time { font-size: 10px; }
}

/* -------- misc -------- */
noscript .no-js {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 16px;
}

@media (max-width: 600px) {
  #hud { gap: 0; padding: 6px 8px; }
  #hud button { width: 34px; height: 34px; font-size: 17px; }
  #slide-counter { font-size: 12px; min-width: 58px; padding: 0 4px; }
}

/* Comfortable touch targets on phones / tablets. */
@media (pointer: coarse) {
  #hud { bottom: 12px; gap: 2px; }
  #hud button { width: 44px; height: 44px; font-size: 21px; }
  #slide-counter { font-size: 13px; min-width: 72px; }
  #menu, #refs { width: min(400px, 94vw); }
}

/* -------- fullscreen -------- */
#viewer:-webkit-full-screen,
#viewer:fullscreen {
  border-radius: 0;
  box-shadow: none;
}
