/* Campaign Card Platform — design foundation (Phase 10). RTL-first, logical properties only.
   One token set for admin and public pages. IBM Plex Sans Arabic is self-hosted (ADR-0031).
   Colours were chosen for WCAG AA on the off-white page (contrast noted beside them). */

@font-face {
  font-family: "IBM Plex Sans Arabic";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic/IBMPlexSansArabic-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic/IBMPlexSansArabic-Bold.woff2") format("woff2");
}

:root {
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;

  /* Warm neutrals */
  --bg: #f7f6f3;
  --surface: #fff;
  --surface-2: #fbfaf8;
  --ink: #18181b; /* 16.4:1 on --bg */
  --muted: #5f5f66; /* 5.9:1 on --bg */
  --border: #e7e5e1;
  --border-strong: #d6d3cd;
  --input-border: #8e8a83; /* 3.2:1: visible field edges (WCAG 1.4.11) */

  /* Admin accent: a restrained warm berry. Never changes with campaign colours. */
  --accent: #7a2948; /* 8.7:1 on --bg, white text 9.4:1 */
  --accent-hover: #64203a;
  --accent-soft: #f6edf1;
  --focus: #7a2948;

  /* Semantic */
  --danger: #a3271b; /* 6.8:1 */
  --danger-hover: #861f15;
  --danger-bg: #fbeeec;
  --danger-border: #eec5bf;
  --success-ink: #1e6b45; /* 6.0:1 */
  --success-bg: #ebf5ef;
  --warning-ink: #7a4a00; /* 6.9:1 */
  --warning-bg: #fdf4e3;
  --warning-border: #f0dcb4;

  /* Spacing scale (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Shape: restrained, not pill-shaped */
  --radius-sm: 6px;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(24 24 27 / 5%);
  --control-height: 2.875rem; /* 46px: comfortable touch targets */

  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  text-rendering: optimizelegibility;
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The hidden attribute must win over component display rules (e.g. flex boxes). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-block-size: 100vh;
  background: var(--bg);
}

h1,
h2,
h3 {
  margin-block: 0 var(--space-3);
  line-height: 1.35;
  font-weight: 700;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.125rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin-block: 0 var(--space-4);
}

a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

img {
  max-inline-size: 100%;
}

.page {
  max-inline-size: 40rem;
  margin-inline: auto;
  padding: var(--space-6) var(--space-4);
}

.muted {
  color: var(--muted);
}

.lead {
  font-size: 1.0625rem;
  color: var(--muted);
}

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

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Forms ----------------------------------------------------------------------------- */

.form {
  display: grid;
  gap: var(--space-4);
}

.field {
  display: grid;
  gap: var(--space-1);
}

label,
.label {
  font-weight: 700;
  font-size: 0.9375rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  inline-size: 100%;
  min-block-size: var(--control-height);
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
}

textarea {
  min-block-size: 4.5rem;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  border-width: 2px;
}

input[readonly] {
  color: var(--muted);
  background: var(--surface-2);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 700;
}

.required {
  color: var(--danger);
}

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

.button {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: center;
  min-block-size: var(--control-height);
  padding: 0.5rem 1.25rem;
  font: inherit;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

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

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

.button-secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border-strong);
}

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

.button-ghost {
  color: var(--ink);
  background: transparent;
  border-color: var(--border-strong);
}

.button-ghost:hover {
  color: var(--ink);
  background: var(--surface);
}

/* Quiet / text action: looks like a link, behaves like a button. */
.button-quiet {
  min-block-size: auto;
  padding: 0.25rem 0.25rem;
  color: var(--muted);
  font-weight: 400;
  background: none;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
}

.button-quiet:hover {
  color: var(--ink);
  text-decoration-color: currentcolor;
}

.button-danger {
  color: #fff;
  background: var(--danger);
}

.button-danger:hover {
  color: #fff;
  background: var(--danger-hover);
}

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

.button-danger-ghost:hover {
  color: var(--danger-hover);
  background: var(--danger-bg);
}

.button-block {
  inline-size: 100%;
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.alert {
  margin-block-end: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}

.alert-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.alert-success {
  color: var(--success-ink);
  background: var(--success-bg);
}

.alert-warning {
  color: var(--warning-ink);
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

.alert-muted {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--border);
}

/* --- System pages (errors) ------------------------------------------------------------- */

.system-page {
  display: grid;
  place-items: center;
  min-block-size: 100vh;
  padding: var(--space-5) var(--space-4);
  text-align: center;
}

.system-page h1 {
  margin-block-end: var(--space-2);
}

.debug {
  overflow-x: auto;
  padding: var(--space-4);
  background: #eceae6;
  font-size: 0.8rem;
  text-align: left;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
