/* internal/webui/static/style.css
   Vitrine: badges are medals in a lit trophy cabinet. The only accent colours are the
   medals' own metals; everything else stays quiet. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

/* Light tokens. The dark set is written twice, for an explicit choice and for the system
   setting; webui_test checks the two copies match. */
:root {
  --bg: #eef2f4; --surface: #ffffff; --ink: #142430; --muted: #5b6e7a; --line: #cfd9df;
  --shelf: #dfe6ea; --shelf-muted: #526470; --edge: #c3ced5; --spot: rgba(255, 255, 255, .95);
  --gold: #c9971f; --silver: #8a96a0; --bronze: #b5754a; --metal-ink: #1d1600;
  --code-bg: #142430; --code-ink: #eaf1f5; --danger: #b3261e; --focus: #142430;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d1c26; --surface: #122633; --ink: #eaf1f5; --muted: #93a9b7; --line: #25414f;
  --shelf: #16303f; --shelf-muted: #93a9b7; --edge: #08131a; --spot: rgba(64, 110, 140, .55);
  --gold: #e2b53a; --silver: #c7d0d6; --bronze: #d39468; --metal-ink: #1d1600;
  --code-bg: #08131a; --code-ink: #eaf1f5; --danger: #f2b8b5; --focus: #e2b53a;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1c26; --surface: #122633; --ink: #eaf1f5; --muted: #93a9b7; --line: #25414f;
    --shelf: #16303f; --shelf-muted: #93a9b7; --edge: #08131a; --spot: rgba(64, 110, 140, .55);
    --gold: #e2b53a; --silver: #c7d0d6; --bronze: #d39468; --metal-ink: #1d1600;
    --code-bg: #08131a; --code-ink: #eaf1f5; --danger: #f2b8b5; --focus: #e2b53a;
    color-scheme: dark;
  }
}

/* Base: 17px body, headings on a 1.25 scale (rem = 17px). */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 106.25%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem; line-height: 1.6;
}
a { color: inherit; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.015em; }
h1 { font-size: 2.441rem; font-weight: 800; margin: .5em 0 .35em; }
h2 { font-size: 1.563rem; font-weight: 700; margin: 2em 0 .5em; }
h3 { font-size: 1.25rem; font-weight: 700; margin: 1.5em 0 .4em; }
p { margin: 0 0 1em; }
.lede { font-size: 1.25rem; line-height: 1.5; color: var(--muted); max-width: 60ch; }
.meta, .hint { color: var(--muted); font-size: .875rem; }
.hint { margin: 0 0 12px; }
.prose { max-width: 68ch; }
code { font: .88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--shelf); padding: .1em .35em; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); color: var(--code-ink); padding: 14px 16px; border-radius: 10px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; color: inherit; overflow-wrap: normal; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header: brand, nav, the gold star pill (the header's only gold), theme and menu buttons. */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 10px 20px; max-width: 1040px; margin: 0 auto; padding: 12px 16px; }
.brand { margin-right: auto; font-weight: 800; font-size: 1.1rem; text-decoration: none; white-space: nowrap; }
.top nav { display: flex; gap: 18px; font-size: .94rem; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover { color: var(--ink); }
.theme-btn, .menu-btn {
  font: inherit; font-size: .875rem; font-weight: 600; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
.menu-btn { display: none; }
.star {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: var(--gold); color: var(--metal-ink); font-size: .875rem; font-weight: 700;
  text-decoration: none; white-space: nowrap; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
}
.star:hover, .star-banner:hover { filter: brightness(1.06); }
.star-count { padding: 0 7px; border-radius: 999px; background: rgba(255, 255, 255, .5); font-variant-numeric: tabular-nums; }

main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 0; }
footer { max-width: 1040px; margin: 64px auto 0; padding: 20px 16px 36px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .94rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--metal-ink); }
.btn.small { padding: 4px 10px; font-size: .82rem; border-radius: 8px; }
.btn.big { padding: 12px 20px; font-size: 1.05rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-decoration-color: var(--gold); cursor: pointer; }
#check-form { display: flex; gap: 8px; max-width: 460px; }
#check-form input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit;
}
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.notice.error { border-color: var(--danger); }
.notice p:last-child { margin-bottom: 0; }

/* The vitrine: a shelf lit from above. ::before carries the spotlight so it can fade in. */
.vitrine {
  --muted: var(--shelf-muted);
  position: relative; isolation: isolate; border-radius: 14px;
  background: linear-gradient(transparent 40%, var(--shelf)); box-shadow: inset 0 -6px 0 var(--edge);
}
.vitrine::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(80% 70% at 50% 0%, var(--spot), transparent 72%);
}
.shelf {
  list-style: none; margin: 0; padding: 22px 12px 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px;
}
.medal { display: grid; justify-items: center; gap: 6px; padding: 0 6px 20px; text-align: center; text-decoration: none; }
.medal-name { font-weight: 700; }
.medal-img, .badge-img, .badge-hero { filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .18)); }
.medal .medal-img { width: 88px; height: 88px; }
.medal-img.placeholder, .badge-img.placeholder, .badge-hero.placeholder {
  display: grid; place-items: center; border-radius: 50%; background: var(--line); color: var(--muted); font-weight: 700; filter: none;
}

/* Result cards: a medal on the shelf; opening one shows its details across the row. */
.badge-card { border-radius: 12px; }
.badge-card summary { list-style: none; cursor: pointer; padding: 6px 6px 18px; display: grid; justify-items: center; gap: 6px; text-align: center; border-radius: 12px; }
.badge-card summary::-webkit-details-marker { display: none; }
.badge-card[open] { grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--line); margin-bottom: 14px; }
.badge-card[open] summary { justify-items: start; text-align: left; grid-template-columns: 96px 1fr; align-items: center; column-gap: 16px; padding: 14px; }
.badge-card[open] summary .badge-img { grid-row: 1 / span 3; }
.badge-card[open] summary > :not(.badge-img) { grid-column: 2; }
.badge-img { width: 96px; height: 96px; }
.badge-img.placeholder { font-size: 1.6rem; }
.locked .badge-img { filter: grayscale(1); opacity: .45; }
.badge-name { font-weight: 700; }
.badge-line { color: var(--muted); font-size: .875rem; }
.badge-detail { padding: 0 16px 16px; overflow-wrap: anywhere; }
.badge-card progress { width: 100%; max-width: 150px; }
.badge-card[open] progress { max-width: 280px; }
progress {
  -webkit-appearance: none; appearance: none; height: 6px; border: 0; border-radius: 3px; overflow: hidden;
  background: color-mix(in srgb, var(--ink) 14%, transparent); color: var(--gold);
}
progress::-webkit-progress-bar { background: color-mix(in srgb, var(--ink) 14%, transparent); border-radius: 3px; }
progress::-webkit-progress-value { background: var(--gold); border-radius: 3px; }
progress::-moz-progress-bar { background: var(--gold); border-radius: 3px; }
.tier {
  display: inline-block; margin-left: 6px; padding: 3px 7px; border-radius: 999px; vertical-align: 2px;
  font-size: .75rem; font-weight: 700; line-height: 1; color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
}
.tier.t2, .tier.t3, .tier.t4 { color: var(--metal-ink); box-shadow: none; }
.tier.t2 { background: var(--bronze); }
.tier.t3 { background: var(--silver); }
.tier.t4 { background: var(--gold); }

/* Result page */
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin: 24px 0 8px; }
.avatar { width: 72px; height: 72px; border-radius: 50%; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line); }
.result-user { margin: 0; font-size: 2.441rem; font-weight: 800; }
.result-sum { margin: 2px 0 0; color: var(--muted); }
.next { margin: 0 0 0 auto; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.next strong { display: block; color: var(--ink); font-size: 1rem; }
.scope { color: var(--muted); font-size: .94rem; }
.shelf-head { margin: 1.8em 0 .2em; }
.archive { margin-top: 24px; padding: 2px 14px; border: 1px dashed var(--line); border-radius: 12px; }
.archive > summary { cursor: pointer; padding: 10px 0; color: var(--muted); font-weight: 600; }
.archive .shelf { margin-bottom: 14px; }
.highlights { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.highlights li { padding: 3px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .875rem; }
.highlights .off { color: var(--muted); background: transparent; border-style: dashed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 10px; }

/* Star banner: the page's one loud moment after the shelves (result) or the FAQ (home). */
.star-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  margin: 32px 0 8px; padding: 18px 22px; border-radius: 14px; background: var(--gold); color: var(--metal-ink);
  text-decoration: none; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .14);
}
.star-banner strong { font-size: 1.25rem; font-weight: 800; }
.star-cta { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: var(--metal-ink); color: var(--gold); font-weight: 700; }
.star-cta .star-count { background: rgba(255, 255, 255, .16); }

/* Home */
.hero { padding: 32px 0 8px; }
.hero h1 { font-size: 3.052rem; letter-spacing: -.025em; margin: 0 0 .25em; max-width: 14ch; }
.hero .lede { margin-bottom: 20px; }
.signin { margin: 12px 0 0; color: var(--muted); font-size: .94rem; }
.home-shelf { margin-top: 36px; }
.points { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 32px; }
.points h3 { margin: .6em 0 .2em; font-size: 1.1rem; }
.points p { margin: 0; color: var(--muted); }
.install { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.install pre { flex: 1 1 320px; margin: 0; }

/* Check page */
.choice { max-width: 540px; padding: 24px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.choice .or { margin: 20px 0 8px; color: var(--muted); }

/* All achievements */
.medal-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px 28px; }
.medal-grid li { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: start; }
.medal-grid .medal-img { width: 64px; height: 64px; }
.medal-grid h3 { margin: 4px 0 2px; font-size: 1.1rem; }
.medal-grid p { margin: 0; }

/* Badge page */
.badge-top { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 36px; margin: 8px 0 28px; padding: 24px 24px 30px; }
.badge-hero { width: 160px; height: 160px; }
.badge-hero.placeholder { font-size: 2.6rem; }
.tier-strip { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 16px; }
.tier-strip li { display: grid; justify-items: center; gap: 4px; color: var(--muted); font-size: .82rem; }
.tier-strip .medal-img { width: 64px; height: 64px; }
table { width: 100%; max-width: 520px; border-collapse: collapse; font-size: .94rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { color: var(--muted); font-weight: 600; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; max-width: 760px; }
.facts dt { font-weight: 700; }
.facts dd { margin: 0; }
.faq dt { font-weight: 700; margin-top: 18px; }
.faq dd { margin: 4px 0 0; color: var(--muted); max-width: 68ch; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 12px 0 0; font-size: .875rem; color: var(--muted); }
.crumbs a { text-decoration: none; }
.pager { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin: 40px 0 8px; }

/* Sign-in callback */
.checking { max-width: 560px; padding: 20px 22px; border-radius: 14px; }
.steps { margin: 6px 0 12px; color: var(--muted); }

#consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 10; max-width: 560px; margin: 0 auto;
  padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
#consent p { margin: 0 0 10px; }

@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; gap: 6px; }
  .brand { font-size: .875rem; }
  .star, .theme-btn, .menu-btn { padding: 5px 8px; font-size: .8125rem; }
  .top .star-count { display: none; }
  .js .menu-btn { display: inline-block; }
  .js .top nav:not([data-open]) { display: none; }
  .top nav { order: 5; flex-basis: 100%; flex-direction: column; gap: 0; padding: 4px 0; }
  .top nav a { padding: 8px 0; }
  .star-long { display: none; }
}
@media (max-width: 600px) {
  h1, .result-user { font-size: 1.953rem; }
  .hero h1 { font-size: 2.441rem; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 18px 6px 0; }
  .next { margin-left: 0; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { margin-bottom: 8px; }
  .badge-hero { width: 120px; height: 120px; }
  .badge-card[open] summary { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .badge-card[open] summary .badge-img { grid-row: auto; }
  .badge-card[open] summary > :not(.badge-img) { grid-column: auto; }
}

/* Motion: the home spotlight fades in once; an opened card grows to its height. */
@media (prefers-reduced-motion: no-preference) {
  :root { interpolate-size: allow-keywords; }
  .home-shelf::before { animation: spot-in 1.4s ease-out both; }
  @keyframes spot-in { from { opacity: 0; } to { opacity: 1; } }
  .badge-card::details-content { height: 0; overflow: clip; transition: height .25s ease, content-visibility .25s allow-discrete; }
  .badge-card[open]::details-content { height: auto; }
}
