/* ============================================================
   Project page layout (Magical Ferry, Friend Forest, Koddi,
   Yaoguai Prom). Uses the tokens and components in lg-system.css;
   each page adds only what is particular to it, such as the column
   ratios of its clip pairs.
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--ui-bg-page); color: var(--ui-text-body); font-family: var(--ui-font-body); }
a { color: var(--ui-text); }
main a, .sub a { text-underline-offset: 3px; }
main a:not(.cta):not(.ui-btn):not(.btn):not(.lg-btn):hover,
.sub a:hover { text-decoration-thickness: 2px; text-decoration-color: currentColor; }
main a:not(.cta):not(.ui-btn):not(.btn):not(.lg-btn):active,
.sub a:active { background: var(--ui-bg-muted); }

header.hero { text-align: center; padding: 48px 20px 8px; position: relative; }
header.hero h1 {
  font-family: var(--ui-font-display); font-weight: 400; font-size: var(--ui-h1);
  line-height: 1.05; color: var(--ui-text); text-wrap: balance;
}
.sub { max-width: 700px; margin: 12px auto 0; color: var(--ui-text-muted); line-height: 1.6; font-size: var(--ui-text-lg); }
.sub a { font-weight: 500; }

main { max-width: 720px; margin: 0 auto; padding: 0 20px 20px; }
section { margin-top: 72px; }
main h2 {
  font-family: var(--ui-font-display); font-weight: 400; font-size: var(--ui-h2);
  line-height: 1.1; color: var(--ui-text); margin-bottom: 16px; text-wrap: balance;
}
main h3 {
  font-family: var(--ui-font-display); font-weight: 400; font-size: var(--ui-h4);
  line-height: 1.15; color: var(--ui-text); margin: 40px 0 10px;
}
main p { line-height: 1.7; font-size: var(--ui-text-base); margin-bottom: 16px; max-width: 68ch; }
main ul, main ol { margin: 0 0 16px 20px; }
main li { line-height: 1.7; font-size: var(--ui-text-base); margin-bottom: 8px; }
main li b, main p b { font-weight: 600; color: var(--ui-text); }
@media (min-width: 1440px) { main p, main li { font-size: 18px; } }
.small { font-size: var(--ui-text-sm); color: var(--ui-text-muted); }

/* ---- figures ---- */
figure { margin: 24px 0; }
figure.phone { max-width: 360px; margin-left: auto; margin-right: auto; }
figure img, figure video { display: block; width: 100%; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); }
figcaption { font-size: var(--ui-text-sm); color: var(--ui-text-muted); margin-top: 10px; line-height: 1.5; }
figure.plain img { image-rendering: auto; }

/* the opening visual, wider than the reading column */
.showcase { max-width: 1100px; margin: 28px auto 40px; padding: 0 20px; }
.showcase img, .showcase video { display: block; width: 100%; border: 1px solid var(--ui-border); border-radius: var(--ui-radius-lg); }
.showcase-cap { max-width: 800px; margin: 12px auto 0; font-size: var(--ui-text-sm); color: var(--ui-text-muted); line-height: 1.5; text-align: center; }

/* a.cta and .cta-wrap are the button component in lg-system.css */
@media (max-width: 480px) { a.cta { width: 100%; } }

/* before/after pairs stay side by side, because comparing is the point */
.ba { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0; }
.ba figure { margin: 0; }
@media (max-width: 560px) { .ba { grid-template-columns: 1fr; } }

/* two clips shown together; each page sets the column ratio so both land at
   the same height */
.pair { display: grid; gap: 16px; margin: 24px 0; align-items: start; }
.pair figure { position: static; margin: 0; }
.pair-even { grid-template-columns: 1fr 1fr; }

/* the short label above a figure in a pair: plain text, not a chip */
.ba .tag, .pair .tag {
  display: block; margin: 0 0 8px; padding: 0; border: 0; background: none;
  font-family: var(--ui-font-body); font-size: var(--ui-text-sm); font-weight: 600;
  color: var(--ui-text); letter-spacing: 0; text-transform: none;
}
.pair .tag { text-align: center; }

/* ---- tabs (the tabs component, with arrows over the picture) ---- */
.tabgroup { margin: 24px 0; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--ui-border); overflow-x: auto; }
.tabs button {
  font-family: var(--ui-font-body); font-size: var(--ui-text-sm); font-weight: 500;
  padding: 10px 0; cursor: pointer; background: none; color: var(--ui-text-muted);
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--ui-text); border-bottom-color: var(--ui-border-strong); }
.tabs button[aria-selected="true"] { color: var(--ui-text); border-bottom-color: var(--ui-text); }
.tabgroup figure { margin: 16px 0 0; }
.tabmedia { position: relative; }
.tabarrow {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 44px; height: 44px; border-radius: var(--ui-radius); cursor: pointer;
  border: 1px solid var(--ui-border-strong); background: var(--ui-bg);
  color: var(--ui-text); font-size: 24px; line-height: 1; padding: 0 0 3px;
  box-shadow: var(--ui-shadow-xs);
}
.tabarrow:hover { background: var(--ui-bg-subtle); }
.tabarrow.prev { left: 12px; }
.tabarrow.next { right: 12px; }

/* ---- code and tables ---- */
pre.code {
  background: var(--ui-bg-inverted); color: #e5e7eb; font-size: 14px; line-height: 1.6;
  padding: 16px 18px; overflow-x: auto; border: 0; border-radius: var(--ui-radius);
  margin: 24px 0; font-family: var(--ui-font-mono);
}
.codewrap { position: relative; margin: 24px 0; }
.codewrap pre.code { margin: 0; }
@media (max-width: 560px) {
  pre.code { font-size: 13px; }
  .codewrap::after {
    content: ''; position: absolute; top: 0; bottom: 0; right: 0; width: 34px;
    border-radius: 0 var(--ui-radius) var(--ui-radius) 0;
    background: linear-gradient(90deg, rgba(17, 24, 39, 0), rgba(17, 24, 39, 0.9));
    pointer-events: none;
  }
}
main table { width: 100%; border-collapse: collapse; font-size: var(--ui-text-sm); margin: 24px 0; }
main th, main td { border-bottom: 1px solid var(--ui-border); padding: 10px 12px; text-align: left; vertical-align: top; }
main th { background: var(--ui-bg-subtle); color: var(--ui-text); font-weight: 600; }
.scrollwrap { overflow-x: auto; }

/* ---- a row of numbers: plain figures with dividers, no boxes ---- */
.stats { display: flex; flex-wrap: wrap; justify-content: center; margin: 28px 0 8px; }
.stats div { padding: 4px 20px; font-size: var(--ui-text-sm); color: var(--ui-text-muted); text-align: center; border: 0; background: none; }
.stats div + div { border-left: 1px solid var(--ui-border); }
.stats b { display: block; font-family: var(--ui-font-display); font-weight: 400; font-size: 28px; line-height: 1.1; color: var(--ui-text); }

/* ---- lightbox: click any figure to see it full size ---- */
figure img, figure video, .showcase video, .showcase img { cursor: zoom-in; }
#lightbox[hidden] { display: none; }
#lightbox {
  position: fixed; inset: 0; z-index: 2000; display: none;
  background: rgba(17, 24, 39, 0.92); cursor: zoom-out;
  align-items: center; justify-content: center; padding: 3vmin;
}
#lightbox.open { display: flex; }
#lightbox img, #lightbox video { max-width: 96vw; max-height: 94vh; width: auto; height: auto; border-radius: var(--ui-radius); }
#lb-stage { display: flex; align-items: center; justify-content: center; max-width: 96vw; max-height: 94vh; }
#lb-close {
  position: fixed; top: 14px; right: 16px; z-index: 2; cursor: pointer;
  width: 44px; height: 44px; font-size: 26px; line-height: 1; padding: 0 0 4px;
  color: #fff; background: rgba(255, 255, 255, 0.12); border: 0; border-radius: var(--ui-radius);
}
#lb-close:hover { background: rgba(255, 255, 255, 0.24); }

/* the clips loop, so there is always a way to stop them */
#motion-toggle {
  position: fixed; right: 16px; bottom: 16px; z-index: 1200; cursor: pointer;
  min-height: 36px; padding: 0 12px; rotate: none;
  font-family: var(--ui-font-body); font-size: var(--ui-text-xs); font-weight: 500;
  letter-spacing: 0; text-transform: none;
  color: var(--ui-text); background: var(--ui-bg);
  border: 1px solid var(--ui-border-strong); border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow-xs);
}
#motion-toggle:hover { background: var(--ui-bg-subtle); color: var(--ui-text); rotate: none; }

footer { text-align: center; padding: 64px 20px 40px; color: var(--ui-text-muted); font-size: var(--ui-text-sm); }
footer a { color: var(--ui-text); text-decoration: none; font-weight: 500; display: inline-block; padding: 12px 6px; }
footer a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
footer a:active { background: var(--ui-bg-muted); }

/* On a wide screen the reading column stays a comfortable measure, and
   figures break out past it so screenshots are legible. Pages opt in with
   body.lg-breakout. */
@media (min-width: 1000px) {
  .lg-breakout main figure, .lg-breakout main .ba, .lg-breakout main .pair,
  .lg-breakout main .tabgroup, .lg-breakout main .codewrap, .lg-breakout main .scrollwrap {
    position: relative; left: 50%; transform: translateX(-50%);
    width: min(1000px, calc(100vw - 80px));
  }
  .lg-breakout main .ba figure, .lg-breakout main .pair figure, .lg-breakout main .tabgroup figure {
    position: static; left: auto; transform: none; width: auto;
  }
  .lg-breakout main figure.phone { position: static; left: auto; transform: none; width: auto; }
}
