/* public/styles.css — dashboard styling.
 *
 * Plain CSS, no build step: the file is served as-is by Express so the whole
 * frontend ships inside the single Vercel deployment.
 *
 * Accessibility notes:
 *   - Colors are chosen to clear WCAG AA (4.5:1) for body text against their
 *     backgrounds.
 *   - Focus is always visible via a high-contrast outline, never removed.
 *   - `prefers-reduced-motion` disables transitions.
 */

:root {
  --bg: #0b0f16;
  --surface: #141a25;
  --surface-2: #1b2331;
  --border: #2a3444;
  --text: #eef2f8;
  --text-muted: #a7b3c4;
  --accent: #4c8dff;
  --accent-strong: #2f6fe0;
  --success: #3ddc97;
  --success-ink: #0c2b1f;
  --warning: #ffc857;
  --warning-ink: #34290a;
  --danger: #ff6b6b;
  --danger-ink: #3a1112;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

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

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

a {
  color: var(--accent);
}

/* The `hidden` attribute is how the dashboard toggles views and messages, but a
 * UA `[hidden] { display: none }` rule loses to any author `display` declaration
 * (e.g. `.login { display: flex }`). Without this, signing in would reveal the
 * dashboard while leaving the login screen rendered on top of it. Author-level
 * and `!important` so it beats every layout rule below. */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Visible focus for every interactive element. */
:where(button, input, select, a, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------- Cards -------------------------------- */

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

/* ------------------------------- Login -------------------------------- */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login__card {
  width: 100%;
  max-width: 380px;
}

.login__title {
  font-size: 1.4rem;
}

.login__subtitle {
  margin: 8px 0 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login__health {
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  min-height: 1.2em;
}

/* ------------------------------- Topbar ------------------------------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
}

.topbar__title {
  font-size: 1.05rem;
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar__page {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* -------------------------------- Main -------------------------------- */

.main {
  display: grid;
  gap: 18px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
}

.section__head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.section__title {
  font-size: 1.05rem;
}

.section__hint {
  margin: 6px 0 0;
  max-width: 62ch;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.section__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

/* ------------------------------- Fields ------------------------------- */

.field {
  display: block;
}

.field--inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field--inline .field__label {
  margin-bottom: 0;
}

.field__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.field__input--tiny {
  width: 84px;
}

.field__input--select {
  width: auto;
  min-width: 120px;
}

/* ------------------------------- Buttons ------------------------------ */

.button {
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button--block {
  display: block;
  width: 100%;
}

.button--primary {
  background: var(--accent);
  color: #08101f;
}

.button--primary:hover:not(:disabled) {
  background: var(--accent-strong);
  color: #fff;
}

.button--secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.button--secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.button--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.button--ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.button--danger {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}

.button--danger:hover:not(:disabled) {
  border-color: var(--danger);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ------------------------------- Alerts ------------------------------- */

.alert {
  margin: 16px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.88rem;
}

.alert--error {
  border-color: var(--danger);
  background: var(--danger-ink);
  color: #ffd9d9;
}

.alert--success {
  border-color: var(--success);
  background: var(--success-ink);
  color: #c9ffe9;
}

.alert--busy {
  border-color: var(--accent);
}

.empty {
  margin: 18px 0 0;
  padding: 22px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-align: center;
}

/* ------------------------------- Posts -------------------------------- */

.posts {
  display: grid;
  gap: 16px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.post {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

@media (max-width: 720px) {
  .post {
    grid-template-columns: 1fr;
  }
}

.post__figure {
  margin: 0;
}

.post__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #000;
}

.post__image-missing {
  display: grid;
  place-items: center;
  aspect-ratio: 1200 / 630;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.post__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.post__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.badge {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge--pending {
  border-color: var(--warning);
  background: var(--warning-ink);
  color: #ffe6ad;
}

.badge--posted {
  border-color: var(--success);
  background: var(--success-ink);
  color: #c9ffe9;
}

.badge--failed {
  border-color: var(--danger);
  background: var(--danger-ink);
  color: #ffd9d9;
}

.post__headline {
  font-size: 1.02rem;
}

.post__caption {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.post__hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hashtag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(76, 141, 255, 0.14);
  color: #b8d2ff;
  font-size: 0.76rem;
}

.post__error {
  margin: 0;
  color: #ffb4b4;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.post__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 4px;
}

.post__link {
  font-size: 0.82rem;
}

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