/* Server tab: Challenges group, Browse challenges and the challenge pages (js/challenges-fill.js).
   Uses the tokens and the room's own panel, button and board-row classes; adds only what is new. */

/* the room's own two blocks give way while a challenge view is open */
.chal-stage{display:none;flex:1;min-height:0;flex-direction:column}
.stage.chal-open>.stage-head,.stage.chal-open>.stage-body{display:none}
.stage.chal-open>.chal-stage{display:flex}
.chal-stage [hidden]{display:none !important}
.chal-pane{flex:1;min-height:0;overflow:auto;padding:var(--sp-4);scrollbar-width:thin;scrollbar-color:var(--line-strong) transparent}
.chal-pane.is-page{display:flex;flex-direction:column;gap:var(--sp-4)}
.chal-pane.is-page>*{width:100%;max-width:900px;margin-inline:auto;flex:none}

/* The rally add-on (js/rally-room.js) puts its own bar with a second Join, a rally strip and a docked ticker on a
   challenge page, and a pace chip in the challenge row. The page's hero is the one place to join and rent, and the
   row carries one chip (3d / Live / Done), so on a single challenge page these are hidden. Browse and the room's
   other views keep them. The add-on toggles `hidden` itself, hence !important. */
.stage.chal-open.chal-page>.rr-bar,.stage.chal-open.chal-page>.rr-cs,.stage.chal-open.chal-page>.rr-act{display:none !important}
#chalList .rr-rowp{display:none !important}

/* header */
.chal-head .chal-coin{flex:none}
.chal-coin{width:22px;height:22px;flex:none;display:block}
.chal-coin.glyph{display:grid;place-items:center;color:var(--accent-text)}
.chal-ico{display:block}
.chal-pill{display:inline-flex;align-items:center;flex:none;min-height:24px;padding:0 10px;border:1px solid var(--line-strong);border-radius:var(--r-round);
  font:500 12px var(--font-display);white-space:nowrap;color:var(--text-muted)}
.chal-pill.before{border-color:var(--accent-line);background:var(--accent-wash);color:var(--accent-text)}
.chal-pill.unlocked{border-color:var(--success-line);background:var(--success-wash);color:var(--success)}
.chal-pill.live{border-color:var(--success-line);background:var(--success-wash);color:var(--success)}

/* the hero */
.chal-hero{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);column-gap:var(--sp-6);row-gap:0;align-items:center;
  grid-template-areas:"goal count" "bar bar" "acts acts" "status status" "panel panel" "facts facts";
  padding:var(--sp-5);background:var(--surface-1);border:1px solid var(--accent-line);border-radius:var(--r-md)}
.ch-g{grid-area:goal;display:flex;flex-direction:column;gap:4px;min-width:0}
.ch-label{font:500 12px var(--font-display);letter-spacing:.12em;color:var(--text-muted)}
.ch-goal{font:500 64px/1 var(--font-mono);color:var(--text);font-variant-numeric:tabular-nums;white-space:nowrap}
.ch-goal small{margin-left:10px;font:500 24px var(--font-mono);color:var(--accent-text)}
.ch-goal.tba{font-size:24px;line-height:1.3;white-space:normal}
.ch-what{font-size:var(--fs-body);color:var(--text-muted);line-height:1.4}
.chal-hero .ch-bar{grid-area:bar;margin-top:var(--sp-4)}
.ch-acts,.ch-status,.ch-panel,.ch-facts{margin-top:var(--sp-4)}
.ch-facts{margin-top:var(--sp-5)}
.chal-head h1{min-width:0;overflow:hidden;text-overflow:ellipsis}
.ch-track{height:14px;border-radius:var(--r-round);background:var(--surface-3);overflow:hidden}
.ch-track.thin{height:6px}
.ch-fill{width:0;height:100%;border-radius:var(--r-round);background:var(--accent);transition:width .6s ease-out}
.ch-bl{display:flex;justify-content:space-between;gap:var(--sp-3);margin-top:var(--sp-2);font:500 13px var(--font-mono);color:var(--text-muted)}
.ch-now{color:var(--text)}
.ch-togo{margin:var(--sp-1) 0 0;font-size:var(--fs-body);color:var(--text-muted)}
.ch-togo.hit{color:var(--success);font-weight:500}
.ch-count{grid-area:count;min-width:0;padding-left:var(--sp-6);border-left:1px solid var(--line-strong)}
.ch-time{margin:4px 0 0;font:600 30px/1.2 var(--font-display);color:var(--accent-text);white-space:nowrap}
.ch-count .ch-label{display:block}
.ch-time.long{font-size:22px}
.ch-count.is-ended .ch-time{color:var(--text)}
.ch-result{margin:var(--sp-2) 0 0;font:500 15px var(--font-mono);color:var(--text)}
.ch-facts{grid-area:facts;display:grid;margin-bottom:0;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--sp-3);padding-top:var(--sp-4);border-top:1px solid var(--line)}
.ch-facts dt{font:500 12px var(--font-display);letter-spacing:.08em;text-transform:uppercase;color:var(--text-muted)}
.ch-facts dd{margin:2px 0 0;font:500 14px/1.35 var(--font-mono);color:var(--text)}
.ch-acts{grid-area:acts;display:flex;flex-wrap:wrap;gap:var(--sp-3)}
.ch-acts .btn{min-height:44px;padding:0 var(--sp-5);font-size:15px}
.ch-join.in{background:var(--success-wash);border-color:var(--success-line);color:var(--success)}
.ch-check{margin-left:8px}
.ch-status{grid-area:status;font-size:var(--fs-body);color:var(--text)}
.ch-panel{grid-area:panel;display:grid;gap:var(--sp-4);padding:var(--sp-4);background:var(--surface-2);border:1px solid var(--line-strong);border-radius:var(--r-md);outline:0}
.ch-panel:focus-visible,.ch-x:focus-visible,.chal-pal:focus-visible,.chal-name:focus-visible,.ch-join:focus-visible,.ch-rent:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ch-ph{display:flex;align-items:center;justify-content:space-between}
.ch-ph h4{margin:0;font:600 15px var(--font-display)}
.ch-x{width:40px;height:40px;border:1px solid var(--line-strong);border-radius:var(--r-sm);background:none;color:var(--text);font-size:20px;line-height:1}
.ch-x:hover{border-color:var(--accent-line)}
.ch-pp h5{margin:0 0 var(--sp-2);font:600 13px var(--font-display);color:var(--text-muted)}
.ch-pp p{margin:0;font-size:var(--fs-body);line-height:1.5}

/* how it works */
.ch-how ol{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--sp-3);margin:0;padding:0;list-style:none;counter-reset:hs}
.ch-how li{counter-increment:hs;display:flex;flex-direction:column;gap:4px;padding:var(--sp-3) var(--sp-4);background:var(--surface-1);border:1px solid var(--line);border-radius:var(--r-md)}
.ch-how li::before{content:counter(hs);display:grid;place-items:center;width:24px;height:24px;margin-bottom:4px;border:1px solid var(--accent-line);border-radius:var(--r-round);font:500 12px var(--font-mono);color:var(--accent-text)}
.ch-how b{font:600 15px var(--font-display);color:var(--text)}
.ch-how span{font-size:var(--fs-small);line-height:1.45;color:var(--text-muted)}
.ch-why{margin:0;font-size:var(--fs-small);line-height:1.5;color:var(--text-muted)}

/* who is mining */
.ch-who{display:grid;gap:var(--sp-2)}
.ch-wholine{margin:0;font-size:var(--fs-body);color:var(--text)}
.ch-wholine:empty{display:none}
.ch-whorow{display:flex;flex-wrap:wrap;align-items:center;gap:var(--sp-2)}
.chal-who{display:flex;flex-wrap:wrap;gap:6px}
.chal-pal{display:grid;place-items:center;width:40px;height:40px;padding:0;border:1px solid var(--line);border-radius:var(--r-round);background:var(--surface-2)}
.chal-pal:hover{border-color:var(--accent-line)}
.chal-pal .chal-av{width:32px;height:32px;font-size:11px}
.chal-more{min-height:40px;padding:0 var(--sp-2);border:0;background:none;color:var(--accent-text);font-size:var(--fs-small)}
.chal-more:hover{text-decoration:underline}
.chal-name{display:block;min-width:0}

/* standings */
.ch-tbls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--sp-5)}
.ch-tbls:has(>.chal-tbl:only-child),.ch-tbls:has(>.note){grid-template-columns:minmax(0,1fr)}
.ch-tbls>.note{margin:0}
.chal-row{min-height:44px}
.chal-val{display:flex;flex-direction:column;align-items:flex-end;line-height:1.25}
.chal-val small{font:500 11px var(--font-mono);color:var(--text-muted)}
.chal-foot{margin:var(--sp-2) 0 0}
.ch-stand .chal-more{margin-top:var(--sp-3)}

/* shared text and steps (join panel, discussion) */
.chal-note{margin:0 0 var(--sp-4)}
.chal-box{min-width:0}
.chal-text{margin:0;font-size:var(--fs-body);line-height:1.55;color:var(--text)}
.chal-steps{margin:0 0 var(--sp-3);padding:0;list-style:none;counter-reset:cs;display:grid;gap:var(--sp-2)}
.chal-steps li{counter-increment:cs;display:grid;grid-template-columns:24px minmax(0,1fr);gap:var(--sp-2);align-items:start;font-size:var(--fs-body);line-height:1.45;color:var(--text)}
.chal-steps li::before{content:counter(cs);display:grid;place-items:center;width:22px;height:22px;border:1px solid var(--accent-line);border-radius:var(--r-round);font:500 12px var(--font-mono);color:var(--accent-text)}
.chal-acts{display:flex;flex-wrap:wrap;gap:var(--sp-2);align-items:center;margin-top:var(--sp-3)}
.chal-steps+.chal-acts{margin-top:0}
.chal-acts .btn{min-height:36px}

/* discussion */
.chal-th{display:grid;gap:2px;margin-bottom:var(--sp-3)}
.chal-th b{font:500 15px var(--font-body);color:var(--text)}
.chal-posts{display:grid;gap:var(--sp-2)}
.chal-post{padding:var(--sp-2) var(--sp-3);border:1px solid var(--line);border-radius:var(--r-sm);background:var(--surface-2)}
.chal-post .h{display:flex;gap:var(--sp-2);align-items:baseline;justify-content:space-between}
.chal-post p{margin:4px 0 0;font-size:var(--fs-small);line-height:1.5;color:var(--text);overflow-wrap:anywhere}
.chal-post p.full{white-space:pre-wrap}
.chal-reply{margin-top:var(--sp-3);color:var(--text-muted)}
.chal-disc .chal-note{margin:0 0 var(--sp-3)}

/* browse */
.chal-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:var(--sp-4)}
.chal-card{display:flex;flex-direction:column;gap:var(--sp-3);min-width:0;padding:var(--sp-4);background:var(--surface-1);border:1px solid var(--line);border-radius:var(--r-md)}
.chal-card:hover{border-color:var(--accent-line)}
.cc-top{display:flex;flex-direction:column;align-items:flex-start;gap:var(--sp-2)}
.cc-name{display:flex;align-items:center;gap:10px;min-width:0;min-height:44px}
.cc-name h3{margin:0;font:600 16px/1.25 var(--font-display);color:var(--text)}
.cc-goal{display:flex;flex-direction:column;gap:2px;min-height:62px}
.cc-goal span{font:500 12px var(--font-display);letter-spacing:.12em;text-transform:uppercase;color:var(--text-muted)}
.cc-goal b{font:500 36px/1.1 var(--font-mono);color:var(--text)}
.cc-goal b small{margin-left:6px;font-size:16px;color:var(--accent-text)}
.cc-goal b.tba{font-size:18px;line-height:1.9}
.cc-bar{display:grid;gap:6px}
.cc-bt{font:500 13px var(--font-mono);color:var(--text-muted)}
.cc-when{margin:0;font-size:var(--fs-small);color:var(--text-muted)}
.cc-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--sp-2) var(--sp-3);margin-top:auto;padding-top:var(--sp-2);min-height:52px}
.cc-acts{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:var(--sp-2);margin-left:auto}
.cc-miners{font-size:var(--fs-small);color:var(--text-muted)}
.chal-card .btn{flex:none}

/* the channel rows: one quiet chip at the right edge, the row keeps its height */
.chans #chalList button>span:not(.count){white-space:nowrap;min-width:0}
.chans #chalList .chal-chip{flex:none;white-space:nowrap}
.chans #chalList .chal-chip.live{color:var(--accent-text)}

/* mount points for other add-ons (see the header of js/challenges-fill.js): empty ones take no room */
.chal-slot{display:flex;flex-wrap:wrap;align-items:center;gap:var(--sp-2);min-width:0}
.chal-slot:empty{display:none}
.chal-slot[data-chal-slot-at="page"]{margin:0}
/* not started yet, and another add-on put something in the card slot (the main link's "who is hashing" faces): a narrow
   card has no room for it beside "Notify me" and "Open", so it takes its own line above the two buttons */
.chal-card .cc-acts.pre{flex-wrap:wrap;justify-content:flex-end}
.chal-card .cc-acts.pre>.chal-slot[data-chal-slot-at="card"]:not(:empty){flex:1 0 100%}

@media (max-width:820px){
  .ch-tbls{grid-template-columns:minmax(0,1fr)}
  .chal-pane{padding:12px}
  .chal-pane.is-page{gap:var(--sp-3)}
  .chal-head .topic{display:none}
  .chal-hero{grid-template-columns:minmax(0,1fr);row-gap:0;padding:var(--sp-4);
    grid-template-areas:"goal" "bar" "count" "acts" "status" "panel" "facts"}
  .ch-goal{font-size:48px}
  .ch-goal small{font-size:20px}
  .ch-count{padding:0;border-left:0;margin-top:var(--sp-3)}
  .ch-acts,.ch-status,.ch-panel{margin-top:var(--sp-3)}
  .ch-facts{margin-top:var(--sp-4)}
  .ch-time{font-size:24px}
  .chal-head{display:grid;grid-template-columns:auto auto minmax(0,1fr);column-gap:8px;row-gap:4px;align-items:center;padding-block:8px}
  .chal-head h1{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.25}
  .chal-head .chal-pill{grid-column:3;justify-self:start}
  .ch-facts{grid-template-columns:minmax(0,1fr);gap:var(--sp-2)}
  .ch-facts>div{display:flex;justify-content:space-between;gap:var(--sp-3)}
  .ch-acts .btn{flex:1 1 140px}
  .ch-how ol{grid-template-columns:minmax(0,1fr)}
  .ch-how li{display:grid;grid-template-columns:24px minmax(0,1fr);column-gap:var(--sp-3)}
  .ch-how li::before{grid-row:1/3;margin:0}
  .chal-acts .btn,.chal-card .btn,.chal-more{min-height:40px}
}
@media (max-width:1100px) and (min-width:821px){
  .ch-goal{font-size:52px}
}
@media (prefers-reduced-motion:reduce){.chal-card,.ch-fill{transition:none}}
.chal-hero .btn.ghost{border-color:var(--line-strong);color:var(--text)}
.chal-hero .btn.ghost:hover{border-color:var(--accent-line);background:var(--accent-wash)}

/* unlocked challenges: group labels, the hit facts, top contributors */
.ch-group{margin:var(--sp-5) 0 var(--sp-3);font:500 12px var(--font-display);letter-spacing:.12em;color:var(--text-muted)}
.ch-group:first-of-type,.chal-note+.ch-group{margin-top:0}
.ch-facts{grid-template-columns:repeat(var(--n,3),minmax(0,1fr))}
.chal-hero.unlocked{grid-template-areas:"goal count" "bar bar" "facts facts"}
.ch-top .ch-topsub{margin:2px 0 var(--sp-3);font-size:var(--fs-small);color:var(--text-muted)}
.ch-crow{grid-template-columns:22px 28px minmax(90px,1.2fr) minmax(90px,2fr) 96px;grid-template-areas:"rk av nm sh vl";column-gap:10px;min-height:48px}
.ch-crow .ch-rk{grid-area:rk}.ch-crow .chal-av{grid-area:av;width:28px;height:28px;font-size:10px}.ch-crow .chal-name{grid-area:nm}
.ch-crow .ch-vl{grid-area:vl;align-items:flex-end;white-space:nowrap}
.ch-sh{grid-area:sh;display:flex;align-items:center;gap:var(--sp-2);min-width:0}
.ch-sh .ch-track{flex:1;min-width:0}
.ch-sh small{flex:none;width:34px;text-align:right;font:500 11px var(--font-mono);color:var(--text-muted)}
@media (max-width:820px){
  .ch-facts{grid-template-columns:minmax(0,1fr)}
  .ch-crow{grid-template-columns:22px 28px minmax(0,1fr) auto;grid-template-areas:"rk av nm vl" ". . sh sh";row-gap:4px;padding-block:6px}
}

/* READY, SET, GO: a challenge that is not on yet. The countdown leads, the goal sits beside it with today's number,
   one button (Notify me) and a quiet line under it. No bar, no Join. */
.chal-hero.is-before{grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);align-items:center;
  grid-template-areas:"count goal" "bar bar" "acts acts" "status status" "panel panel" "facts facts"}
.chal-hero.is-before .ch-count{padding-left:0;border-left:0}
.chal-hero.is-before .ch-g{padding-left:var(--sp-6);border-left:1px solid var(--line-strong)}
.chal-hero.is-before .ch-time{margin-top:6px;font:600 46px/1.08 var(--font-display);letter-spacing:-.01em;white-space:normal;color:var(--accent-text)}
.chal-hero.is-before .ch-time.long{font-size:34px}
.chal-hero.is-before .ch-time.secs{font-family:var(--font-mono);font-weight:500;font-variant-numeric:tabular-nums;letter-spacing:0}
.chal-hero.is-before .ch-goal{font-size:40px}
.chal-hero.is-before .ch-goal small{font-size:18px;margin-left:8px}
.chal-hero.is-before .ch-goal.tba{font-size:20px}
.ch-today{margin:var(--sp-2) 0 0;font:500 13px/1.4 var(--font-mono);color:var(--text)}
.chal-hero.is-before .ch-acts{margin-top:var(--sp-5)}
.chal-hero.is-before .ch-status{margin:var(--sp-2) 0 0}
.ch-status.quiet{font-size:var(--fs-small);color:var(--text-muted)}
.ch-notify{display:inline-flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap}
.ch-notify .ch-bell{flex:none;display:block}
.ch-notify .ch-check{margin-left:0}
.ch-notify.on{background:var(--success-wash);border-color:var(--success-line);color:var(--success)}
.ch-notify.on:hover{background:var(--success-wash);border-color:var(--success)}
.ch-notify:focus-visible,.cl-join:focus-visible,.cl-x:focus-visible,.chal-card .btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ch-how li.done::before{content:"✓";border-color:var(--success-line);background:var(--success-wash);color:var(--success)}
/* Browse: Notify me beside a quiet Open */
.chal-card .btn.ghost{border-color:var(--line-strong);color:var(--text)}
.chal-card .btn.ghost:hover{border-color:var(--accent-line);background:var(--accent-wash)}
@media (max-width:820px){
  .chal-hero.is-before{grid-template-columns:minmax(0,1fr);grid-template-areas:"count" "goal" "bar" "acts" "status" "panel" "facts"}
  .chal-hero.is-before .ch-count{margin-top:0}
  .chal-hero.is-before .ch-g{margin-top:var(--sp-4);padding:var(--sp-4) 0 0;border-left:0;border-top:1px solid var(--line)}
  .chal-hero.is-before .ch-time{font-size:36px}
  .chal-hero.is-before .ch-time.long{font-size:28px}
  .chal-hero.is-before .ch-goal{font-size:34px}
  .chal-hero.is-before .ch-goal small{font-size:16px}
  .chal-hero.is-before .ch-acts{margin-top:var(--sp-4)}
  /* the long label takes the whole row on a phone; anything another add-on puts after it wraps to the next row */
  .ch-acts .ch-notify{flex:1 1 100%;white-space:normal;text-align:center;padding-block:6px}
  .cc-acts.pre .btn{min-height:44px}
}

/* the go-live notice: its own node on <body>, fixed under the top bar. --topbar-h is the room's own (shell.css: 76px on
   desktop = the bar plus the 10px gap above the panels, 112px on phones; a phone add-on may set 52px, 44px sideways, 0px
   with the keyboard up). Desktop: inside the stage's header band (54px tall in a 56px band), at the stage's right edge
   (the script sets `right` from the stage; the room's header text sits on the left). Phone: full width under the bar.
   Above the room, under the drawers and their scrim (65/70), the room's sheets and the sign-in box (1000), and gone
   while a drawer is open. */
.chal-live{position:fixed;z-index:64;top:calc(var(--topbar-h, 76px) + 2px);right:24px;
  width:max-content;max-width:min(560px,calc(100vw - 24px));display:flex;align-items:center;gap:var(--sp-3);
  padding:6px 6px 6px var(--sp-4);background:var(--surface-1);border:1px solid var(--success-line);
  border-radius:var(--r-md);box-shadow:0 10px 28px var(--scrim);animation:chal-live-in .24s var(--motion-ease) both}
.chal-live .cl-dot{flex:none;width:10px;height:10px;border-radius:50%;background:var(--success);animation:chal-live-dot 1.8s ease-out infinite}
.chal-live .cl-txt{margin:0;min-width:0;font-size:var(--fs-body);line-height:1.35;color:var(--text)}
.chal-live .cl-txt b{font-weight:600}
.chal-live .cl-acts{display:flex;align-items:center;gap:var(--sp-2);flex:none;margin-left:auto}
.chal-live .cl-join{min-height:40px;padding:0 var(--sp-5);font-size:15px}
.chal-live .cl-x{width:40px;height:40px;border:1px solid var(--line-strong);border-radius:var(--r-sm);background:none;color:var(--text);font-size:20px;line-height:1}
.chal-live .cl-x:hover{border-color:var(--accent-line)}
@keyframes chal-live-in{from{opacity:0;translate:0 -8px}to{opacity:1;translate:0 0}}
@keyframes chal-live-dot{0%{box-shadow:0 0 0 0 var(--success-line)}70%,100%{box-shadow:0 0 0 8px transparent}}
/* phones, upright or sideways (the same query the phone add-on uses) */
@media (max-width:820px),(orientation:landscape) and (max-height:500px) and (max-width:950px){
  .chal-live{top:calc(var(--topbar-h, 112px) + 8px);left:12px;right:12px;width:auto;max-width:none;padding:var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3)}
  .chal-live .cl-join{min-height:44px}
  .chal-live .cl-x{width:44px;height:44px}
}
body.nav-open .chal-live,body.mem-open .chal-live{display:none}
@media (prefers-reduced-motion:reduce){.chal-live,.chal-live .cl-dot{animation:none}}
