/* ==========================================================================
   Cotavela — design tokens
   --------------------------------------------------------------------------
   Swiss grammar (see DRS tokens.css and design-canvas/lessons/swiss-grammar):

     1. Structure from ALIGNMENT and HAIRLINES, never from fill.
     2. Hierarchy from TYPE, never from decoration.
     3. Context as bordered chips, not coloured badges.
     4. One size per semantic level.
     5. No emoji, no icon that merely restates a number.

   Vogue register on top of that Swiss skeleton:
     * A high-contrast DIDONE serif for mastheads and figures. Didone (Bodoni /
       Didot) is the fashion-masthead letter — extreme thick/thin, unbracketed
       hairline serifs, vertical stress. Set LARGE and TIGHT; a Didone set small
       loses its hairlines and just looks broken, which is why body text below
       stays in a neutral grotesque.
     * Editorial whitespace: generous, asymmetric, and used as a layout
       material rather than as padding.
     * Rules (hairline + one heavy rule) instead of boxes wherever possible.
     * Ink-on-paper palette. Colour appears ONLY for market direction and for
       the single accent — never to decorate.

   Icons are drawn as inline SVG strokes (see app.js ICON), never emoji: an
   emoji is a full-colour illustration that fights a monochrome editorial page.

   MODE SWITCHING — a manual stamp always beats the OS preference.
     <html data-mode="light"> | <html data-mode="dark">

   NAMING:  --jo-<group>-<role>[-<variant>]
   ========================================================================== */

:root {
  /* --- Typefaces -----------------------------------------------------------
     No webfonts, no CDN, no build step — this has to keep working untouched.
     Didone is reached via the system serif stack: Didot ships on Apple, Bodoni
     MT on Windows/Office, and Playfair/Georgia catch the rest. Georgia is the
     deliberate floor: it is a Scotch rather than a Didone, but it is the only
     serif guaranteed everywhere, and it degrades honestly.

     The mono stack is load-bearing, not stylistic: every price sits in a
     column that has to align. */
  --jo-font-display: "Didot", "Bodoni MT", "Playfair Display", "Didot LT STD",
                     "Hoefler Text", Garamond, "Times New Roman", serif;
  --jo-font-sans: "Helvetica Neue", Helvetica, Inter, system-ui, -apple-system,
                  "Segoe UI", Roboto, Arial, sans-serif;
  --jo-font-mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono",
                  Menlo, Consolas, "Liberation Mono", monospace;

  /* --- Type scale. Ratio ~1.25, truncated hard. Few sizes, used strictly. */
  --jo-type-00: 0.625rem;   /* 10px — micro label, ALL CAPS, tracked out   */
  --jo-type-0:  0.75rem;    /* 12px — metadata, source attribution         */
  --jo-type-1:  0.875rem;   /* 14px — body, list rows                      */
  --jo-type-2:  1rem;       /* 16px — emphasised body; iOS zoom floor      */
  --jo-type-3:  1.375rem;   /* 22px — section figure                       */
  --jo-type-4:  2rem;       /* 32px — screen figure (display serif)        */
  --jo-type-5:  3.25rem;    /* 52px — masthead. Exactly one per screen.    */

  --jo-leading-flat:  0.95;  /* display figures — negative-ish leading      */
  --jo-leading-tight: 1.28;
  --jo-leading-body:  1.6;   /* the only place prose is allowed to breathe  */

  /* Tracking. Small caps must open out; Didone at size must close up. */
  --jo-track-caps:   0.18em;  /* 10px all-caps editorial labels             */
  --jo-track-wide:   0.1em;
  --jo-track-flat:   0;
  --jo-track-tight: -0.015em;
  --jo-track-hero:  -0.03em;  /* masthead only                              */

  --jo-weight-normal: 400;
  --jo-weight-medium: 500;
  --jo-weight-semi:   600;
  --jo-weight-loud:   700;    /* reserved for URGENTE. Scarcity is the point.*/

  /* --- Space. 4px base. Nothing between steps, ever. Editorial layouts lean
     on the TOP of this scale — whitespace is the material. */
  --jo-space-1:  0.25rem;
  --jo-space-2:  0.5rem;
  --jo-space-3:  0.75rem;
  --jo-space-4:  1rem;
  --jo-space-5:  1.5rem;
  --jo-space-6:  2rem;
  --jo-space-7:  3rem;
  --jo-space-8:  4.5rem;

  /* --- Grid. Mobile-first; breakpoints only ADD, never un-do. */
  --jo-grid-margin: var(--jo-space-5);   /* 24px — editorial page margin */
  --jo-grid-gutter: var(--jo-space-4);
  --jo-grid-max:    880px;               /* a briefing is a column, not a letterbox */

  /* --- Radii. Zero. An editorial page is orthogonal; rounded cards read as
     "app chrome" and break the paper illusion. The one exception is the chat
     bubble, which is a speech convention rather than a layout container. */
  --jo-radius-0: 0;
  --jo-radius-1: 1px;
  --jo-radius-bubble: 2px;

  /* --- Rules. Structure comes from these, not from fills. */
  --jo-hairline-width: 1px;
  --jo-rule-width:     2px;   /* section rule                                */
  --jo-rule-heavy:     4px;   /* masthead rule — exactly one per screen      */

  /* --- Motion. One job: show that a number changed. Never decorates. */
  --jo-motion-quick: 140ms;
  --jo-motion-flash: 900ms;
  --jo-ease: cubic-bezier(0.2, 0, 0.2, 1);

  --jo-safe-bottom: env(safe-area-inset-bottom, 0px);
  --jo-safe-top:    env(safe-area-inset-top, 0px);
}

/* --------------------------------------------------------------------------
   LIGHT — ink on paper. The default, because she reads this at 08:00.
   -------------------------------------------------------------------------- */
:root {
  --jo-canvas:        #fbfaf8;   /* warm paper, not clinical white */
  --jo-surface:       #ffffff;
  --jo-surface-sunk:  #f2f0ec;
  --jo-hairline:      #dedbd4;
  --jo-hairline-firm: #b6b2a9;
  --jo-rule:          #16151a;   /* the heavy editorial rule = near-black */

  --jo-ink-1: #16151a;
  --jo-ink-2: #4d4b52;
  --jo-ink-3: #8a8780;   /* metadata; AA on canvas at 12px+ */

  /* Single accent, Bradesco-adjacent crimson. Interactive + brand ONLY. */
  --jo-accent:      #a8072a;
  --jo-accent-ink:  #ffffff;
  --jo-accent-soft: #f6e9ec;

  /* Market direction. Lightness differs as well as hue, so the pair stays
     separable under deuteranopia — do not "harmonise" these. */
  --jo-up:        #16653c;
  --jo-up-soft:   #e8f1eb;
  --jo-down:      #a8221a;
  --jo-down-soft: #f8eae8;
  --jo-flat:      var(--jo-ink-3);

  --jo-urgent:      #8f0018;
  --jo-urgent-soft: #f8e7ea;
}

/* --------------------------------------------------------------------------
   DARK — OS preference. Zero specificity so a manual light stamp wins.
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-mode="light"])) {
    --jo-canvas:        #0c0c0e;
    --jo-surface:       #141416;
    --jo-surface-sunk:  #1b1b1f;
    --jo-hairline:      #2a2a30;
    --jo-hairline-firm: #45454f;
    --jo-rule:          #f2f1ee;

    --jo-ink-1: #f4f3f0;
    --jo-ink-2: #a9a7a2;
    --jo-ink-3: #7a7873;

    --jo-accent:      #ff5f78;
    --jo-accent-ink:  #16151a;
    --jo-accent-soft: #2b0d14;

    --jo-up:        #4ad489;
    --jo-up-soft:   #0e2519;
    --jo-down:      #ff7264;
    --jo-down-soft: #2b1310;

    --jo-urgent:      #ff5f78;
    --jo-urgent-soft: #2e0e15;
  }
}

:root[data-mode="dark"] {
  --jo-canvas:        #0c0c0e;
  --jo-surface:       #141416;
  --jo-surface-sunk:  #1b1b1f;
  --jo-hairline:      #2a2a30;
  --jo-hairline-firm: #45454f;
  --jo-rule:          #f2f1ee;

  --jo-ink-1: #f4f3f0;
  --jo-ink-2: #a9a7a2;
  --jo-ink-3: #7a7873;

  --jo-accent:      #ff5f78;
  --jo-accent-ink:  #16151a;
  --jo-accent-soft: #2b0d14;

  --jo-up:        #4ad489;
  --jo-up-soft:   #0e2519;
  --jo-down:      #ff7264;
  --jo-down-soft: #2b1310;

  --jo-urgent:      #ff5f78;
  --jo-urgent-soft: #2e0e15;
}
