/* Copyright 2026 Robert G. Patterson. SPDX-License-Identifier: MIT */

:root {
  color-scheme: light dark;
  --background: #f4f5f7;
  --surface: #ffffff;
  --text: #20242b;
  --muted: #606a78;
  --border: #c9ced6;
  --accent: #245aa8;
  --accent-hover: #174785;
  --success: #176b43;
  --warning: #825500;
  --error: #a32626;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

header, main, footer { width: min(760px, calc(100% - 2rem)); margin-inline: auto; }
header { padding: 2.5rem 0 1.25rem; }
h1 { margin: 0; font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.1; }
.tagline { color: var(--muted); margin: .5rem 0 0; }

.preview-notice, .privacy {
  border-radius: .5rem;
  margin: 0 0 1rem;
  padding: .75rem 1rem;
}

.preview-notice {
  background: #fff4d6;
  border: 1px solid #e2b95b;
  color: #5b3b00;
}

.privacy {
  background: #e4f2e9;
  border: 1px solid #a8d1b7;
  color: #164c31;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .65rem;
  box-shadow: 0 2px 8px rgb(0 0 0 / 6%);
  margin-bottom: 1rem;
  padding: 1.25rem;
}

h2 { font-size: 1.2rem; margin: 0 0 1rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset + fieldset { margin-top: 1.25rem; }
legend, .label { display: block; font-weight: 650; margin-bottom: .5rem; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: .5rem;
  padding: 1rem;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop-zone.dragging { border-color: var(--accent); background: #eaf1fb; }
.drop-zone.invalid { border-color: var(--error); }
.drop-zone input { max-width: 100%; }
.input-error { color: var(--error); font-weight: 650; margin: .65rem 0 0; }

.file-summary, .status-row, .output-list li, .actions, .preview-heading {
  align-items: center;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
}
.file-summary { background: var(--background); border-radius: .35rem; margin-top: .75rem; padding: .6rem .75rem; }
.file-summary span, .help, footer, #version { color: var(--muted); }

select, input[type="number"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .35rem;
  color: inherit;
  font: inherit;
  padding: .55rem;
  width: 100%;
}

.check-row { align-items: start; display: flex; gap: .55rem; margin: .45rem 0; }
.check-row input { margin-top: .3rem; }
.check-row label { font-weight: inherit; margin: 0; }
.label-row { align-items: baseline; display: flex; gap: .4rem; }
.label-row .label { margin-bottom: .5rem; }
/* Hint bubbles are anchored to the row so they can never overflow the panel.
   They hide with opacity, not display/visibility, so the aria-describedby text
   they hold stays in the accessibility tree while the bubble is not shown. */
.check-row, .label-row { position: relative; }

.hint { display: inline-flex; }
.hint-toggle {
  align-items: center;
  background: transparent;
  border-color: var(--border);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: .75rem;
  height: 1.15rem;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 1.15rem;
}
.check-row .hint-toggle { margin-top: .2rem; }
.hint-toggle:hover { background: var(--background); border-color: var(--accent); color: var(--accent); }
.hint-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .4rem;
  box-shadow: 0 4px 14px rgb(0 0 0 / 18%);
  color: var(--text);
  font-size: .88rem;
  font-weight: 400;
  left: 0;
  line-height: 1.4;
  max-width: min(26rem, 100%);
  opacity: 0;
  padding: .5rem .65rem;
  pointer-events: none;
  position: absolute;
  top: calc(100% + .2rem);
  transition: opacity .12s;
  width: max-content;
  z-index: 5;
}
.hint:hover .hint-bubble, .hint:focus-within .hint-bubble { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .hint-bubble { transition: none; } }
.documents { border-left: 3px solid var(--border); padding-left: .9rem; }
.documents-heading { align-items: center; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; }
.documents-heading .label { margin: 0; }
.document-actions { display: flex; gap: .35rem; }
.help { font-size: .9rem; margin: .35rem 0; }

button, .button-link {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: .4rem;
  color: white;
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-weight: 650;
  padding: .65rem 1rem;
  text-align: center;
  text-decoration: none;
}
button:hover, .button-link:hover { background: var(--accent-hover); color: white; }
button:disabled { cursor: not-allowed; opacity: .48; }
button.secondary { background: transparent; border-color: var(--border); color: var(--text); }
button.secondary:hover { background: var(--background); }
button.small { padding: .35rem .65rem; }
:focus-visible { outline: 3px solid #4c8fe8; outline-offset: 2px; }

.status-row { border-top: 1px solid var(--border); margin-top: 1.25rem; padding-top: 1rem; }
#status { margin: 0; }
#status[data-kind="success"] { color: var(--success); }
#status[data-kind="warning"] { color: var(--warning); }
#status[data-kind="error"] { color: var(--error); font-weight: 650; }

.output-list, .diagnostic-list { list-style: none; margin: 0; padding: 0; }
.output-list li { border-bottom: 1px solid var(--border); padding: .65rem 0; }
.output-list li:last-child { border-bottom: 0; }
.output-list li > span { min-width: 0; }
.output-name { font-weight: 650; overflow-wrap: anywhere; }
.output-item-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.diagnostic-list { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88rem; }
.diagnostic { border-left: 4px solid var(--border); margin: .5rem 0; overflow-wrap: anywhere; padding: .45rem .65rem; white-space: pre-wrap; }
.diagnostic-warning { border-color: var(--warning); }
.diagnostic-error { border-color: var(--error); }
.actions { flex-wrap: wrap; justify-content: flex-start; margin-top: 1rem; }

.score-preview { border-top: 1px solid var(--border); margin-top: 1.25rem; padding-top: 1rem; }
.preview-heading { align-items: start; }
.preview-heading h3 { margin: 0; }
.preview-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.preview-guidance { margin: .35rem 0 0; }
.preview-heading .help { margin-bottom: 0; }
.preview-canvas { background: #d5d8dc; border: 1px solid var(--border); border-radius: .4rem; margin-top: .75rem; max-width: calc(100vw - 2rem); min-height: 8rem; overflow: auto; padding: 1rem; scrollbar-gutter: stable; width: calc(100% + 1rem); }
.preview-render-surface > div { margin-inline: auto; }
.preview-license { color: var(--muted); font-size: .8rem; margin: .5rem 0 0; text-align: right; }

details summary { cursor: pointer; font-weight: 650; }
details p:last-child { margin-bottom: 0; }
footer { font-size: .9rem; padding: 1rem 0 2.5rem; }

[hidden] { display: none !important; }

@media print {
  @page { margin: 0; }
  body { background: #fff; color: #000; }
  body > header, body > footer, main > :not(#results), #results > :not(#previewSection),
  .preview-heading, .preview-license { display: none !important; }
  main, #results, #previewSection { background: none; border: 0; box-shadow: none; margin: 0; padding: 0; width: auto; }
  .preview-canvas { background: #fff; border: 0; border-radius: 0; margin: 0; max-height: none !important; max-width: none; min-height: 0; overflow: visible; padding: 0; scrollbar-gutter: auto; width: auto; }
  .preview-render-surface { width: 100% !important; }
  .preview-render-surface > div { break-inside: avoid; margin: 0 !important; page-break-inside: avoid; }
  .preview-render-surface > div + div { break-before: page; page-break-before: always; }
  .preview-render-surface svg { display: block; height: auto !important; width: calc(100% - 1px) !important; }
  .preview-render-surface img { display: none !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #15181d;
    --surface: #20242b;
    --text: #edf0f4;
    --muted: #acb4c0;
    --border: #49515c;
    --accent: #80b2ff;
    --accent-hover: #a8caff;
    --success: #70d4a3;
    --warning: #f0bf61;
    --error: #ff8989;
  }
  .preview-notice { background: #443512; border-color: #80682e; color: #ffe2a0; }
  .privacy { background: #163b29; border-color: #2b6848; color: #b8eccd; }
  .drop-zone.dragging { background: #263a55; }
  button, .button-link { background: #3979cf; color: white; }
  a { color: var(--accent); }
}
