/* Open Quest: design tokens and styles. Values follow plan/design.md. */
:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --text: #0f172a;
  --muted: #5a6a80; /* darkened from #64748B to reach WCAG AA on grey surfaces */
  --primary: #4d8ee9;
  --primary-strong: #2f6fcf; /* darker blue for text and buttons: meets WCAG AA contrast on white */
  --accent: #5fbfff;
  --success: #15803d; /* darkened from #16A34A for WCAG AA */
  --warning: #b45309;
  --error: #dc2626;
  --border: #e2e8f0;
  --radius-card: 16px;
  --radius-btn: 10px;
  --space: 8px;
  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #141b2d;
    --text: #e6eaf2;
    --muted: #94a3b8;
    --primary-strong: #4d8ee9;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #f87171;
    --border: #243049;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}
main, header, footer { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 40px; padding-bottom: 8px; }
h1 { font-size: 2.5rem; font-weight: 300; line-height: 1.1; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; font-weight: 300; margin: 32px 0 16px; letter-spacing: -0.01em; }
h3 { font-size: 1.25rem; font-weight: 500; margin: 0 0 4px; }
p { margin: 0 0 8px; }
.lede { font-size: 1.25rem; color: var(--muted); font-weight: 300; margin-bottom: 24px; }
.muted { color: var(--muted); }
small, .small { font-size: 0.875rem; }
a { color: var(--primary-strong); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
code, .mono { font-family: var(--mono); font-size: 0.875rem; }

.note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 24px;
  margin-bottom: 24px;
}
.note strong { font-weight: 500; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 24px; min-height: 48px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 16px; font-size: 0.875rem; background: var(--surface);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--success); }

.btn {
  font: inherit; font-weight: 500;
  min-height: 44px; padding: 8px 24px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn[aria-disabled="true"] { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0b1020; } }

.safe { margin: 0 0 24px; font-size: 0.9375rem; }
.safe summary { cursor: pointer; color: var(--primary-strong); font-weight: 500; min-height: 44px; display: flex; align-items: center; }
.safe[open] { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 0 24px 16px; }
.safe[open] summary { margin-bottom: 4px; }
.safe ul { margin: 8px 0 16px; padding-left: 24px; }
.safe p { margin: 0 0 8px; }
.banner {
  border: 1px solid var(--warning); border-radius: var(--radius-card);
  padding: 16px 24px; margin-bottom: 24px; background: var(--surface);
}
.banner.error { border-color: var(--error); }
.banner p { margin-bottom: 8px; }
.banner .btn { margin-top: 8px; }
[hidden] { display: none !important; }

.status-line:empty { display: none; }
.status-line { margin: 0 0 16px; color: var(--muted); font-size: 0.875rem; }

/* ---- the hero arc: the same arc as the badge, filling as quests are completed ---- */
.hero { text-align: center; margin: 8px auto 40px; max-width: 460px; }
.arc-wrap { position: relative; }
.arc-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.arc-track { fill: none; stroke: var(--border); stroke-width: 10; stroke-linecap: round; }
.arc-fill { fill: none; stroke: url(#heroGrad); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 700ms ease; }
.hero.earned .arc-fill { filter: drop-shadow(0 0 7px rgba(95, 191, 255, 0.6)); }
.stop .node { fill: var(--bg); stroke: var(--border); stroke-width: 6; transition: fill 300ms ease, stroke 300ms ease; }
.stop.next .node { stroke: var(--primary); }
.stop.on .node { fill: var(--primary-strong); stroke: var(--accent); }
.stop .tick { fill: none; stroke: #fff; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 300ms ease; }
.stop.on .tick { opacity: 1; }
@media (prefers-color-scheme: dark) { .stop.on .tick { stroke: #0b1020; } .stop.on .node { stroke: var(--accent); } }
.arc-center { position: absolute; left: 0; right: 0; top: 32%; }
.arc-count { margin: 0; font-size: 4.5rem; font-weight: 300; line-height: 1; letter-spacing: -0.03em; }
.arc-count span { font-size: 2rem; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.arc-label { margin: 8px 0 0; font-size: 0.8125rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.arc-note { margin: 0; font-size: 1.125rem; }

/* ---- the path: quests are stops along a line, not identical boxes ---- */
.quests { list-style: none; margin: 0; padding: 0; }
.quest { position: relative; display: grid; grid-template-columns: 48px 1fr; gap: 24px; padding: 8px 0 32px; }
.quest::before { content: ""; position: absolute; left: 23px; top: 56px; bottom: -8px; width: 2px; background: var(--border); }
.quest.done::before { background: var(--primary); }
.quests .quest:last-child::before { bottom: -40px; }
#badge-area .quest::before { display: none; }
.quest .num {
  position: relative; z-index: 1;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.25rem; font-weight: 500;
  background: var(--bg); color: var(--muted); border: 2px dashed var(--border);
}
.quest.active .num { border: 2px solid var(--primary); color: var(--primary-strong); box-shadow: 0 0 0 6px rgba(95, 191, 255, 0.22); }
.quest.done .num { background: var(--primary-strong); border: 2px solid var(--primary-strong); color: #fff; }
@media (prefers-color-scheme: dark) { .quest.done .num { color: #0b1020; } }
.quest .body { min-width: 0; }
.quest.active .body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 24px; margin-top: -8px; }
.quest.locked .body h3, .quest.locked .body p { color: var(--muted); }
.quest .state { font-size: 0.875rem; margin-top: 8px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quest.done .state { color: var(--success); font-weight: 500; }
.quest.active .state { color: var(--primary-strong); font-weight: 500; }
.quest .actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.quest .actions:empty { display: none; }
.quest .feedback { margin-top: 8px; font-size: 0.875rem; color: var(--muted); }
.quest .feedback.error { color: var(--error); }
.quest .steps { display: flex; gap: 16px; font-size: 0.875rem; color: var(--muted); margin: 8px 0 0; padding: 0; list-style: none; }
.quest .steps li.current { color: var(--text); font-weight: 500; }
.ic { flex: none; vertical-align: -0.15em; }

.check { animation: pop 150ms ease-out; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.badge-card { position: relative; z-index: 1; }
.badge-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.badge-card {
  margin-top: 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 24px;
}


pre:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
pre {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 16px; overflow-x: auto; font-family: var(--mono); font-size: 0.8125rem; line-height: 1.5; margin: 8px 0 16px;
}

footer { padding-top: 48px; padding-bottom: 48px; color: var(--muted); font-size: 0.875rem; }

/* ---- community quests and the register form ---- */
.community { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 16px; }
.cq { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 24px; }
.cq-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.cq h3 { margin: 0; overflow-wrap: anywhere; }
.cq p { margin: 8px 0 0; overflow-wrap: anywhere; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 16px; font-size: 0.875rem; font-weight: 500; border: 1px solid var(--border); background: var(--surface); }
.chip.yes { color: var(--success); border-color: var(--success); }
.chip.no { color: var(--muted); }

.form { display: grid; gap: 16px; margin: 16px 0; }
.field { display: grid; gap: 8px; }
label { font-weight: 500; }
input, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  padding: 8px 16px; min-height: 44px; width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--primary); }
textarea { resize: vertical; }
#reg-preview:empty { display: none; }
.form .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.form .feedback { margin-top: 0; font-size: 0.875rem; color: var(--muted); }
.form .feedback.error { color: var(--error); }
.btn[aria-disabled="true"] { opacity: 0.55; }

.badge-card img { width: 240px; height: 240px; max-width: 100%; border-radius: 40px; }
@media (min-width: 640px) {
  header { padding-top: 64px; }
  h1 { font-size: 3rem; }
}
@media (max-width: 480px) {
  .quest { grid-template-columns: 40px 1fr; gap: 16px; }
  .quest::before { left: 19px; top: 48px; }
  .quest .num { width: 40px; height: 40px; font-size: 1.0625rem; }
  .quest.active .body { padding: 16px; }
  .arc-count { font-size: 3.5rem; }
  .arc-center { top: 30%; }
  .btn { width: 100%; }
  .toolbar .btn { width: auto; }
  .cq { padding: 16px; }
  .form .actions .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
