/* SkillSpector Web: package-insert world.
   The carton band is the shell, the leaflet is the page, the verdict is the strength. */

:root {
  --paper: #fbfbf9;
  --surface: #ffffff;
  --ink: #161a19;
  --muted: #545d5a;
  --rule: #d6dad8;
  --rule-strong: #161a19;
  --field: #f4f6f5;
  --field-border: #959e9b;

  --carton: #00756d;
  --carton-deep: #005a54;
  --carton-dot: #55b3aa;
  --carton-ink: #ffffff;
  --carton-soft: #e3f1ef;
  --accent: #00756d;

  --sev-critical: #a3141c;
  --sev-high: #b93a09;
  --sev-medium: #8a6100;
  --sev-low: #2e6280;
  --sev-safe: #1d7447;
  --sev-info: #545d5a;

  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --narrow: 72%;
  --semi: 86%;

  --step--2: 0.75rem;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2.25rem;
  --step-4: clamp(2.75rem, 3vw + 1.6rem, 4.5rem);

  --radius: 3px;
  --border: 1.5px solid var(--rule-strong);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1413;
    --surface: #161d1c;
    --ink: #e5ebe9;
    --muted: #9ba8a4;
    --rule: #2b3634;
    --rule-strong: #4a5956;
    --field: #0f1413;
    --field-border: #4f5d5a;

    --carton: #0a6a63;
    --carton-deep: #064843;
    --carton-dot: #3f9f96;
    --carton-ink: #ffffff;
    --carton-soft: #13302d;
    --accent: #55c4b8;

    --sev-critical: #c4343a;
    --sev-high: #ad4512;
    --sev-medium: #9a6f06;
    --sev-low: #3a7699;
    --sev-safe: #23805a;
    --sev-info: #5f6b68;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--field-border) var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.55 var(--sans);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
}
::selection { background: color-mix(in srgb, var(--carton) 26%, transparent); color: inherit; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { text-wrap: balance; }

.carton-inner, main > section {
  width: min(100% - 32px, 1180px);
  margin-inline: auto;
}

/* ---------------------------------------------------------------- carton band */
.carton { background: var(--carton); color: var(--carton-ink); }
.carton-inner { display: flex; align-items: center; gap: 28px; min-height: 72px; }
.brand { display: inline-flex; align-items: baseline; gap: 8px; color: inherit; text-decoration: none; }
.brand-name { font-weight: 800; font-stretch: var(--narrow); font-size: 1.875rem; line-height: 1; letter-spacing: -0.005em; }
.brand-sub { font-weight: 500; font-size: var(--step--1); }
.braille { width: 172px; height: auto; flex: none; }
.braille-dots { fill: var(--carton-dot); }
.braille-shade { fill: var(--carton-deep); }
.mast-links { display: flex; gap: 24px; margin-left: auto; font-size: var(--step--1); font-weight: 500; }
.mast-links a { color: inherit; text-decoration: none; text-underline-offset: 0.25em; }
.mast-links a:hover { text-decoration: underline; }
.mast-links a:focus-visible { outline-color: var(--carton-ink); }
.carton-stripes {
  height: 8px;
  background: linear-gradient(var(--paper) 0 3px, var(--carton) 3px 5px, var(--paper) 5px 7px, var(--carton) 7px 8px);
}

/* ---------------------------------------------------------------- intro */
.intro {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 64px;
  align-items: start;
  padding: 56px 0 40px;
}
h1 {
  font-size: var(--step-4); font-weight: 800; font-stretch: var(--narrow);
  line-height: 0.98; letter-spacing: -0.012em;
  margin: 0 0 20px; max-width: 12ch;
}
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--muted); margin: 0; max-width: 46ch; }

.checks { margin-top: 40px; }
.checks-title { font-size: var(--step--1); font-weight: 700; margin: 0 0 6px; }
.checks-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px;
  font-size: var(--step--1);
}
.checks-list li { border-top: 1px solid var(--rule); padding: 7px 0; }

/* ---------------------------------------------------------------- scanner (the carton face) */
.scanner { background: var(--surface); border: var(--border); border-radius: var(--radius); }
.source-tabs { display: flex; border-bottom: var(--border); overflow-x: auto; }
.source-tabs button {
  appearance: none; background: none; border: 0; cursor: pointer;
  font: 700 var(--step-0) var(--sans); font-stretch: var(--semi); color: var(--muted);
  padding: 14px 22px; white-space: nowrap;
  border-right: 1px solid var(--rule);
}
.source-tabs button:hover { color: var(--ink); background: var(--field); }
.source-tabs button[aria-selected="true"] { background: var(--carton); color: var(--carton-ink); }
.source-tabs button:focus-visible { outline-offset: -4px; }

.source-panel { padding: 24px 28px 0; }

.field-label { display: block; font-weight: 700; font-size: var(--step--1); margin-bottom: 6px; }
.optional { color: var(--muted); font-weight: 400; }
input[type="url"], input[type="text"], input[type="password"], select, textarea {
  width: 100%; font: 400 var(--step-0) var(--sans); color: var(--ink);
  background: var(--field); border: 1px solid var(--field-border); border-radius: var(--radius);
  padding: 11px 12px;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea, #url-input, #api-key, #model { font-family: var(--mono); font-size: var(--step--1); }
textarea { resize: vertical; min-height: 200px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.hint { color: var(--muted); font-size: var(--step--1); margin: 8px 0 0; }

.dropzone {
  border: 1.5px dashed var(--field-border); border-radius: var(--radius);
  padding: 28px 16px; text-align: center; background: var(--field);
  transition: border-color .15s, background-color .15s;
}
.dropzone.is-over { border-color: var(--carton); border-style: solid; background: var(--carton-soft); }
.drop-title { margin: 0; font-weight: 700; }
.drop-or { margin: 6px 0 10px; color: var(--muted); font-size: var(--step--1); }
.drop-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.drop-selected { margin: 14px 0 0; font-family: var(--mono); font-size: var(--step--1); overflow-wrap: anywhere; }

/* analysis depth: leaflet rows */
.depth { border: 0; padding: 0; margin: 26px 28px 0; min-width: 0; }
.depth legend { font-weight: 700; font-size: var(--step--1); margin-bottom: 8px; padding: 0; }
.depth-option {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  padding: 13px 12px; border-top: 1px solid var(--rule);
  transition: background-color .15s;
}
.depth-option:last-of-type { border-bottom: 1px solid var(--rule); }
.depth-option:hover { background: var(--field); }
.depth-option:has(input:checked) { background: var(--carton-soft); }
.depth-option:has(input:focus-visible) { outline: 2.5px solid var(--accent); outline-offset: -2px; }
.depth-option input { margin: 3px 0 0; accent-color: var(--carton); width: 17px; height: 17px; flex: none; }
.depth-name { display: block; font-weight: 700; }
.depth-desc { display: block; color: var(--muted); font-size: var(--step--1); margin-top: 2px; max-width: 62ch; }

.byok { margin-top: 14px; padding: 16px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--field); display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.byok-row:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
.byok .hint { grid-column: 1 / -1; margin: 0; }
.byok input, .byok select { background: var(--surface); }

.submit-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 24px; padding: 20px 28px 24px; border-top: var(--border);
}
.form-error { color: var(--sev-critical); margin: 0; font-size: var(--step--1); font-weight: 600; }
.form-error:empty { display: none; }

/* buttons */
.btn-primary, .btn-secondary, .btn-ghost {
  font: 700 var(--step-0) var(--sans); border-radius: var(--radius); cursor: pointer;
  padding: 11px 20px; border: 1px solid transparent; text-decoration: none; display: inline-block;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary {
  background: var(--carton); color: var(--carton-ink); font-stretch: var(--semi);
  font-size: 1.0625rem; padding: 13px 34px;
}
.btn-primary:hover { background: var(--carton-deep); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--field-border); font-size: var(--step--1); padding: 9px 14px; font-weight: 600; }
.btn-secondary:hover { border-color: var(--ink); }
.btn-ghost { background: none; color: var(--accent); font-size: var(--step--1); padding: 9px 4px; }
.btn-ghost:hover { text-decoration: underline; text-underline-offset: 0.2em; }

/* ---------------------------------------------------------------- progress */
.result { padding: 16px 0 8px; scroll-margin-top: 16px; }
.progress { background: var(--surface); border: var(--border); border-radius: var(--radius); padding: 28px; }
.progress-bar { height: 8px; background: var(--carton-soft); overflow: hidden; }
.progress-bar span {
  display: block; height: 100%; width: 34%;
  background: var(--carton);
  animation: sweep 1.6s cubic-bezier(.45,0,.2,1) infinite;
}
@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.progress-text { margin: 18px 0 0; font-weight: 800; font-stretch: var(--semi); font-size: var(--step-2); font-variant-numeric: tabular-nums; }
.progress-sub { margin: 4px 0 0; color: var(--muted); font-size: var(--step--1); max-width: 70ch; }

.error-panel { background: var(--surface); border: 1.5px solid var(--sev-critical); border-radius: var(--radius); padding: 24px 28px; }
.error-panel h2 { margin: 0 0 8px; font-size: var(--step-3); font-stretch: var(--narrow); font-weight: 800; line-height: 1.05; }
.error-panel p { margin: 0 0 18px; color: var(--muted); max-width: 65ch; }

/* ---------------------------------------------------------------- verdict carton */
.report { --tone: var(--sev-medium); }
.report[data-tone="critical"] { --tone: var(--sev-critical); }
.report[data-tone="high"] { --tone: var(--sev-high); }
.report[data-tone="medium"] { --tone: var(--sev-medium); }
.report[data-tone="safe"] { --tone: var(--sev-safe); }

.verdict { background: var(--surface); border: var(--border); border-radius: var(--radius); overflow: hidden; }
.verdict-band {
  background: var(--tone); color: #fff;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end;
  padding: 22px 28px 24px;
  box-shadow: 0 3px 0 var(--surface), 0 5px 0 var(--tone);
  margin-bottom: 5px;
}
.verdict-source { margin: 0; font-family: var(--mono); font-size: var(--step--1); color: #fff; overflow-wrap: anywhere; }
.verdict-word {
  margin: 10px 0 0; color: #fff;
  font-size: clamp(2.75rem, 5vw + 1.2rem, 5.5rem); font-weight: 850; font-stretch: 68%;
  line-height: 0.9; letter-spacing: -0.01em;
}
.verdict-strength {
  margin: 0; display: flex; align-items: flex-end; gap: 10px;
  padding-left: 24px; border-left: 1px solid rgba(255,255,255,.45);
}
.strength-num {
  font-size: clamp(2.75rem, 4vw + 1.2rem, 5rem); font-weight: 800; font-stretch: var(--narrow);
  line-height: 0.85; font-variant-numeric: tabular-nums;
}
.strength-unit { font-size: var(--step--2); font-weight: 700; line-height: 1.2; text-transform: uppercase; letter-spacing: 0.06em; padding-bottom: 2px; }

.verdict-body { padding: 24px 28px 26px; }
.verdict-summary { margin: 0 0 28px; font-size: var(--step-1); max-width: 60ch; }

.scale { margin-bottom: 24px; }
.scale-track {
  position: relative; height: 8px;
  background: linear-gradient(90deg, var(--sev-safe) 0 30%, var(--sev-medium) 30% 50%, var(--sev-high) 50% 80%, var(--sev-critical) 80% 100%);
}
.scale-marker {
  position: absolute; top: 50%; left: 0; width: 8px; height: 26px; margin-left: -4px; margin-top: -13px;
  background: var(--ink); border: 2px solid var(--surface); border-radius: 2px;
  transition: left 900ms cubic-bezier(.16,1,.3,1);
}
.scale-threshold { position: absolute; left: 50%; top: -6px; bottom: -6px; width: 0; border-left: 2px dashed var(--ink); margin-left: -1px; }
.scale-labels { position: relative; display: flex; justify-content: space-between; font-size: var(--step--2); color: var(--muted); margin-top: 9px; font-variant-numeric: tabular-nums; }
.scale-threshold-label { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-weight: 700; color: var(--ink); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); column-gap: 24px; margin: 0; }
.facts div { min-width: 0; border-top: 1px solid var(--rule); padding: 9px 0; }
.facts dt { font-size: var(--step--2); color: var(--muted); font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.caveat {
  margin: 20px 0 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--sev-medium) 55%, transparent); border-radius: var(--radius);
  background: color-mix(in srgb, var(--sev-medium) 9%, var(--surface)); font-size: var(--step--1); max-width: 90ch;
}
.caveat::before { content: "Note. "; font-weight: 800; }

/* ---------------------------------------------------------------- findings: leaflet warnings */
.findings { margin-top: 44px; }
.findings-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; margin-bottom: 14px; border-bottom: var(--border); }
.findings-head h3 { margin: 0; font-size: var(--step-3); font-weight: 800; font-stretch: var(--narrow); line-height: 1; }
.sev-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.sev-filter button {
  font: 600 var(--step--1) var(--sans); cursor: pointer; color: var(--ink); font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--field-border); border-radius: var(--radius); padding: 5px 11px;
  display: inline-flex; align-items: center; gap: 7px;
}
.sev-filter button:hover { border-color: var(--ink); }
.sev-filter button[aria-pressed="false"] { color: var(--muted); background: transparent; border-style: dashed; }
.sev-filter button[aria-pressed="false"] .dot { opacity: .3; }
.dot { width: 10px; height: 10px; border-radius: 1px; background: var(--sev, var(--muted)); flex: none; }

.finding-list {
  list-style: none; margin: 0; padding: 0; counter-reset: finding;
  border-bottom: var(--border);
}
.finding-list > li { counter-increment: finding; min-width: 0; }
.finding-list > li + li { border-top: 1px solid var(--rule); }
.finding-body > div { min-width: 0; }
.finding { --sev: var(--sev-low); }
.finding[data-sev="CRITICAL"] { --sev: var(--sev-critical); }
.finding[data-sev="HIGH"] { --sev: var(--sev-high); }
.finding[data-sev="MEDIUM"] { --sev: var(--sev-medium); }
.finding[data-sev="INFO"] { --sev: var(--sev-info); }

/* entry head: rank, severity, title, location, open/close mark */
.finding summary {
  list-style: none; cursor: pointer; padding: 14px 4px 14px 0;
  display: grid; grid-template-columns: 2.25rem 5.25rem minmax(0, 1fr) auto 14px; gap: 4px 14px; align-items: baseline;
}
.finding summary::-webkit-details-marker { display: none; }
.finding summary::before {
  content: counter(finding); font-weight: 800; font-stretch: var(--narrow); font-size: var(--step-2);
  line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); text-align: right;
}
.finding summary::after {
  content: ""; width: 12px; height: 12px; align-self: center;
  background: linear-gradient(var(--ink), var(--ink)) center / 12px 2px no-repeat,
              linear-gradient(var(--ink), var(--ink)) center / 2px 12px no-repeat;
  transition: transform .2s cubic-bezier(.16,1,.3,1);
}
.finding[open] summary::after { transform: rotate(45deg); }
.finding summary:hover .f-title { text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
.finding summary:focus-visible { outline-offset: 2px; }
.finding .sev-tag {
  justify-self: start; background: var(--sev); color: #fff;
  font-size: var(--step--2); font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 7px; border-radius: 2px; line-height: 1.3;
}
.finding .f-title { font-weight: 800; }
.finding .f-cat { color: var(--muted); font-weight: 400; font-size: var(--step-0); }
.finding .f-loc { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); text-align: right; overflow-wrap: anywhere; }

/* entry body: leaflet paragraphs with run-in heads */
.finding-body { padding: 0 28px 22px calc(2.25rem + 5.25rem + 28px); display: grid; gap: 12px; }
.finding-body h4 { margin: 0 0 6px; font-size: var(--step-0); color: var(--ink); font-weight: 800; }
.finding-body > div:has(> p) > h4 { display: inline; margin: 0; }
.finding-body > div:has(> p) > h4::after { content: ". "; }
.finding-body > div:has(> p) > p { display: inline; }
.finding-body > div:has(> p) { max-width: 72ch; }
.finding-body p { margin: 0; }
.finding-body pre {
  margin: 0; padding: 12px 14px; background: var(--field); border: 1px solid var(--rule); border-radius: var(--radius);
  font: 400 0.8125rem/1.55 var(--mono); overflow-x: auto; white-space: pre; max-height: 320px;
  scrollbar-color: var(--field-border) var(--field);
}
.finding-body mark { background: color-mix(in srgb, var(--sev) 22%, transparent); color: inherit; border-radius: 2px; }
.f-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--muted); padding-top: 2px; }
.f-meta strong { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: var(--step--2); padding: 1px 7px; border-radius: 2px; border: 1px solid var(--field-border); color: var(--muted); }
.empty { color: var(--muted); max-width: 65ch; }

.report-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; align-items: center; }

/* ---------------------------------------------------------------- how it works: leaflet columns */
.how { padding: 48px 0 56px; border-top: var(--border); margin-top: 56px; }
.how h2 { font-size: var(--step-3); font-weight: 800; font-stretch: var(--narrow); line-height: 1; margin: 0 0 28px; }
.how-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.how-grid > div { padding: 0 24px; border-left: 1px solid var(--rule); }
.how-grid > div:first-child { padding-left: 0; border-left: 0; }
.how-grid > div:last-child { padding-right: 0; }
.how h3 { font-size: var(--step-0); font-weight: 800; margin: 0 0 8px; }
.how p { margin: 0; color: var(--muted); font-size: 0.9375rem; line-height: 1.55; }
.how .credit { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: var(--step--1); max-width: 90ch; }

/* ---------------------------------------------------------------- footer */
.site-footer { width: min(100% - 32px, 1180px); margin-inline: auto; padding: 20px 0 40px; border-top: 1px solid var(--rule); color: var(--muted); font-size: var(--step--1); line-height: 1.55; }
.site-footer p { margin: 0 0 6px; max-width: 90ch; }
.site-footer a { color: inherit; }
.site-footer a:hover { color: var(--ink); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1020px) {
  .intro { grid-template-columns: 1fr; gap: 32px; padding-top: 36px; }
  h1 { max-width: 14ch; }
  .lede { max-width: 60ch; }
  .checks { margin-top: 28px; }
  .checks-list { grid-template-columns: repeat(4, 1fr); }
  .how-grid { grid-template-columns: 1fr 1fr; row-gap: 28px; }
  .how-grid > div:nth-child(3) { padding-left: 0; border-left: 0; }
}

@media (max-width: 680px) {
  .carton-inner { gap: 16px; min-height: 60px; }
  .brand-name { font-size: 1.5rem; }
  .braille { display: none; }
  .mast-links { gap: 16px; }
  .mast-links a:first-child { display: none; }
  .intro { padding: 24px 0 24px; gap: 20px; }
  .intro-copy { display: contents; }
  .intro h1 { order: 1; margin: 0; }
  .scanner { order: 2; }
  .lede { order: 3; font-size: var(--step-0); }
  .checks { display: none; }
  .source-tabs button { padding: 12px 14px; flex: 1 0 auto; }
  .source-panel { padding: 18px 16px 0; }
  .depth { margin: 22px 16px 0; }
  .submit-row { padding: 16px; }
  .byok { grid-template-columns: 1fr; }
  .byok-row:nth-child(2) { grid-row: auto; }
  .btn-primary { width: 100%; }
  .verdict-band { grid-template-columns: 1fr; padding: 18px 16px 20px; gap: 16px; }
  .verdict-strength { padding-left: 0; border-left: 0; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.45); }
  .verdict-body { padding: 20px 16px 22px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .finding summary { grid-template-columns: 1.75rem minmax(0, 1fr) 14px; padding: 14px 2px 14px 0; gap: 6px 12px; }
  .finding summary::before { grid-row: 1 / span 3; font-size: var(--step-1); }
  .finding summary::after { grid-column: 3; grid-row: 1; }
  .finding .sev-tag { grid-column: 2; grid-row: 1; }
  .finding .f-title { grid-column: 2 / -1; }
  .finding .f-loc { grid-column: 2 / -1; text-align: left; }
  .finding-body { padding: 0 0 20px calc(1.75rem + 12px); }
  .how-grid { grid-template-columns: 1fr; }
  .how-grid > div { padding: 0; border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
