/* #2819: the finished-challenge look. Colours, fonts and spacing come from the design tokens (design-system/tokens.css). */

/* The page's state. data.js sets data-challenge on <html> (live or done) and prerender.mjs writes it into the static HTML,
   so these hold from the first paint. live-only parts vanish once the challenge is finished, done-only ones show only then. */
html[data-challenge="done"] .live-only { display: none !important; }
html:not([data-challenge="done"]) .done-only { display: none !important; }

/* The round seal: red ink when finished, green while running, plain ink when planned */
.fin-seal { display: block; width: 100%; height: auto; font-family: var(--display); color: var(--pop); }
.fin-seal-live { color: var(--go-ink); }
.fin-seal-soon { color: var(--text); }
/* The finished seal's band text is dark ink: white on the orange fails contrast (tokens.json, on-pop). The live and planned seals keep var(--card). */
.fin-seal-done .fin-band { fill: var(--on-pop); }

/* Challenge page header: the seal at the top right of the title, a short facts row and a link back to the list */
html[data-challenge="done"] .chead { position: relative; }
html[data-challenge="done"] .chead h1 { padding-right: clamp(96px, 16vw, 168px); text-wrap: balance; }
.fin-sealbox { position: absolute; right: 0; top: var(--s3); width: clamp(96px, 16vw, 168px); transform: rotate(12deg); pointer-events: none; }
.fin-all { display: inline-block; margin-top: var(--s3); font-family: var(--mono); font-size: var(--fs-small); color: var(--text); text-decoration: underline; }

/* Section headings of the finished page: The result, What I did, Every day */
.fin-h { margin-top: var(--s5); }
#body > .fin-h:first-child { margin-top: var(--s4); }

/* What I did: a tinted box per goal group, each goal with its score and a thin bar */
.fin-goals { columns: 3 240px; column-gap: var(--s3); }
.fin-grp { break-inside: avoid; margin-bottom: var(--s3); background: var(--tint); border: var(--bw-card) solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-small); padding: var(--s3); }
.fin-grp h4 { font-weight: 800; font-size: var(--fs-body); margin-bottom: var(--s2); }
.fin-g { display: grid; grid-template-columns: 1fr auto; gap: var(--s1) var(--s2); align-items: baseline; padding: var(--s2) 0; border-top: var(--bw-chip) dashed color-mix(in srgb, var(--line) 35%, transparent); }
.fin-g:first-of-type { border-top: 0; }
.fin-gn { font-size: var(--fs-small); font-weight: 600; }
.fin-g b { font-weight: 800; font-size: calc(var(--fs-body) * 1.15); }
.fin-g b small { font-family: var(--mono); font-size: var(--fs-micro); font-weight: 400; color: var(--muted); }
.fin-bar { grid-column: 1 / -1; height: var(--s2); border: var(--bw-chip) solid var(--line); border-radius: var(--r-pill); background: var(--card); overflow: hidden; }
.fin-bar i { display: block; height: 100%; background: var(--go); }

/* The result strip: a tinted tile per platform, the start struck through, the end big, the gain in a pill */
.fin-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); margin-top: var(--s4); }
.fin-s { display: flex; flex-direction: column; gap: var(--s1); background: var(--tint); border: var(--bw-card) solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: var(--s3); color: var(--text); }
.fin-s small { font-family: var(--mono); font-size: var(--fs-label); }
.fin-ft { display: flex; align-items: baseline; gap: var(--s1); flex-wrap: wrap; }
.fin-ft s { font-family: var(--mono); font-size: var(--fs-small); color: var(--muted); }
.fin-ft i { font-style: normal; font-weight: 800; }
.fin-ft b { font-weight: 800; font-size: calc(var(--fs-h3) * 1.3); letter-spacing: var(--fs-headingTracking); line-height: 1; }
.fin-s em { font-style: normal; align-self: flex-start; font-family: var(--mono); font-size: var(--fs-label); background: var(--card); border: var(--bw-chip) solid var(--line); border-radius: var(--r-sm); padding: 0 var(--s1); }

/* Home hero: the big seal where the live card sits, the challenge title in mono under it, the whole thing one link */
.fin-hero { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2); padding: var(--s3) 0; color: var(--text); text-decoration: none; }
.fin-hero .fin-seal { width: min(260px, 70%); transform: rotate(-10deg); transition: transform var(--ease-hover); }
.fin-hero:hover .fin-seal { transform: rotate(-4deg) scale(1.04); }
.fin-hero span { font-family: var(--mono); font-size: var(--fs-small); color: var(--muted); text-align: center; }

/* The compact finished card (home feature card and Past challenges): small seal left, title, dates, link line, then the strip */
.feature .fin-top { justify-content: flex-start; align-items: center; gap: var(--s4); flex-wrap: nowrap; }
.fin-sealsm { width: clamp(84px, 12vw, 120px); flex: none; transform: rotate(-10deg); }
.fin-dates { font-family: var(--mono); font-size: var(--fs-small); color: var(--muted); margin-top: var(--s1); text-wrap: balance; }
.feature .fin-top .title { text-wrap: balance; }
/* With the intro line gone (live-only), the Challenges heading keeps its gap to the card */
html[data-challenge="done"] #challenges > h2 { margin-bottom: var(--s4); }
.feature .fin-top .own-page { display: inline-block; margin-top: var(--s2); }
.fin-card { display: block; color: var(--text); text-decoration: none; }
.fin-card .fin-strip { margin-top: var(--s4); }
.others .fin-strip { grid-template-columns: repeat(2, 1fr); }
/* Past challenges shows only when it holds a card */
.more-ch:has(#others:empty) { display: none; }

/* The challenges list: a shelf of tiles. A finished or running tile has the seal, the title, the total followers gained as one
   big number and a small tinted card per platform; a planned one has the seal, the title and its start date. */
.fin-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s4); margin-top: var(--s3); }
.fin-tile { display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center; background: var(--card); border: var(--bw-card) solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: var(--s4) var(--s3); color: var(--text); text-decoration: none; transition: transform var(--ease-hover), box-shadow var(--ease-hover); }
a.fin-tile:hover { transform: translate(calc(var(--s1) * -.5), calc(var(--s1) * -.5)); box-shadow: var(--shadow-lifted); }
.fin-tseal { width: 150px; transform: rotate(-8deg); margin-bottom: var(--s2); }
.fin-tt { font-weight: 800; font-size: calc(var(--fs-body) * 1.25); line-height: 1.1; }
.fin-when { font-family: var(--mono); font-size: var(--fs-label); color: var(--muted); }
/* #3056: a planned tile's goals line, a step up from the small mono lines so it reads at a glance */
.fin-goal { font-size: var(--fs-body); font-weight: 600; line-height: 1.3; text-wrap: balance; }
.fin-total { display: flex; flex-direction: column; align-items: center; margin-top: var(--s2); }
.fin-total b { font-weight: 800; font-size: calc(var(--fs-h3) * 2); line-height: 1; letter-spacing: var(--fs-headingTracking); }
.fin-total span { font-family: var(--mono); font-size: var(--fs-label); color: var(--muted); }
.fin-mini { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); width: 100%; margin-top: var(--s2); }
.fin-m { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s1); text-align: left; background: var(--tint); border: var(--bw-chip) solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-small); padding: var(--s2); }
.fin-m small { font-family: var(--mono); font-size: var(--fs-micro); }
.fin-m b { font-weight: 800; font-size: calc(var(--fs-body) * 1.15); line-height: 1.1; }
.fin-m span, .fin-m em { font-family: var(--mono); font-size: var(--fs-micro); font-style: normal; color: var(--muted); }
.fin-tile.empty { border-style: dashed; box-shadow: none; background: transparent; justify-content: center; }
.fin-tile.empty .fin-tseal { aspect-ratio: 1; transform: none; border: calc(var(--bw-card) * 1.5) dashed color-mix(in srgb, var(--line) 40%, transparent); border-radius: 50%; }
.fin-tile.empty .fin-tt { color: var(--muted); }
/* In dark the ink border is the same as the background, so the empty tile uses the muted colour (as the design system's empty slots do) */
:root[data-theme="dark"] .fin-tile.empty { border-color: var(--muted); }
:root[data-theme="dark"] .fin-tile.empty .fin-tseal { border-color: color-mix(in srgb, var(--muted) 60%, transparent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fin-tile.empty { border-color: var(--muted); }
  :root:not([data-theme="light"]) .fin-tile.empty .fin-tseal { border-color: color-mix(in srgb, var(--muted) 60%, transparent); }
}

/* Keyboard focus: the house ring */
.fin-tile:focus-visible, .fin-hero:focus-visible, .fin-card:focus-visible, .fin-all:focus-visible, .fin-top .own-page:focus-visible { outline: 3px solid var(--pop); outline-offset: 3px; }

/* A seal drawn under about 110px wide cannot hold the ring text at 11px, so only the FINISHED band stays: the home card's small
   seal is 84px to 120px wide (12vw), the challenge page seal 96px to 168px (16vw) */
@media (max-width: 915px) { .fin-sealsm .fin-ring { display: none; } }
@media (max-width: 689px) { .fin-sealbox .fin-ring { display: none; } }

@media (max-width: 760px) {
  .fin-sealbox { top: var(--s2); }
  .fin-strip { grid-template-columns: 1fr 1fr; }
  .fin-ft b { font-size: calc(var(--fs-h3) * 1.05); flex-basis: 100%; }
  .fin-s small span { display: block; }
}
