/* Semantic theme tokens: colors named by role, not by value.

   Markup and new CSS style against these (Tailwind exposes them as utilities:
   bg-surface, text-fg-muted, border-border, bg-accent… see
   app/assets/tailwind/application.css), never against the concrete brand tokens
   (--dark-3, --on-dark-1) or raw hex. A theme is then just a block that
   redefines these variables.

   Dark is the product default. data-theme="light" flips everything built on
   these tokens inside it: on <html> a whole screen, on an element one block
   (the landing page's light sections). */

/* Accessibility override of the brand's tertiary text on dark (#6A7C84): it
   read 3.6:1 on cards. #8A9CA5 reaches 5.5:1 on cards and 4.6:1 on raised
   surfaces, keeping the same hue. Applies to legacy screens too. */
:root {
  --on-dark-3: #8A9CA5;
}

/* data-theme="dark" brings it back inside a light block (code panels in the docs). */
:root, [data-theme="dark"] {
  --ui-bg:             var(--dark-2);
  --ui-bg-deep:        var(--dark-1);
  --ui-surface:        var(--dark-3);
  --ui-surface-raised: var(--dark-4);
  --ui-border:         var(--dark-4);
  --ui-border-strong:  var(--dark-5);

  --ui-fg-strong: #FFFFFF;
  --ui-fg:        var(--on-dark-1);
  --ui-fg-muted:  var(--on-dark-2);
  --ui-fg-subtle: var(--on-dark-3);

  /* Navy on teal: white on #17C4A3 is 2.2:1, navy is 8:1 (WCAG AA needs 4.5).
     The hover lightens the teal so it keeps that contrast. */
  --ui-accent:       var(--living-teal);
  --ui-accent-hover: #3DD6B8;
  --ui-accent-fg:    var(--deep-core-navy);
  --ui-focus-ring:   rgba(23, 196, 163, 0.18);
  /* Behind an accent-coloured selection (the active filter chip). */
  --ui-accent-soft:  rgba(23, 196, 163, 0.14);
  /* The accent as text or a link: on light grounds teal is too pale to read. */
  --ui-accent-text:  var(--living-teal);

  /* Status: the plain token is the foreground (text, dots, icons), -soft is
     the tinted background behind it. Tuned for contrast on the dark surface. */
  --ui-success:         var(--mint-layer);
  --ui-success-soft:    rgba(23, 196, 163, 0.14);
  --ui-processing:      #94B2D4;
  --ui-processing-soft: rgba(93, 138, 184, 0.18);
  --ui-warning:         #F0BE73;
  --ui-warning-soft:    rgba(219, 162, 76, 0.18);
  --ui-danger:          #F47B82;
  --ui-danger-soft:     rgba(224, 77, 85, 0.18);
  --ui-danger-solid:    var(--danger);

  --ui-radius-control: 10px;
  --ui-radius-card:    14px;

  --ui-shadow-raised:  var(--shadow-dark-1);
  --ui-shadow-overlay: var(--shadow-dark-2);
  --ui-shadow-glow:    var(--shadow-teal-glow);

  /* Dims the page behind a modal (the confirmation dialog's backdrop). */
  --ui-scrim: rgba(5, 15, 20, 0.65);

  /* Behind a Pix QR code: scanners need dark modules on white in any theme. */
  --ui-qr-bg: #FFFFFF;

  /* Native controls (checkbox, radio, date picker, scrollbars) follow it. */
  --ui-color-scheme: dark;
}

[data-theme="light"] {
  --ui-bg:             var(--surface-mist);
  --ui-accent-text:    var(--success-dark);
  --ui-bg-deep:        var(--surface-mist);
  --ui-surface:        var(--white);
  --ui-surface-raised: var(--surface-mist);
  --ui-border:         var(--border);
  --ui-border-strong:  var(--text-muted);

  --ui-fg-strong: var(--text-primary);
  --ui-fg:        var(--text-primary);
  --ui-fg-muted:  var(--text-secondary);
  /* The brand's tertiary (#8FA0A8) reads 2.6:1 on mist; this keeps its hue at 4.5:1. */
  --ui-fg-subtle: #627580;

  --ui-success:         var(--success-dark);
  --ui-success-soft:    var(--success-soft);
  --ui-processing:      var(--processing);
  --ui-processing-soft: var(--processing-soft);
  --ui-warning:         #9A6A1F;
  --ui-warning-soft:    var(--warning-soft);
  --ui-danger:          var(--danger);
  --ui-danger-soft:     var(--danger-soft);

  --ui-shadow-raised:  var(--shadow-1);
  --ui-shadow-overlay: var(--shadow-pop);

  --ui-scrim: rgba(8, 26, 34, 0.45);

  --ui-qr-bg: #FFFFFF;

  --ui-color-scheme: light;
}

/* Motion only for people who haven't asked to reduce it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
