/*
 * Landing page redesign layer - loaded last. Layout / sizing first; every animation sits inside
 * @media (prefers-reduced-motion: no-preference). Colours come from the existing theme variables (light + dark).
 */

/* ============================== layout: wide screens, zoom-out, footer at the bottom ============================== */
:root { --container: 1140px; --gutter: clamp(1rem, 4vw, 2rem); }
body.landing { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; overflow-x: clip; font-size: 15px; }
body.landing > header, body.landing > section, body.landing > div.first-screen, body.landing > footer { width: 100%; }
.site-footer { margin-top: auto; }
.hero, .stats-inner, .section, .safety-inner, .cta-band, .footer-inner { max-width: var(--container); }
.site-header { padding-inline: max(var(--gutter), calc((100% - var(--container)) / 2 + var(--gutter))); }
.hero { gap: clamp(28px, 5vw, 56px); }
/* ONE container for every landing section: same max width, same side padding, same left edge. */
.hero, .stats-inner, .section, .safety-inner, .cta-band, .footer-inner { box-sizing: border-box; width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.hero h1, body.landing .hero h1 { font-size: clamp(2rem, 1rem + 3.2vw, 3.25rem); line-height: 1.1; }
.hero-sub { font-size: clamp(1rem, 0.95rem + 0.4vw, 1.1rem); max-width: 40ch; }
.section-head h2 { font-size: clamp(1.7rem, 1.1rem + 1.8vw, 2.3rem); }
.cat-card h3, .step-card h3, .pillar h3 { font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem); }
.step-card p, .cat-card p, .pillar p, .safety-item { font-size: clamp(0.9rem, 0.85rem + 0.25vw, 1rem); }

/* Hero fills the first screen (capped at 900px so a tall / zoomed-out window never shows an empty band), content centred. */
@media (min-width: 861px) and (min-height: 560px) {
  .first-screen { min-height: min(calc(100dvh - var(--header-h)), 900px); }
  .first-screen .hero { flex: 1; align-content: center; }
  .first-screen .hero-art img { max-height: none; object-fit: cover; }
  #about, #how, #communities, #safety { min-height: min(calc(100dvh - var(--header-h)), 820px); }
}
.first-screen { width: 100%; }
.hero-art { width: 100%; min-width: 0; }

/* ============================== live stats ============================== */
.stats-inner { position: relative; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-block: clamp(22px, 3vw, 36px); }
.stat { min-width: 0; }
.stat b { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat span { font-size: clamp(0.75rem, 0.7rem + 0.2vw, 0.85rem); }
@media (max-width: 639px) { .stats-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 20px; padding-top: 34px; } }
.live-badge { position: absolute; top: 8px; right: var(--gutter); display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-ffffff-75); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd38d; box-shadow: 0 0 0 0 rgba(95, 211, 141, .6); }

/* ============================== mock community card (hero) ============================== */
.hero-art { position: relative; }
.mock-card { position: absolute; right: clamp(8px, 2vw, 20px); bottom: clamp(8px, 2vw, 20px); width: min(270px, 62%); padding: 14px 16px 14px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lift); color: var(--ink); font-size: 13px; }
.mock-tag { position: absolute; top: -10px; left: 14px; padding: 2px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--marigold); color: #fff; }
.mock-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mock-icon { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; background: var(--paper); box-shadow: 0 0 0 1px var(--line) inset; color: var(--plum); }
.mock-title { display: flex; flex-direction: column; min-width: 0; }
.mock-title b { font-family: var(--font-serif); color: var(--plum); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mock-title small { color: var(--ink-soft); font-size: 11.5px; }
.mock-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mock-badges span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--mint-soft); color: var(--sage); }
.mock-flow { list-style: none; display: grid; gap: 5px; margin: 0; padding: 0; font-size: 12px; color: var(--ink-soft); }
.mock-flow li { display: flex; align-items: center; gap: 8px; }
.mock-flow i { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; border: 2px solid var(--line); background: transparent; }
.mock-flow .done { color: var(--sage); font-weight: 600; }
.mock-flow .done i { background: var(--sage); border-color: var(--sage); }
.mock-flow .now { color: var(--plum); font-weight: 600; }
.mock-flow .now i { border-color: var(--marigold); background: var(--marigold); }
@media (max-width: 768px) {
  .mock-card { position: relative; right: auto; bottom: auto; width: calc(100% - 32px); max-width: 320px; margin: -28px 0 0 16px; }
}

/* ============================== topics: strip + card grid (last row centred) ============================== */
#communities { --gap: clamp(12px, 2vw, 24px); }
.lanes-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; margin-bottom: 3rem; border-radius: 20px; background: #DDD3BF; box-sizing: border-box; }
.lanes-strip .lane { aspect-ratio: 240 / 132; min-width: 0; border-radius: 14px; overflow: hidden; }
.lanes-strip .lane-a { background: #E9E4EC; }
.lanes-strip .lane-b { background: #F2F2F2; }
.lanes-strip svg { display: block; width: 100%; height: 100%; }
@media (min-width: 640px) { .lanes-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; padding: 24px; } }
.cat-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); width: 100%; }
.cat-card { box-sizing: border-box; min-width: 0; flex: 0 0 100%; overflow-wrap: anywhere; }
.cat-card h3, .cat-card p { overflow-wrap: anywhere; }
@media (min-width: 640px) { .cat-card { flex-basis: calc((100% - var(--gap)) / 2); } }
.cat-card { display: flex; flex-direction: column; }
/* Desktop: fixed 4 columns (no auto-fit), 26px gap, equal cards; titles reserve two lines so descriptions line up. Nothing changes above 1100px. */
@media (min-width: 1100px) { #communities { --gap: 26px; } .cat-card { flex-basis: calc((100% - 3 * var(--gap)) / 4); } .cat-card h3 { min-height: 2.6em; } }

/* ============================== how it works: badges on the card edge, a connector per card ============================== */
.how-head { display: flex; align-items: center; justify-content: space-between; gap: clamp(1rem, 3vw, 2rem); }
.how-head .section-head { flex: 1 1 auto; min-width: 0; }
.voices-art { width: clamp(110px, 16vw, 200px); margin: 0 0 34px; flex: 0 0 auto; }
@media (max-width: 767px) { .voices-art { display: none; } }
.steps { --gap: clamp(12px, 2vw, 24px); --badge: 36px; --p: 1; position: relative; display: grid; grid-template-columns: 1fr; gap: var(--gap); margin-top: 0; }
@media (min-width: 768px) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.steps::before { display: none !important; }
.step-card { position: relative; min-width: 0; margin-top: 1.75rem; overflow-wrap: anywhere; }
.step-num { position: absolute; top: 0; left: 1.25rem; transform: translateY(-50%); z-index: 2; margin: 0; width: var(--badge); height: var(--badge); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; line-height: 1; font-size: 15px; font-weight: 700; background: var(--marigold); color: var(--ink); box-shadow: 0 0 0 4px var(--paper); }
@media (min-width: 768px) {
  .step-card:not(:last-child)::after { content: ""; position: absolute; z-index: 1; top: 0; left: calc(1.25rem + var(--badge)); width: calc(100% + var(--gap) - var(--badge)); height: 3px; border-radius: 3px;
    background: linear-gradient(90deg, var(--marigold), var(--rose)); transform: translateY(-50%); pointer-events: none; }
}
/* ============================== safety strip ============================== */
.safety-item .check { display: inline-flex; width: 36px; height: 36px; border-radius: 12px; align-items: center; justify-content: center; background: var(--card); box-shadow: 0 0 0 1px var(--line) inset; color: var(--sage); }
.safety-item { align-items: center; gap: 14px; }

/* ============================== background shapes ============================== */
.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .22; }
.blob.b1 { width: 46vmax; height: 46vmax; left: -14vmax; top: -10vmax; background: var(--plum-soft); }
.blob.b2 { width: 40vmax; height: 40vmax; right: -12vmax; top: 22vh; background: var(--marigold); opacity: .18; }
.blob.b3 { width: 34vmax; height: 34vmax; left: 30vw; bottom: -16vmax; background: var(--rose); opacity: .14; }
[data-theme="dark"] .blob { opacity: .26; }

/* ============================== interactivity ============================== */
.main-nav a.nav-link { position: relative; padding-block: 6px; }
.main-nav a.nav-link::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px; background: currentColor; transform: scaleX(0); transform-origin: left; }
.main-nav a.nav-link:hover::after, .main-nav a.nav-link:focus-visible::after { transform: scaleX(1); }
.site-header.scrolled { box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.btn:focus-visible, .step-card:focus-within, .cat-card:focus-within { outline: 3px solid var(--plum); outline-offset: 3px; }
.site-header .btn:focus-visible { outline-color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .btn { transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease; }
  .btn:hover { transform: translateY(-2px); box-shadow: 0 10px 22px var(--sh-d9694e-25); }
  .step-card, .cat-card, .pillar, .mock-card { transition: transform .18s ease, box-shadow .18s ease, opacity .6s ease, translate .6s var(--ease-out); }
  .step-card:hover, .cat-card:hover { transform: translateY(-4px); box-shadow: 0 16px 36px var(--sh-573258-12), 0 0 0 1px var(--line); }
  .cat-icon { transition: transform .2s ease; }
  .cat-card:hover .cat-icon { transform: scale(1.12) rotate(-6deg); }
  .main-nav a.nav-link::after { transition: transform .22s ease; }
  .site-header { transition: box-shadow .2s ease; }

  /* scroll reveal: fade-up once, staggered 80ms; uses the independent `translate` property so hover transforms still work */
  .js [data-reveal] { opacity: 0; translate: 0 18px; transition: opacity .6s ease, translate .6s var(--ease-out); transition-delay: calc(var(--i, 0) * 80ms); }
  .js [data-reveal].in { opacity: 1; translate: 0 0; }
  .js [data-reveal].in.step-card, .js [data-reveal].in.cat-card { transition-delay: calc(var(--i, 0) * 80ms), calc(var(--i, 0) * 80ms), 0s, 0s; }

  /* step numbers pop in; the connecting line is driven by scroll (--p set from landing.js) */
  .js .step-card .step-num { scale: 0; transition: scale .45s cubic-bezier(.34, 1.56, .64, 1) calc(var(--i, 0) * 120ms + 150ms); }
  .js .step-card.in .step-num { scale: 1; }
  .js .steps { --p: 0; }

  /* hero art floats, example card drifts the other way; the nav lantern glows */
  .hero-art img { animation: lcFloat 7s ease-in-out infinite; }
  .mock-card { animation: lcFloat 6s ease-in-out -2s infinite reverse; }
  .site-header .brand { position: relative; }
  .site-header .brand::before { content: ""; position: absolute; left: -6px; top: 50%; width: 46px; height: 46px; margin-top: -23px; border-radius: 50%; pointer-events: none;
    background: radial-gradient(circle, rgba(246, 201, 185, .55), transparent 68%); animation: lcGlow 3.2s ease-in-out infinite; }
  .live-dot { animation: lcPing 1.8s ease-out infinite; }
  .blob.b1 { animation: lcDrift1 38s ease-in-out infinite alternate; }
  .blob.b2 { animation: lcDrift2 46s ease-in-out infinite alternate; }
  .blob.b3 { animation: lcDrift3 52s ease-in-out infinite alternate; }
}
@keyframes lcFloat { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }
@keyframes lcGlow { 0%, 100% { opacity: .35; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes lcPing { 0% { box-shadow: 0 0 0 0 rgba(95, 211, 141, .6); } 100% { box-shadow: 0 0 0 10px rgba(95, 211, 141, 0); } }
@keyframes lcDrift1 { to { transform: translate(8vw, 10vh) scale(1.08); } }
@keyframes lcDrift2 { to { transform: translate(-10vw, -6vh) scale(.94); } }
@keyframes lcDrift3 { to { transform: translate(6vw, -8vh) scale(1.1); } }

/* ============================== stats bar: compact, capped at every zoom / screen size ============================== */
.stats-strip .stats-inner { max-width: 1140px; margin-inline: auto; box-sizing: border-box; padding: clamp(1rem, 2.5vw, 1.5rem) clamp(1rem, 4vw, 2rem); gap: clamp(1rem, 3vw, 2rem); grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
.stats-strip .stat b { font-size: clamp(1.5rem, 2.5vw, 2rem); line-height: 1.1; }
.stats-strip .stat span { display: block; margin-top: .25rem; font-size: clamp(.75rem, 1vw, .875rem); }
.stats-strip .live-badge { top: .45rem; right: clamp(1rem, 4vw, 2rem); gap: 5px; font-size: .7rem; }
.stats-strip .live-dot { width: 8px; height: 8px; }
@media (max-width: 639px) {
  .stats-strip .stats-inner { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-block: 1.25rem .9rem; row-gap: .9rem; }
  .stats-strip .stat b { font-size: 1.5rem; }
}
/* anchors land below the sticky navbar; the active nav item is highlighted while its section is in view */
.main-nav a.nav-link.active { color: #fff; }
.main-nav a.nav-link.active::after { transform: scaleX(1); }
.mobile-nav a.nav-link.active { background: var(--paper); color: var(--plum); }
/* Jumping to Communities shows the strip + all topic cards right under the navbar (not centred in a tall section). */
#communities { justify-content: flex-start; padding-top: 1.25rem; padding-bottom: clamp(1.5rem, 4vh, 3rem); }

/* Stats bar: a compact band (~85px) */
.stats-strip .stats-inner { padding-block: 16px; padding-inline: clamp(1rem, 4vw, 2rem); gap: clamp(.75rem, 3vw, 2rem); align-items: center; }
.stats-strip .stat b { font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.1; }
.stats-strip .stat span { display: block; margin-top: 2px; font-size: .75rem; line-height: 1.2; }
.stats-strip .live-badge { top: 50%; right: clamp(.5rem, 1.5vw, 1rem); transform: translateY(-50%); }
@media (min-width: 640px) { .stats-strip .stats-inner { padding-right: clamp(3.5rem, 6vw, 4.5rem); } }
@media (max-width: 639px) { .stats-strip .stats-inner { padding-block: 14px 12px; row-gap: .6rem; } .stats-strip .live-badge { top: 6px; transform: none; right: 12px; } }
/* ============================== Topics section: anchor offset, one equal grid, no overlap ============================== */
#communities { padding-bottom: 64px; --gap: clamp(20px, 2vw, 24px); }

/* Topic cards: 12-column grid, 20px gap. Cards 1-4 span 3 columns, cards 5-7 span 4, so both rows end flush at the same left and right edges. */
.cat-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: 1fr; align-items: stretch; gap: 20px; width: 100%; justify-content: normal; }
.cat-card { grid-column: span 3; flex: none; width: auto; position: relative; z-index: 0; box-sizing: border-box; min-width: 0; padding: 24px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 10px; }
.cat-card:nth-child(n+5) { grid-column: span 4; }
.cat-card:hover, .cat-card:focus-within { z-index: 2; }
.cat-card h3, .cat-card p { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.cat-card p { flex: 0 0 auto; }
.cat-card h3 { min-height: 0; line-height: 1.3; }   /* 1.3 x 2 lines = the 2.6em reserved below, so descriptions line up exactly */
@media (min-width: 1001px) { .cat-card:nth-child(-n+4) h3 { min-height: 2.6em; } }   /* titles reserve two lines on the 4-across row only */
@media (max-width: 1000px) {
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat-card, .cat-card:nth-child(n+5) { grid-column: auto; }
  .cat-card:nth-child(7) { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .cat-grid { grid-template-columns: minmax(0, 1fr); }
  .cat-card:nth-child(7) { grid-column: auto; }
}.blobs, .blob { z-index: -1; pointer-events: none; }
/* Anchored sections: the offset comes only from html { scroll-padding-top: var(--nav-h) } (see responsive.css); each section brings its own top padding. */
section[id] { scroll-margin-top: 0; }
#about, #how, #communities, #safety { padding-top: clamp(48px, 8vw, 96px); }   /* id selectors: they must out-rank the older per-id rules in landing.css */
.lanes-wrap { max-width: var(--container); margin-inline: auto; width: 100%; padding: clamp(32px, 5vw, 56px) var(--gutter) 0; box-sizing: border-box; }
/* Reserve the Safety picture's height before the lazy image loads (width:auto + unloaded = 0px tall, so the page grew by ~600px mid-scroll and the Safety anchor stopped short). */
@media (max-width: 860px) { .safety-inner img { width: 100%; max-width: 420px; max-height: none; height: auto; aspect-ratio: 575 / 700; } }

/* Phones: the Live badge sits on its own line under the 2x2 numbers instead of floating over them. */
@media (max-width: 639px) { .stats-strip .live-badge { position: static; transform: none; grid-column: 1 / -1; justify-self: center; } }

/* "Find your topic" fits one screen on laptops/desktops (>=1000px wide, >=700px tall): heading + both card rows under the nav, nothing fixed-height.
   Smaller windows keep the natural, scrolling layout above. */
@media (min-width: 1000px) and (min-height: 700px) {
  #communities { min-height: calc(100dvh - var(--nav-h)); display: flex; flex-direction: column; justify-content: center; padding-block: clamp(16px, 3vh, 40px); }
  #communities .section-head { margin-bottom: clamp(12px, 2.5vh, 28px); }
  #communities .section-head h2 { font-size: clamp(1.6rem, 4vh, 2.4rem); margin-bottom: 0; }
  #communities .section-head .kicker { margin-bottom: 4px; }
  .cat-card { padding: clamp(14px, 2.2vh, 22px); gap: 8px; }
  .cat-icon { width: 40px; height: 40px; }
  .cat-card h3 { font-size: clamp(1rem, 2vh, 1.2rem); }
  .cat-card p { font-size: clamp(.8rem, 1.7vh, .95rem); line-height: 1.45; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
}
/* Signed-in header: avatar + name instead of Log in / Sign up */
.account-menu { position: relative; }
.account-menu > summary { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 14px 4px 5px; border-radius: 999px; cursor: pointer; list-style: none;
  color: #fff; font-weight: 700; background: var(--bg-ffffff-10); border: 1px solid var(--ln-ffffff-35); }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.account-avatar { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; background: var(--plum-solid); color: #fff; font-size: 14px; }
.account-name { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-card { position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--z-drawer); min-width: 200px; padding: 6px; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lift); }
.account-menu-card a, .account-menu-card button { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent;
  font: inherit; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer; }
.account-menu-card a:hover, .account-menu-card button:hover { background: var(--paper); color: var(--plum); }
.account-menu-card form { margin: 0; }

/* ============================== every section lands at the same height, top-aligned ============================== */
:root { --sec-top: clamp(44px, 6vh, 64px); }
#about, #how, #communities, #safety { justify-content: flex-start; padding-top: var(--sec-top); }
#about .split, #safety .safety-inner { align-items: start; }
#about .section-head, #how .section-head, #safety .section-head { margin-top: 0; }
#how .how-head { align-items: flex-start; }
#safety { padding-bottom: 32px; background: transparent; }   /* same soft page gradient as the sections above */
#safety .safety-inner { padding-top: 0; padding-bottom: 0; }
/* The Safety picture always fits on screen. Its width is explicit, so the height is reserved before the lazy image loads. */
#safety .safety-inner img { --pic-h: min(600px, calc(100vh - var(--nav-h) - var(--sec-top) - 32px)); width: min(100%, calc(var(--pic-h) * 575 / 700)); max-width: 100%; height: auto; max-height: none; aspect-ratio: 575 / 700; justify-self: center; }
@supports (height: 100dvh) { #safety .safety-inner img { --pic-h: min(600px, calc(100dvh - var(--nav-h) - var(--sec-top) - 32px)); } }
/* Tablets: the picture sits under the text, so it also leaves room for the heading and bullets above it. */
@media (min-width: 600px) and (max-width: 900px) and (min-height: 700px) { #safety .safety-inner img { --pic-h: min(520px, calc(100vh - var(--nav-h) - var(--sec-top) - 300px)); } }
