/* Hopper styles. docs/design-spec.md records the roles of these tokens and components. */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --border: #e2e0da;          /* separates surfaces; not a control boundary */
  --control-border: #85837c;  /* boundary of inputs and secondary buttons (3:1 or more) */
  --text: #1d1d1b;
  --muted: #6c6a64;
  --accent: #3b5bdb;          /* primary action, selected state, links, focus */
  --accent-text: #ffffff;
  --ok: #237536;
  --warn: #8a5300;
  --bad: #c92a2a;
  --bad-text: #ffffff;
  --notice-bg: #fff4d6;
  --notice-text: #4d3800;
  --radius-surface: 12px;     /* cards, tiles, dialog, drop area */
  --radius-control: 8px;      /* buttons, inputs, tabs */
  --radius-pill: 999px;       /* platform selectors, status labels, counts */
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1e1c;
    --surface-2: #272725;
    --border: #353532;
    --control-border: #7a7972;
    --text: #ecebe6;
    --muted: #9b9991;
    --accent: #7b93f5;
    --accent-text: #0f1220;
    --ok: #69db7c;
    --warn: #ffc078;
    --bad: #ff8787;
    --bad-text: #141413;
    --notice-bg: #3a2f12;
    --notice-text: #ffe3a3;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1 { font-size: 22px; line-height: 1.3; margin: 0; }
h2 { font-size: 18px; line-height: 1.3; margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--control-border);
  background: var(--surface);
  border-radius: var(--radius-control);
  padding: 7px 14px;
  cursor: pointer;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { border-color: transparent; background: transparent; color: var(--accent); }
button.ghost:hover { background: var(--surface-2); }
button.danger, button.ghost.danger { color: var(--bad); }
.handle button.ghost { color: var(--text); }
button.small { padding: 4px 10px; font-size: 13px; }
/* A link that goes to a different site to complete the task, for example "Connect Instagram". It has the primary action role. */
a.button.primary {
  display: inline-block; padding: 7px 14px; border: 1px solid var(--accent); border-radius: var(--radius-control);
  background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none;
}
a.button.primary:hover { filter: brightness(1.08); }
button.icon { padding: 4px 8px; }
input, select, textarea {
  border: 1px solid var(--control-border);
  background: var(--surface);
  border-radius: var(--radius-control);
  padding: 7px 10px;
  max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- header and navigation --- */
.topbar {
  display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { display: block; }
.brand-name { font-weight: 700; font-size: 18px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
nav { min-width: 0; max-width: 100%; }
.tabs a {
  display: inline-block; padding: 7px 14px; border-radius: var(--radius-control);
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.count:not(:empty) {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: var(--radius-pill); background: var(--surface-2); font-size: 12px; text-align: center; color: var(--text);
}
.tabs a[aria-current="page"] .count { background: var(--surface); }
.account { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; overflow-wrap: anywhere; }
.notice {
  background: var(--notice-bg); color: var(--notice-text);
  padding: 10px 24px; font-size: 14px; border-bottom: 1px solid var(--border);
}
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head p { margin: 0; }

/* --- new post --- */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; }
.dropzone {
  display: grid; place-items: center;
  min-height: 320px;
  border: 2px dashed var(--control-border);
  border-radius: var(--radius-surface);
  background: var(--surface);
  cursor: pointer; overflow: hidden;
}
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.drag { border-color: var(--accent); }
.dropzone-empty { display: grid; gap: 4px; text-align: center; color: var(--muted); padding: 24px; }
.dropzone-empty strong { color: var(--text); }
.dropzone-preview { width: 100%; height: 100%; display: grid; place-items: center; background: var(--surface-2); }
.dropzone-preview img, .dropzone-preview video { max-width: 100%; max-height: 480px; display: block; }
.media-meta { margin: 8px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.compose-form { display: grid; gap: 18px; align-content: start; }
.field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field-label { font-weight: 600; font-size: 13px; padding: 0; }
.hint { font-size: 12px; color: var(--muted); }
.when { display: flex; gap: 8px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form-error { color: var(--bad); margin: 0; min-height: 1.5em; font-size: 14px; }

.platform-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--control-border); background: var(--surface);
  font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.notes .ok { color: var(--ok); }
.notes .warn { color: var(--warn); }
.notes .bad { color: var(--bad); }

/* --- post cards --- */
.post-list, .history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--control-border); border-radius: var(--radius-surface); }
.card {
  display: grid; grid-template-columns: auto 128px minmax(0, 1fr); gap: 16px;
  padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-surface); box-shadow: var(--shadow);
}
.card.no-handle { grid-template-columns: 128px minmax(0, 1fr); }
.card.dragging { opacity: 0.4; }
.card.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.card.drop-after { box-shadow: 0 3px 0 var(--accent); }
.handle { display: grid; align-content: center; gap: 2px; }
.handle .grip { cursor: grab; color: var(--muted); text-align: center; font-size: 18px; line-height: 1; padding: 4px 0; }
.thumb {
  width: 100%; aspect-ratio: 1; border-radius: var(--radius-control); overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center; position: relative;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge { position: absolute; bottom: 4px; left: 4px; background: rgb(0 0 0 / 0.7); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.thumb-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.card-body { display: grid; gap: 10px; min-width: 0; }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.card-top .when-label { font-weight: 600; }
.saved { font-size: 12px; color: var(--muted); }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.card .chip { font-size: 12px; padding: 3px 10px; }

.status { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: var(--radius-pill); background: var(--surface-2); }
.status.published { color: var(--ok); }
.status.partial, .status.publishing { color: var(--warn); }
.status.failed { color: var(--bad); }

/* --- history --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-surface); padding: 12px 14px; margin: 0; }
.tile dt { font-size: 13px; color: var(--muted); }
.tile dd { margin: 0; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* "Not reported" and "Not available" are text, not values, so they use the body size. */
.tile dd.no-value { font-size: 15px; font-weight: 400; color: var(--muted); padding-top: 8px; }
#history-basis { margin: 0 0 16px; }
.platform-stats { overflow-x: auto; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.history-item .targets { overflow-x: auto; }
.history-item .error { color: var(--bad); font-size: 13px; white-space: normal; text-align: left; }
.caption-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

/* --- platforms --- */
.connection-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.connection {
  display: grid; gap: 10px; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-surface); box-shadow: var(--shadow);
}
.connection p { margin: 0; overflow-wrap: anywhere; }
.connection-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.connection h3 { margin: 6px 0 0; font-size: 15px; font-weight: 600; }
.connect-form { display: grid; gap: 12px; max-width: 420px; }
.connect-form input { width: 100%; }
.import-status { font-size: 13px; }
.import-status.ok { color: var(--ok); }
.import-status.warn { color: var(--warn); }
.import-status.bad, .error-text { color: var(--bad); }

/* --- login --- */
main.login { max-width: none; min-height: 100vh; display: grid; justify-items: center; align-content: start; padding: max(48px, 14vh) 16px 48px; }
.login-card {
  width: min(420px, 100%); display: grid; gap: 20px; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-surface); box-shadow: var(--shadow);
}
.login-card p { margin: 0; }
.login-mark { display: block; margin-bottom: -6px; }
.login-option { display: grid; gap: 6px; }
.login-option .hint { padding-left: 26px; }
.login-option .check { align-items: flex-start; }
.login-option .check input { margin-top: 2px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; flex: none; }
.login-form { display: grid; gap: 20px; }
.login-form button.primary { width: 100%; padding: 10px 14px; }
.login-card .form-error:empty { display: none; }
.connect-form .form-error:empty { display: none; }

/* --- platform versions dialog --- */
dialog {
  width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-surface);
  background: var(--surface); color: var(--text); overflow: auto;
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); margin: 0; }
.dialog-tabs { display: flex; gap: 4px; padding: 10px 18px 0; flex-wrap: wrap; }
.dialog-tabs button { border-radius: var(--radius-control) var(--radius-control) 0 0; border-bottom: 0; }
.dialog-tabs button[aria-selected="true"] { background: var(--surface-2); font-weight: 600; }
.dialog-body { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; border-top: 1px solid var(--border); }
.version-preview { background: var(--surface-2); border-radius: var(--radius-control); display: grid; place-items: center; min-height: 220px; overflow: hidden; }
.version-preview img, .version-preview video { max-width: 100%; max-height: 360px; display: block; }
.version-controls { display: grid; gap: 14px; align-content: start; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.segmented { display: inline-flex; width: fit-content; border: 1px solid var(--control-border); border-radius: var(--radius-control); overflow: hidden; }
.segmented button { border: 0; border-radius: 0; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.counter { font-size: 12px; color: var(--muted); text-align: right; }
.counter.over { color: var(--bad); font-weight: 600; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: var(--radius-control); z-index: 20; max-width: calc(100vw - 32px);
  pointer-events: none; /* QA-06: the message does not block the controls below it */
}
.toast.error { background: var(--bad); color: var(--bad-text); }

/* --- narrow screens --- */
@media (max-width: 760px) {
  .compose { grid-template-columns: 1fr; }
  .dialog-body { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .notice { padding: 10px 16px; }
  .card { grid-template-columns: auto 72px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .card.no-handle { grid-template-columns: 72px minmax(0, 1fr); }
  .handle .grip { display: none; }
}
@media (max-width: 480px) {
  .card { grid-template-columns: auto minmax(0, 1fr); }
  .card.no-handle { grid-template-columns: minmax(0, 1fr); }
  .thumb { width: 96px; }
  .card-body { grid-column: 1 / -1; }
  .card-actions input[type="datetime-local"] { flex: 1 1 100%; min-width: 0; }
}
