/* Flipbook reader - The Move Live Love TX Team's copy of Krista's
   magazine-publisher reader (copied 2026-11-10). Team changes: brand colors
   below, the .link-layer rules at the end (live links over page images).
   Original header follows.

   Flipbook reader - generic reader chrome, zero issue-specific values.
   Everything issue-specific (title, page images, publication name) is
   injected at runtime by app.js from window.ISSUE (issue.js). Do not add
   any brand-specific strings or colors here - this file ships to every
   business/professional that uses the magazine-publisher skill.

   Breakpoint contract: single-page mode at <=820px, matching the
   MOBILE_BREAKPOINT constant in app.js. Keep both in sync if this changes. */

:root {
  --bg: #16163f;  /* team navy, darker than --brand #24246c */
  --bg-elevated: #1f1f52;
  --panel-bg: #24246c;
  --text: #f3f3f0;
  --muted: #a7abb6;
  --accent: #ff8a8f;  /* team red, lightened to read on navy (about 6:1) */
  --accent-ink: #16163f;
  --border: rgba(255, 255, 255, 0.12);
  --focus-ring: #6fb7ff;
  --page-bg: #ffffff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --toolbar-h: 60px;
  --turn-duration: 660ms;
  --turn-ease: cubic-bezier(0.45, 0.05, 0.15, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px; top: -48px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
  z-index: 100;
}
.skip-link:focus { top: 8px; }

/* Focus-visible treatment applied broadly. Buttons/links/inputs get a
   clear ring only for keyboard focus, not mouse clicks. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- Toolbar ---------- */

.toolbar {
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  /* No flex-wrap: the bar is fixed-height, so a wrapped row would clip.
     Narrow widths are handled by the media queries below instead. */
}

.toolbar-group { display: flex; align-items: center; gap: 8px; }
/* overflow:hidden so shrunken nowrap content clips inside its own box
   instead of spilling under the right-side buttons (mobile overlap bug). */
.toolbar-center { flex: 1; justify-content: center; min-width: 0; overflow: hidden; }

.toolbar button,
.pdf-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 44px;
  min-width: 44px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.toolbar button:hover,
.pdf-download:hover { background: rgba(255, 255, 255, 0.08); }
.toolbar button .icon { font-size: 16px; }

.nav-btn { font-size: 20px; padding: 8px 14px; }

.page-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.page-indicator input[type="range"] {
  width: clamp(90px, 22vw, 240px);
  accent-color: var(--accent);
}
.page-count-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* Below ~640px, hide text labels on buttons to save space; icons remain.
   Team change (2026-11-10): button labels hide below 900px, not 640px. Between
   640 and ~900 (an iPad held upright) the labelled buttons pushed the page
   count under the next-page arrow. Every button keeps its spoken name. */
@media (max-width: 900px) {
  .btn-label { display: none; }
}
@media (max-width: 640px) {
  .toolbar { gap: 6px; padding: 0 8px; }
  .toolbar-group { gap: 4px; }
  .page-indicator input[type="range"] { width: clamp(70px, 16vw, 240px); }
}

/* Below ~480px there is no honest room for the slider next to five 44px tap
   targets. Drop it (buttons, swipe, and TOC still navigate) rather than let
   anything overlap - measured overlap at 375px was the bug this fixes. */
@media (max-width: 480px) {
  .page-indicator input[type="range"] { display: none; }
}

/* ---------- Viewer / stage ---------- */

.viewer {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: radial-gradient(ellipse at center, var(--bg-elevated) 0%, var(--bg) 70%);
  overflow: hidden;
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 64px;
  perspective: 2400px;
}

@media (max-width: 820px) {
  .stage-wrap { padding: 12px 44px; }
}


.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  max-height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
}

/* The "leaving" stage during a page turn is stacked exactly on top of the
   incoming stage and rotated away. See app.js turnTo(). */
.stage.leaving {
  position: absolute;
  inset: 0;
  z-index: 2;
  transition: transform var(--turn-duration) var(--turn-ease),
              opacity var(--turn-duration) var(--turn-ease);
  backface-visibility: hidden;
}
.stage.leaving.turn-forward {
  transform-origin: right center;
  transform: rotateY(-115deg);
  opacity: 0;
}
.stage.leaving.turn-backward {
  transform-origin: left center;
  transform: rotateY(115deg);
  opacity: 0;
}

.page-frame {
  position: relative;
  height: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  box-shadow: var(--shadow);
}

.page-frame img {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  background: var(--page-bg);
}

/* Cover / single-page frames get a touch more shadow presence since
   there's no facing page to visually anchor them. */
.page-frame.single { box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55); }

/* prefers-reduced-motion: the CSS-side backstop. app.js also skips
   creating the .leaving overlay entirely when reduced motion is set, so
   under normal operation this rule never has anything to zero out - it
   exists as defense in depth in case a leaving node is ever present. */
@media (prefers-reduced-motion: reduce) {
  .stage.leaving {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.edge-tap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12%;
  min-width: 32px;
  max-width: 90px;
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 3;
}
.edge-tap-left { left: 0; }
.edge-tap-right { right: 0; }
.edge-tap:hover { background: rgba(255, 255, 255, 0.03); }
.edge-tap:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
}
.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.01ms linear; }
}

/* ---------- Contents overlay ----------
   Team change (2026-11-10): styled like the magazine's own contents page.
   Paper background, navy and red, the website's Newsreader serif for titles
   and Figtree for the small capitals. Fonts ship in this folder (OFL). */

@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-wght-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree-wght-normal.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(19, 19, 66, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 24px;
}
.overlay[hidden] { display: none; }

.contents-panel {
  --paper: #fbfaf8;
  --navy: #24246c;
  --ink: #131342;
  --red: #c2262e;
  --rule: rgba(36, 36, 108, 0.14);
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  width: min(560px, 100%);
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  border-top: 5px solid var(--red);
  overflow: hidden;
}

.contents-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--navy);
}
.contents-kicker {
  margin: 0 0 6px;
  font-family: "Figtree", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--navy);
}
.contents-header h2 {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
}
.contents-header .ct-a { color: var(--navy); }
.contents-header .ct-b { color: var(--red); font-style: italic; font-weight: 500; }
.contents-header button {
  flex: none;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--navy);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 16px;
  cursor: pointer;
}
.contents-header button:hover { background: rgba(36, 36, 108, 0.06); }
.contents-header button:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

.contents-list {
  list-style: none;
  margin: 0;
  padding: 6px 14px 14px;
  overflow-y: auto;
}
.contents-list li { margin: 0; border-bottom: 1px solid var(--rule); }
.contents-list li:last-child { border-bottom: 0; }
.contents-list button {
  display: grid;
  grid-template-columns: 44px 34px 1fr;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  color: var(--ink);
  padding: 10px 10px 10px 9px;
  min-height: 64px;
  cursor: pointer;
}
.contents-list button:hover { background: rgba(36, 36, 108, 0.05); }
.contents-list button:focus-visible { outline: 3px solid var(--navy); outline-offset: -3px; }
.contents-thumb {
  width: 44px;
  aspect-ratio: 2 / 3;
  background: #e9e6df;
  box-shadow: 0 2px 6px rgba(19, 19, 66, 0.25);
  overflow: hidden;
}
.contents-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.contents-num {
  font-family: "Newsreader", Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--red);
  font-variant-numeric: lining-nums tabular-nums;
}
.contents-title {
  font-family: "Newsreader", Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--navy);
}
.contents-list button[aria-current="true"] {
  border-left-color: var(--red);
  background: rgba(194, 38, 46, 0.06);
}
.contents-list button[aria-current="true"] .contents-title { font-weight: 700; }

@media (max-width: 640px) {
  .overlay { padding: 0; align-items: stretch; }
  .contents-panel { width: 100%; max-height: none; border-radius: 0; }
  .contents-header { padding: 18px 18px 14px; }
  .contents-header h2 { font-size: 30px; }
  .contents-list { padding: 4px 8px 20px; }
  .contents-list button { grid-template-columns: 40px 30px 1fr; gap: 12px; }
  .contents-thumb { width: 40px; }
  .contents-title { font-size: 17px; }
}

/* ---------- Live links (team addition) ----------
   The SVG covers the image box and scales like object-fit: contain, so each
   rect sits on its button. The stage sits above the edge-tap zones (z 3) so a
   link near a page edge is tappable on a phone; pointer-events: none on the
   stage lets every tap that is NOT on a link fall through to the edge zones,
   so tap-to-turn keeps working. */
.stage-wrap { z-index: 4; pointer-events: none; }
.link-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.link-layer a { pointer-events: auto; cursor: pointer; }
.link-layer rect { fill: transparent; }
.link-layer a:hover rect { fill: rgba(36, 36, 108, 0.12); }
.link-layer a:focus { outline: none; }
.link-layer a:focus-visible rect {
  fill: rgba(111, 183, 255, 0.18);
  stroke: var(--focus-ring);
  stroke-width: 2;
}

/* ---------- The page turn and the open book (team addition) ----------
   app.js builds a "leaf" (two faces, back to back) over the page that turns,
   and rotates it around the spine. The pages are drawn together as an open
   book: no gap, a soft crease at the spine. */
.stage { gap: 0; }
.page-frame.left { box-shadow: -6px 12px 34px rgba(0, 0, 0, 0.45); }
.page-frame.right { box-shadow: 6px 12px 34px rgba(0, 0, 0, 0.45); }
.page-frame.left::after,
.page-frame.right::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7%;
  pointer-events: none;
}
.page-frame.left::after {
  right: 0;
  background: linear-gradient(to left, rgba(19, 19, 66, 0.22), rgba(19, 19, 66, 0));
}
.page-frame.right::after {
  left: 0;
  background: linear-gradient(to right, rgba(19, 19, 66, 0.22), rgba(19, 19, 66, 0));
}
.page-frame.blank {
  height: 100%;
  background: transparent;
  box-shadow: none;
}
.page-frame.blank::after { display: none; }

.leaf {
  position: absolute;
  z-index: 5;
  transform-style: preserve-3d;
  pointer-events: none;
  will-change: transform;
}
.leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--page-bg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.leaf-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.leaf-back { transform: rotateY(180deg); }
.leaf-face.paper { background: #f1efe9; }
.leaf-shade {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(to right, rgba(19, 19, 66, 0.55), rgba(19, 19, 66, 0.15) 60%, rgba(255, 255, 255, 0.08));
}
.leaf-back .leaf-shade {
  background: linear-gradient(to left, rgba(19, 19, 66, 0.55), rgba(19, 19, 66, 0.15) 60%, rgba(255, 255, 255, 0.08));
}

/* Team change (2026-11-10): every page frame is exactly the page, sized by
   app.js sizeBook() into --pw/--ph from the room available, so there are no
   white bands, a cover never collapses beside its blank partner, and a phone
   page fills the width. Phones get small side gutters. */
.page-frame,
.page-frame.blank {
  width: var(--pw, auto);
  height: var(--ph, 100%);
  max-height: none;
  flex: none;
}
.page-frame img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
}
@media (max-width: 820px) {
  .stage-wrap { padding: 8px 6px; }
}
