/* ==========================================================================
   front.css — the front page at relaaay.online (#front-page in index.html).

   Built entirely from the app's own theme tokens (app.css), so it wears
   whichever theme it is given: the device's light or dark by default, and
   the one a visitor picks in "Make it yours". Themes are scoped to any
   element, which is also how the example chats each wear their own.
   Every class here starts with fp- so nothing leaks into the app.
   ========================================================================== */

/* Before the modules load, entry.js's attribute is all there is: show the
   front page and keep the sign-in form out of sight, so a new visitor never
   sees it flash first. front.js sets the real hidden attributes after that. */
html[data-entry="front"] #auth-screen { display: none !important; }
html[data-entry="front"] #front-page[hidden] { display: block !important; }

/* The theme a visitor picks lives on #front-page and #auth-screen, not the
   document. front.js copies the picked background into --fp-canvas, and the
   page's background is painted here, on the document, rather than on
   #front-page itself (see below). Nothing behind the page, in an overscroll
   bounce or round the browser's own bars, shows the old theme either. */
html[data-entry] body { background: var(--fp-canvas, var(--bg)); }

.front-page {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  /* No background (and no colour transition) on this scroller: the document
     behind it carries the picked colour (--fp-canvas above). With GPU
     compositing, Brave and Chrome could keep painting a scroller's own
     background in the previous pick's colour while everything on it changed. */
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
}
.front-page h2, .front-page h3 { color: var(--text); }

/* ---------- Top bar ---------- */
.fp-nav {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  padding-top: max(0.75rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
[data-reduce-transparency="true"] .fp-nav { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
.fp-logo {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--text); text-decoration: none;
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em;
}
.fp-nav-actions { display: flex; gap: 0.5rem; }
.fp-nav-signin { border-color: transparent; background: transparent; }

/* ---------- Hero ---------- */
.fp-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 4rem);
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 5.5rem) clamp(1rem, 4vw, 2.5rem) clamp(2rem, 5vw, 4rem);
  position: relative;
}
.fp-hero::before {
  content: "";
  position: absolute; inset: -6rem -20vw auto 30%;
  height: 34rem;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 22%, transparent), transparent);
  pointer-events: none;
  z-index: 0;
}
.fp-hero > * { position: relative; z-index: 1; }
.fp-eyebrow {
  display: inline-block;
  font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-soft-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  margin-bottom: 1rem;
}
.fp-title {
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
}
.fp-title:focus { outline: none; }
.fp-lead {
  margin-top: 1.1rem;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.6;
  color: var(--text-2);
  max-width: 34rem;
}
.fp-ctas { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.btn.fp-big { min-height: 3rem; padding: 0.7rem 1.4rem; font-size: 1.0625rem; font-weight: 600; border-radius: var(--radius-m); }
.fp-note {
  display: flex; align-items: center; gap: 0.5rem;
  margin-top: 1.25rem;
  color: var(--text-2); font-size: 0.9375rem;
}
.fp-note .icon { color: var(--accent); }

/* Three example chats, fanned out. */
.fp-hero-art {
  position: relative;
  height: 25rem;
  display: flex; align-items: center; justify-content: center;
}
.fp-hero-art .fp-chat { position: absolute; width: min(16.5rem, 62%); }
.fp-tilt-l { transform: translate(-56%, -1.5rem) rotate(-7deg); }
.fp-tilt-r { transform: translate(56%, -1.5rem) rotate(7deg); }
.fp-front { transform: translateY(2.25rem); z-index: 2; }

/* ---------- An example chat ----------
   Reads the bubble and surface colours of whichever theme it is wearing. */
.fp-chat {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  font-size: 0.875rem;
  text-align: start;
}
.fp-chat-head {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.fp-av {
  display: inline-grid; place-items: center;
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  font-size: 0.75rem; font-weight: 700;
}
.fp-chat-name { font-weight: 600; flex: 1; }
.fp-dot-online { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--online); }
.fp-chat-body { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.85rem 0.75rem; }
.fp-b {
  max-width: 85%;
  padding: var(--pad-bubble-y, 0.5rem) var(--pad-bubble-x, 0.75rem);
  border-radius: var(--radius-l);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.fp-b.in { align-self: flex-start; background: var(--bubble-in-bg); color: var(--bubble-in-text); border-bottom-left-radius: var(--radius-s); }
.fp-b.out { align-self: flex-end; background: var(--bubble-out-bg); color: var(--bubble-out-text); border-bottom-right-radius: var(--radius-s); }
[data-theme^="contrast-"] .fp-b { border: 2px solid var(--border); }
[data-theme^="mono-"] .fp-b.in { border: 1px solid var(--border-strong); }
.fp-chat-foot {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.fp-input {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  color: var(--text-3);
  background: var(--bg);
}
.fp-send {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
}

/* ---------- Sections ---------- */
.fp-section {
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1rem, 4vw, 2.5rem);
}
.fp-section-head { max-width: 40rem; margin-bottom: 2rem; }
.fp-section-head h2, .fp-final h2, .fp-everyone h2 {
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.fp-section-head p { margin-top: 0.75rem; color: var(--text-2); font-size: 1.0625rem; line-height: 1.6; }
.fp-hint { color: var(--text-2); font-size: 0.875rem; margin-top: 0.6rem; }
.fp-center { text-align: center; justify-content: center; }

/* ---------- Make it yours ---------- */
.fp-studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
.fp-controls {
  display: flex; flex-direction: column; gap: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: clamp(1.1rem, 3vw, 1.75rem);
  box-shadow: var(--shadow-1);
}
.fp-control { border: 0; padding: 0; min-width: 0; }
.fp-control legend, .fp-label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
  width: 100%;
  font-weight: 700; font-size: 0.9375rem;
  margin-bottom: 0.6rem;
  padding: 0;
}
.fp-out { font-weight: 500; color: var(--text-2); font-size: 0.875rem; }

/* Swatches: each dot wears its own theme, so it shows that theme's colours. */
.fp-swatches { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.fp-swatch { position: relative; display: inline-flex; cursor: pointer; }
.fp-swatch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.fp-dot {
  display: block;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--bg) 0 48%, var(--accent) 52% 100%);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: transform 0.12s ease;
}
.fp-swatch:hover .fp-dot { transform: scale(1.08); }
.fp-swatch input:checked + .fp-dot {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}
.fp-swatch input:focus-visible + .fp-dot { outline: 3px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 6px var(--focus-halo); }

/* Segmented choices: Light/Dark and the fonts. */
.fp-seg { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; background: var(--sunken); border-radius: var(--radius-m); padding: 0.25rem; }
.fp-seg label { position: relative; display: inline-flex; }
.fp-seg input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.fp-seg span {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-s);
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-2);
}
.fp-seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); font-weight: 600; }
.fp-seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.fp-control input[type="range"] { width: 100%; accent-color: var(--accent); }

.fp-tones { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.fp-tone {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.8rem 0.35rem 0.6rem;
  font-size: 0.875rem; font-weight: 500;
}
.fp-tone .icon { color: var(--accent); fill: currentColor; }
.fp-tone:hover { background: var(--accent-soft); color: var(--accent-soft-text); border-color: var(--accent); }
.fp-tone[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fp-tone[aria-pressed="true"] .icon { color: var(--on-accent); }

/* The live preview: font and size apply here only. */
.fp-preview-wrap { position: sticky; top: 5rem; }
.fp-preview { font-family: var(--font-body); font-size: calc(0.9375rem * var(--fp-scale, 1)); }
.fp-preview .fp-chat-body { min-height: 15rem; padding: 1.1rem 1rem; gap: 0.5rem; }
.fp-preview .fp-av { width: 2rem; height: 2rem; font-size: 0.8125rem; }
.fp-b.fp-ping { animation: fp-ping 0.6s ease; }
@keyframes fp-ping {
  0% { transform: scale(1); }
  35% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------- Features ---------- */
.fp-features {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.fp-features li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 1.25rem;
}
.fp-features .icon {
  width: 2.5rem; height: 2.5rem; padding: 0.55rem;
  border-radius: var(--radius-m);
  background: var(--accent-soft); color: var(--accent-soft-text);
  margin-bottom: 0.85rem;
}
.fp-features h3 { font-size: 1.0625rem; margin-bottom: 0.35rem; }
.fp-features p { color: var(--text-2); font-size: 0.9375rem; line-height: 1.55; }

/* ---------- Comfortable for everyone ---------- */
.fp-everyone { padding-top: 0; padding-bottom: 0; }
.fp-everyone-card {
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  border-radius: calc(var(--radius-l) * 1.5);
  padding: clamp(1.5rem, 4vw, 2.75rem);
}
.fp-everyone-card h2 { color: inherit; }
.fp-everyone-card p { margin-top: 0.75rem; font-size: 1.0625rem; line-height: 1.6; max-width: 46rem; }

/* ---------- Last call ---------- */
.fp-final { text-align: center; }
.fp-final .fp-ctas { justify-content: center; }
.fp-play { margin-top: 1.25rem; }
.fp-play-badge { display: inline-block; border-radius: 6px; line-height: 0; }
.fp-play-badge img { display: block; width: 162px; height: auto; }
.fp-play-badge:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---------- Footer ---------- */
.fp-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 72rem; margin: 0 auto;
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem) max(2rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.875rem;
}
.fp-logo-sm { font-size: 1rem; color: var(--text-2); }
.fp-footer nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.fp-footer a { color: var(--text-2); }
.fp-footer a:hover { color: var(--accent); }

/* ---------- The sign-in card's way back ---------- */
.auth-home { align-self: center; font-size: 0.9375rem; }

/* ---------- Narrow screens ---------- */
@media (max-width: 900px) {
  .fp-hero, .fp-studio-grid { grid-template-columns: minmax(0, 1fr); }
  /* Full width here, so its edge is the screen's: the glow and the fanned
     chats reach past it, and must never make the page scroll sideways. */
  .fp-hero { text-align: center; overflow-x: hidden; overflow-x: clip; }
  .fp-lead { margin-inline: auto; }
  .fp-ctas, .fp-note { justify-content: center; }
  .fp-note { display: block; }
  .fp-note .icon { display: inline-block; vertical-align: -0.15em; margin-right: 0.3rem; }
  .fp-hero-art { height: 21rem; }
  /* The example chat rides along above the controls, so a font or size
     picked further down shows straight away. */
  .fp-preview-wrap { order: -1; top: 4.25rem; z-index: 2; }
  /* …and a control that gets focus is scrolled clear of it, not under it. */
  .fp-controls :is(input, button) { scroll-margin-top: 20rem; }
  .fp-preview-wrap .fp-hint { display: none; }
  .fp-preview .fp-b:nth-child(-n+2) { display: none; }
  .fp-preview .fp-chat-body { min-height: 0; }
  .fp-features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .fp-features { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
  .fp-features li { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 0.85rem; padding: 1rem; }
  .fp-features .icon { grid-row: span 2; margin-bottom: 0; }
}
@media (max-width: 480px) {
  .fp-hero-art { height: 18rem; }
  .fp-hero-art .fp-chat { width: 13.5rem; font-size: 0.8125rem; }
  .fp-tilt-l { transform: translate(-34%, -1.25rem) rotate(-7deg); }
  .fp-tilt-r { transform: translate(34%, -1.25rem) rotate(7deg); }
  .fp-ctas .btn { flex: 1 1 100%; }
  .fp-footer { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 380px) {
  .fp-nav-actions .btn.primary { display: none; }
}

/* A theme picked on the front page carries on to the sign-in card, which
   otherwise shows the page behind it. */
.auth-screen[data-theme] { background: var(--bg); color: var(--text); }
