/*
 * One deliberate dark theme.
 *
 * Every text/background pair here is measured, not eyeballed — see
 * test/contrast.test.ts, which fails the build if any pair drops below WCAG AA.
 * The 16px floor on UI text is a hard rule, so no interactive or explanatory
 * text is smaller than that anywhere in this file.
 */

:root {
  --bg: #0d141b;
  --surface: #17212b;
  --surface-2: #1e2b37;
  --border: #2c3d4c;
  --text: #eef4f9;
  --muted: #a9bccd;
  --accent: #56d98a;
  --accent-ink: #04220f;
  --danger: #ff9c8f;
  --warn: #f5c86b;
  --focus: #7cc4ff;

  --radius: 10px;
  --gap: 18px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.view[hidden] { display: none; }
.centred { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }

/* ---- type ---------------------------------------------------------------- */

h1, h2 { line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 19px; letter-spacing: 0.01em; }

.wordmark {
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px;
}
.wordmark span { display: block; font-size: 16px; font-weight: 500; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; }
.wordmark.small { font-size: 19px; margin: 0; }
.wordmark.small span { display: inline; font-size: 16px; margin-left: 8px; letter-spacing: 0.04em; }

.muted { color: var(--muted); margin: 0 0 12px; }
.hint  { color: var(--muted); font-size: 16px; margin: 6px 0 14px; }
.hint.indent { margin-left: 30px; }
.hint.warn, .warn { color: var(--warn); }
.error { color: var(--danger); margin: 12px 0 0; }
.status { margin: 12px 0 0; min-height: 1.5em; color: var(--muted); }
.status.ok { color: var(--accent); }
.status.bad { color: var(--danger); }

/* ---- surfaces ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: var(--gap);
}

.auth-card { width: min(420px, 100%); }

.topbar {
  /* Sticky so the app identity stays on screen while scrolling — it is also what
     a platform reviewer sees for the whole length of a demo recording. */
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-right .muted { margin: 0; }

.badge {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--warn);
  border-radius: 999px; padding: 4px 12px; font-size: 16px; font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: var(--gap);
  padding: var(--gap);
  align-items: start;
}
.col { min-width: 0; }

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

label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: 16px; }
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="password"], input[type="datetime-local"],
textarea, select {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
}
textarea { resize: vertical; min-height: 90px; }

input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input:disabled, select:disabled, textarea:disabled {
  opacity: 1;            /* opacity would drag the text under AA */
  color: var(--muted);
  background: #16202a;
  cursor: not-allowed;
}

.check {
  display: flex; align-items: flex-start; gap: 10px;
  font-weight: 500; margin: 10px 0;
  cursor: pointer;
}
/* 24px, not 20: WCAG 2.2 sets 24x24 CSS px as the minimum target size, and a
   checkbox is the smallest thing on this page. The wrapping <label> is
   clickable too, but the control itself should not need that rescue. */
.check input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--accent); }
.check input:disabled { cursor: not-allowed; }
.check.toggle { font-weight: 600; }

fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 18px 0 0; }
legend { padding: 0 8px; font-weight: 600; font-size: 16px; }

/* ---- buttons ------------------------------------------------------------- */

.button {
  display: inline-block;
  font: inherit; font-size: 16px; font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.button:hover:not(:disabled) { border-color: var(--muted); }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button.ghost { background: transparent; }
.button.block { display: block; width: 100%; margin-top: 10px; }
.button:disabled { opacity: 1; color: var(--muted); background: #16202a; cursor: not-allowed; }

.row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.row .button { flex: 1 1 auto; }

/* ---- accounts + drafts --------------------------------------------------- */

.accounts, .drafts { list-style: none; margin: 0; padding: 0; }
.accounts li, .drafts li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.accounts li:last-child, .drafts li:last-child { border-bottom: 0; }
.handle { font-weight: 600; word-break: break-word; }
/* No text-transform: capitalize here — it renders TikTok as "Tiktok".
   Display names come from PLATFORM_NAMES in app.js instead. */
.platform {
  font-size: 16px; color: var(--muted);
}
.link-danger {
  background: none; border: 0; color: var(--danger); font: inherit; font-size: 16px;
  cursor: pointer; text-decoration: underline; padding: 4px;
}

.draft-open {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  flex: 1 1 auto;
}
.draft-open:hover .handle { text-decoration: underline; }

.targets { margin-top: 20px; }
#target-list .check { margin: 8px 0; }

/* ---- TikTok panel -------------------------------------------------------- */

.tiktok { border-color: #3b5064; }
.creator { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); object-fit: cover; }
.creator-name { font-weight: 700; margin: 0; font-size: 17px; }
.creator .muted { margin: 0; }

.disclosure-label {
  margin: 14px 0 0; padding: 12px 14px;
  background: var(--surface-2);
  border-left: 4px solid var(--warn);
  border-radius: 6px;
  font-weight: 600;
}

.issues { list-style: none; margin: 16px 0 0; padding: 0; }
.issues li {
  color: var(--danger);
  padding: 8px 0 8px 24px;
  position: relative;
}
.issues li::before { content: "•"; position: absolute; left: 8px; }
.issues.warn li { color: var(--warn); }

/* ---- preview + results --------------------------------------------------- */

.preview p { margin: 0 0 10px; }
.preview .result { padding: 12px 0; border-bottom: 1px solid var(--border); }
.preview .result:last-child { border-bottom: 0; }
.result-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.verdict-ok { color: var(--accent); }
.verdict-bad { color: var(--danger); }

.consent { color: var(--muted); margin: 0 0 14px; }

#publish-results .result { padding: 10px 0; border-bottom: 1px solid var(--border); }

/* ---- OAuth callback page ------------------------------------------------- */

body.callback { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.callback-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius); padding: 28px; max-width: 520px;
}
.callback-card.bad { border-left-color: var(--danger); }
.callback-card h1 { font-size: 22px; }
.callback-card p { color: var(--muted); }
.callback-card .button { margin-top: 12px; }

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .col-accounts { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .col-accounts { grid-column: auto; }
  .topbar { padding: 14px 16px; }
  :root { --gap: 14px; }
}

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