* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;

  font-family:
    "Segoe UI",
    system-ui,
    sans-serif;

  background: #0c0c0c;
  color: #f3f3f3;
}

button,
input {
  font: inherit;
}


/* ============================================================
   PAGE
   ============================================================ */

.demo-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.demo-header {
  margin-bottom: 28px;
}

.brand {
  margin-bottom: 12px;

  font-size: 13px;
  font-weight: 700;

  letter-spacing: 0.25em;

  color: #9b9b9b;
}

h1 {
  margin: 0;

  font-size: clamp(
    32px,
    5vw,
    58px
  );

  font-weight: 500;
}

.demo-header p {
  margin-top: 12px;

  color: #aaa;
}


/* ============================================================
   MODE CONTROLS
   ============================================================ */

.mode-controls {
  display: flex;
  gap: 10px;

  margin-bottom: 24px;
}

.mode-button,
.playback-controls button {
  padding: 10px 15px;

  border: 1px solid #3a3a3a;
  border-radius: 7px;

  background: #171717;
  color: #ddd;

  cursor: pointer;
}

.mode-button.active {
  background: #eee;
  color: #111;
}


/* ============================================================
   COMPARE MODE
   ============================================================ */

.comparison {
  position: relative;

  width: min(
    100%,
    1280px
  );

  aspect-ratio: 16 / 9;

  margin: 0 auto;

  overflow: hidden;

  background: #000;

  border-radius: 10px;
}

.comparison-video {
  position: absolute;

  inset: 0;

  width: 100%;
  height: 100%;

  object-fit: contain;

  background: #000;
}

.aperion-layer {
  position: absolute;

  inset: 0;

  overflow: hidden;

  /*
   * Aperion begins on the RIGHT half.
   */
  clip-path: inset(
    0
    0
    0
    50%
  );
}

.aperion-layer .comparison-video {
  position: absolute;

  inset: 0;

  width: 100%;
  height: 100%;

  object-fit: contain;

  background: #000;
}


/* ============================================================
   DIVIDER
   ============================================================ */

.divider {
  position: absolute;

  top: 0;
  bottom: 0;
  left: 50%;

  width: 0;

  z-index: 10;

  pointer-events: none;
}

.divider-line {
  position: absolute;

  top: 0;
  bottom: 0;
  left: -1px;

  width: 2px;

  background: #fff;
}

.divider-handle {
  position: absolute;

  top: 50%;
  left: 0;

  width: 42px;
  height: 42px;

  transform:
    translate(
      -50%,
      -50%
    );

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: #fff;
  color: #111;

  font-weight: 700;

  box-shadow:
    0 4px 18px
    rgba(
      0,
      0,
      0,
      0.45
    );
}


/* ============================================================
   LABELS
   ============================================================ */

.label {
  position: absolute;

  top: 16px;

  z-index: 12;

  padding: 7px 10px;

  border-radius: 5px;

  background:
    rgba(
      0,
      0,
      0,
      0.62
    );

  font-size: 12px;

  letter-spacing: 0.08em;

  text-transform: uppercase;
}

.label-original {
  left: 16px;
}

.label-aperion {
  right: 16px;
}


/* ============================================================
   PLAYBACK CONTROLS
   ============================================================ */

.playback-controls {
  width: min(
    100%,
    1280px
  );

  margin: 16px auto 0;

  display: grid;

  grid-template-columns:
    auto
    1fr
    auto;

  gap: 14px;

  align-items: center;
}

#timeline {
  width: 100%;
}

#time-display {
  min-width: 100px;

  text-align: right;

  font-size: 13px;

  color: #aaa;
}


/* ============================================================
   INSPECT MODE
   ============================================================ */

.inspect-mode {
  display: grid;

  gap: 34px;
}

.inspect-panel {
  padding-top: 10px;
}

.inspect-heading {
  display: flex;

  align-items: baseline;
  justify-content: space-between;

  gap: 20px;

  margin-bottom: 12px;
}

.inspect-heading h2 {
  margin: 0;

  font-size: 20px;
}

.inspect-heading span {
  font-family:
    Consolas,
    monospace;

  font-size: 13px;

  color: #999;
}


/*
 * This is intentionally scrollable.
 *
 * The video itself is displayed at its true
 * videoWidth in CSS pixels unless the viewport
 * is too small.
 */

.native-scroll {
  width: 100%;

  overflow: auto;

  padding: 14px;

  border: 1px solid #292929;

  border-radius: 8px;

  background: #060606;
}

.native-video {
  display: block;

  width: auto;
  height: auto;

  max-width: none;
  max-height: none;
}


/* ============================================================
   UTILITIES
   ============================================================ */

.hidden {
  display: none;
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (
  max-width: 700px
) {

  .demo-shell {
    padding:
      24px
      14px
      60px;
  }

  .mode-controls {
    flex-direction: column;
  }

  .playback-controls {
    grid-template-columns:
      auto
      1fr;

    grid-template-areas:
      "play time"
      "timeline timeline";
  }

  #play-button {
    grid-area: play;
  }

  #timeline {
    grid-area: timeline;
  }

  #time-display {
    grid-area: time;
  }
}

.original-pip {
  position: absolute;

  left: 24px;
  bottom: 24px;

  z-index: 20;

  overflow: hidden;

  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 7px;

  background: #000;

  box-shadow:
    0 10px 30px
    rgba(0, 0, 0, 0.45);

  pointer-events: none;
}

.original-pip video {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: contain;

  background: #000;
}

.pip-label {
  position: absolute;

  left: 8px;
  bottom: 8px;

  padding: 5px 7px;

  border-radius: 4px;

  background:
    rgba(
      0,
      0,
      0,
      0.68
    );

  font-size: 11px;
  font-weight: 600;

  letter-spacing: 0.06em;

  text-transform: uppercase;
}

.pip-label span {
  margin-left: 5px;

  color: #aaa;
}

.inspect-toolbar {
  display: flex;
  align-items: center;
  gap: 9px;

  width: fit-content;

  margin-bottom: 18px;

  padding: 8px 10px;

  border: 1px solid #292929;
  border-radius: 7px;

  background: #121212;
}

.inspect-zoom-label {
  margin-right: 4px;

  font-size: 12px;
  color: #aaa;

  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.inspect-toolbar button {
  border: 1px solid #3a3a3a;
  border-radius: 5px;

  padding: 5px 9px;

  background: #1b1b1b;
  color: #eee;

  cursor: pointer;
}

.inspect-note {
  width: fit-content;
  margin-bottom: 18px;
  padding: 8px 10px;

  border: 1px solid #292929;
  border-radius: 7px;

  background: #121212;

  font-size: 12px;
  line-height: 1.5;

  color: #aaa;
}

.inspect-note span {
  display: block;
  margin-top: 2px;

  color: #777;
}

/* =========================================================
   MOBILE LOUPE
   ========================================================= */

.mobile-loupe {
  display: none;
}


/* ---------------------------------------------------------
   Mobile Inspect mode
   --------------------------------------------------------- */

@media (max-width: 700px) {

  /*
   * Desktop native-canvas presentation disappears only
   * on mobile.
   */
  #inspect-stage,
  .inspect-note {
    display: none;
  }


  .mobile-loupe {
    display: block;

    width: 100%;
    max-width: 100%;

    margin: 0 auto;
  }


  .mobile-loupe-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 16px;

    margin-bottom: 12px;
  }


  .mobile-loupe-eyebrow {
    display: block;

    margin-bottom: 3px;

    font-size: 10px;
    font-weight: 600;

    letter-spacing: 0.14em;
    text-transform: uppercase;

    color: #777;
  }


  .mobile-loupe-header h3 {
    margin: 0;

    font-size: 18px;
    font-weight: 500;

    color: #eee;
  }


  .mobile-loupe-resolution {
    flex: 0 0 auto;

    padding-bottom: 2px;

    font-size: 12px;
    font-variant-numeric: tabular-nums;

    color: #999;
  }


  /*
   * The phone becomes the loupe.
   *
   * Videos underneath this viewport are NOT fitted
   * to its dimensions.
   */
  .mobile-loupe-viewport {
    position: relative;

    width: 100%;
    aspect-ratio: 16 / 9;

    overflow: hidden;

    border: 1px solid #292929;
    border-radius: 10px;

    background: #000;

    touch-action: none;

    cursor: grab;
  }


  .mobile-loupe-viewport.is-dragging {
    cursor: grabbing;
  }


  /*
   * CRITICAL:
   * Do not use width:100%, object-fit:contain,
   * max-width:100%, transforms that scale, etc.
   *
   * JS will assign the decoded native dimensions.
   */
  .mobile-loupe-video {
    position: absolute;

    left: 0;
    top: 0;

    display: none;

    width: auto;
    height: auto;

    max-width: none;
    max-height: none;

    object-fit: none;

    user-select: none;
    pointer-events: none;
  }


  .mobile-loupe-video.is-active {
    display: block;
  }


  /*
   * Fixed reference point.
   * It marks the same normalized image location
   * between Original and Aperion.
   */
  .mobile-loupe-reticle {
    position: absolute;

    left: 50%;
    top: 50%;

    width: 14px;
    height: 14px;

    transform: translate(-50%, -50%);

    pointer-events: none;

    opacity: 0.45;
  }


  .mobile-loupe-reticle::before,
  .mobile-loupe-reticle::after {
    content: "";

    position: absolute;

    background: rgba(255, 255, 255, 0.75);
  }


  .mobile-loupe-reticle::before {
    left: 50%;
    top: 0;

    width: 1px;
    height: 100%;

    transform: translateX(-50%);
  }


  .mobile-loupe-reticle::after {
    left: 0;
    top: 50%;

    width: 100%;
    height: 1px;

    transform: translateY(-50%);
  }


  .mobile-loupe-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;

    gap: 6px;

    margin-top: 12px;

    padding: 4px;

    border: 1px solid #292929;
    border-radius: 9px;

    background: #111;
  }


  .mobile-loupe-toggle-button {
    appearance: none;

    min-height: 40px;

    border: 0;
    border-radius: 6px;

    background: transparent;

    font: inherit;
    font-size: 12px;
    font-weight: 600;

    letter-spacing: 0.08em;
    text-transform: uppercase;

    color: #777;

    cursor: pointer;
  }


  .mobile-loupe-toggle-button.is-active {
    background: #242424;
    color: #f2f2f2;
  }


  .mobile-loupe-help {
    margin: 10px 2px 0;

    font-size: 11px;
    line-height: 1.5;

    color: #777;
  }

}

/* =========================================================
   PRO RESOLUTION PROOF
   ========================================================= */

.pro-resolution-proof {
  margin-bottom: 42px;
}

.pro-resolution-copy {
  max-width: 720px;
}

.pro-resolution-eyebrow {
  display: block;

  margin-bottom: 6px;

  font-size: 10px;
  font-weight: 600;

  letter-spacing: 0.16em;
  text-transform: uppercase;

  color: #777;
}

.pro-resolution-copy h2 {
  margin: 0 0 12px;

  font-size: 28px;
  font-weight: 500;

  color: #f2f2f2;
}

.pro-resolution-copy p {
  margin: 0;

  max-width: 650px;

  font-size: 14px;
  line-height: 1.7;

  color: #999;
}


/* ---------------------------------------------------------
   Stats
   --------------------------------------------------------- */

.pro-resolution-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));

  gap: 10px;

  margin-top: 24px;
  margin-bottom: 28px;
}

.pro-resolution-stat {
  padding: 18px;

  border: 1px solid #292929;
  border-radius: 9px;

  background: #111;
}

.pro-resolution-stat strong {
  display: block;

  margin-bottom: 4px;

  font-size: 24px;
  font-weight: 500;

  color: #f2f2f2;
}

.pro-resolution-stat span {
  font-size: 11px;

  letter-spacing: 0.08em;
  text-transform: uppercase;

  color: #777;
}


/* ---------------------------------------------------------
   Ratio-accurate canvas visualization
   --------------------------------------------------------- */

.pro-canvas-visual {
  width: 100%;

  overflow-x: auto;

  padding: 20px 0 6px;
}


/*
 * 3840 × 2160 = 16:9
 *
 * The source is exactly 1/3 the width
 * and 1/3 the height.
 */
.pro-canvas-output {
  position: relative;

  width: min(900px, 100%);
  aspect-ratio: 16 / 9;

  margin: 0;

  border: 1px solid #444;
  border-radius: 10px;

  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.018),
      rgba(255, 255, 255, 0.005)
    );

  overflow: hidden;
}


/*
 * Exact 3:1 linear relationship.
 */
.pro-canvas-source {
  position: absolute;

  left: 50%;
  top: 50%;

  width: 33.333333%;
  height: 33.333333%;

  transform: translate(
    -50%,
    -50%
  );

  border: 1px solid #888;
  border-radius: 5px;

  background: #161616;
}


.pro-canvas-label {
  position: absolute;

  display: flex;
  flex-direction: column;

  gap: 2px;

  font-size: 10px;

  letter-spacing: 0.08em;
  text-transform: uppercase;

  color: #777;
}


.pro-canvas-label strong {
  font-size: 12px;
  font-weight: 500;

  letter-spacing: 0;

  text-transform: none;

  color: #ddd;
}


.pro-canvas-label-output {
  left: 14px;
  top: 12px;
}


.pro-canvas-label-source {
  left: 10px;
  top: 8px;
}


/* ---------------------------------------------------------
   Mobile
   --------------------------------------------------------- */

@media (max-width: 700px) {

  .pro-resolution-stats {
    grid-template-columns: 1fr;
  }

  .pro-resolution-copy h2 {
    font-size: 23px;
  }

  .pro-canvas-output {
    width: 100%;
  }

}