/* Editor chrome. Screen only -- everything here is hidden when printing. */

:root {
  --bg: #eef0f4;
  --panel: #ffffff;
  --ink: #1a1d23;
  --ink-soft: #5b6472;
  --line: #d9dde4;
  --line-soft: #e8ebf0;
  --accent: #1f4fd8;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { margin: 0; font-size: 15px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--ink-soft); }

.actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: #f4f6fa; border-color: #c3c9d4; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover { background: #1a44bd; border-color: #1a44bd; }

.btn-ghost { color: var(--danger); }
.btn-ghost:hover { background: #fdf3f2; border-color: #eab9b4; }

/* pane tabs -- only useful on narrow screens */
.tabs { display: none; gap: 4px; background: #f0f2f6; padding: 3px; border-radius: var(--radius); }
.tab {
  font: inherit; font-size: 13px; padding: 5px 14px;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.tab.is-active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- panes ---------- */

.panes {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(0, 1.15fr);
}

/* both axes: the document is a fixed 210mm and must stay reachable when the
   pane is narrower than that */
.pane { min-height: 0; overflow: auto; }

.pane-form {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 20px 60px;
}

.pane-preview { padding: 24px; }

/* auto margins rather than justify-content: centred when it fits, and still
   scrollable from the left edge when it does not */
.preview-scroll { display: block; }

/* ---------- form ---------- */

.fs {
  border: 0;
  padding: 0;
  margin: 0 0 26px;
  /* clear the sticky section nav when jumped to. The nav wraps to two rows at
     narrow widths, so app.js measures it and sets --nav-h; the constant is only
     a fallback for before the first measurement. */
  scroll-margin-top: var(--nav-h, 64px);
}

.fs-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.fs-head h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.fs-hint { font-size: 12px; color: var(--ink-soft); }

.f { display: block; margin: 0 0 10px; }
.f-lab { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }

.f-in {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
.f-in:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea.f-in { resize: vertical; min-height: 38px; line-height: 1.45; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 > .f { margin-bottom: 10px; }

/* repeatable cards */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 0 0 10px;
  background: #fcfdff;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.ctl { margin-left: auto; display: flex; gap: 4px; flex: none; }

.btn-icon {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}
.btn-icon:hover:not(:disabled) { background: #f0f3f8; color: var(--ink); }
.btn-icon:disabled { opacity: .3; cursor: default; }
.btn-del:hover:not(:disabled) { background: #fdf3f2; border-color: #eab9b4; color: var(--danger); }

.btn-add {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px dashed #b9c1cf;
  border-radius: 6px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}
.btn-add:hover { border-color: var(--accent); color: var(--accent); background: #f6f8ff; }

/* bullet rows: textarea + controls side by side */
.bullet { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 6px; }
.bullet .f-in { flex: 1 1 auto; }
.bullet .ctl { margin-left: 0; padding-top: 3px; }

.sub-lab {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 10px 0 5px;
}


/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: #1a1d23;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 50;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- save indicator ---------- */

.brand-sub.is-saving { color: #91600a; }
.brand-sub.is-saved  { color: #1a7f47; }
.brand-sub.is-warn   { color: var(--danger); }

/* ---------- undo / redo ---------- */

.undo-group { display: flex; gap: 4px; }

.btn-sq {
  width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
}
.btn-sq:disabled { opacity: .35; cursor: default; background: #fff; border-color: var(--line); }
.btn-sq:disabled:hover { background: #fff; }

/* ---------- section nav ---------- */

.form-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: -20px -20px 18px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line-soft);
}

.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}
.nav-chip:hover { border-color: var(--accent); color: var(--accent); }
.nav-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* hollow until the section has something in it */
.nav-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1.5px solid #c3c9d4;
  flex: none;
}
.nav-chip.is-done { color: var(--ink); border-color: #b7c6ea; }
.nav-chip.is-done .dot { background: #1a7f47; border-color: #1a7f47; }

/* ---------- drag to reorder ---------- */

.grip {
  flex: none;
  width: 16px;
  color: #b9c1cf;
  font-size: 13px;
  line-height: 1;
  cursor: grab;
  user-select: none;
}
.grip:active { cursor: grabbing; }
.card:hover .grip, .bullet:hover .grip { color: var(--ink-soft); }
.bullet .grip { padding-top: 10px; }

.is-dragging { opacity: .45; }

/* a 2px rule where the row would land */
.is-drop-target { box-shadow: 0 -2px 0 0 var(--accent); }

/* ---------- page footer (also the indexable copy) ---------- */

.site-foot {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.site-foot h2 { font-size: 15px; color: var(--ink); margin: 20px 0 6px; scroll-margin-top: var(--nav-h, 64px); }
.site-foot h3 { font-size: 13px; color: var(--ink); margin: 16px 0 4px; }
.site-foot p { margin: 0 0 8px; }
.site-foot a { color: var(--accent); }
.site-foot strong { color: var(--ink); }

.foot-note {
  padding: 10px 12px;
  background: #f6f8fc;
  border-radius: 6px;
  font-size: 12px;
}
.foot-meta { margin-top: 18px; font-size: 12px; }
.foot-more { margin-top: 12px; font-size: 12px; }

/* ---------- video guides ---------- */

.guides {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin: 14px 0 4px;
}

.guide h3 { margin: 10px 0 4px; }
.guide h3 a { text-decoration: none; }
.guide h3 a:hover { text-decoration: underline; }
.guide p { font-size: 12.5px; }

/* The thumbnail is a facade: nothing is requested from YouTube until the
   button is pressed, so a visit to this page contacts no third party. */
.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1a1d23;
}

.video-play {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.video-play img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-play:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.play-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(20, 23, 28, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, transform .15s ease;
}
/* a triangle, rather than an icon font or an SVG file to fetch */
.play-icon::after {
  content: "";
  margin-left: 4px;
  border-left: 16px solid #fff;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}
.video-play:hover .play-icon { background: var(--accent); transform: scale(1.06); }

.video-dur {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(20, 23, 28, .82);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}

.video-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- download menu ---------- */

.menu { position: relative; }

.menu > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: #f0f3f8; border-color: #c3c9d4; }

.menu-body {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 300px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
}

.menu-body hr {
  border: 0;
  border-top: 1px solid var(--line-soft);
  margin: 6px 4px;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.menu-item:hover { background: #f4f6fa; }
.menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu-item strong { display: block; font-size: 13px; font-weight: 600; }
.menu-item span { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 1px; }

/* ---------- template picker ---------- */

.tpl-bar {
  max-width: 210mm;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tpl-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-right: 3px;
}

.tpl-chip {
  font: inherit;
  font-size: 12.5px;
  padding: 5px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}
.tpl-chip:hover { border-color: #b7c6ea; color: var(--ink); }
.tpl-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tpl-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* ---------- ATS check ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ink-soft);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.badge.is-error { background: var(--danger); }
.badge.is-warn { background: #b5730c; }
.badge.is-clean { background: #1a7f47; }

.ats-panel {
  max-width: 210mm;
  margin: 0 auto 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.ats-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.ats-head h2 { margin: 0; font-size: 14px; }
.ats-sub { font-size: 12px; color: var(--ink-soft); }
.ats-head .btn-icon { margin-left: auto; }

.ats-body { padding: 6px 0; max-height: 44vh; overflow-y: auto; }

.ats-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  padding: 9px 14px;
  border-left: 3px solid transparent;
  font-size: 13px;
}
.ats-item + .ats-item { border-top: 1px solid var(--line-soft); }
.ats-item.is-clickable { cursor: pointer; }
.ats-item.is-clickable:hover { background: #f6f8fc; }

.ats-item .tag {
  grid-row: 1 / span 2;
  align-self: start;
  margin-top: 1px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ats-item[data-severity="error"] { border-left-color: var(--danger); }
.ats-item[data-severity="error"] .tag { background: #fdecea; color: var(--danger); }
.ats-item[data-severity="warn"] { border-left-color: #d99311; }
.ats-item[data-severity="warn"] .tag { background: #fdf3e2; color: #91600a; }
.ats-item[data-severity="info"] { border-left-color: #b9c1cf; }
.ats-item[data-severity="info"] .tag { background: #f0f2f6; color: var(--ink-soft); }

.ats-item .msg { margin: 0; }
.ats-item .fix { margin: 0; font-size: 12px; color: var(--ink-soft); }

.ats-empty {
  padding: 22px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
}
.ats-empty strong { display: block; color: #1a7f47; font-size: 14px; margin-bottom: 3px; }

/* a field the user jumped to from a finding */
.f-in.is-flagged {
  outline: 2px solid #d99311;
  outline-offset: -1px;
  background: #fffdf7;
}

/* ---------- narrow screens: one pane at a time ---------- */

@media (max-width: 900px) {
  .tabs { display: flex; }
  .panes { grid-template-columns: 1fr; }
  .pane-preview { display: none; }
  body.show-preview .pane-form { display: none; }
  body.show-preview .pane-preview { display: block; }
  .actions .btn { font-size: 12px; padding: 6px 9px; }
  .brand-sub { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .menu-body { width: min(300px, calc(100vw - 24px)); }
  .ats-body { max-height: none; }

  /* the ATS panel belongs to the preview pane, so it follows the pane toggle */
  .ats-panel { margin-bottom: 12px; }
}

/* ---------- print: nothing but the document ---------- */

@media print {
  .topbar,
  .pane-form,
  .toast,
  .ats-panel,
  .tpl-bar,
  .site-foot { display: none !important; }

  html, body {
    height: auto;
    background: #fff;
    display: block;
    overflow: visible;
  }

  .panes { display: block; }

  .pane-preview {
    display: block !important;
    overflow: visible;
    padding: 0;
    border: 0;
  }

  .preview-scroll { display: block; }
}
