/*
 * Plegoo Search design tokens.
 *
 * WHY ONE THEME CONTROL, AND IT IS NOT A CONTROL
 *
 * There is exactly one appearance source: the operating system. `prefers-color-scheme` is read
 * directly by the media query below, so a change to the OS theme repaints the page while it is
 * open, with no reload, no script, and nothing stored anywhere. There is deliberately no
 * theme button, no theme state in localStorage, sessionStorage, a cookie, or the backend,
 * because each of those would make the application's appearance disagree with the user's
 * system and would need a control to reconcile them again.
 *
 * WHY SEMANTIC TOKENS
 *
 * Component CSS never names a raw colour. A token says what a surface is FOR, so dark mode is
 * a second set of values for the same meanings rather than a search-and-replace of hex codes.
 * That is what keeps a border visible in both themes and stops dark mode becoming light grey
 * pretending to be dark.
 *
 * PLEGОO ACCENT
 *
 * One blue, defined here as a Plegoo token and not borrowed from any other product. It marks
 * links, focus, active filters and the primary action - and nothing else. Every state in this
 * interface is still legible with the accent mentally removed, because colour is never the
 * only carrier of meaning.
 */

:root {
  color-scheme: light dark;

  /* Surfaces, from furthest back to closest. */
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-surface-hover: #f4f6f8;
  --color-surface-sunken: #f7f8fa;

  /* Text, in descending emphasis. */
  --color-text: #14181d;
  --color-text-secondary: #444c56;
  --color-text-tertiary: #6b7480;

  /* Structure. */
  --color-border: #dfe3e8;
  --color-border-strong: #c3c9d1;

  /* The single Plegoo accent. */
  --color-accent: #1a5fd0;
  --color-accent-hover: #164da8;
  --color-accent-contrast: #ffffff;

  /* Focus must be visible in both themes and must not rely on hue alone. */
  --color-focus: #1a5fd0;

  /* Status. Used sparingly and never as decoration. */
  --color-success: #157a4a;
  --color-warning: #8a5a00;
  --color-danger: #b3261e;

  --color-selected-bg: #e8f0fd;

  /* Hairlines and radii. Compact density, not decoration. */
  --border-hairline: 1px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-pill: 999px;

  /* THE HIT-AREA FLOOR, AND IT IS NOT A SIZE ON THE SCALE.
   *
   * Every interactive target - a link, a button, a field, anything with role=button - reaches
   * at least this far in both axes, whatever the type inside it says. 44px is the smallest
   * square a fingertip lands on reliably, so it is a floor on the target and not a preference
   * about the design: the words, the icon and the colour are unchanged, only the area that
   * answers to a press grows.
   *
   * It is unconditional rather than a `pointer: coarse` rule, because a mouse click is not the
   * only way this interface is used and a trackpad gesture lands in the same few pixels a
   * thumb does. A rule that only switched the floor on for touch was a floor that was off
   * whenever nobody thought about it.
   */
  --target-min: 44px;

  /* A compact but comfortable scale. */
  --font-sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-caption: 0.6875rem;   /* 11px */
  --text-metadata: 0.8125rem;  /* 13px */
  --text-body: 0.9375rem;      /* 15px */
  --text-result-title: 1.1875rem; /* 19px */
  --text-heading: 1.75rem;     /* 28px */

  --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;

  --measure-result: 44rem;
  --measure-page: 60rem;

  /* Motion is optional and subtle, and honours the OS preference. */
  --duration-fast: 90ms;
  --easing-standard: cubic-bezier(0.2, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Genuinely dark: a deep neutral, not a light grey in dark clothing. */
    --color-bg: #0d1117;
    --color-surface: #0d1117;
    --color-surface-hover: #171d26;
    --color-surface-sunken: #010409;

    --color-text: #e8edf3;
    --color-text-secondary: #b6bfcb;
    --color-text-tertiary: #8b95a3;

    /* Borders stay visible rather than dissolving into the background. */
    --color-border: #262d38;
    --color-border-strong: #39424f;

    --color-accent: #6ba4f5;
    --color-accent-hover: #8bb8f8;
    --color-accent-contrast: #06121f;

    --color-focus: #6ba4f5;

    --color-success: #4cc38a;
    --color-warning: #d9a441;
    --color-danger: #f2837c;

    --color-selected-bg: #16243a;
  }
}

/*
 * Reduced motion is honoured, not merely mentioned. Transitions are the only thing this
 * disables; nothing here is load-bearing for comprehension.
 */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
