/* ==========================================================================
   FRONTLINE21 — THE FIELD MANUAL READER
   One spread at a time, at its own exact proportions, never cropped.
   Deep blue carries this movement, which is the manual's own ground.
   ========================================================================== */

.reader {
  border: 1px solid var(--ink-line);
  background: linear-gradient(180deg, rgba(34, 47, 97, 0.22), rgba(34, 47, 97, 0.06));
  margin-bottom: var(--stack-xl);
}

.reader__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--stack-sm);
  padding: 14px clamp(14px, 2vw, 22px);
  border-bottom: 1px solid var(--ink-line);
}

.reader__head [data-reader-current] {
  font-family: var(--font-display);
  font-weight: 700;
}

.reader__stage {
  position: relative;
  padding: clamp(14px, 2.4vw, 30px);
}

/* The frame takes its ratio from the spread currently shown, so the cover and
   the interior spreads each display at their true proportions. */
.reader__frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--spread-ratio, 1500 / 580);
  background: var(--ink-deep);
  overflow: hidden;
  /* The frame ratio is set from the current spread. It must not transition:
     an animated aspect-ratio fed by a custom property keeps its interpolated
     value and stops tracking later changes, which leaves a wide spread sitting
     inside the cover's proportions. */
}

.reader__page {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  visibility: hidden;
  transition: opacity 320ms var(--ease-out), visibility 320ms;
}

.reader__page.is-current {
  opacity: 1;
  visibility: visible;
}

.reader__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: rgba(18, 22, 22, 0.72);
  border: 1px solid var(--ink-line);
  transition: background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}

.reader__nav svg {
  width: 20px;
  height: 20px;
}

.reader__nav--prev { left: clamp(18px, 3vw, 38px); }
.reader__nav--next { right: clamp(18px, 3vw, 38px); }

.reader__nav:hover,
.reader__nav:focus-visible {
  background: var(--f21-red);
  border-color: var(--f21-red);
}

.reader__nav[disabled] {
  opacity: 0.3;
  cursor: default;
}

.reader__nav[disabled]:hover {
  background: rgba(18, 22, 22, 0.72);
  border-color: var(--ink-line);
}

.reader__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--stack-sm);
  padding: 0 clamp(14px, 2.4vw, 30px) clamp(16px, 2vw, 24px);
}

.reader__hint {
  color: var(--paper-faint);
  flex: none;
}

/* --- Slider --------------------------------------------------------------- */

.reader__slider {
  flex: 1 1 200px;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

.reader__slider::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--ink-line);
}

.reader__slider::-moz-range-track {
  height: 2px;
  background: var(--ink-line);
}

.reader__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  background: var(--f21-red);
  border: 0;
}

.reader__slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--f21-red);
  border: 0;
  border-radius: 0;
}

.reader__slider:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

/* --- Expanded reading mode ------------------------------------------------- */

.reader.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 120;
  margin: 0;
  border: 0;
  background: var(--ink-deep);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.reader.is-expanded .reader__stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  padding: clamp(16px, 3vw, 44px);
}

.reader.is-expanded .reader__frame {
  max-height: 78vh;
  margin-inline: auto;
  width: min(100%, calc(78vh * var(--spread-aspect, 2.586)));
}

.reader.is-expanded .reader__head {
  border-bottom: 1px solid rgba(26, 30, 33, 0.18);
}

body.reader-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  .reader__nav {
    width: 38px;
    height: 38px;
  }

  .reader__nav--prev { left: 6px; }
  .reader__nav--next { right: 6px; }

  .reader__hint {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader__page {
    transition: none;
  }
}
