/* ==========================================================================
 * highlights9.css — PRESET 9's highlight + story-player styling.
 * ==========================================================================
 * A scoped copy of the highlight CSS that lives in site.css. Every rule here
 * is prefixed with `html.preset9`, so it applies ONLY when preset 9 is active
 * (AZ_MODE === 9) and overrides the unscoped originals by specificity. Preset
 * 1's rules in site.css are never touched — edit this file freely to reshape
 * preset 9's highlights. The class names match js/stories2.js (shared by
 * stories.js), so no markup changes are needed.
 * ========================================================================== */

/* Highlight row */
html.preset9 #highlights {
  display: flex;
  gap: 1.6rem;
  padding: 2.75rem 1.5rem;
  max-width: 100vw;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

html.preset9 #highlights::-webkit-scrollbar {
  display: none;
}

/* ---------- highlight items ---------- */

html.preset9 .hl-item {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  font: inherit;
}

/* position:relative is REQUIRED — the aura canvas centers itself inside. */
html.preset9 .hl-circle {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
  overflow: visible;
}

html.preset9 .hl-cover {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

/* Fallback dot when a highlight has no cover image (stories7.js sets color inline). */
html.preset9 .hl-glyph {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  background: currentColor;
  box-shadow: 0 0 10px currentColor, 0 0 24px currentColor;
}

html.preset9 .hl-label {
  font: 500 12px/1.2 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #b9b9c4;
  letter-spacing: 0.14em;
  text-transform: lowercase;
}

/* ---------- story player overlay (z:100) ---------- */

html.preset9 .story-player {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* No safe-area padding here (unlike preset1's site.css version) — it made
     the media sit lower in the standalone webapp than in Safari browsing,
     because iOS reports a real env(safe-area-inset-top) only in the webapp
     (Safari's own chrome already covers that zone, so it reports ~0 there).
     .sp-media is full-bleed instead; the progress bar and buttons already
     carry their own safe-area offset (see below), so they stay clear of the
     notch in both contexts without pushing the video down. */
}

html.preset9 .sp-progress {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 5;
}

html.preset9 .sp-bar {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  overflow: hidden;
}

html.preset9 .sp-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: #f2f2f5;
}

html.preset9 .sp-close,
html.preset9 .sp-sound {
  position: absolute;
  z-index: 6;
  top: calc(24px + env(safe-area-inset-top));
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
}

html.preset9 .sp-close {
  right: 10px;
  font-size: 26px;
}

html.preset9 .sp-sound {
  right: 54px;
  font-size: 18px;
}

/* the display:grid above would defeat the hidden attribute's UA rule */
html.preset9 .sp-sound[hidden] {
  display: none;
}

html.preset9 .sp-media {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

html.preset9 .sp-media img,
html.preset9 .sp-media video {
  /* FILL the frame, not letterbox. width/height 100% + object-fit:cover makes
     the media cover the whole viewport; a portrait video on a portrait phone
     of the same aspect (e.g. the 1170x2532 story on a ~1:2.16 screen) fills it
     exactly with no bars and no visible crop. Wider/narrower frames crop the
     overflow rather than showing black bars. */
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* STANDALONE WEBAPP ONLY, story-player media ONLY (scoped tightly to .sp-media;
   the emblem, mist, and Safari-tab browsing are all untouched). The webapp is
   truly fullscreen while Safari-with-toolbar shows a shorter viewport, so the
   webapp reveals more of the video's own (dark) top before the subject — a
   visible gap under the sound/close buttons that Safari doesn't have.
   object-position could NOT fix this: the video nearly matches the fullscreen
   aspect, so cover leaves ~no crop margin to reposition. transform physically
   moves it regardless. translateY(-...) lifts the subject up; the scale(>1)
   gives headroom so the bottom still fills after the lift (no black gap) and
   also mimics Safari's slightly-more-zoomed crop. Detected via html.standalone
   (JS, robust across iOS versions), not the display-mode media query alone.
   Tunable — nudge translateY/scale from the on-device look. */
html.preset9.standalone .sp-media img,
html.preset9.standalone .sp-media video {
  transform: translateY(-4%) scale(1.08);
}

/* story2 AND story3: the 8% zoom read as too much on these items — dropped
   here, keeping the same lift. story1 has neither class (see
   stories/manifestV.js's item.id hook) and keeps the base rule above.
   This existed only in highlights2.css until story3 was added (2026-07-29);
   presets 3-9 share the same stories via stories/manifestV.js, so the same
   items were still being zoomed here. Paired in one selector so they cannot
   drift apart. */
html.preset9.standalone .sp-media video.sp-video-story2 {
  transform: translateY(-4%) scale(1);
}

/* story3 — its OWN rules throughout, never merged into story2's. story2's
   selectors are exactly as they were before story3 existed.

   CONTAINED, AND LIFTED. The two are independent properties: object-fit
   decides how the frame is fitted, transform still moves it afterwards.

   story1 is 1170x2532, a tall 1:2.16 that fills a portrait phone almost
   exactly under object-fit:cover, which is what the base rule is built for.
   story3 is 1170x1174, near-SQUARE, so cover magnifies it hugely to reach full
   height and crops the sides off — which is why it read as too large. I
   answered that with object-fit:contain, which fixed the size but BROKE the
   thing he had actually asked for: story3 positioned like story2. contain also
   compounded with a scale(0.5) into ~23%, far smaller than intended.

   Mirroring story2 exactly was tried and rejected: story2 inherits
   object-fit:cover, which crops 53% off ITS sides — invisible there because it
   fills the screen edge to edge, but on a shrunken story3 the same cropping
   reads as a cut-off frame, which is what he saw. cover crops to fill, and any
   scale applied afterwards shrinks what is already cropped.

   So story3 uses object-fit:contain: the whole frame is visible, nothing cut.
   That alone renders it at ~46% of cover's size, which is the reduction he
   asked for, so NO scale is applied on top — the earlier contain+scale(0.5)
   compounded to ~23% and read far too small. The transform keeps the same lift
   the other rules use (-4% portrait, -6% landscape), which still works
   normally: object-fit and transform do not interfere.

   THE LIFT IS story3'S OWN, not story2's. Portrait is -7% and landscape is
   none at all, both by his instruction. -20% was tried first and read as too
   much. Note that translateY is a percentage
   of the ELEMENT'S OWN height, so the same figure moves the two stories
   different distances: story2 renders 2532px tall under cover, story3 only
   1174px under contain, so -4% was ~101px on story2 but ~47px here. -7% is
   ~82px.

   If the size ever needs revisiting, add a scale here and nothing else.

   story2 is near-square too (1164x1186) and has the same magnification, but it
   is NOT resized here: it has been playing at its current size since it was
   added, and he asked about story3 only. */
html.preset9 .sp-media video.sp-video-story3,
html.preset9.standalone .sp-media video.sp-video-story3 {
  object-fit: contain;
  transform: translateY(-7%);
}

/* MOBILE LANDSCAPE ONLY. Render the portrait video at the SAME scale it has in
   portrait (plus the 8% zoom), letting it overflow the short landscape viewport
   rather than shrinking to fit. In portrait the video is sized to the screen's
   SHORT edge (its width); in landscape the short edge is the HEIGHT, so
   width:100vh reproduces that exact size. height:auto keeps the aspect, so the
   video overflows top/bottom (clipped by the screen) with black bars at the
   sides; scale(1.08) is the same 8% zoom as the standalone portrait view. The
   standalone rule's translateY lift is portrait-only, so it's replaced by a
   plain scale here. Scoped to phone landscape (orientation, short height, touch)
   so portrait / tablet / desktop are untouched. */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  html.preset9 .sp-media img,
  html.preset9 .sp-media video {
    width: 100vh;
    height: auto;
    transform: translateY(-6%) scale(1.08);
  }
  html.preset9.standalone .sp-media img,
  html.preset9.standalone .sp-media video {
    transform: translateY(-6%) scale(1.08);
  }
  /* story2 and story3 — same de-zoom as the rules above. */
  html.preset9 .sp-media video.sp-video-story2,
  html.preset9.standalone .sp-media video.sp-video-story2 {
    transform: translateY(-6%) scale(1);
  }
  /* story3 — its own, separate from story2's. Contained and halved as in
     portrait; this block comes AFTER the portrait rules and is equally
     specific, so without repeating it landscape would reinstate scale(1). */
  html.preset9 .sp-media video.sp-video-story3,
  html.preset9.standalone .sp-media video.sp-video-story3 {
    object-fit: contain;
    transform: none;
  }
}

/* DESKTOP ONLY (pointer:fine = mouse-driven; phones/tablets are coarse, so
   they're excluded and keep their own rules above). On a wide desktop viewport
   object-fit:cover would blow the portrait video up to cover the width. Instead
   fit it to the FULL viewport height, centered (black bars at the sides), with
   the same 8% zoom as portrait — so it reads at full size, top/bottom trimmed
   only by that zoom. Portrait phone / landscape phone / tablet untouched. */
@media (pointer: fine) {
  html.preset9 .sp-media img,
  html.preset9 .sp-media video {
    width: auto;
    height: 100vh;
    object-fit: contain;
    transform: translateY(-13%) scale(2.67);
  }
}

/* Tap zones for prev/next navigation. */
html.preset9 .sp-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 33%;
  z-index: 4;
}

html.preset9 .sp-zone-left {
  left: 0;
}

html.preset9 .sp-zone-right {
  right: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 480px) {
  html.preset9 #highlights {
    gap: 1.1rem;
  }

  html.preset9 .hl-circle {
    width: 66px;
    height: 66px;
  }
}
