/* Ghostlovecake v9: premium refinement layer.
   Loads after styles.v2.css, integrations.v1.css and conversion.v8.css and only
   overrides layout, rhythm and composition. Hooks (data-*, IDs) are untouched.

   Thesis: one container edge, one chapter mark, one framed "stream window".
   The 720 x 350 hero loop is shown inside a frame sized so it is never
   upscaled past roughly 1.15x, instead of a soft full-bleed crop. */

:root {
  --edge: max(var(--gutter), calc((100% - var(--max)) / 2));
  --chapter-pad: clamp(56px, 6.5vw, 96px);
  --frame-ring: 0 0 0 1px rgba(244, 238, 228, 0.16);
  --frame-shadow: 0 34px 80px -34px rgba(0, 0, 0, 0.85);
}

/* ---------- Chapter treatment (shared) ---------- */

.chapter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.chapter::before {
  content: "";
  flex: none;
  width: 28px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

/* Hairline at the top of each chapter, aligned to the shared content edge. */
.preview,
.about,
.footer { position: relative; }
.preview::before,
.about::before,
.footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--edge);
  right: var(--edge);
  height: 1px;
  background: var(--line);
}

.chapter-title,
.preview-head h2,
.about-copy h2 {
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  font-weight: 600;
  font-size: clamp(2rem, 1.35rem + 2.4vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

/* ---------- Hero: framed stream window ---------- */

.hero {
  display: block;
  min-height: 0;
  padding: calc(var(--mast-h) + 6px) var(--gutter) clamp(40px, 6vw, 72px);
}
.hero-visual {
  position: relative;
  inset: auto;
  width: 100%;
  max-width: 560px;
  height: clamp(176px, 28svh, 250px);
  aspect-ratio: auto;
  margin: 0 0 22px;
}
/* Offset hairline behind the window: one quiet layer, not a panel. */
.hero-visual::before {
  content: "";
  position: absolute;
  inset: 10px -10px -10px 10px;
  border: 1px solid rgba(143, 227, 214, 0.28);
  border-radius: 24px;
  pointer-events: none;
}
.hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: 20px;
  background: var(--night-2);
  box-shadow: var(--frame-ring), var(--frame-shadow), 0 0 110px -30px var(--teal-glow);
}
.hero-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 46% 42%;
}
.hero-shade {
  background: linear-gradient(0deg, rgba(5, 8, 18, 0.62) 0%, rgba(5, 8, 18, 0) 34%);
}
.hero-caption {
  position: absolute;
  z-index: 3;
  top: auto;
  left: 12px;
  right: 12px;
  bottom: 12px;
  justify-content: space-between;
}
.hero-caption p {
  display: block;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--muted);
}
.hero-inner { padding-top: 0; }
.hero .eyebrow { margin-bottom: 8px; }
/* The frame stacks above the decorative stars so nothing ever crosses her face. */
.hero-visual { z-index: 2; }
.hero .s1 { top: 43%; bottom: auto; left: auto; right: 6%; }
.hero .s2 { top: auto; bottom: 24%; left: auto; right: 5%; }
.hero .s3 { display: none; }

@media (min-width: 880px) {
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, min(47%, 600px));
    grid-template-areas: "copy visual";
    align-items: center;
    column-gap: clamp(40px, 5vw, 88px);
    padding: calc(var(--mast-h) + clamp(32px, 5vh, 64px)) var(--edge) clamp(56px, 6vw, 88px);
  }
  .hero-inner { grid-area: copy; width: auto; max-width: 560px; }
  .hero-visual {
    grid-area: visual;
    max-width: none;
    height: auto;
    /* 3:2 of a 350px-tall source: at 600px wide the loop is scaled 1.14x. */
    aspect-ratio: 3 / 2;
    margin: 0;
  }
  .hero-visual::before { inset: 16px -16px -16px 16px; border-radius: 28px; }
  .hero-media { border-radius: 24px; }
  .hero-caption { left: 16px; right: 16px; bottom: 16px; }
  .hero-caption p { font-size: 0.85rem; padding: 8px 14px; }
  .wordmark { font-size: min(7.25rem, 8vw); }
  .hero .s1 { top: 18%; right: auto; left: 46%; }
  .hero .s2 { bottom: 12%; right: auto; left: 3%; }
  .hero .s3 { display: block; top: auto; bottom: 6%; left: 50%; }
}

/* ---------- Preview chapter ---------- */

.preview {
  padding: var(--chapter-pad) var(--edge);
  background: none;
}
.preview-inner {
  max-width: none;
  gap: 28px;
}
.preview-head .section-lede { margin-top: 12px; }
.preview-more {
  grid-area: more;
  min-width: 0;
}
.library-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(143, 227, 214, 0.45);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}
.library-link:hover { color: var(--teal-strong); text-decoration-color: var(--teal); }
.library-link .arrow { width: 14px; height: 14px; }

@media (max-width: 879px) {
  .stage-caption { max-width: 320px; margin-inline: auto; }
}
@media (min-width: 880px) {
  .preview-inner {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    grid-template-areas: "stage head" "stage why" "stage more";
    grid-template-rows: auto auto 1fr;
    column-gap: clamp(48px, 7vw, 112px);
    row-gap: 26px;
  }
  .preview-head,
  .preview-why,
  .preview-more { max-width: 34rem; }
  .preview-head { padding-top: 8px; }
}

/* ---------- About chapter ---------- */

.about {
  overflow-x: clip;
  gap: clamp(48px, 6vw, 96px);
  padding: var(--chapter-pad) var(--edge) calc(var(--chapter-pad) + 12px);
}
.about-media { max-width: 460px; }
.about-photo img {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 24px;
}
.about-copy > p { max-width: 30em; }

/* The real Ghost, pinned to the illustration like a print. */
.ghost-print {
  position: absolute;
  right: -4px;
  bottom: -30px;
  display: block;
  width: clamp(104px, 30%, 148px);
  padding: 7px 7px 0;
  border-radius: 6px;
  background: var(--cream);
  color: var(--night);
  text-decoration: none;
  transform: rotate(4deg);
  box-shadow: 0 22px 44px -18px rgba(0, 0, 0, 0.85);
  transition: transform 0.25s var(--ease);
}
.ghost-print:hover { transform: rotate(2deg) translateY(-3px); }
.ghost-print-img {
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 3px;
}
.ghost-print img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 40% 66%;
  transform: scale(1.3);
  transform-origin: 40% 66%;
}
.ghost-print-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1;
}
.ghost-print-label .arrow { width: 12px; height: 12px; }
.ghost-print:focus-visible { outline-offset: 4px; }

/* Ghost line: a pull quote, not a boxed panel. */
.copilot {
  display: block;
  margin-top: 26px;
  padding: 2px 0 2px 20px;
  border: 0;
  border-left: 2px solid var(--teal);
  border-radius: 0;
  background: none;
  box-shadow: none;
  max-width: 30em;
}
.about-copy .copilot-line {
  margin: 0;
  font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.45rem);
}
.rules-details { margin-top: 26px; max-width: 30em; }

@media (min-width: 880px) {
  .about { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .about-media { margin-inline: 0; }
  .ghost-print { right: -28px; bottom: -32px; }
}

/* ---------- Closing + footer ---------- */

.footer {
  padding: var(--chapter-pad) var(--edge) max(28px, env(safe-area-inset-bottom));
  border-top: 0;
  background:
    radial-gradient(60% 70% at 85% 0%, rgba(64, 196, 186, 0.1), transparent 70%),
    var(--deep);
}
.closing {
  display: grid;
  gap: 24px 64px;
  align-items: end;
}
.closing .footer-title {
  font-size: clamp(2.3rem, 1.5rem + 3.4vw, 4.1rem);
  line-height: 1;
}
.closing .footer-lede {
  margin-top: 14px;
  max-width: 28em;
  color: var(--muted);
  font-size: 1.05rem;
}
.closing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
}
.closing-actions .btn { min-height: 54px; padding: 0 28px; font-size: 1.05rem; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 40px;
  margin-top: clamp(36px, 5vw, 56px);
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.footer-links-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 18px;
}
.footer-links-label {
  color: var(--faint);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--cream);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
}
.footer-links a:hover { color: var(--teal-strong); }
.footer-links .icon { width: 16px; height: 16px; fill: currentColor; flex: none; }
.footer-base {
  margin-top: 8px;
  padding-top: 14px;
  font-size: 0.82rem;
}

@media (min-width: 880px) {
  .closing { grid-template-columns: minmax(0, 1fr) auto; }
  .closing-actions { justify-content: flex-end; padding-bottom: 6px; }
}
@media (max-width: 479px) {
  .closing-actions .btn { flex: 1 1 100%; }
  .footer-links { gap: 4px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .ghost-print, .ghost-print:hover { transition: none; }
}
