/* ===========================================================
   GARDEN STREET GAMES — Play with friends (pages/friends.html)
   js/friends.js fills it from the registry. Depends on tokens.css,
   pages.css (.wrap, .btn, .btn--accent) and fx.css (.plat-grid,
   .page-hero__eyebrow). It was a home page section for a day (2026-11-29);
   founder, 2026-11-30: too much scrolling there, so it got its own tab.
   No hardcoded colors below this line.
   =========================================================== */

.friends {
  position: relative;
  padding: var(--s-7) 0 var(--s-8);
  overflow: hidden;
  isolation: isolate;
}
.friends[hidden] { display: none; }
/* A little light from the top corner, green on one side and the sunset on the other: P1 and P2. */
.friends::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 88% 8%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(ellipse 50% 40% at 4% 92%, color-mix(in srgb, var(--amber) 9%, transparent), transparent 70%);
}

/* Phones: the title, the versus screen, then how it works. Wide: words left, screen right. */
.friends__top {
  display: grid;
  gap: var(--s-6);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "arena" "how";
}
@media (min-width: 900px) {
  .friends__top {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "head arena" "how arena";
    column-gap: var(--s-8);
    row-gap: var(--s-5);
    align-items: start;
  }
}
.friends__head { grid-area: head; }
.friends__arena { grid-area: arena; width: 100%; max-width: 36rem; justify-self: center; }
.friends__how { grid-area: how; }
@media (min-width: 900px) { .friends__arena { justify-self: end; } }

.friends__title {
  font-family: var(--font-display); font-weight: 400;
  letter-spacing: var(--tracking-display); text-transform: uppercase;
  line-height: 0.92;
  font-size: var(--fs-billboard);
  margin: 0 0 var(--s-5);
}
.friends__title .line { display: block; }
.friends__title .accent { color: var(--accent); }
.friends__title .outline {
  color: transparent;
  -webkit-text-stroke: 2px var(--text);
  paint-order: stroke fill;
}
.friends__lede {
  font-size: var(--fs-md);
  color: var(--text-muted);
  max-width: 46ch;
  margin: 0;
}

/* ---- How it works: three steps, big numbers ---- */
.friends__steps {
  list-style: none; margin: 0 0 var(--s-5); padding: 0;
  counter-reset: step;
  display: grid; gap: var(--s-4);
}
.friends__steps li {
  counter-increment: step;
  display: grid; grid-template-columns: auto 1fr; column-gap: var(--s-4);
  align-items: baseline;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.friends__steps li::before {
  content: counter(step, decimal-leading-zero);
  grid-row: span 2;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--accent);
}
.friends__steps b {
  display: block;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 700;
}
.friends__perks {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: var(--s-2);
}
.friends__perks li {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border: var(--hairline); border-radius: var(--radius);
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
}
.friends__perks li::before {
  content: ""; width: 0.5em; height: 0.5em; flex: none;
  background: var(--accent); border-radius: var(--radius);
}

/* ================= THE VERSUS SCREEN =================
   A screen (dark by day too, .screen-scope). Square, so the phones can turn
   between upright side by side (.is-up) and sideways stacked (.is-side)
   inside the same box: each layout is the other turned a quarter. */
.vs {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--screen);
  border-radius: var(--radius-lg);
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 30px 60px -30px var(--shadow-strong);
}
.vs__bg { position: absolute; inset: 0; z-index: -2; }
.vs__bg img {
  position: absolute; inset: -12%;
  width: 124%; height: 124%; max-width: none;
  object-fit: cover;
  filter: var(--vs-bg-filter);
}
.lite .vs__bg img { filter: none; opacity: 0.22; }
.vs .plat-grid { z-index: -1; opacity: 0.7; }
/* P1's green and P2's sunset, split on the diagonal like a fight card. */
.vs::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(115deg,
    color-mix(in srgb, var(--accent) 20%, transparent) 0%,
    color-mix(in srgb, var(--accent) 4%, transparent) 49.6%,
    color-mix(in srgb, var(--amber) 4%, transparent) 50.4%,
    color-mix(in srgb, var(--amber) 22%, transparent) 100%);
}
.vs::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  box-shadow: inset 0 0 var(--s-8) color-mix(in srgb, var(--screen) 80%, transparent);
}

.vs__pair { position: absolute; inset: 0; }
.vs__phone {
  position: absolute;
  padding: var(--s-2);
  background: var(--phone-body);
  border-radius: var(--radius-phone);
  box-shadow:
    0 0 0 1px var(--phone-edge),
    0 24px 40px -16px var(--shadow-strong);
  transition:
    top var(--dur-slow) var(--ease-in-out), left var(--dur-slow) var(--ease-in-out),
    width var(--dur-slow) var(--ease-in-out), height var(--dur-slow) var(--ease-in-out),
    rotate var(--dur-slow) var(--ease-in-out);
}
/* Upright, side by side: 37% wide and 9:19.5 tall (80.2% of the square). */
.vs__pair.is-up .vs__phone { top: 11%; width: 37%; height: 80.2%; }
.vs__pair.is-up .vs__phone--p1 { left: 7%;  rotate: -4deg; }
.vs__pair.is-up .vs__phone--p2 { left: 56%; rotate: 4deg; }
/* Sideways, one above the other: the same phones turned a quarter. */
.vs__pair.is-side .vs__phone { left: 9.9%; width: 80.2%; height: 37%; }
.vs__pair.is-side .vs__phone--p1 { top: 7%;  rotate: -2deg; }
.vs__pair.is-side .vs__phone--p2 { top: 56%; rotate: 2deg; }

.vs__screen {
  position: relative;
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--screen);
  border-radius: calc(var(--radius-phone) - var(--s-2));
}
.vs__still, .vs__clip {
  position: absolute; inset: 0;
  width: 100%; height: 100%; max-width: none;
  object-fit: cover;
}
.vs__clip { opacity: 0; transition: opacity var(--dur) var(--ease-out); }
.vs__clip.is-on { opacity: 1; }
/* The cut between games: both screens go dark under the slam, then the new game comes up. */
.vs__screen::after {
  content: ""; position: absolute; inset: 0;
  background: var(--screen);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}
.vs.is-swapping .vs__screen::after { opacity: 1; transition-duration: var(--dur-fast); }

/* P1 / P2 stickers on each phone's corner. */
.vs__tag {
  position: absolute; z-index: 1;
  top: calc(var(--s-3) * -1); left: var(--s-4);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--radius);
  font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 14px -6px var(--shadow-strong);
}
.vs__tag b { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.02em; margin-right: var(--s-1); }
.vs__phone--p2 .vs__tag { background: var(--amber); color: var(--screen); }

/* The VS, slammed down between them. */
.vs__mark {
  position: absolute; left: 50%; top: 50%; z-index: 2;
  translate: -50% -50%;
  transform: skewX(-8deg);
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 13vw, 7.5rem);
  line-height: 1;
  color: var(--accent);
  -webkit-text-stroke: 4px var(--screen);
  paint-order: stroke fill;
  text-shadow: 0 0 var(--s-6) color-mix(in srgb, var(--accent) 55%, transparent);
  pointer-events: none;
}
@media (min-width: 900px) { .vs__mark { font-size: clamp(3.5rem, 7vw, 7.5rem); } }
.vs__mark.is-slam { animation: vs-slam var(--dur-slam) var(--ease-out) both; }
@keyframes vs-slam {
  0%   { scale: 2.4; opacity: 0; }
  55%  { scale: 0.9; opacity: 1; }
  75%  { scale: 1.06; }
  100% { scale: 1; }
}
.vs.is-swapping .vs__pair { animation: vs-shake var(--dur-slam) linear; }
@keyframes vs-shake {
  0%, 100% { translate: 0 0; }
  20% { translate: -1% 0.6%; }
  40% { translate: 1% -0.6%; }
  60% { translate: -0.5% 0.3%; }
  80% { translate: 0.4% 0; }
}

/* ---- The invite, as the text you'd send. Overlaps the screen's foot. ---- */
.vs-text {
  position: relative; z-index: 4;
  display: flex; flex-direction: column; align-items: flex-end;
  margin: calc(var(--s-6) * -1) var(--s-3) 0 var(--s-7);
}
.vs-text__bubble {
  margin: 0;
  max-width: 26rem;
  padding: var(--s-3) var(--s-4);
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius) var(--radius-bubble);
  font-size: var(--fs-md); font-weight: 600; line-height: 1.3;
  box-shadow: 0 16px 30px -14px var(--shadow-strong);
}
.vs-text__meta {
  margin: var(--s-1) var(--s-1) 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.vs-text.is-in .vs-text__bubble { animation: vs-bubble var(--dur-slow) var(--ease-out) both; }
@keyframes vs-bubble {
  from { opacity: 0; translate: 0 var(--s-4); scale: 0.94; }
  to   { opacity: 1; translate: 0 0; scale: 1; }
}

/* ---- Under it: which game, and the button for it ---- */
.vs-now {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: var(--hairline);
}
.vs-now__what { display: grid; gap: var(--s-1); min-width: 0; }
.vs-now__label {
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--text-faint);
}
.vs-now__game {
  font-family: var(--font-display); font-size: var(--fs-lg);
  text-transform: uppercase; letter-spacing: var(--tracking-display);
  line-height: 1;
}
.vs-now__mode { font-size: var(--fs-sm); color: var(--text-muted); }
.vs-now__do { display: flex; align-items: center; gap: var(--s-2); }
.vs-now__do .btn { text-decoration: none; padding: var(--s-3) var(--s-6); }
.vs-now__pause {
  display: inline-grid; place-items: center;
  width: var(--s-7); height: var(--s-7);
  background: transparent; color: var(--text);
  border: var(--hairline); border-radius: var(--radius);
  font-size: var(--fs-xs); cursor: pointer;
}
.vs-now__pause:hover { border-color: var(--text); }
.vs-now__pause[hidden] { display: none; }

/* ================= THE PICKS ================= */
.friends__picks { margin-top: var(--s-8); }
.friends__pick-title {
  font-family: var(--font-display); font-weight: 400;
  letter-spacing: var(--tracking-display); text-transform: uppercase;
  line-height: 0.92;
  font-size: var(--fs-lg);
  margin: 0 0 var(--s-5);
}
.friends__games {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 900px) {
  .friends__games { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--s-5); }
}
.fgame {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: var(--hairline); border-radius: var(--radius-lg);
  overflow: hidden;
  transition: translate var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.fgame:hover, .fgame:focus-within { border-color: var(--accent); translate: 0 calc(var(--s-1) * -1); }
.fgame__art { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--screen); }
.fgame__art img { width: 100%; height: 100%; object-fit: cover; }
.fgame__chip {
  position: absolute; top: var(--s-2); right: var(--s-2);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-display); font-size: var(--fs-sm);
  letter-spacing: 0.04em; text-transform: uppercase; line-height: 1;
}
.fgame__body {
  flex: 1;
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-3) var(--s-4) var(--s-4);
}
.fgame__mode {
  margin: 0;
  font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--accent);
}
.fgame__line {
  flex: 1; margin: 0 0 var(--s-2);
  font-size: var(--fs-sm); line-height: 1.4;
  color: var(--text-muted);
}
.fgame__go { display: flex; justify-content: center; text-align: center; text-decoration: none; padding: var(--s-3) var(--s-4); }
@media (max-width: 560px) {
  .fgame__body { padding: var(--s-3); }
  .fgame__go { padding: var(--s-3) var(--s-2); font-size: var(--fs-xs); letter-spacing: 0.06em; }
  .fgame__line { font-size: var(--fs-xs); }
}
.friends__note { margin: var(--s-5) 0 0; font-size: var(--fs-sm); color: var(--text-faint); }

/* ---- Day: white cards with soft shadows, like the rest of the page ---- */
[data-theme="day"] .fgame { box-shadow: 0 10px 28px -16px var(--shadow-strong); }

@media (prefers-reduced-motion: reduce) {
  .vs__phone, .fgame { transition: none; }
  .vs.is-swapping .vs__pair { animation: none; }
}
