/* The web demo page: a poster made of the product's own marks, the yellow
   of a match and the dashed ring of the current one. The viewer in its
   frame keeps the extension's own styles (viewer.html), tinted to match in
   viewer-web.css. Colours meet WCAG 2.1 AA in both schemes: text at least
   4.5:1 against its background, control borders and focus rings 3:1. The
   ratios noted below were measured from the rendered page. */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #0b0b0b;
  --muted: #3b3b3b;      /* 11:1 */
  --accent: #0b0b0b;
  --on-accent: #ffe14d;
  --error: #b3261e;      /* 6.6:1 */
  --focus: #0b0b0b;
  --mark: #ffe14d;       /* black on it 15:1 */
  --ring: #00532c;
  --viewer-bg: #e9e8e2;
  --sans: KaTeX_SansSerif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b;
    --surface: #0b0b0b;
    --ink: #f6f5ef;
    --muted: #cfcdc4;
    --accent: #ffe14d;
    --on-accent: #0b0b0b;
    --error: #ff8a80;
    --focus: #ffe14d;
    --ring: #5ee49b;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-padding-top: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--ink);
  text-underline-offset: 2px;
  text-decoration-color: var(--mark);
  text-decoration-thickness: 3px;
}
a:hover { color: #0b0b0b; background: var(--mark); }

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

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.skip-link:focus { top: 12px; color: var(--on-accent); }

.hint { color: var(--muted); font-size: 14px; }

/* Header */
.site-header { border-bottom: 3px solid var(--ink); background: var(--bg); }
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: none;
}
.header-link {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* The poster: headline, lede, and a formula shown as found */
.intro {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-areas: "title formula" "lede formula";
  column-gap: 48px;
  align-items: center;
  padding-top: 64px;
  padding-bottom: 40px;
}
h1 {
  grid-area: title;
  margin: 0 0 20px;
  font-weight: 700;
  font-size: clamp(52px, 8.5vw, 112px);
  line-height: 0.95;
  letter-spacing: -0.035em;
}
h1 .mark {
  /* A highlighter stroke under the word, not a box around it. */
  background: linear-gradient(transparent 58%, var(--mark) 58%, var(--mark) 92%, transparent 92%);
}
@media (prefers-color-scheme: dark) {
  h1 .mark { color: #0b0b0b; background: var(--mark); padding: 0 0.08em; }
}
.lede {
  grid-area: lede;
  margin: 0;
  max-width: 34ch;
  font-size: 20px;
}

.hero-formula {
  grid-area: formula;
  justify-self: center;
  position: relative;
  margin: 0;
  padding: 18px 26px;
  background: rgba(0, 200, 83, 0.18);
  outline: 4px dashed var(--ring);
  outline-offset: 10px;
  font-size: clamp(44px, 6vw, 76px);
}
.hero-formula::after {
  content: "1 of 1 match";
  position: absolute;
  right: -10px;
  bottom: -52px;
  padding: 4px 10px;
  background: var(--ink);
  color: var(--bg);
  font: 700 15px/1.3 var(--sans);
  letter-spacing: 0.02em;
}

/* Opening a PDF, and the samples */
.open {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 24px;
  padding-top: 36px;
  padding-bottom: 28px;
  align-items: start;
}

.open-card, .samples {
  min-width: 0;
  background: var(--surface);
  border: 3px solid var(--ink);
  padding: 20px;
}

.card-heading {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-label { display: block; margin-bottom: 6px; font-size: 15px; }

.open-row { display: flex; gap: 8px; }

#paper-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-family: var(--mono);
  font-size: 15px;
}
#paper-input::placeholder { color: var(--muted); opacity: 1; }
#paper-input[aria-invalid="true"] { border-color: var(--error); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid transparent;
  border-radius: 0;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.button.primary { background: var(--mark); color: #0b0b0b; border-color: #0b0b0b; }
.button.primary:hover { background: #0b0b0b; color: var(--mark); border-color: var(--ink); }
.button[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
.button.secondary {
  background: transparent;
  border-color: var(--ink);
  color: var(--ink);
}
.button.secondary:hover { background: var(--mark); color: #0b0b0b; }

.file-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 16px;
}

.open-status { min-height: 1.5em; margin: 12px 0 0; font-size: 15px; }
.open-status:empty { margin: 0; min-height: 0; }
.open-status.error { color: var(--error); font-weight: 600; }

.sample-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: sample;
}
.sample-list li { display: flex; min-width: 0; counter-increment: sample; }

.sample {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-width: 0;
  padding: 38px 14px 14px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sample::before {
  content: counter(sample, decimal-leading-zero);
  position: absolute;
  top: 8px;
  left: 14px;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
}
.sample:hover { background: var(--mark); color: #0b0b0b; border-color: #0b0b0b; }
.sample:hover .sample-field,
.sample:hover .sample-byline,
.sample:hover .sample-source code { color: #0b0b0b; }
.sample-field {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sample-title { font-weight: 700; line-height: 1.3; }
.sample-byline { color: var(--muted); font-size: 14px; }
.sample-formula {
  margin-top: 10px;
  font-size: 20px;
  max-width: 100%;
  overflow: hidden;
}
.sample-source {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.sample-source code {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
}

/* The viewer */
.viewer-section { padding-bottom: 32px; }
/* Targets of the page's own links: focused only so the next Tab starts there. */
.viewer-section:focus, .install:focus { outline: none; }
.viewer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 8px;
}
.viewer-head h2 {
  margin: 0;
  min-width: 0;
  font-size: 20px;
  overflow-wrap: anywhere;
}
.viewer-head .hint { margin: 0; }

.viewer-frame {
  display: block;
  width: 100%;
  height: 82vh;
  height: 82svh;
  min-height: 440px;
  max-height: 1000px;
  border: 3px solid var(--ink);
  background: var(--viewer-bg);
}

/* Install: a yellow band, edge to edge */
.install {
  margin-top: 24px;
  padding-top: 56px;
  padding-bottom: 56px;
  background: var(--mark);
  box-shadow: 0 0 0 100vmax var(--mark);
  clip-path: inset(0 -100vmax);
  color: #0b0b0b;
}
.install h2 {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: clamp(34px, 5vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.install p { max-width: 62ch; margin: 0 0 16px; font-size: 18px; }
.install a { color: #0b0b0b; text-decoration-color: #0b0b0b; }
.install-note { font-weight: 600; }
.install-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.install-button { min-width: 180px; font-size: 17px; }
.install .button.primary { background: #0b0b0b; color: var(--mark); border-color: #0b0b0b; }
.install .button.primary:hover { background: #ffffff; color: #0b0b0b; }
.install .button.secondary { border-color: #0b0b0b; color: #0b0b0b; }
/* The dark scheme's yellow focus ring would vanish on the band. */
.install :focus-visible { outline-color: #0b0b0b; }
.install-others { font-size: 15px; }
.install-others:empty { display: none; }

/* Reporting a bug */
.report {
  padding-top: 48px;
  padding-bottom: 40px;
}
.report h2 { margin: 0 0 8px; font-size: 28px; line-height: 1.3; letter-spacing: -0.01em; }
.report > p { max-width: 62ch; margin: 0 0 16px; }

.report-form { max-width: 62ch; }
.report-form textarea,
.report-form input[type="email"] {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.report-form textarea { resize: vertical; }
.report-form [aria-invalid="true"] { border-color: var(--error); }

.report-include { display: flex; align-items: flex-start; gap: 8px; }
.report-include input { width: 18px; height: 18px; margin: 3px 0 0; flex-shrink: 0; }
.report-details {
  margin: 2px 0 16px 26px;
  overflow-wrap: anywhere;
}
.report-details:empty { display: none; }

.report-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.report-status { margin: 0; font-size: 15px; }
.report-status.error { color: var(--error); font-weight: 600; }

/* Footer */
.site-footer {
  border-top: 3px solid var(--ink);
  background: var(--bg);
  padding: 24px 0 40px;
  color: var(--muted);
  font-size: 14px;
}
.site-footer h2 { margin: 0 0 8px; color: var(--ink); font-size: 15px; }
.site-footer p { max-width: 75ch; margin: 0 0 10px; }

/* Shown while a file is dragged over the page: ringed like a match */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 225, 77, 0.35);
  border: 4px dashed var(--ring);
}
.drop-overlay[hidden] { display: none; }
.drop-overlay p {
  margin: 0;
  padding: 16px 24px;
  border: 3px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
}

/* Narrower screens */
@media (max-width: 900px) {
  .intro {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "title" "lede" "formula";
    padding-top: 40px;
  }
  .hero-formula { margin: 36px 0 52px; }
  .open { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .brand, .header-link { font-size: 12px; letter-spacing: 0.02em; }
  .lede { font-size: 17px; }
  .hero-formula { font-size: 40px; padding: 12px 18px; }
  .sample-list { grid-template-columns: minmax(0, 1fr); }
  .open-card, .samples { padding: 16px; }
  .viewer-frame { height: 78vh; height: 78svh; min-height: 400px; }
  .install-button { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media (forced-colors: active) {
  .button, .sample, #paper-input { border: 1px solid ButtonText; }
}
