/* ════════════════════════════════════════════════════════════════
   RandWOD Website — community.css
   The COMMUNITY panel (#pc): WOD board + shared counter + marquee
   Uses the tokens already defined in css/style.css §01
   (--bg --bg2 --text --text-60/40/25 --line --line-strong
    --orange --blue --green --body --mono). Link this AFTER style.css.

   CONTENTS
   01 · Panel shell
   02 · Live ticker
   03 · Columns
   04 · Segmented toggle + board header
   05 · Board rows
   06 · Row expansion (top 3)
   07 · Shared counter
   08 · Marquee
   09 · WOD / result card
   10 · Responsive
   11 · Reduced motion
   ════════════════════════════════════════════════════════════════ */

/* ── 01 · PANEL SHELL ────────────────────────────────────────── */
/* .panel / .panel-inner / .chap / h2 / .panel-foot come from style.css.
   The marquee needs to bleed past the panel's 6vw padding, so the panel
   becomes a flex column and the marquee is pushed to the bottom. */
#pc { justify-content: flex-start; }
#pc .panel-inner { max-width: 1240px; }
.cm h2 { max-width: 1100px; }

/* ── 02 · LIVE TICKER ────────────────────────────────────────── */
.cm-ticker {
  margin-top: 18px; padding: 9px 0; display: flex; align-items: center; gap: 14px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; overflow: hidden;
}
.cm-now {
  flex: none; display: flex; align-items: center; gap: 7px;
  letter-spacing: 0.16em; color: var(--green);
}
.cm-now::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); animation: pulse 1.6s infinite;
}
.cm-ticker .cm-who { flex: none; color: var(--text); font-weight: 500; }
.cm-ticker .cm-what { color: var(--text-60); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-ticker .cm-what.pr { color: var(--orange); }
.cm-ticker .cm-val { flex: none; color: var(--blue); }
.cm-training { margin-left: auto; flex: none; letter-spacing: 0.16em; color: var(--text-25); }

/* ── 03 · COLUMNS ────────────────────────────────────────────── */
/* 2fr / 1fr: the board is the point of the panel, the counter is centred against it */
.cm-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 48px; margin-top: 20px; align-items: start; }
.cm-board { min-width: 0; }
.cm-side { align-self: center; min-width: 0; }

/* ── 04 · SEGMENTED TOGGLE + BOARD HEADER ────────────────────── */
/* capsule segmented control — mirrors the iOS control, thumb and all. The two
   labels differ in width, so community.js measures the active button and drives
   the thumb's width + translate; CSS owns only the easing. */
.cm-bar { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.cm-seg { position: relative; display: inline-flex; gap: 2px; padding: 3px; border-radius: 100px; background: rgba(242,240,235,0.08); }
.cm-seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 0; width: 0;
  border-radius: 100px; background: var(--orange); pointer-events: none;
}
/* .ready is added a frame after the first measure so the thumb doesn't slide
   in from zero width when the panel arrives */
.cm-seg.ready .cm-seg-thumb { transition: transform .34s cubic-bezier(.2,.8,.2,1), width .34s cubic-bezier(.2,.8,.2,1); }
.cm-seg-b {
  position: relative; z-index: 1;
  border: none; cursor: pointer; border-radius: 100px; padding: 8px 18px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  background: transparent; color: var(--text-60);
  transition: color .2s ease;
}
.cm-seg-b.on { color: #fff; font-weight: 700; }

.cm-dev {
  border: 1px dashed var(--text-25); border-radius: 4px; padding: 3px 9px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em;
  color: var(--text-40); white-space: nowrap;
}

/* 22px left inset on the header, every row and the expansion so the
   rank-01 accent bar never touches the "01" */
.cm-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 18px;
  margin-top: 14px; padding: 0 0 6px 22px; border-bottom: 1px dashed var(--line);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; color: var(--text-40);
}
.cm-head .cm-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-head .cm-unit { white-space: nowrap; color: var(--text-25); }
.cm-head .cm-unit em { font-style: normal; color: var(--text-40); }

/* ── 05 · BOARD ROWS ─────────────────────────────────────────── */
.cm-item {
  border-bottom: 1px solid var(--line);
  transition: opacity .4s ease, transform .28s cubic-bezier(.2,.8,.2,1), background .2s ease;
}
.cm-item.lead { box-shadow: inset 3px 0 0 var(--blue); }
.cm-item:hover { background: rgba(255,74,9,0.045); transform: translateX(6px) scale(1.008); }
.cm-item.open { background: rgba(242,240,235,0.035); }
/* toggle: .leaving clears the old rows, then .staged offsets the new ones and
   is removed a frame later so they stage in (community.js swap()/stageIn()) */
.cm-list.leaving .cm-item {
  opacity: 0; transform: translateY(-7px);
  transition: opacity .17s ease, transform .17s ease;
}
.cm-list.staged .cm-item { opacity: 0; transform: translateY(12px); transition: none; }

.cm-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 96px;
  align-items: center; gap: 16px; padding: 9px 0 9px 22px; cursor: pointer;
}
.cm-rank {
  display: flex; align-items: baseline; gap: 6px; line-height: 1;
  font-family: var(--mono); font-weight: 700; font-size: 28px; letter-spacing: -0.05em;
  color: var(--text-25);
}
.cm-item.lead .cm-rank { color: var(--orange); }
.cm-rank i { font-style: normal; font-size: 11px; font-weight: 400; color: rgba(242,240,235,0.16); }

.cm-name { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cm-name b { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.cm-name span,
.cm-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-name span { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; color: var(--text-40); }

.cm-val-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.cm-val-cell b { font-family: var(--mono); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.cm-item.lead .cm-val-cell b { color: var(--orange); }
.cm-val-cell i {
  font-style: normal; height: 12px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.1em; color: var(--green); animation: cm-flash 2.2s ease both;
}
@keyframes cm-flash {
  0% { opacity: 0; transform: translateY(4px); }
  18% { opacity: 1; transform: none; }
  82% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── 06 · ROW EXPANSION (top 3) ──────────────────────────────── */
/* .enter only: the live tick rebuilds the rows every 1.9s, so an always-on
   animation would re-play on an already-expanded row. community.js adds the
   class on the click that opens it. */
.cm-top3 { padding: 0 13px 9px 22px; display: flex; flex-direction: column; gap: 3px; }
.cm-top3.enter { animation: cm-in .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes cm-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.cm-u {
  display: flex; align-items: baseline; gap: 12px; line-height: 1.7;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; color: var(--text-40);
}
.cm-u b { flex: none; font-weight: 400; color: var(--text-25); }
.cm-u.first b { color: var(--orange); }
.cm-u span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-60); }
.cm-u em { margin-left: auto; flex: none; font-style: normal; color: var(--text-40); }
.cm-u.first em { color: var(--text); }

/* ── 07 · SHARED COUNTER ─────────────────────────────────────── */
/* only the short label sits beside the numeral — the paragraph gets the
   full column, otherwise the measure collapses to ~18 characters */
.cm-shared-top { display: flex; align-items: center; gap: 18px; }
.cm-big {
  font-family: var(--mono); font-weight: 700; font-size: clamp(72px, 6vw, 92px);
  letter-spacing: -0.05em; line-height: 0.92; color: var(--orange); flex: none;
  /* counts up on arrival (main.js §04): reserve the final width in advance,
     or the SHARED / BY / ATHLETES label gets shoved right on every digit */
  font-variant-numeric: tabular-nums; min-width: 6ch;
}
.cm-label {
  min-width: 0; padding-left: 18px; border-left: 1px solid var(--line);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em;
  line-height: 1.9; color: var(--text-40);
}
.cm-copy { margin: 18px 0 0; max-width: 440px; font-size: 16px; line-height: 1.6; color: var(--text-60); }

/* ── 08 · MARQUEE ────────────────────────────────────────────── */
.cm-marquee-wrap { position: relative; z-index: 2; margin: auto -6vw 0; padding-top: 16px; overflow: hidden; }
.cm-marquee { display: flex; gap: 14px; width: max-content; padding-left: 6vw; animation: cm-marquee 46s linear infinite; }
@keyframes cm-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.cm-card {
  flex: none; width: 268px; padding: 14px 16px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg2);
  transition: border-color .25s;
}
.cm-card:hover { border-color: rgba(255,74,9,0.5); }
.cm-card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; }
.cm-card-h b { font-weight: 400; white-space: nowrap; color: var(--orange); }
.cm-card-h b.result { color: var(--blue); }
.cm-card-h span { white-space: nowrap; color: var(--text-25); }
.cm-card h3 { margin: 10px 0 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.cm-card p { margin: 10px 0 0; font-family: var(--mono); font-size: 10.5px; color: var(--text-40); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 09 · WOD / RESULT CARD ──────────────────────────────────── */
/* parity with .wod-card in hero-wod.css */
.cm-modal { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(0,0,0,0.6); }
.cm-modal[hidden] { display: none; }
.cm-c {
  width: 430px; max-width: 92vw; background: #1A1A1A; border: 2px solid #000; border-radius: 32px;
  box-shadow: 0 30px 80px -20px #000; display: flex; flex-direction: column; overflow: hidden;
  animation: cm-in .3s cubic-bezier(.2,.8,.2,1) both;
}
.cm-c-top { display: flex; align-items: center; gap: 12px; padding: 20px 22px 0; }
.cm-c-pill { display: inline-flex; background: var(--orange); color: #fff; padding: 8px 14px; border-radius: 100px; font-size: 14px; font-weight: 500; }
.cm-c-x { width: 32px; height: 32px; margin-left: auto; border: none; border-radius: 50%; background: rgba(242,240,235,.08); color: var(--text-60); font-size: 13px; font-weight: 700; cursor: pointer; }
.cm-c h3 { padding: 16px 22px 0; margin: 0; font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.cm-c-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 22px 0; font-size: 14px; color: var(--text-40); }
.cm-c-meta .wod-tag { font-family: var(--mono); font-size: 11px; border: 1px solid #2a2a2a; border-radius: 5px; padding: 2px 7px; color: var(--text-60); }
.cm-c-steps { padding: 18px 22px 8px; display: flex; flex-direction: column; gap: 9px; }
.cm-c-steps div { display: flex; align-items: baseline; gap: 8px; }
.cm-c-steps b { font-size: 24px; font-weight: 700; white-space: nowrap; }
.cm-c-steps span { font-size: 24px; font-weight: 400; color: var(--text-60); } /* 300 isn't loaded */
/* scores next to display-face WOD names — numbers are mono, per STYLE_GUIDE §3 */
.cm-card h3 .cm-score, .cm-c h3 .cm-score { font-family: var(--mono); font-weight: 500; }
.cm-c-bar { display: flex; gap: 10px; padding: 14px 18px 18px; }
.cm-c-bar > * { flex: 1; text-align: center; padding: 14px; border-radius: 14px; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; border: none; }
.cm-c-ghost { background: transparent; border: 1px solid #333; color: var(--text); }
.cm-c-o { background: var(--orange); color: #fff; }

/* ── 10 · RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 980px) {
  .cm-cols { grid-template-columns: 1fr; gap: 34px; }
  .cm-row { grid-template-columns: 38px minmax(0, 1fr) 88px; }
  #pc .grid-fx { display: none; }
}
/* Laptop viewports minus browser chrome: the panel is pinned, so claw back
   ~40px without changing the composition. */
@media (max-height: 880px) {
  .cm-row { padding: 6px 0 6px 22px; }
  .cm-top3 { padding-bottom: 6px; gap: 1px; }
  .cm-card { padding: 11px 14px; }
}

/* ── 11 · REDUCED MOTION ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cm-marquee { animation: none; }
  .cm-item, .cm-seg.ready .cm-seg-thumb { transition: none; }
  .cm-now::before { animation: none; }
  .cm-val-cell i, .cm-top3.enter, .cm-c { animation: none; }
}
