/* Shared design tokens and primitives for the landing page and the admin panel.
   Source of truth: app/lib/design/tokens.dart (monochrome). Amber and red are
   the only hues, for warnings and faults. No gradients, no glow. */

:root {
  color-scheme: light;
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --sunken: #E8EAEF;
  --line: #D6DAE1;
  --ink: #1C1F24;
  --muted: #565E6B;
  --faint: #868D99;
  --signal: #2A2D33;
  --on-signal: #FFFFFF;
  --signal-soft: #E9EBEF;
  --warn: #8F5A12;
  --warn-soft: #F6ECDD;
  --fault: #A3372D;
  --fault-soft: #F5E3E0;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --gutter: 20px;

  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "IBM Plex Sans Arabic", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0B0C0E;
    --surface: #121418;
    --sunken: #1B1D22;
    --line: #282B32;
    --ink: #E8EBF1;
    --muted: #A1A8B4;
    --faint: #6C7380;
    --signal: #FFFFFF;
    --on-signal: #050608;
    --signal-soft: #1E2126;
    --warn: #D6A55E;
    --warn-soft: #241D12;
    --fault: #E08378;
    --fault-soft: #2A1715;
  }
}

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

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img, svg, picture { display: block; max-width: 100%; }
img { height: auto; }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--ink); color: var(--bg); }

/* Numbers, prices and codes. Fixed-width digits so values do not jitter. */
.num, .mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0;
}
.ltr { direction: ltr; unicode-bidi: isolate; }

/* Focus: always visible for keyboard users, never for mouse clicks. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 4px;
}

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

.skip {
  position: absolute;
  inset-inline-start: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--signal);
  color: var(--on-signal);
  border-radius: var(--r-sm);
  text-decoration: none;
  font-weight: 600;
}
.skip:focus-visible { top: 12px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--signal); color: var(--on-signal); }
.btn-primary:hover:not(:disabled) { background: var(--ink); }
@media (prefers-color-scheme: dark) {
  .btn-primary:hover:not(:disabled) { background: #D9DDE4; }
}

.btn-ghost { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn-ghost:hover:not(:disabled) { border-color: var(--faint); }

.btn-quiet { color: var(--ink); padding: 0 12px; }
.btn-quiet:hover:not(:disabled) { background: var(--sunken); }

.btn-danger { border-color: var(--line); background: var(--surface); color: var(--fault); }
.btn-danger:hover:not(:disabled) { border-color: var(--fault); }
.btn-danger-solid { background: var(--fault); color: #FFFFFF; }
@media (prefers-color-scheme: dark) {
  .btn-danger-solid { color: #160A08; }
}

.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

.btn svg { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------ forms */

.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field > .label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.field .opt { font-weight: 400; color: var(--faint); }
.hint { font-size: 13px; color: var(--muted); line-height: 1.5; }

.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  transition: border-color .15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
  border-color: var(--ink);
}
.textarea { min-height: 112px; resize: vertical; }
.select {
  appearance: none;
  padding-inline-start: 14px;
  padding-inline-end: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23868D99' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--fault);
}
.field-error { font-size: 13px; color: var(--fault); line-height: 1.5; }
.field-error:empty { display: none; }

/* ------------------------------------------------------------ notices */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.6;
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.notice-warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.notice-warn strong, .notice-fault strong { color: inherit; }
.notice-fault { border-color: transparent; background: var(--fault-soft); color: var(--fault); }

/* State shown as a dot next to a word (DESIGN.md rule 4). */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.dot-live { background: var(--signal); }
.dot-warn { background: var(--warn); }
.dot-fault { background: var(--fault); }
.dot-off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
