/*!
 * scanner-compare.css  v1.2
 * Before/after comparison exhibits, spreads, cards, modals, story rail.
 * Merges the v1.0 core styles and the v1.1 additions into one file.
 * Pairs with scanner-compare.js v1.2. No dependencies.
 *
 *   <link rel="stylesheet" href="/css/scanner-compare.css">
 *
 * Theme overrides: set --accent on .sgx / .sgx-card, or globally on :root.
 */

/* =====================================================================
   1. EXHIBIT
   ===================================================================== */
.sgx {
  --pos: 50%;
  --bar: 3px;
  --accent: #c9a227;
  --ink: #111;
  --paper: #fff;
  max-width: 1100px;
  margin: 2rem auto;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}
.sgx * { box-sizing: border-box; }

/* ---- stage ---- */
.sgx__stage {
  position: relative;
  overflow: hidden;
  background: #e8e8e8;
  border: 1px solid #cfcfcf;
  border-radius: 6px;
  touch-action: pan-y;
  cursor: col-resize;
  user-select: none;
  -webkit-user-select: none;
}
.sgx__stage img { display: block; width: 100%; height: auto; }

.sgx__layer { position: absolute; inset: 0; }
.sgx__layer img { width: 100%; height: 100%; object-fit: cover; }

/* base layer = degraded / as docketed; sets the intrinsic height */
.sgx__base { position: relative; }
/* top layer = original / as filed */
.sgx__top { will-change: clip-path, opacity; }

/* ---- modes ---- */
.sgx[data-mode="wipe"] .sgx__top { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.sgx[data-mode="wipe"] .sgx__handle { display: flex; }

.sgx[data-mode="fade"] .sgx__top { opacity: calc(var(--pos) / 100%); }

.sgx[data-mode="peek"] .sgx__top { opacity: 0; transition: opacity .18s ease; }
.sgx[data-mode="peek"][data-peeking="true"] .sgx__top { opacity: 1; }
.sgx[data-mode="peek"] .sgx__stage { cursor: pointer; }

/* ---- wipe handle ---- */
.sgx__handle {
  display: none;
  position: absolute;
  top: 0; bottom: 0;
  left: var(--pos);
  width: var(--bar);
  margin-left: calc(var(--bar) / -2);
  background: var(--accent);
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.sgx__grip {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .45);
  display: grid;
  place-items: center;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -1px;
}

/* ---- corner labels ---- */
.sgx__tag {
  position: absolute;
  bottom: 8px;
  padding: .28rem .6rem;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  background: rgba(17, 17, 17, .82);
  color: #fff;
  border-radius: 3px;
  pointer-events: none;
}
.sgx__tag--l { left: 8px; }
.sgx__tag--r { right: 8px; }

/* ---- controls ---- */
.sgx__ctl {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-top: .75rem;
}
.sgx__modes {
  display: flex;
  gap: 2px;
  background: #ddd;
  padding: 2px;
  border-radius: 5px;
}
.sgx__modes button {
  border: 0;
  background: transparent;
  padding: .4rem .7rem;
  border-radius: 4px;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  color: #333;
}
.sgx__modes button[aria-pressed="true"] {
  background: var(--paper);
  color: #000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  font-weight: 600;
}
.sgx__range {
  flex: 1 1 180px;
  min-width: 140px;
  accent-color: var(--accent);
  height: 28px;
}
.sgx__zoom {
  border: 1px solid #bbb;
  background: var(--paper);
  padding: .4rem .7rem;
  border-radius: 4px;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.sgx__zoom[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.sgx__cap { margin: .6rem 0 0; font-size: .83rem; color: #4a4a4a; }
.sgx__cap strong { color: #111; }

/* ---- magnifier ----
   The loupe holds a fixed 50/50 split so both states stay visible at
   magnification regardless of where the wipe handle sits. */
.sgx__loupe {
  position: absolute;
  width: 180px; height: 180px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 3px 14px rgba(0, 0, 0, .5);
  overflow: hidden;
  pointer-events: none;
  display: none;
  background: #fff;
}
.sgx[data-zoom="true"] .sgx__loupe { display: block; }
.sgx__loupe > div { position: absolute; inset: 0; background-repeat: no-repeat; }
.sgx__loupeTop { clip-path: inset(0 50% 0 0); }
.sgx__loupeSplit {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accent);
}

/* ---- progressive enhancement: unbound exhibits render side by side ---- */
.sgx:not([data-ready]) .sgx__ctl { display: none; }
.sgx:not([data-ready]) .sgx__top {
  position: static;
  clip-path: none;
  opacity: 1;
  border-top: 2px solid var(--accent);
}
.sgx:not([data-ready]) .sgx__stage { cursor: auto; }

@media (max-width: 520px) {
  .sgx__loupe { width: 130px; height: 130px; }
  .sgx__tag { font-size: .66rem; padding: .22rem .45rem; }
  .sgx__modes button { padding: .4rem .55rem; font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sgx[data-mode="peek"] .sgx__top { transition: none; }
}

/* =====================================================================
   2. TWO-PAGE SPREAD (container-query driven)
   ===================================================================== */
.sgx-spread-wrap {
  container-type: inline-size;
  container-name: spread;
  max-width: 1240px;
  margin: 2rem auto;
}
.sgx-spread {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;      /* stacked by default */
}
.sgx-spread .sgx { margin: 0; max-width: none; }
.sgx-spread__pagenum {
  font: 600 .74rem/1 system-ui, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6b6b6b;
  margin: 0 0 .35rem;
}

/* side by side once the CONTAINER has room, independent of viewport */
@container spread (min-width: 700px) {
  .sgx-spread { grid-template-columns: 1fr 1fr; gap: 1rem; }
}
@supports not (container-type: inline-size) {
  @media (min-width: 760px) {
    .sgx-spread { grid-template-columns: 1fr 1fr; }
  }
}

/* shared control bar for a synced group */
.sgx-groupctl {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin: 0 0 1rem;
  padding: .6rem .75rem;
  background: #f4f4f4;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.sgx-groupctl__lbl { font-size: .8rem; font-weight: 600; color: #444; }
.sgx-groupctl input[type="range"] {
  flex: 1 1 200px;
  accent-color: #c9a227;
  height: 28px;
}
.sgx-spread[data-grouped="true"] .sgx__ctl { display: none; }

/* =====================================================================
   3. THUMBNAIL CARD
   ===================================================================== */
.sgx-card {
  --w: 280px;
  display: block;
  width: var(--w);
  max-width: 100%;
  text-decoration: none;
  color: inherit;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .09);
  transition: box-shadow .2s, transform .2s;
}
.sgx-card:focus-visible { outline: 3px solid #c9a227; outline-offset: 2px; }

.sgx-card__stage {
  position: relative;
  display: block;
  overflow: hidden;
  background: #e9e9e9;
  --cpos: 50%;
}
.sgx-card__stage img { display: block; width: 100%; height: auto; }
.sgx-card__top {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--cpos)) 0 0);
  will-change: clip-path;
}
.sgx-card__top img { width: 100%; height: 100%; object-fit: cover; }
.sgx-card__seam {
  position: absolute;
  top: 0; bottom: 0;
  left: var(--cpos);
  width: 2px;
  margin-left: -1px;
  background: #c9a227;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .3);
}
.sgx-card__badge {
  position: absolute;
  top: 8px; left: 8px;
  padding: .2rem .5rem;
  border-radius: 3px;
  background: #c9a227;
  color: #1a1a1a;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.sgx-card__mini {
  position: absolute;
  bottom: 6px; left: 6px; right: 6px;
  display: flex;
  justify-content: space-between;
  gap: .4rem;
  pointer-events: none;
}
.sgx-card__mini span {
  padding: .16rem .4rem;
  border-radius: 2px;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: rgba(17, 17, 17, .8);
  color: #fff;
}
.sgx-card__body { display: block; padding: .7rem .8rem .85rem; }
.sgx-card__title {
  display: block;
  margin: 0 0 .25rem;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.25;
}
.sgx-card__sub { display: block; font-size: .79rem; color: #555; }
.sgx-card__cta {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  margin-top: .55rem;
  min-height: 44px;
  padding: .5rem .8rem;
  border: 1px solid #c9a227;
  border-radius: 5px;
  background: #fffdf3;
  font-size: .8rem;
  font-weight: 700;
  color: #7a5f00;
}
.sgx-card__hint { display: none; }

/* mouse and trackpad: hover previews, click opens */
@media (hover: hover) and (pointer: fine) {
  .sgx-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .16); transform: translateY(-2px); }
  .sgx-card__cta { display: none; }
  .sgx-card__hint {
    display: block;
    margin-top: .5rem;
    font-size: .74rem;
    color: #7a7a7a;
  }
}
/* touch and coarse pointers: visible 44px target, hover plays no role */
@media (hover: none), (pointer: coarse) {
  .sgx-card__hint { display: none; }
  .sgx-card__seam { width: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .sgx-card { transition: none; }
  .sgx-card__top { will-change: auto; }
}

/* =====================================================================
   4. MODAL
   ===================================================================== */
.sgx-modal {
  border: 0;
  padding: 0;
  max-width: min(96vw, 1100px);
  width: 100%;
  max-height: 92vh;
  border-radius: 10px;
  background: #fff;
  overflow: auto;
}
.sgx-modal::backdrop { background: rgba(10, 10, 10, .78); }
.sgx-modal__hd {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid #e6e6e6;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}
.sgx-modal__ttl { margin: 0; font: 700 1rem/1.3 system-ui, sans-serif; }
.sgx-modal__x {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.sgx-modal__bd { padding: .5rem 1rem 1.25rem; }
.sgx-modal__more {
  display: inline-block;
  margin-top: .9rem;
  font-weight: 700;
  color: #7a5f00;
}

/* =====================================================================
   5. TWO-STAGE STORY RAIL
   ===================================================================== */
.sgx-rail {
  max-width: 1100px;
  margin: 2.5rem auto;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.sgx-rail__hd { margin: 0 0 1.1rem; font: 800 1.35rem/1.2 system-ui, sans-serif; }
.sgx-rail__track {
  display: grid;
  gap: 1.4rem;
  grid-template-columns: 1fr;
  position: relative;
}
.sgx-rail__arrow { color: #c9a227; font-size: 1.4rem; text-align: center; }
@media (min-width: 720px) {
  .sgx-rail__track { grid-template-columns: 1fr auto 1fr; align-items: start; }
  .sgx-rail__arrow { align-self: center; font-size: 1.6rem; padding: 0 .3rem; }
}
.sgx-rail__step { display: flex; flex-direction: column; gap: .55rem; }
.sgx-rail__step .sgx-card { --w: 100%; }
.sgx-rail__meta { margin: 0; font-size: .8rem; color: #666; }
.sgx-rail__kicker {
  font: 800 .72rem/1 system-ui, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8a6d00;
}
.sgx-rail__note {
  max-width: 70ch;
  margin: 1.4rem auto 0;
  font-size: .92rem;
  color: #3d3d3d;
}
.sgx {
    display: flex;
    flex-direction: column;
}

.sgx__ctl {
    order: -1;
    margin: 0 0 .75rem;
}
.sgx__ctl {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #fff;
    padding: .5rem;
}
