/* iFrame styles. Classes are prefixed (iframe-, csvt-) so the viewer
   can sit inside any page. Colors come from CSS variables on .iframe-root. */

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


.iframe-root {
  --iframe-ink: #eee;
  --iframe-panel: rgba(0, 0, 0, 0.6);
  --iframe-head-bg: #dbe8ff;     /* light table header on every background */
  --iframe-head-ink: #14213d;
  --bar-wrapper-h: 180px;         /* updated by JS from the player bar height */
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--iframe-ink);
}

/* ---------- Frame ---------- */
.frame-content {
  position: absolute;
  inset: 10px;
  border: 10px solid #222;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  transition: background 0.3s;
}
.frame-stage { position: absolute; inset: 0; }

/* Each item sits in a slot so transitions can overlap two items */
.frame-slot {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
}
.frame-content:not(.is-hidden) .frame-slot:not(.iframe-img) {
  bottom: var(--bar-wrapper-h);
}

/* Base sizing for everything inside a slot */
.frame-slot > * {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.iframe-media-img { object-fit: cover; }
.iframe-video { object-fit: contain; background: #000; cursor: pointer; }
.frame-slot iframe { background: #fff; }

/* ---------- Text views ---------- */
.iframe-view {
  overflow: auto;
  padding: 72px 16px 16px;     /* room for the navbar */
  background: var(--iframe-panel);
  color: var(--iframe-ink);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.iframe-raw { white-space: pre-wrap; font-family: monospace; }
.iframe-csv { overflow: hidden; display: flex; flex-direction: column; }

.iframe-md img { max-width: 100%; }
.iframe-md pre { background: rgba(128,128,128,0.2); padding: 10px; overflow-x: auto; }
.iframe-md code { background: rgba(128,128,128,0.2); padding: 1px 4px; border-radius: 3px; }
.iframe-md pre code { background: none; padding: 0; }
.iframe-md table, .iframe-md th, .iframe-md td {
  border: 1px solid rgba(128,128,128,0.5);
  border-collapse: collapse;
  padding: 4px 8px;
}

/* ---------- Audio card ---------- */
.iframe-audio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 72px 20px 20px;
  background: var(--iframe-panel);
  color: var(--iframe-ink);
  text-align: center;
}
.iframe-audio-icon { font-size: 9rem; line-height: 1; }
.iframe-audio-status { font-size: 1.3rem; opacity: 0.9; }
.iframe-audio-label { font-size: 1.8rem; font-weight: 600; }
.iframe-audio-hide {
  margin-top: 8px;
  padding: 8px 14px;
  font-size: 0.95rem;
  color: var(--iframe-ink);
  background: rgba(128,128,128,0.25);
  border: 1px solid rgba(128,128,128,0.6);
  border-radius: 4px;
  cursor: pointer;
}

/* ---------- Navbar (click-through except its controls) ---------- */
.navbar-view {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0));
  color: #fff;
  pointer-events: none;
}
.navbar-view > * { pointer-events: auto; }
.iframe-brand { font-weight: 600; font-size: 1.1rem; }
.navbar-view-right { display: flex; gap: 8px; align-items: center; }

.iframe-btn {
  padding: 8px 14px;
  font-size: 0.95rem;
  color: #fff;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.iframe-btn:hover { background: rgba(255,255,255,0.3); }

.iframe-dropdown { position: relative; }
.iframe-dd-list {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  color: #000;
  min-width: 260px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  overflow-y: auto;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.iframe-dropdown.open .iframe-dd-list { display: block; }
.iframe-dd-item {
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.iframe-dd-item:hover { background: #f0f0f0; }
.iframe-dd-item img { width: 60px; height: 40px; object-fit: cover; flex-shrink: 0; }
.iframe-dd-icon { width: 60px; text-align: center; font-size: 1.4rem; flex-shrink: 0; }

/* ---------- Bottom bar ---------- */
.bar-wrapper {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.75);
  color: #fff;
}
.frame-content.is-hidden .bar-wrapper { display: none; }

.bar-thumbnails {
  display: flex;
  gap: 8px;
  padding: 10px 12px 4px;
  overflow-x: auto;
}
.iframe-thumb {
  width: 96px;
  height: 64px;
  flex-shrink: 0;
  border: 2px solid transparent;
  border-radius: 3px;
  overflow: hidden;
  opacity: 0.8;
  cursor: pointer;
  background: #222;
}
.iframe-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.iframe-thumb.iframe-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.72rem;
  padding: 4px;
  word-break: break-word;
}
.iframe-thumb:hover, .iframe-thumb.is-active { border-color: #fff; opacity: 1; }

.bar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 12px 6px;
}
.bar-controls button {
  min-width: 44px;
  height: 44px;
  font-size: 1.1rem;
  color: #fff;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  cursor: pointer;
}
.bar-controls button:hover { background: rgba(255,255,255,0.3); }
.bar-controls .is-active { background: rgba(255,255,255,0.4); }
.bar-controls select {
  height: 44px;
  max-width: 200px;
  padding: 0 8px;
  font-size: 0.95rem;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.bar-controls select option { color: #000; }

/* Timing row under the player buttons; JS shows it for video and audio */
.bar-progress {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 16px 10px;
}
.bar-progress input[type="range"] { flex: 1; cursor: pointer; }
.bar-progress span { font-family: monospace; font-size: 0.95rem; white-space: nowrap; }

/* ---------- Toast ---------- */
.iframe-toast {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translate(-50%, -10px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  border-radius: 6px;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
}
.iframe-toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------- CSV table (csv-table.js) ---------- */
.csvt-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.csvt-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.csvt-tools input,
.csvt-tools select,
.csvt-tools button {
  padding: 6px 8px;
  font-size: 0.95rem;
  border-radius: 4px;
  border: 1px solid #888;
  background: #fff;
  color: #111;
}
.csvt-search { flex: 1; min-width: 160px; }
.csvt-check {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 0.9rem;
  color: var(--iframe-ink);
}
.csvt-check input { padding: 0; border: 0; }
.csvt-count { font-size: 0.9rem; opacity: 0.85; }

.csvt-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 4px;
}
.csvt-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
  color: var(--iframe-ink);
}
.csvt-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--iframe-head-bg);
  color: var(--iframe-head-ink);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(0,0,0,0.15);
}
.csvt-table td {
  padding: 8px 12px;
  border: 1px solid rgba(128,128,128,0.4);
  white-space: nowrap;
}
.csvt-table tbody tr:nth-child(even) { background: rgba(128,128,128,0.15); }
.csvt-table tbody tr:hover { background: rgba(255,255,255,0.12); }

/* Captions: title, description, and the metadata the settings allow. */
.frame-slot > .iframe-caption {
  position: absolute; inset: auto; width: auto; height: auto;
  max-width: min(60vw, 560px); padding: 8px 12px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.55); color: #fff; pointer-events: none;
  font: 15px/1.3 system-ui, sans-serif; z-index: 2;
}
.iframe-caption.is-bottom-left  { left: 16px;  bottom: var(--bar-wrapper-h, 180px); }
.iframe-caption.is-bottom-right { right: 16px; bottom: var(--bar-wrapper-h, 180px); }
.iframe-caption.is-top-left     { left: 16px;  top: 64px; }
.iframe-caption.is-top-right    { right: 16px; top: 64px; }
.frame-content.is-hidden .iframe-caption.is-bottom-left,
.frame-content.is-hidden .iframe-caption.is-bottom-right { bottom: 16px; }
.iframe-caption-title { font-weight: 600; font-size: 1.2rem; }
.iframe-caption-description { font-size: 0.95rem; }
.iframe-caption-meta { font-size: 0.85rem; opacity: 0.8; }
/* Section dividers. Used by js/dividers.js and the iFrame slideshow. */

.iframe-div {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
  color: #fff;
  text-align: center;
}

/* Text shared by all styles. Fades in after the opening motion starts. */
.iframe-div-text {
  position: relative;
  z-index: 3;
  padding: 20px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.8s ease 0.9s, transform 0.8s ease 0.9s;
}
.iframe-div.is-in .iframe-div-text { opacity: 1; transform: none; }
.iframe-div-kicker {
  font-size: 1rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  opacity: 0.7;
}
.iframe-div-title {
  font-size: clamp(2.4rem, 8vw, 6rem);
  font-weight: 700;
  margin: 0.2em 0;
  line-height: 1.05;
}
.iframe-div-sub { font-size: 1.2rem; opacity: 0.85; }
.iframe-div-count { font-size: 0.95rem; opacity: 0.6; margin-top: 0.5em; }

/* Dividers use the full height, even when the player bar is showing */
.frame-content:not(.is-hidden) .frame-slot.frame-divider-slot { bottom: 0; }

/* 1. Curtain */
.iframe-div-curtain { background: radial-gradient(#3a1010, #000); }
.iframe-curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 2;
  background: repeating-linear-gradient(90deg, #7a0e1c 0 28px, #5c0a15 28px 56px);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6);
  transition: transform 1.4s cubic-bezier(0.6, 0, 0.3, 1);
}
.iframe-curtain-l { left: 0; }
.iframe-curtain-r { right: 0; }
.iframe-div-curtain.is-in .iframe-curtain-l { transform: translateX(-100%); }
.iframe-div-curtain.is-in .iframe-curtain-r { transform: translateX(100%); }
.iframe-div-curtain .iframe-div-text { transition-delay: 1.1s, 1.1s; }

/* 2. Clapperboard */
.iframe-div-clapper { flex-direction: column; gap: 24px; background: #111; }
.iframe-clap-stick {
  width: min(440px, 80vw);
  height: 46px;
  border-radius: 4px;
  background: repeating-linear-gradient(90deg, #fff 0 34px, #111 34px 68px);
  transform-origin: 0 100%;
  transform: rotate(-18deg);
  transition: transform 0.3s cubic-bezier(0.5, 0, 1, 0.5) 0.7s;
  margin-bottom: -6px;
}
.iframe-div-clapper.is-in .iframe-clap-stick { transform: rotate(0); }
.iframe-clap-board {
  width: min(440px, 80vw);
  padding: 12px 16px;
  background: #f2f2f2;
  color: #111;
  font-family: monospace;
  text-align: left;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
.iframe-clap-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 6px 0;
  border-bottom: 1px solid #999;
  font-size: 1.1rem;
}
.iframe-clap-row span { opacity: 0.7; }
.iframe-clap-row b { font-weight: 700; }

/* 3. Spotlight */
.iframe-div-spotlight { background: #000; }
.iframe-spot-beam {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  left: calc(50% - 35vmax);
  top: calc(50% - 35vmax);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,236,190,0.5) 0%, rgba(255,236,190,0.15) 35%, rgba(0,0,0,0) 60%);
  transform: translateX(-45vw);
  transition: transform 1.8s cubic-bezier(0.3, 0, 0.2, 1);
}
.iframe-div-spotlight.is-in .iframe-spot-beam { transform: translateX(0); }

/* 4. Page flip */
.iframe-div-pageflip {
  perspective: 1200px;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
}
.iframe-flip-card {
  padding: 36px 56px;
  border-radius: 8px;
  background: #fff;
  color: #14213d;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  transform-origin: left center;
  transform: rotateY(-90deg);
  transition: transform 1s ease 0.2s;
}
.iframe-div-pageflip.is-in .iframe-flip-card { transform: rotateY(0); }

/* 5. Cinematic title card */
.iframe-div-cinema { background: radial-gradient(#2a2a2a, #000); }
.iframe-lb {
  position: absolute;
  left: 0;
  right: 0;
  height: 13%;
  z-index: 2;
  background: #000;
  transition: transform 1s ease;
}
.iframe-lb-top { top: 0; transform: translateY(-100%); }
.iframe-lb-bot { bottom: 0; transform: translateY(100%); }
.iframe-div-cinema.is-in .iframe-lb-top,
.iframe-div-cinema.is-in .iframe-lb-bot { transform: none; }
.iframe-div-cinema .iframe-div-title {
  letter-spacing: 0.02em;
  transition: letter-spacing 2.4s ease 0.6s;
}
.iframe-div-cinema.is-in .iframe-div-title { letter-spacing: 0.18em; }
