/* Structural tokens (skin-independent) */
:root {
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------------------------------------------------------------- skins --
 * Colors live in data-skin scopes so the palette can be swapped without
 * touching any rule. Two skins: `moonbow` (light, the default — also bound
 * to :root so the page is never unstyled if the attribute is missing) and
 * `moonbow-dark` (explicit dark mode). The active skin is chosen by the
 * header toggle, not by prefers-color-scheme, so it's deterministic.
 */

/* skin: moonbow (default) — electric purple + gold, per moonbow.co */
:root,
[data-skin="moonbow"] {
  color-scheme: light;
  --accent: #621eff;
  --accent-soft: #621eff1f;
  --accent-2: #fbd600;
  --bg: #ffffff;
  --surface: #f4f4f6;
  --text: #1c1633;
  --muted: #6a6588;
  --border: #e4e4ea;
  --pass: #16a34a;
  --warn: #c98a00;
  --fail: #c02b0a;
  --skip: #8a8a8a;
}

/* skin: moonbow-dark — the same palette shifted into dark mode */
[data-skin="moonbow-dark"] {
  color-scheme: dark;
  --accent: #9b81ff;
  --accent-soft: #9b81ff26;
  --accent-2: #fbd600;
  --bg: #140f2e;
  --surface: #1f1947;
  --text: #ece9fb;
  --muted: #a49fce;
  --border: #332a63;
  --pass: #3ecf6a;
  --warn: #e8b53a;
  --fail: #ff6b6b;
  --skip: #8a8a8a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  /* sticky footer: body fills the viewport, main grows so the footer
     always sits at the bottom even when content is short */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main.container { flex: 1 0 auto; }

.container { max-width: 860px; margin: 0 auto; padding: 0 1.25rem; }

/* header / footer */
.site-header { border-bottom: 1px solid var(--border); }
.header-row { display: flex; justify-content: space-between; align-items: center; padding: .95rem 1.25rem; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); }
.brand-mark { font-weight: 800; font-size: 1.15rem; letter-spacing: -.03em; }
.brand-logo { height: 22px; width: auto; display: block; }
/* the wordmark ships in brand purple; whiten it on the dark header/footer */
.site-header .brand-logo,
.footer-brand .brand-logo { filter: brightness(0) invert(1); }
.footer-brand .brand-logo { height: 20px; margin-bottom: .1rem; }
.brand-tool { font-weight: 600; font-size: .82rem; color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 1rem; }
.header-link { color: var(--accent); text-decoration: none; font-size: .9rem; }
.skin-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; font-size: 1rem; line-height: 1; cursor: pointer;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 99px; padding: 0;
}
.skin-toggle:hover { background: var(--accent); color: #fff; }

.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; padding: 1.75rem 0; color: var(--muted); font-size: .85rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; flex-wrap: wrap; }
.footer-brand .brand-mark { font-size: 1.05rem; color: var(--text); }
.footer-tagline { margin: .3rem 0 0; }
.footer-meta { text-align: right; }
.footer-meta p { margin: 0 0 .25rem; }
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* moonbow branding — purple header + dark footer, per moonbow.co.
   `^="moonbow"` matches both the light (moonbow) and dark (moonbow-dark) skins. */
[data-skin^="moonbow"] .site-header {
  background: linear-gradient(120deg, #621eff 0%, #4718bd 100%);
  border-bottom: none;
}
[data-skin^="moonbow"] .site-header .brand,
[data-skin^="moonbow"] .site-header .brand-mark { color: #fff; }
[data-skin^="moonbow"] .site-header .brand-tool { color: rgba(255, 255, 255, .82); }
[data-skin^="moonbow"] .header-link { color: #fff; }
[data-skin^="moonbow"] .header-link:hover { color: var(--accent-2); }
[data-skin^="moonbow"] .skin-toggle {
  background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .55);
}
[data-skin^="moonbow"] .skin-toggle:hover { background: #fff; color: #621eff; border-color: #fff; }

[data-skin^="moonbow"] .site-footer { background: #100c26; border-top: none; color: #b7b1d8; }
[data-skin^="moonbow"] .footer-brand .brand-mark { color: #fff; }
[data-skin^="moonbow"] .site-footer a { color: var(--accent-2); }

/* hero */
h1 { font-size: 2.4rem; margin: 2.5rem 0 .5rem; letter-spacing: -.02em; }
.lede { color: var(--muted); max-width: 640px; }
.lede.small { font-size: .9rem; }

/* form */
.input-row { display: flex; gap: .6rem; margin: 1.5rem 0 .5rem; }
#url-input {
  flex: 1; padding: .8rem 1rem; font-size: 1rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
#url-input:focus { outline: none; border-color: var(--accent); }
#scan-btn {
  padding: .8rem 1.8rem; font-size: 1rem; font-weight: 600;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); cursor: pointer;
}
#scan-btn:hover { filter: brightness(1.08); }
#scan-btn:disabled { opacity: .55; cursor: wait; }

.link-btn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: .9rem; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* customize panel */
.customize-panel {
  margin-top: 1rem; padding: 1rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.customize-head { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }

/* site-type profile selector */
.site-type { margin-bottom: 1.1rem; }
.site-type-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .45rem; }
.site-type-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.site-type-btn {
  font-size: .85rem; font-weight: 600; cursor: pointer; line-height: 1;
  padding: .45rem .95rem; border-radius: 99px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.site-type-btn:hover { border-color: var(--accent); }
.site-type-btn.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.site-type-desc { font-size: .82rem; color: var(--muted); margin: .55rem 0 0; }

.check-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.check-group { border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem .9rem .8rem; margin: 0; min-width: 0; }
.check-group legend { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 .35rem; }
.check-group label { display: flex; align-items: center; gap: .45rem; font-size: .9rem; padding: .15rem 0; cursor: pointer; }
.check-group label.disabled { color: var(--muted); opacity: .5; cursor: not-allowed; }
.check-group input { accent-color: var(--accent); }
.check-group input:disabled { cursor: not-allowed; }
.stub-tag { font-size: .7rem; color: var(--skip); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; }

.error { color: var(--fail); font-weight: 500; }

/* results — score card */
.score-card {
  position: relative;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface);
  padding: 1.75rem 1.5rem 2rem;
  margin: 2.5rem 0 1.25rem;
  text-align: center;
}
.score-card-label {
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .3rem;
}
#scanned-url { margin: 0; font-size: 1.3rem; word-break: break-all; }

/* share button (top-right of the card) */
.share-btn {
  position: absolute; top: 1.05rem; right: 1.05rem;
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .82rem; font-weight: 600; cursor: pointer; line-height: 1;
  padding: .42rem .8rem; border-radius: 99px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-btn svg { width: 14px; height: 14px; }
.share-btn svg circle { fill: currentColor; }
.share-btn svg line { stroke: currentColor; stroke-width: 1.6; }

/* semicircle score gauge */
.gauge { position: relative; width: 220px; max-width: 100%; margin: 1.1rem auto .2rem; }
.gauge-svg { width: 100%; height: auto; display: block; }
.gauge-bg, .gauge-fg { fill: none; stroke-width: 14; stroke-linecap: round; }
.gauge-bg { stroke: var(--border); }
.gauge-fg { stroke: var(--accent); transition: stroke-dashoffset .9s ease; }
.gauge-text { position: absolute; left: 0; right: 0; bottom: .2rem; display: flex; justify-content: center; }
#score-value { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }

/* level badge + name */
.level-badge {
  display: inline-block; margin: .35rem 0 0;
  font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: #fff; background: var(--accent); padding: .3rem .75rem; border-radius: 99px;
}
.level-name { margin: .45rem 0 0; font-size: 1.35rem; letter-spacing: -.01em; }

.score-card-divider { height: 1px; background: var(--border); margin: 1.5rem 0 1.4rem; }

/* per-category sub-score rings */
.subscores { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 1rem; }
.subscore { display: flex; flex-direction: column; align-items: center; }
.subscore-ringwrap { position: relative; width: 66px; height: 66px; }
.subscore-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.sub-bg, .sub-fg { fill: none; stroke-width: 6; stroke-linecap: round; }
.sub-bg { stroke: var(--border); }
.sub-fg { stroke: var(--accent); transition: stroke-dashoffset .9s ease; }
.subscore-val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: 800;
}
.subscore.is-optional .subscore-val { color: var(--muted); }
.subscore-name { font-size: .78rem; font-weight: 700; margin-top: .4rem; line-height: 1.2; }
.subscore-frac { font-size: .74rem; color: var(--muted); margin-top: .1rem; }

/* actions row under the card */
.results-actions {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin: 0 0 2rem; flex-wrap: wrap;
}
.results-actions p { margin: 0; color: var(--muted); font-size: .9rem; }

/* category groups — bordered section with a passed/total header */
.result-group {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1.25rem;
}
.result-group-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .7rem; }
.result-group-head h3 { margin: 0; font-size: 1rem; }
.result-group-count { font-size: .85rem; font-weight: 700; color: var(--muted); }

/* each check is a collapsible card */
.result-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: .5rem; background: var(--surface); overflow: hidden;
}
.result-item:last-child { margin-bottom: 0; }
.result-item > summary {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .9rem; cursor: pointer; list-style: none;
}
.result-item > summary::-webkit-details-marker { display: none; }
.result-item > summary::after { content: "⌄"; margin-left: auto; color: var(--muted); }
.result-item[open] > summary::after { content: "⌃"; }
.res-icon {
  flex: none; width: 20px; height: 20px; border-radius: 99px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 800; color: #fff;
}
.res-icon.pass { background: var(--pass); }
.res-icon.warn { background: var(--warn); }
.res-icon.fail { background: var(--fail); }
.res-icon.skipped, .res-icon.error { background: var(--skip); }
.res-name { font-weight: 600; }

.res-body { padding: 0 .9rem .9rem; }
.res-body h4 {
  margin: .85rem 0 .3rem; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.res-body .rec-body { padding: 0; }
.res-issue { margin: .2rem 0; font-size: .9rem; color: var(--muted); }
.result-item.status-fail .res-issue,
.result-item.status-warn .res-issue { color: var(--fail); }
.res-issue a { color: var(--accent); }
.res-resources { display: flex; flex-wrap: wrap; gap: .4rem; }
.res-pill {
  font-size: .75rem; text-decoration: none; color: var(--accent);
  border: 1px solid var(--border); border-radius: 99px; padding: .15rem .6rem;
}
.res-pill:hover { border-color: var(--accent); }

/* recommendations */
#recs-section { margin-top: 1.5rem; }

/* rendered markdown inside a recommendation */
.rec-body { padding: .3rem 1.1rem 1rem; }
.rec-body > :first-child { margin-top: .6rem; }
.rec-body h3, .rec-body h4, .rec-body h5 { margin: 1rem 0 .4rem; line-height: 1.3; }
.rec-body h3 { font-size: 1rem; }
.rec-body h4, .rec-body h5 { font-size: .92rem; }
.rec-body p { margin: .5rem 0; font-size: .9rem; }
.rec-body ul, .rec-body ol { margin: .5rem 0; padding-left: 1.4rem; }
.rec-body li { margin: .3rem 0; font-size: .9rem; }
.rec-body a { color: var(--accent); }
.rec-body :not(pre) > code {
  font-family: var(--mono); font-size: .82em;
  background: var(--accent-soft); color: var(--accent);
  padding: .05rem .32rem; border-radius: 4px;
}
.rec-body pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; margin: .6rem 0; padding: .85rem 1rem;
  overflow-x: auto;
}
.rec-body pre code {
  background: none; padding: 0; color: var(--text);
  font-family: var(--mono); font-size: .82rem; white-space: pre-wrap; word-break: break-word;
}
.disclaimer { font-size: .78rem; color: var(--muted); margin-top: 1.5rem; }

/* faq */
.faq { margin-top: 3.5rem; }
.faq details { border-bottom: 1px solid var(--border); padding: .75rem 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); }

/* spinner state on button */
.scanning #scan-btn::after { content: "…"; }

@media (max-width: 560px) {
  h1 { font-size: 1.8rem; }
  .input-row { flex-direction: column; }
  .footer-meta { text-align: left; }
}
