/* style.css — Datafort design tokens and shared primitives.
 *
 * Loaded on every page. Page-specific rules live in their own file
 * (login.css, dashboard.css, ...) so the sign-in screen — the one page
 * every visitor fetches cold with no warm cache — stays small.
 *
 * Palette is sampled directly from brand/logo.png (FolksFirst Labs):
 * red #B91917 and ink #0B0B0C are the two exact values pulled off the
 * artwork. Everything else is derived from them. Update here and they
 * update everywhere.
 */

/* ══ Tokens ══════════════════════════════════════════════════════ */

:root {
  /* Brand — sampled from brand/logo.png */
  --ink:         #0B0B0C;
  --ink-700:     #16161A;
  --ink-600:     #24242B;
  --brand:       #B91917;
  --brand-600:   #9C1513;
  --brand-100:   #FDECEB;

  /* Brand red lifted for use ON the near-black chrome, where the stock
   * #B91917 sits too close to the background to read as a surface. */
  --brand-on-ink: #D62B23;

  /* Functional. Danger shares the brand hue, so it is always rendered as
   * a tint, an outline or a transient toast — never a solid fill that
   * would compete with a primary button. See .alert--error, .badge--lost.
   *
   * --status-new is deliberately NOT the brand red: "new" and "lost"
   * badges sit in the same column and must not read as the same thing.
   * The value matches STATUS.new in charts.js so a status means the same
   * colour whether it is a badge or a chart segment. */
  --red:         #DC2626;
  --amber:       #F59E0B;
  --green:       #16A34A;
  --status-new:    #2a6fe0;
  --status-new-bg: #E8F0FD;

  /* Surfaces */
  --bg:          #F5F5F6;
  --surface:     #FFFFFF;
  --surface-alt: #FAFAFB;
  --border:      #E4E4E7;
  --border-soft: #EEEEF0;

  /* Text */
  --text:        #16181B;
  --text-muted:  #6B6B75;
  --text-faint:  #8A8A95;
  --on-dark:     #FFFFFF;
  --on-dark-dim: rgba(255, 255, 255, .72);

  /* Type */
  --font-head: 'Poppins', 'Montserrat', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Shape */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(11, 11, 12, .06);
  --shadow-md: 0 4px 16px rgba(11, 11, 12, .08);
  --shadow-lg: 0 18px 48px rgba(11, 11, 12, .14);

  --ring: 0 0 0 3px rgba(185, 25, 23, .22);
}

/* Dark theme. Only tokens are redefined — no component rule below this
 * point needs to know a theme exists. */
:root[data-theme="dark"] {
  --bg:          #0C0C0E;
  --surface:     #151518;
  --surface-alt: #1D1D21;
  --border:      #2C2C32;
  --border-soft: #232328;

  --text:        #F0F0F2;
  --text-muted:  #9E9EA8;
  --text-faint:  #71717B;

  /* Brand and danger both lift on dark so they clear 4.5:1 as text. */
  --brand:       #E5443B;
  --brand-600:   #F05B52;
  --brand-100:   #3A1211;
  --red:         #F0564B;
  --status-new:    #4d8ef5;
  --status-new-bg: #16294D;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .5);
}

/* Follow the OS when the user has expressed no preference. The :not()
 * guard is what stops this from overriding an explicit light choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0C0C0E;
    --surface:     #151518;
    --surface-alt: #1D1D21;
    --border:      #2C2C32;
    --border-soft: #232328;

    --text:        #F0F0F2;
    --text-muted:  #9E9EA8;
    --text-faint:  #71717B;

    /* Brand and danger both lift on dark so they clear 4.5:1 as text. */
    --brand:       #E5443B;
    --brand-600:   #F05B52;
    --brand-100:   #3A1211;
    --red:         #F0564B;
    --status-new:    #4d8ef5;
    --status-new-bg: #16294D;
  --status-new:    #4d8ef5;
  --status-new-bg: #16294D;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .5);
  }
}


/* ══ Reset ═══════════════════════════════════════════════════════ */

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -.01em;
}

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

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }


/* ══ Focus ═══════════════════════════════════════════════════════ */

/* :focus-visible only, so pointer users never see a ring but keyboard
 * users always do. Never remove this — an admin auditing a leak at 2am
 * is exactly the person who will be driving by keyboard. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}


/* ══ Form controls ═══════════════════════════════════════════════ */

.field { display: grid; gap: 6px; }

.field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.input {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}

.input::placeholder { color: var(--text-faint); }

.input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

/* Focus now borders in brand red, which is a near-neighbour of alert red,
 * so an invalid field also carries a tint at rest. Focused = red border on
 * a plain surface; invalid = red border on a tinted one. The .field__error
 * message below the input remains the non-colour signal. */
.input[aria-invalid="true"] {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 5%, var(--surface));
}

.input:disabled {
  background: var(--surface-alt);
  color: var(--text-faint);
  cursor: not-allowed;
}

.field__error {
  font-size: 12.5px;
  color: var(--red);
  min-height: 1em;
}


/* ══ Buttons ═════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .15s, transform .06s, opacity .15s;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--brand);
  color: #fff;
}
.btn--primary:hover:not(:disabled) { background: var(--brand-600); }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface-alt); }

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--block { width: 100%; }


/* ══ Alert ═══════════════════════════════════════════════════════ */

.alert {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  border: 1px solid transparent;
}

.alert--error {
  background: color-mix(in srgb, var(--red) 8%, transparent);
  border-color: color-mix(in srgb, var(--red) 28%, transparent);
  color: var(--red);
}

/* Neutral on purpose. This variant carries success and status copy
 * ("password changed", quota notes, file details), and a brand tint put
 * those in the same red as .alert--error. */
.alert--info {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--text);
}

.alert[hidden] { display: none; }


/* ══ Utility ═════════════════════════════════════════════════════ */

/* Visible to screen readers, invisible on screen. Used for live regions
 * that announce errors without duplicating them visually. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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