/* ==========================================================================
   Lambda Phi Epsilon — Alpha Xi Chapter
   MorphSlider — vanilla port of the React Bits component of the same name.
   The transition lives in the shader; this file only frames it. The plate is
   a photographic one and is intrinsically dark, so the caption scrim and its
   ink are hardcoded — everything around the plate uses the site's tokens and
   follows the light/dark theme.
   Self-contained: styles nothing outside .morph-slider.

   The same rules dress the WebGL canvas and the plain-image fallback, so a
   machine without WebGL sees the identical layout, captions and controls.
   ========================================================================== */

/* ---- 1. Root ------------------------------------------------------------ */
.morph-slider {
  position: relative;
  display: block;
  width: 100%;

  --ms-overlay: #0C1B38;       /* --navy-900; also the shader's uOverlay */
}

/* ---- 2. Stage ----------------------------------------------------------- */
.morph-slider__stage {
  position: relative;
  width: 100%;
  /* 3:2 rather than 16:9 — a gentler frame, so an upright photograph gives up
     far less of itself to the crop. */
  aspect-ratio: 3 / 2;
  min-height: 240px;
  overflow: hidden;
  background: var(--ms-overlay);
  border: 1px solid var(--line-2, #C4B896);
  outline: none;
  cursor: grab;
  touch-action: pan-y;          /* the page keeps its vertical scroll */
}

.morph-slider.is-dragging .morph-slider__stage { cursor: grabbing; }

.morph-slider__stage:focus-visible {
  outline: 1px solid var(--line-2, #C4B896);
  outline-offset: 3px;
}

/* Older engines without aspect-ratio still get a sensible band. */
@supports not (aspect-ratio: 3 / 2) {
  .morph-slider__stage { height: clamp(260px, 46vw, 600px); }
}

.morph-slider__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- 3. Fallback plates ------------------------------------------------- */
/* Used when no WebGL context can be had, or when a texture upload is refused.
   A plain crossfade, same indices, same controls. */
.morph-slider__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 620ms ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.morph-slider__img.is-current { opacity: 1; }

/* ---- 4. Caption --------------------------------------------------------- */
/* Sits on the photograph, so its ink is fixed light regardless of theme. */
.morph-slider__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  margin: 0;
  padding: 3rem 1.5rem 1.15rem;
  text-align: center;
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: clamp(1rem, 1.4vw, 1.2rem);
  line-height: 1.45;
  color: rgba(245, 241, 230, .94);      /* --paper, on a dark plate */
  text-shadow: 0 1px 2px rgba(12, 27, 56, .55);
  background: linear-gradient(to top, rgba(12, 27, 56, .62) 0%, rgba(12, 27, 56, 0) 100%);
  pointer-events: none;
  transition: opacity 280ms ease;
}

.morph-slider__caption.is-swapping { opacity: 0; transition: none; }

/* ---- 5. Controls -------------------------------------------------------- */
/* Below the plate, in the page's own ink — engraved, not glassy. */
.morph-slider__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.15rem;
  margin-top: 1rem;
}

.morph-slider__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--line-2, #C4B896);
  border-radius: 0;
  background: transparent;
  color: var(--ink-soft, #4C463A);
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.morph-slider__arrow:hover {
  color: var(--ink, #23201A);
  border-color: var(--ink-mute, #7C7360);
  background: var(--paper-2, #EDE7D6);
}

.morph-slider__arrow:focus-visible {
  outline: 1px solid var(--ink-mute, #7C7360);
  outline-offset: 2px;
}

/* ---- 6. Indicators ------------------------------------------------------ */
.morph-slider__dots {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.morph-slider__dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.morph-slider__dot::before {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  background: var(--line-2, #C4B896);
  transition: background-color 200ms ease, transform 200ms ease;
}

.morph-slider__dot:hover::before { background: var(--ink-mute, #7C7360); }

.morph-slider__dot.is-current::before {
  background: var(--ink, #23201A);
  transform: scaleY(2);
}

.morph-slider__dot:focus-visible {
  outline: 1px solid var(--ink-mute, #7C7360);
  outline-offset: 2px;
}

/* ---- 7. Screen-reader line ---------------------------------------------- */
.morph-slider__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- 8. Responsive ------------------------------------------------------ */
@media (max-width: 720px) {
  .morph-slider__stage { aspect-ratio: 4 / 3; }
  .morph-slider__caption { padding: 2.2rem 1rem 0.9rem; }
  .morph-slider__controls { gap: 0.75rem; margin-top: 0.85rem; }
  .morph-slider__dot { width: 1.2rem; }
}

/* ---- 9. Reduced motion --------------------------------------------------- */
/* The shader also receives uReduce = 1 and a much shorter duration. */
@media (prefers-reduced-motion: reduce) {
  .morph-slider__img { transition: opacity 120ms linear; }
  .morph-slider__caption,
  .morph-slider__arrow,
  .morph-slider__dot::before { transition: none; }
}

/* ---- 10. Print ----------------------------------------------------------- */
@media print {
  .morph-slider__controls { display: none; }
  .morph-slider__stage { border-color: #000; }
}
