/* /before-and-after: full-screen trade show viewer, built for an iPad.
   Standalone on purpose: it loads none of styles.css, so the page stays a
   few kilobytes and nothing in the main site can move it. Palette tokens are
   the site's own (docs/10): charcoal, navy, gold, white. No red. */

@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(../fonts/public-sans-var-latin.woff2) format('woff2');
}

:root {
  --gold: #C6953F;
  --charcoal: #1D1D1E;
  --charcoal-2: #2A2A2C;
  --navy: #1E2B49;
  --white: #FFFFFF;
  --mute: rgba(255, 255, 255, 0.62);
  --pos: 50%;
  --font: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body.bav {
  display: grid;
  /* Side column, then the photo. minmax(0, 1fr): the photo column is the
     viewport's remainder, never the frame's last pixel size, so a rotation
     cannot stretch the page before fit() runs. */
  grid-template-columns: 196px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--charcoal);
  color: var(--white);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* Keyboard focus only: a 1px gold hairline, never on a tap. */
:focus {
  outline: none;
}

:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Side column ---------- */
.bav-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: max(18px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.bav-side__mark {
  display: block;
  width: 100%;
  max-width: 168px;
  height: auto;
}

.bav-side__eyebrow {
  margin: 10px 0 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.bav-side__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.bav-count {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--mute);
}

.bav-iconbtn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-right: -8px;
  border-radius: 50%;
  color: var(--mute);
}

.bav-iconbtn[hidden] {
  display: none;
}

/* ---------- Stage and slider ---------- */
.bav-stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) 0;
}

/* Sized by the script to the largest box of the pair's own aspect ratio
   that fits the stage, so neither photo is ever cropped. */
.bav-frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 3px;
  background: var(--charcoal-2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  touch-action: none;
  cursor: ew-resize;
}

.bav-frame__ph,
.bav-layer img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* The placeholder is the job's thumbnail, already cached from the strip,
   stretched and softened until the full frames have decoded. */
.bav-frame__ph {
  filter: blur(14px);
  transform: scale(1.06);
}

/* Once the frames have faded in the blurred placeholder is hidden, so the
   iPad is not compositing a blur filter under every wipe. */
.bav-frame.is-loaded .bav-frame__ph {
  visibility: hidden;
  transition: visibility 0s 0.3s;
}

.bav-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.bav-frame.is-loaded .bav-layer {
  opacity: 1;
}

.bav-layer--before {
  clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}

.bav-chip {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 6px 14px;
  background: rgba(29, 29, 30, 0.86);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.bav-chip--after {
  left: auto;
  right: 14px;
  background: var(--gold);
  color: var(--charcoal);
}

.bav-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.bav-handle__line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: var(--white);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
}

.bav-handle__knob {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--white);
  color: var(--charcoal);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.bav-frame.is-dragging .bav-handle__knob {
  background: var(--gold);
}

/* ---------- Caption ---------- */
.bav-caption {
  margin: 22px 0 16px;
  min-height: 4.6em;
}

.bav-caption p {
  margin: 0;
}

.bav-caption__title {
  margin-top: 4px !important;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

.bav-caption__meta {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute);
}

/* ---------- Thumbnails, stacked down the side ---------- */
/* Each thumb takes an equal share of the column's height, so all seven sit
   on screen with no scrolling; max-height stops them growing on a tall
   screen. */
.bav-strip {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 8px;
  min-height: 0;
}

.bav-thumb {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  max-height: 126px;
  width: 100%;
  overflow: hidden;
  border-radius: 3px;
  background: var(--charcoal-2);
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.bav-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bav-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-radius: 3px;
}

.bav-thumb.is-active {
  opacity: 1;
}

.bav-thumb.is-active::after {
  border-color: var(--gold);
}

.bav-noscript {
  padding: 24px;
  text-align: center;
}

.bav-noscript a {
  color: var(--gold);
}

/* Portrait iPad and phones: the side column turns into a band under the
   photo, caption on the left, the seven thumbs in a row. */
@media (orientation: portrait) {
  body.bav {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .bav-stage {
    grid-row: 1;
    padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }

  .bav-side {
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "mark foot"
      "cap cap"
      "strip strip";
    align-items: center;
    padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .bav-side__mark {
    grid-area: mark;
    max-width: 150px;
  }

  .bav-side__eyebrow {
    display: none;
  }

  .bav-side__foot {
    grid-area: foot;
    margin: 0;
  }

  .bav-caption {
    grid-area: cap;
    min-height: 0;
    margin: 10px 0;
  }

  .bav-strip {
    grid-area: strip;
    flex-direction: row;
  }

  .bav-thumb {
    height: 72px;
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bav-layer,
  .bav-thumb {
    transition: none;
  }
}
