/* ======================================================
   Sayonara_Alice.exe — v92_pages_shell.css
   Shared shell for the two dedicated pages: story.html and
   alice.html.
   ------------------------------------------------------
   Holds only what both pages need: reading tokens, the
   uncropped image frame, the page opening, the back link
   and the bridge card. The reading system lives in
   v93_story_reading.css, the archive structure in
   v94_alice_codex.css — nothing is declared twice.

   Reads the palette already exported by style.css
   (--sa-bg / --sa-text / --sa-muted / --sa-blue / --sa-deep)
   and the reveal contract shipped with v71
   (.v71-reveal + v71_reveal.js).
====================================================== */

/* ------------------------------------------------------
   1. Tokens
------------------------------------------------------ */

/* style.css does not set a global border-box, so the page containers
   opt in explicitly: width + padding must never exceed the viewport. */
.page-shell,
.page-shell *,
.page-shell *::before,
.page-shell *::after {
  box-sizing: border-box;
}

.page-shell {
  --page-ink: rgba(238, 251, 255, .93);
  --page-ink-soft: rgba(214, 240, 252, .78);
  --page-accent: var(--sa-blue, #00d9ff);
  --page-deep: var(--sa-deep, #4072ff);
  --page-hair: rgba(0, 220, 255, .20);
  --page-hair-strong: rgba(120, 230, 255, .42);
  --page-measure: 58ch;
  --page-max: 1180px;
  --page-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --page-mono: "Courier New", Consolas, monospace;
  --page-ease: cubic-bezier(.16, 1, .3, 1);

  position: relative;
  display: block;
  padding-bottom: clamp(3rem, 8vw, 6rem);
}

/* Ambient: one blue haze plus a paper grain, both decorative. */
.page-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(0, 190, 255, .10), transparent 44%),
    radial-gradient(ellipse at 92% 88%, rgba(64, 114, 255, .08), transparent 50%);
}

.page-shell > * {
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------
   2. Back link
------------------------------------------------------ */

.page-back {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin: clamp(1.1rem, 3vw, 2rem) 0 0 clamp(1.1rem, 5vw, 4rem);
  padding: .45rem .2rem;
  color: rgba(158, 244, 255, .72);
  font: 700 .68rem/1 var(--page-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color .25s ease, transform .25s var(--page-ease);
}

.page-back:hover,
.page-back:focus-visible {
  color: #d8f8ff;
  transform: translateX(-3px);
}

.page-back i {
  font-style: normal;
}

/* ------------------------------------------------------
   3. Uncropped image frame
   The three page images carry their own typography — titles,
   handwriting, HUD panels. They are never cropped: the frame
   takes the source ratio and the picture scales inside it.
------------------------------------------------------ */

.page-figure {
  position: relative;
  margin: 0;
  border-radius: clamp(12px, 1.4vw, 20px);
  overflow: hidden;
  border: 1px solid rgba(0, 220, 255, .16);
  background: linear-gradient(160deg, rgba(0, 24, 34, .5), rgba(0, 0, 0, .3));
  box-shadow:
    0 26px 70px rgba(0, 0, 0, .55),
    inset 0 0 40px rgba(0, 140, 255, .06);
}

.page-figure img {
  display: block;
  width: 100%;
  height: auto;
  /* Reserves the box before load: no layout shift, no crop. */
  aspect-ratio: var(--figure-ratio, 3 / 2);
  object-fit: contain;
  transform: scale(1);
  transition: transform 1.4s var(--page-ease), opacity 1s ease;
}

/* Very light veil, only along the lower edge, so the frame melts
   into the page without touching the artwork's atmosphere. */
.page-figure::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 26%;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(2, 5, 9, .55));
  opacity: .7;
}

/* Corner marks: archive framing, drawn in CSS, no new asset. */
.page-figure-marks i {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 0 solid rgba(140, 235, 255, .5);
  pointer-events: none;
  opacity: 1;
  transition: opacity .8s ease .25s;
}

.page-figure-marks i:nth-child(1) { top: 10px; left: 10px; border-top-width: 1px; border-left-width: 1px; }
.page-figure-marks i:nth-child(2) { top: 10px; right: 10px; border-top-width: 1px; border-right-width: 1px; }
.page-figure-marks i:nth-child(3) { bottom: 10px; left: 10px; border-bottom-width: 1px; border-left-width: 1px; }
.page-figure-marks i:nth-child(4) { bottom: 10px; right: 10px; border-bottom-width: 1px; border-right-width: 1px; }

/* Entrance: the picture settles from a 1.03 scale to exactly 1,
   so the final frame shows the whole image, never a crop. */
.page-figure.v71-reveal-pending img {
  transform: scale(1.03);
  opacity: 0;
}

.page-figure.v71-reveal-pending .page-figure-marks i {
  opacity: 0;
}

/* One slow sweep, once, when the frame appears. */
.page-figure-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 42%, rgba(170, 240, 255, .10) 50%, transparent 58%);
  transform: translateX(-120%);
  opacity: 0;
}

.page-figure.is-revealed .page-figure-scan {
  animation: pageFigureScan 1.9s var(--page-ease) .2s 1 both;
}

@keyframes pageFigureScan {
  0% { transform: translateX(-120%); opacity: 0; }
  22% { opacity: 1; }
  100% { transform: translateX(120%); opacity: 0; }
}

/* ------------------------------------------------------
   4. Page opening
------------------------------------------------------ */

.page-hero {
  width: min(var(--page-max), 100%);
  margin: clamp(1.4rem, 4vw, 3rem) auto 0;
  padding-inline: clamp(1.1rem, 5vw, 4rem);
}

.page-hero .page-figure {
  --figure-ratio: 3 / 2;
}

.page-hero-copy {
  max-width: var(--page-measure);
  margin-top: clamp(1.6rem, 4vw, 2.8rem);
}

.page-hero-kicker {
  margin: 0 0 .8rem;
  color: #8ff4ff;
  font: 800 .74rem/1.2 var(--page-mono);
  letter-spacing: .2em;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(0, 220, 255, .45);
}

.page-hero h1 {
  margin: 0;
  color: var(--sa-text, #effcff);
  font-family: var(--page-serif);
  font-size: clamp(2.1rem, 5vw, 3.9rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -.02em;
  text-wrap: balance;
  text-shadow: 0 0 30px rgba(0, 220, 255, .13);
}

.page-hero-sub {
  margin: clamp(.9rem, 2vw, 1.4rem) 0 0;
  color: var(--page-ink-soft);
  font-family: var(--page-serif);
  font-size: clamp(1.02rem, 1.2vw, 1.18rem);
  line-height: 1.75;
}

/* Hairline closing the opening block, drawn on reveal. */
.page-rule {
  display: block;
  width: min(240px, 62%);
  height: 1px;
  margin: clamp(1.3rem, 3vw, 2.2rem) 0 0;
  border: 0;
  background: linear-gradient(90deg, var(--page-hair-strong), transparent);
  transform: scaleX(1);
  transform-origin: left center;
  transition: transform 1s var(--page-ease) .12s;
}

.v71-reveal-pending .page-rule,
.page-rule.v71-reveal-pending {
  transform: scaleX(0);
}

/* ------------------------------------------------------
   5. Bridge card — the elegant hand-off between pages
------------------------------------------------------ */

.page-bridge {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
  width: min(var(--page-max), 100%);
  margin: clamp(3rem, 8vw, 6rem) auto 0;
  padding: clamp(1.5rem, 3.4vw, 2.6rem) clamp(1.3rem, 3.4vw, 2.6rem);
  border: 1px solid rgba(0, 220, 255, .26);
  border-radius: 20px;
  background:
    radial-gradient(ellipse 80% 120% at 12% 0%, rgba(0, 220, 255, .09), transparent 68%),
    linear-gradient(135deg, rgba(0, 32, 44, .48), rgba(0, 0, 0, .3));
  overflow: hidden;
  text-decoration: none;
  transition: border-color .3s ease, box-shadow .3s ease, transform .3s var(--page-ease);
}

.page-bridge::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(0, 220, 255, .05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 220, 255, .035) 1px, transparent 1px);
  background-size: 62px 62px;
  mask-image: radial-gradient(ellipse at 0% 50%, black, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 0% 50%, black, transparent 72%);
  opacity: .5;
}

.page-bridge:hover,
.page-bridge:focus-visible {
  border-color: rgba(0, 235, 255, .5);
  box-shadow: 0 0 44px rgba(0, 190, 255, .16);
  transform: translateY(-2px);
}

.page-bridge-copy {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  min-width: 0;
}

.page-bridge-kicker {
  color: rgba(158, 244, 255, .74);
  font: 700 .68rem/1 var(--page-mono);
  letter-spacing: .2em;
  text-transform: uppercase;
}

.page-bridge-title {
  color: var(--sa-text, #effcff);
  font-family: var(--page-serif);
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  line-height: 1.2;
}

.page-bridge-note {
  color: var(--page-ink-soft);
  font-family: var(--page-serif);
  font-size: clamp(.96rem, 1.1vw, 1.05rem);
  line-height: 1.6;
}

.page-bridge-arrow {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(44px, 5vw, 58px);
  height: clamp(44px, 5vw, 58px);
  border: 1px solid rgba(0, 220, 255, .3);
  border-radius: 50%;
  color: #cdf6ff;
  font-size: 1.2rem;
  transition: transform .3s var(--page-ease), border-color .3s ease, background-color .3s ease;
}

.page-bridge:hover .page-bridge-arrow,
.page-bridge:focus-visible .page-bridge-arrow {
  transform: translateX(5px);
  border-color: rgba(0, 235, 255, .62);
  background: rgba(0, 190, 255, .1);
}

/* ------------------------------------------------------
   6. Focus, selection, motion budget
------------------------------------------------------ */

.page-shell :focus-visible {
  outline: 2px solid rgba(140, 240, 255, .85);
  outline-offset: 4px;
  border-radius: 6px;
}

.page-shell ::selection {
  background: rgba(0, 180, 255, .28);
  color: #ffffff;
}

.page-shell .v71-reveal {
  --v71-reveal-duration: .68s;
  --v71-reveal-distance: 12px;
}

html.visual-soft .page-shell .v71-reveal {
  --v71-reveal-duration: .34s;
  --v71-reveal-distance: 5px;
}

html.visual-full .page-shell .v71-reveal {
  --v71-reveal-duration: .8s;
  --v71-reveal-distance: 16px;
}

html.visual-soft .page-shell::before {
  opacity: .3;
}

/* ------------------------------------------------------
   7. Responsive
------------------------------------------------------ */

@media (max-width: 760px) {
  .page-shell {
    --page-measure: 100%;
  }

  .page-back {
    margin-left: 1.15rem;
  }

  .page-hero,
  .page-bridge {
    padding-inline: 1.15rem;
  }

  /* The three page images carry baked-in typography, so they are never
     cropped. On a phone that would leave a short strip, so instead the
     frame goes edge to edge: same complete image, as large as the screen
     allows. */
  .page-hero .page-figure {
    margin-inline: -1.15rem;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .page-bridge {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 1.2rem;
    padding: 1.5rem 1.2rem;
    border-radius: 16px;
  }

  .page-bridge-arrow {
    justify-self: start;
  }

  .page-figure-marks i {
    width: 11px;
    height: 11px;
  }
}

/* ------------------------------------------------------
   8. Reduced motion
   v71_reveal.js never hides anything in this mode; here every
   remaining transition and the sweep are switched off.
------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .page-shell .v71-reveal,
  .page-figure img,
  .page-rule,
  .page-figure-marks i,
  .page-bridge,
  .page-bridge-arrow,
  .page-back {
    transition: none !important;
    transform: none !important;
  }

  .page-figure-scan,
  .page-figure.is-revealed .page-figure-scan {
    display: none;
    animation: none !important;
  }
}
