/* metar-pt. Fonts are kept with the site (SIL Open Font License, see the OFL files
   next to them); nothing is loaded from other domains. */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); }

:root {
  --bg: #F2F5F9; --surface: #FFFFFF; --surface-2: #E8EEF5; --ink: #0E1B2C; --muted: #46566B; --line: #C9D4E1;
  --accent: #0B4F8A; --accent-ink: #FFFFFF; --mark: #FFE7A3; --mark-line: #B9770E; --warn-bg: #FFF1E3; --warn: #8A3D00;
  --err: #A1271B; --focus: #0B4F8A; --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1320; --surface: #101C2E; --surface-2: #16263D; --ink: #E7EEF6; --muted: #A9B8CA; --line: #2B3D58;
    --accent: #8CC2F2; --accent-ink: #0A1320; --mark: #4B3C12; --mark-line: #F0BE5E; --warn-bg: #2D1F10; --warn: #F5C27A;
    --err: #F29489; --focus: #8CC2F2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1320; --surface: #101C2E; --surface-2: #16263D; --ink: #E7EEF6; --muted: #A9B8CA; --line: #2B3D58;
  --accent: #8CC2F2; --accent-ink: #0A1320; --mark: #4B3C12; --mark-line: #F0BE5E; --warn-bg: #2D1F10; --warn: #F5C27A;
  --err: #F29489; --focus: #8CC2F2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.55 "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-wrap: break-word;
}
h1, h2, h3, h4 { line-height: 1.2; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 8px; z-index: 10; text-decoration: none; font-weight: 600; }
.skip:focus { top: 12px; }
.mono, code, .raw { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; }

/* header */
.top { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 6px; flex-wrap: wrap; }
.brand { margin: 0; display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: url("../img/mark.svg") center / cover no-repeat; flex: none; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar select { min-height: 40px; width: auto; }
.intro { padding-top: 14px; padding-bottom: 22px; }
.intro h1 { font-size: clamp(1.7rem, 4.4vw, 2.7rem); margin: 0 0 10px; font-weight: 750; letter-spacing: -.01em; }
.lead { font-size: 1.06rem; max-width: 72ch; margin: 0 0 12px; }
.warning { margin: 0 0 10px; padding: 10px 14px; max-width: 72ch; border: 1px solid var(--warn); border-left-width: 5px; border-radius: 8px; background: var(--warn-bg); color: var(--ink); font-weight: 600; }
.notice { display: inline-block; margin: 0; padding: 6px 12px; border: 1px dashed var(--muted); border-radius: 12px; color: var(--muted); font-size: .92rem; }

/* controls */
button, select, input, textarea { font: inherit; color: inherit; }
select, input[type="search"], textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 44px; width: 100%; }
select:hover, input:hover, textarea:hover { border-color: var(--muted); }
textarea { resize: vertical; line-height: 1.45; font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
label { font-weight: 600; font-size: .95rem; display: block; margin-bottom: 6px; }

/* layout */
main { padding: 22px 0 40px; }
main:focus { outline: none; }
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; }
.picker { position: sticky; top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.picker h2 { margin: 0 0 10px; font-size: 1.15rem; }
.ad-list { border: 0; margin: 12px 0 0; padding: 0; min-width: 0; }
.ad-region + .ad-region { margin-top: 10px; }
.ad-region-title { margin: 0 0 4px; font-size: .78rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.ad-opts { display: grid; gap: 2px; }
.ad-opt { display: flex; align-items: center; gap: 8px; margin: 0; padding: 6px 8px; min-height: 40px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.ad-opt:hover { background: var(--surface-2); }
.ad-opt input { margin: 0; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.ad-opt .ad-code { margin-left: auto; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .82rem; color: var(--muted); }
.ad-opt:has(input:checked) { background: var(--surface-2); font-weight: 700; }
.ad-opt[hidden], .ad-region[hidden] { display: none; }

.reports { min-width: 0; }
.reports > h2 { margin: 0; font-size: clamp(1.5rem, 3.2vw, 2rem); }
.ad-meta { margin: 4px 0 16px; color: var(--muted); }

/* one report */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; margin-bottom: 20px; }
.report-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-head h3 { margin: 0; font-size: 1.3rem; }
.badge { font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; color: var(--warn); }
.report-meta { margin: 6px 0 0; color: var(--muted); font-size: .94rem; }
.report-meta p { margin: 2px 0; }
.unknown-note { color: var(--err); font-weight: 600; }
.report-body { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; margin-top: 14px; align-items: start; }
.raw-wrap { position: sticky; top: 12px; min-width: 0; }
.raw-label { margin: 0 0 6px; font-size: .82rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.raw { margin: 0; padding: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; line-height: 2; font-size: .95rem; }
.tok { font: inherit; padding: 1px 4px; margin: 0 1px; border: 1px solid transparent; border-radius: 5px; background: transparent; cursor: pointer; white-space: nowrap; }
.tok:hover, .tok.hl { background: var(--mark); border-color: var(--mark-line); }
.tok.unknown { text-decoration: underline wavy var(--err); text-underline-offset: 4px; }
.explain h4 { margin: 14px 0 6px; font-size: .95rem; color: var(--accent); }
.explain h4:first-child { margin-top: 0; }
.groups { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.grp { display: grid; grid-template-columns: minmax(5.5em, max-content) minmax(0, 1fr); gap: 4px 12px; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.grp:hover, .grp.hl { background: var(--mark); border-color: var(--mark-line); }
.grp-raw { font-size: .86rem; font-weight: 600; overflow-wrap: anywhere; padding-top: 1px; }
.grp-text p { margin: 0; }
.grp-text .grp-note { margin-top: 2px; color: var(--muted); font-size: .88rem; }
.grp.hl .grp-note { color: var(--ink); }
.flag { display: inline-block; margin-left: 6px; font-size: .74rem; font-weight: 700; color: var(--err); border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; }

.summary { margin: 14px 0 0; padding: 12px 14px; background: var(--surface-2); border-radius: 8px; }
.summary h4 { margin: 0 0 6px; font-size: .95rem; }
.summary dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 14px; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }
.summary p { margin: 8px 0 0; color: var(--muted); font-size: .88rem; }
.no-taf { color: var(--muted); }

/* paste */
.paste { margin-top: 18px; padding-top: 22px; border-top: 1px solid var(--line); }
.paste h2, .about h2 { margin: 0 0 8px; font-size: 1.4rem; }
.paste > p { max-width: 72ch; }
.actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
#paste-out { margin-top: 14px; }

/* about */
.about { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; margin-bottom: 10px; }
summary { cursor: pointer; padding: 12px 0; font-weight: 700; min-height: 44px; }
.prose { padding-bottom: 12px; }
.prose p { max-width: 80ch; margin: 0 0 10px; }
.table-scroll { overflow-x: auto; margin: 6px 0 10px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
caption { text-align: left; font-weight: 700; padding: 0 0 6px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); }
.small { font-size: .88rem; color: var(--muted); }

/* footer */
.foot { border-top: 1px solid var(--line); padding: 20px 0 60px; color: var(--muted); font-size: .9rem; }
.foot p { margin: 0 0 6px; max-width: 90ch; }

/* narrow screens */
@media (max-width: 1000px) {
  .report-body { grid-template-columns: minmax(0, 1fr); }
  .raw-wrap { position: static; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .picker { position: static; }
  .ad-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .report { padding: 12px; }
  .grp { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ad-opt .ad-code { font-size: .76rem; }
}
@media print {
  .toolbar, .picker, .paste, .skip { display: none; }
  .layout { grid-template-columns: 1fr; }
}
