/* ==========================================================================
   Design tokens

   The same Nordic layer the extension's panels ship, so the page and the
   product read as one thing. The panel's stylesheet cannot be reused wholesale
   — it is written against the webview's DOM and consumes --vscode-* fallbacks
   that do not exist outside VS Code — so the token block is what travels, and
   every rule below consumes --dt-*, never a literal colour.

   The panel switches on a class VS Code stamps on <body>; a browser has no such
   class, so the switch here is the OS preference.
   ========================================================================== */

:root {
  --dt-bg: #191d21;
  --dt-chrome: #14181b;
  --dt-raised: #1f2429;
  --dt-line: #262c32;
  --dt-line-hi: #364049;
  --dt-hover: #1e2429;
  --dt-text: #dde4e8;
  --dt-dim: #95a2aa;
  --dt-faint: #8a959c;
  --dt-accent: #74bccb;
  --dt-accent-ink: #07171c;
  --dt-accent-soft: rgba(116, 188, 203, 0.15);
  --dt-good: #8fc7a4;
  --dt-good-soft: rgba(143, 199, 164, 0.15);
  --dt-warn: #de9c7c;
  --dt-warn-soft: rgba(222, 156, 124, 0.15);
  --dt-neutral: #8a959c;
  --dt-neutral-soft: rgba(138, 149, 156, 0.16);
  --dt-track: #232a2f;
  --dt-danger: #e0827c;
  --dt-shadow: rgba(0, 0, 0, 0.45);
  --dt-mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --dt-bg: #fcfdfd;
    --dt-chrome: #f1f4f5;
    --dt-raised: #ffffff;
    --dt-line: #e3e8ea;
    --dt-line-hi: #c6d0d4;
    --dt-hover: #f0f4f5;
    --dt-text: #14191c;
    --dt-dim: #54626a;
    --dt-faint: #6b767d;
    --dt-accent: #1c6a7a;
    --dt-accent-ink: #ffffff;
    --dt-accent-soft: rgba(28, 106, 122, 0.1);
    --dt-good: #2e6b47;
    --dt-good-soft: rgba(46, 107, 71, 0.1);
    --dt-warn: #9e4e2a;
    --dt-warn-soft: rgba(158, 78, 42, 0.1);
    --dt-neutral: #6b767d;
    --dt-neutral-soft: rgba(107, 118, 125, 0.14);
    --dt-track: #e9eeef;
    --dt-danger: #b3261e;
    --dt-shadow: rgba(20, 25, 28, 0.14);
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  color-scheme: dark light;
}

/* A column the height of the viewport, so the footer sits at the bottom of the
   screen on the cold page instead of floating halfway up it with a field of
   empty background underneath. `dvh` first for mobile browsers, whose toolbars
   make `vh` wrong by exactly the height of the toolbar. */
body {
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--dt-text);
  background: var(--dt-bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

main {
  flex: 0 0 auto;
}

/* Once the masthead has given its height back, the main column takes it, so a
   scan in progress -- or a short result -- still leaves the footer on the
   bottom edge of the window rather than floating under the status box. */
body.has-scan main {
  flex: 1 0 auto;
}

.wrap {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}

a {
  color: var(--dt-accent);
}

code {
  font-family: var(--dt-mono);
  font-size: 0.9em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--dt-accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Masthead and the input
   ========================================================================== */

/* One surface, two hairlines. The masthead used to be a chrome-coloured band
   whose full-bleed edge cut the page in half, while the footer's rule was inset
   to the content column -- two different kinds of divider on one page. Both are
   the same rule now, in the same column.

   `flex-grow` is what animates: on a cold page the masthead takes the leftover
   height, so its rule sits just above the footer; on the first scan it gives the
   height back and the rule travels up to meet the result. Growing to zero is a
   plain number interpolation, and the layout it produces at each frame is the
   layout the page would have had anyway. */
.masthead {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 0 auto;
  padding: 56px 0 40px;
  transition: flex-grow 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

body.has-scan .masthead {
  flex-grow: 0;
}

.masthead::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100% - 40px, 980px);
  border-top: 1px solid var(--dt-line);
}

.masthead > .wrap {
  width: 100%;
}

.eyebrow {
  font-family: var(--dt-mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dt-faint);
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(26px, 5.2vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 750;
  max-width: 20ch;
}

.lede {
  margin-top: 14px;
  max-width: 56ch;
  color: var(--dt-dim);
}

.scan-form {
  display: flex;
  gap: 8px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.scan-form input {
  flex: 1 1 260px;
  min-width: 0;
  padding: 12px 14px;
  font: inherit;
  font-family: var(--dt-mono);
  font-size: 14px;
  color: var(--dt-text);
  background: var(--dt-bg);
  border: 1px solid var(--dt-line-hi);
  border-radius: 6px;
}

/* Scan and Cancel are one control in two states, never two controls: the second
   replaces the first in the same box, so the row cannot resize under the cursor
   and the only live action is the one wearing the emphasis. */
.scan-form button {
  min-width: 112px;
  padding: 12px 22px;
}

.scan-form input::placeholder {
  color: var(--dt-faint);
}

button,
a.primary {
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

/* .primary sets display, which would otherwise beat the browser's [hidden]
   rule and leave a hidden button occupying the row. */
[hidden] {
  display: none !important;
}

.primary {
  padding: 12px 22px;
  background: var(--dt-accent);
  color: var(--dt-accent-ink);
  text-decoration: none;
  display: inline-block;
}

.primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.ghost {
  padding: 11px 16px;
  background: none;
  color: var(--dt-text);
  border-color: var(--dt-line-hi);
}

.ghost:hover {
  background: var(--dt-hover);
}

.ghost.wide {
  width: 100%;
  margin-top: 10px;
}

.examples {
  margin-top: 14px;
  font-size: 13.5px;
  color: var(--dt-faint);
}

/* Sits under the band it explains, styled as a note rather than a panel: it is
   a key to three words, not a fourth section. */
.primer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 18px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--dt-line);
  border-radius: 6px;
  background: var(--dt-chrome);
  list-style: none;
  font-size: 12.5px;
  color: var(--dt-faint);
}

.primer-key {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.primer-documented {
  background: var(--dt-good-soft);
  color: var(--dt-good);
}

.primer-bare {
  background: var(--dt-warn-soft);
  color: var(--dt-warn);
}

.primer-unused {
  background: var(--dt-neutral-soft);
  color: var(--dt-neutral);
}

.example {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-family: var(--dt-mono);
  font-size: 13px;
  color: var(--dt-accent);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* ==========================================================================
   Status — progress, refusal, failure all land here
   ========================================================================== */

/* Applied by JS when a box appears, and restarted each time it reappears -- an
   animation on the rule itself would run once, at load, while the box was still
   hidden, and never again. */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.rise {
  animation: rise 0.45s cubic-bezier(0.2, 0, 0.2, 1) both;
}

/* A coloured left rail is the shape of a validation error, and three quarters
   of what this box says is "working". It is a card with a state light instead:
   the dot carries the colour, the progress is a hairline along the bottom edge
   where a loading bar belongs, and nothing about it says something went wrong
   until something has. */
.status {
  position: relative;
  overflow: hidden;
  margin: 28px 0;
  padding: 16px 18px 17px;
  border: 1px solid var(--dt-line);
  border-radius: 8px;
  background: var(--dt-raised);
  --status-tone: var(--dt-accent);
}

.status.error {
  --status-tone: var(--dt-danger);
}

.status.refusal {
  --status-tone: var(--dt-warn);
}

.status-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-tone);
}

/* Only while something is actually happening: a light that keeps breathing
   after a failure says the page is still trying. */
.status-dot.working {
  animation: breathe 1.6s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    opacity: 0.35;
    transform: scale(0.82);
  }
}

.status-title {
  font-weight: 650;
}

.status-detail {
  margin-top: 5px;
  padding-left: 19px;
  font-size: 13.5px;
  color: var(--dt-dim);
  font-family: var(--dt-mono);
  /* `anywhere` only reached Safari in 15.4; the older keyword covers the rest. */
  word-break: break-word;
  overflow-wrap: anywhere;
}

.progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--dt-track);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--status-tone);
  transition: width 0.25s ease;
}

/* Before the file count is known there is nothing to be a fraction of, so the
   bar says "moving" rather than inventing a number. */
.progress-fill.indeterminate {
  width: 30%;
  animation: sweep 1.35s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes sweep {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(440%);
  }
}

/* ==========================================================================
   Result — hero and composition band, as the panel draws them
   ========================================================================== */

.result {
  margin: 28px 0 0;
}

.panel {
  padding: 22px 20px;
  border: 1px solid var(--dt-line);
  border-radius: 8px;
  background: var(--dt-raised);
}

.hero {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-figure {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hero-count {
  font-size: 54px;
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 0.86;
  color: var(--dt-accent);
  font-variant-numeric: tabular-nums;
}

.hero-unit {
  font-size: 13.5px;
  color: var(--dt-dim);
  max-width: 26ch;
  line-height: 1.35;
}

.hero-unit strong {
  color: var(--dt-text);
  font-weight: 650;
}

.hero-meta {
  margin-left: auto;
  text-align: right;
  font-size: 11.5px;
  color: var(--dt-faint);
  line-height: 1.5;
}

.hero-meta a {
  font-family: var(--dt-mono);
}

.band {
  display: flex;
  gap: 3px;
  height: 32px;
  margin-top: 18px;
}

.band:empty {
  display: none;
}

.band-seg {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  /* Proportional, but never so narrow that its own label is clipped: a segment
     that reads "no reaso" is worse than one slightly wider than its share. */
  min-width: -webkit-fit-content;
  min-width: fit-content;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid transparent;
  background: none;
  font-family: inherit;
  transition: transform 0.18s ease;
}

.band-seg:hover {
  transform: translateY(-2px);
}

.band-seg[aria-pressed='true'] {
  box-shadow: inset 0 0 0 2px currentColor;
}

.band-seg-count {
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.band-seg-label {
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
  flex: none;
}

.band-documented {
  background-color: var(--dt-good-soft);
  color: var(--dt-good);
}

.band-bare {
  background-color: var(--dt-warn-soft);
  color: var(--dt-warn);
}

.band-unused {
  background-color: var(--dt-neutral-soft);
  color: var(--dt-neutral);
}

/* ==========================================================================
   Caveats — on the page, not in a footnote
   ========================================================================== */

.caveats {
  margin-top: 14px;
  padding: 12px 16px;
  border: 1px solid var(--dt-line);
  border-radius: 6px;
  background: var(--dt-chrome);
  font-size: 13.5px;
}

.caveats summary {
  cursor: pointer;
  font-weight: 600;
}

.caveat-count {
  color: var(--dt-faint);
  font-weight: 400;
}

.caveats ul {
  margin: 10px 0 0 18px;
  color: var(--dt-dim);
}

.caveats li + li {
  margin-top: 6px;
}

/* ==========================================================================
   Findings table
   ========================================================================== */

.table-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 32px 0 10px;
  flex-wrap: wrap;
}

h2 {
  font-size: 12px;
  font-family: var(--dt-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dt-faint);
  font-weight: 600;
}

.table-note {
  font-size: 12.5px;
  color: var(--dt-faint);
  margin-right: auto;
}

.exports {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.exports-label {
  font-family: var(--dt-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dt-faint);
}

.ghost.small {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 550;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--dt-line);
  border-radius: 8px;
}

/* Fixed layout, so the four columns keep their share of the width whatever is
   in them. Auto layout sizes to content, and a deep path or a long reason then
   pushes the last column past the right edge -- present, scrollable, and
   invisible to anyone who does not think to scroll a table sideways. */
table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13.5px;
}

col.col-symbol {
  width: 22%;
}

col.col-kind {
  width: 10%;
}

col.col-location {
  width: 33%;
}

col.col-reason {
  width: 35%;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dt-faint);
  background: var(--dt-chrome);
  border-bottom: 1px solid var(--dt-line);
  white-space: nowrap;
}

tbody td {
  padding: 9px 14px;
  border-top: 1px solid var(--dt-line);
  vertical-align: top;
}

tbody tr:hover {
  background: var(--dt-hover);
}

.cell-name {
  font-family: var(--dt-mono);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cell-kind {
  color: var(--dt-faint);
  font-size: 12px;
  white-space: nowrap;
}

.cell-loc a {
  font-family: var(--dt-mono);
  font-size: 12.5px;
  color: var(--dt-dim);
  text-decoration: none;
  /* Long paths wrap rather than widen the table. `break-word` keeps whole
     segments together where they fit, so a break is the exception. */
  word-break: break-word;
  overflow-wrap: anywhere;
}

.cell-loc a:hover {
  color: var(--dt-accent);
  text-decoration: underline;
}

.cell-reason {
  color: var(--dt-dim);
  overflow-wrap: anywhere;
}

.cell-reason.none {
  color: var(--dt-warn);
}

/* The classification a row belongs to, as the same rail the band uses.

   Painted as a background rather than an inset shadow: with `border-collapse:
   collapse` the shadow is clipped to the cell's content box, so on a two-line
   row the rail stopped short of the bottom and read as an artefact. */
.row-documented td:first-child {
  background-image: linear-gradient(to right, var(--dt-good) 0 2px, transparent 2px);
}

.row-bare td:first-child {
  background-image: linear-gradient(to right, var(--dt-warn) 0 2px, transparent 2px);
}

.row-unused td:first-child {
  background-image: linear-gradient(to right, var(--dt-neutral) 0 2px, transparent 2px);
}

/* ==========================================================================
   Funnel and footer
   ========================================================================== */

.funnel {
  margin: 44px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--dt-line);
}

.funnel-lede {
  margin-top: 10px;
  max-width: 62ch;
  color: var(--dt-dim);
  font-size: 14px;
}

.funnel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}

.funnel-card {
  padding: 18px;
  border: 1px solid var(--dt-line);
  border-radius: 8px;
  background: var(--dt-raised);
}

.funnel-card h3 {
  font-size: 15px;
  font-weight: 650;
}

.funnel-card p {
  margin: 6px 0 14px;
  font-size: 13.5px;
  color: var(--dt-dim);
}

/* Stacked, not side by side: the command carries a repository name and a
   package name, and a button beside it leaves too little width for either. Full
   width and wrapping, with the button under it. */
.copy-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.copy-row code {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--dt-line-hi);
  border-radius: 6px;
  background: var(--dt-bg);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.copy-row button {
  flex: none;
  align-self: flex-start;
}

.copy-row code {
  flex: none;
}

/* On the cold page the masthead's own rule is already sitting directly above
   the footer, so the footer does not draw a second one 56px below it -- two
   parallel hairlines with a strip of nothing between them. Once a scan has
   started the masthead's rule travels up to the result and the footer takes its
   own back. */
body:not(.has-scan) .footnote {
  margin-top: 0;
  border-top: none;
}

.footnote {
  flex: none;
  margin: 56px auto 0;
  padding-top: 20px;
  padding-bottom: 28px;
  border-top: 1px solid var(--dt-line);
  font-size: 12.5px;
  color: var(--dt-faint);
  max-width: 980px;
}

.footnote p + p {
  margin-top: 8px;
}

@media (max-width: 600px) {
  .masthead {
    padding: 36px 0 28px;
  }

  .hero-meta {
    margin-left: 0;
    text-align: left;
    width: 100%;
  }

  .band {
    height: auto;
    flex-direction: column;
  }

  .band-seg {
    padding: 8px 12px;
  }

  /* A four-column table on a 390px screen is a table nobody reads: the reason
     wraps off-screen and sets a row height the visible columns cannot fill, so
     each row is a symbol, a path, and a column of blank space. Below 600px the
     rows become cards instead — same DOM, same order, no sideways scrolling. */
  .table-scroll {
    overflow-x: visible;
    border: none;
    border-radius: 0;
  }

  thead {
    display: none;
  }

  tbody tr {
    display: block;
    padding: 12px 14px 12px 12px;
    border: 1px solid var(--dt-line);
    border-radius: 8px;
  }

  tbody tr + tr {
    margin-top: 8px;
  }

  tbody td {
    display: block;
    padding: 0;
    border: none;
  }

  /* The rail moves to the card's own edge; the cell no longer has one. */
  .row-documented td:first-child,
  .row-bare td:first-child,
  .row-unused td:first-child {
    background-image: none;
  }

  .row-documented {
    border-left: 3px solid var(--dt-good);
  }

  .row-bare {
    border-left: 3px solid var(--dt-warn);
  }

  .row-unused {
    border-left: 3px solid var(--dt-neutral);
  }

  .cell-name {
    font-size: 14px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* The kind is the least useful of the four on a phone. */
  .cell-kind {
    display: none;
  }

  .cell-loc a {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .cell-reason {
    margin-top: 6px;
  }

  /* The cards are blocks, so the table stops being a table — colgroup included.
     Leaving the table element as `display: table` while its cells are blocks
     leaves Firefox still honouring the column widths, and the reason arrives
     32px wide. WebKit does not, which is exactly why this is checked in both. */
  table {
    display: block;
    table-layout: auto;
  }

  tbody {
    display: block;
  }

  colgroup {
    display: none;
  }

  .exports {
    width: 100%;
  }

  .exports button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
