/* Design tokens. Every colour, size and radius in the UI comes from here – the CSS (components.css, app.css) and the
 * canvas drawings (charts, maps, thumbnails, the ride HUD: they read these through frontend/src/engine/theme.js).
 *
 * To play with colours, change the BASE COLOURS first: tints (selected rows, tag backgrounds, glows, …) are mixed
 * from them with color-mix(), so they follow. Canvas colours (DATA COLOURS) must be plain colours (#hex or rgb/rgba),
 * not color-mix() or var(). The 3D world's sky, terrain and materials are scenery and live with each world
 * (engine/worlds.js, engine/world3d.js), not here.
 */
:root {
  /* ===== BASE COLOURS ===== */
  --bg: #030208;                 /* the page behind everything: near black */
  --ink: #030208;                /* dark base for bars, overlays and wells (mixed with alpha below) */
  --light: #ffffff;              /* light base for lines, hovers and fills on the dark UI */
  --shade: #000000;              /* shadows */
  --text: #e9e5f0;
  --text-muted: #948eab;
  --text-on-accent: #140a26;     /* text on accent-coloured buttons and pills */
  --text-on-art: #ffffff;        /* text over world artwork and the 3D world (HUD) */
  --accent: #a77bff;             /* brand violet: primary buttons, selection */
  --accent-2: #ff7a8c;           /* coral: highlights, tags, focus rings */
  --ok: #6ee69a;
  --warn: #ffc53d;
  --bad: #ff5d7a;
  --danger: #ff3d6e;             /* destructive buttons */
  --dusk: #2a2060;               /* deep indigo between the violet and the black (page gradient) */
  --custom: #7d98d6;             /* your own workouts */
  --brand-strava: #fc4c02;

  /* ===== DERIVED: surfaces and lines ===== */
  --surface-base: #0a0816;                                         /* the near-black navy cards are made of */
  --surface: color-mix(in srgb, var(--surface-base) 86%, transparent);/* cards on the menu */
  --surface-strong: color-mix(in srgb, #08061a 97%, transparent);   /* sheets, dialogs */
  --surface-sunk: color-mix(in srgb, var(--shade) 30%, transparent);/* inputs, chart wells */
  --surface-inner: color-mix(in srgb, var(--light) 4%, transparent);/* cards inside cards */
  --glass: color-mix(in srgb, var(--ink) 45%, transparent);         /* HUD panels over the 3D world */
  --hud-on: color-mix(in srgb, var(--light) 26%, transparent);      /* a chosen / switched-on HUD control (not the accent) */
  --bar: color-mix(in srgb, var(--ink) 88%, transparent);           /* start bar */
  --bar-top: color-mix(in srgb, var(--ink) 70%, transparent);       /* title bar: see-through, the page blurs behind it */
  --popover: color-mix(in srgb, #08061a 78%, transparent);         /* dropdown menus: see-through, blurred behind */
  --blur-glass: blur(14px) saturate(1.4);                          /* the blur behind the title bar and dropdowns */
  --scrim: color-mix(in srgb, var(--ink) 65%, transparent);         /* behind modals and ride overlays */
  --pause-veil: color-mix(in srgb, var(--ink) 35%, transparent);    /* over the blurred world while paused */
  --scrim-strong: color-mix(in srgb, var(--ink) 86%, transparent);  /* behind the big map */
  --line: color-mix(in srgb, var(--light) 9%, transparent);
  --line-strong: color-mix(in srgb, var(--light) 25%, transparent);
  --hover: color-mix(in srgb, var(--light) 14%, transparent);
  --fill: color-mix(in srgb, var(--light) 7%, transparent);
  --text-on-art-muted: color-mix(in srgb, var(--text-on-art) 75%, transparent);
  --text-shadow: 0 1px 8px color-mix(in srgb, var(--shade) 60%, transparent);
  --accent-top: color-mix(in srgb, var(--accent) 88%, var(--light));      /* primary button gradient */
  --accent-bottom: color-mix(in srgb, var(--accent) 90%, var(--shade));
  --accent-grad: linear-gradient(135deg, var(--accent-top), var(--accent) 45%, color-mix(in srgb, var(--accent) 55%, var(--accent-2)));   /* violet → coral */
  --accent-tint: color-mix(in srgb, var(--accent) 13%, transparent);   /* selected rows / tiles */
  --accent-glow: color-mix(in srgb, var(--accent) 40%, transparent);   /* primary button shadow */
  --accent-ring: color-mix(in srgb, var(--accent) 40%, transparent);  /* ring around the selected world */
  --gold-tint: color-mix(in srgb, var(--accent-2) 24%, transparent);
  /* gradients: the image's light – coral rising from the bottom-left corner into violet, indigo, then black; a violet one from the top right */
  --page-bg:
    radial-gradient(140% 90% at 0% 100%, color-mix(in srgb, var(--accent-2) 13%, transparent) 0%, color-mix(in srgb, var(--accent) 9%, transparent) 30%, color-mix(in srgb, var(--dusk) 12%, transparent) 50%, transparent 72%),
    radial-gradient(110% 75% at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, color-mix(in srgb, var(--accent-2) 7%, transparent) 28%, color-mix(in srgb, var(--dusk) 12%, transparent) 48%, transparent 70%),
    var(--bg);
  --card-grad: linear-gradient(160deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 45%, color-mix(in srgb, var(--shade) 25%, transparent)), var(--surface);
  --sheet-grad: linear-gradient(160deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 40%, color-mix(in srgb, var(--accent-2) 5%, transparent)), var(--surface-strong);
  --map-ground: radial-gradient(circle at 50% 40%, rgba(42, 34, 80, .5), rgba(6, 5, 18, .88));   /* map wells */

  /* ===== DATA COLOURS (canvas: charts, maps, HUD) – plain colours only ===== */
  /* power zones: zone colour, its light top and its deep base (each block is a diagonal gradient top → zone → base) */
  --zone-1: #8a94a6; --zone-1-light: #c9d2e0; --zone-1-deep: rgba(92, 104, 128, .7);     /* recovery */
  --zone-2: #3d8bfd; --zone-2-light: #5fd8ff; --zone-2-deep: rgba(70, 72, 230, .72);     /* endurance */
  --zone-3: #2fbf71; --zone-3-light: #b6f36a; --zone-3-deep: rgba(14, 150, 140, .72);    /* tempo */
  --zone-4: #ffc53d; --zone-4-light: #fff07a; --zone-4-deep: rgba(255, 128, 30, .75);    /* sweet spot / threshold */
  --zone-5: #ff7a1a; --zone-5-light: #ffd23f; --zone-5-deep: rgba(240, 58, 30, .75);     /* above threshold */
  --zone-6: #ff2b2b; --zone-6-light: #ff9a3d; --zone-6-deep: rgba(190, 10, 50, .75);     /* hardest */
  --zone-free: #8a8a8a;                                       /* free-ride steps */
  --aura-1: #ff1a1a; --aura-2: #ff3b1f; --aura-3: #ff5a3c;    /* the halo around hard blocks (> 105 % FTP), outside in */
  --chart-line: rgba(255, 255, 255, .32);                     /* FTP line and other dashed guides */
  --cursor: #ffffff;                                          /* "you are here" in charts, start dot, map nodes */
  /* gradient of the road: steep / hard / climbing / flat / descending */
  --grade-steep: #ff2b2b; --grade-hard: #ff9a3d; --grade-up: #ffd23f; --grade-flat: rgba(255, 255, 255, .65); --grade-down: #7dc8ff;
  /* maps */
  --road: rgba(255, 255, 255, .25);
  --road-faint: rgba(255, 255, 255, .025);   /* roads you didn't ride, on the ridden-track maps */
  --road-map: rgba(255, 255, 255, .75);      /* roads on the ride map */
  --road-outline: rgba(0, 0, 0, .55);
  --route: #ff8a9a;                          /* the chosen route (route previews: its end) */
  --route-start: #ff3b4e;                    /* route previews: the route's start (→ --route) */
  --route-choice: #ffd23f;                   /* roads to pick at a junction */
  --trail: #4fd1ff;                          /* where you rode */
  --path-start: #7cc8ff; --path-end: #ff8fd0;   /* the ride previews' ridden line: light blue at the start → pink at the end */
  --start: #6ee69a; --finish: #ff5d7a;
  --me: #a77bff;                             /* your marker */
  --rider: #1fa7ff;                          /* another rider without a colour */
  --map-label: rgba(255, 255, 255, .8);
  --map-land-low: #42603f;                   /* map relief: low ground … */
  --map-land-high: #9a8762;                  /* … hill tops (shaded by the slopes) */
  --map-wood: rgba(22, 52, 26, .65);         /* woods on the map */
  --map-field: rgba(196, 170, 96, .28);      /* farmland on the map */
  --map-town: rgba(150, 132, 138, .45);      /* built-up land on the map */
  --map-water: rgba(70, 120, 170, .85);      /* water on the map */
  --map-building: rgba(232, 222, 205, .8);   /* buildings on the map */
  --map-contour: rgba(255, 255, 255, .13);   /* contour lines */
  /* power & heart rate */
  --power-fill: rgba(255, 122, 140, .45);     /* fades to transparent downwards */
  --power-label: #ffa3b0;
  --hr: rgba(255, 64, 84, .95);
  --hr-label: #ff8f9b;
  /* HUD: your power against the workout target */
  --on-target: #7dffa6; --above-target: #ffa3b0; --below-target: #9fd0ff;
  --step-done: #4a4560;
  /* landing page: the bolts behind the hero */
  --bolt: #8a8a8a;

  /* ===== tags (LIT / MIT / HIT / Custom) ===== */
  --tag-z2: #8fbcff; --tag-z4: var(--zone-4); --tag-z6: #ff7b6e; --tag-custom: #9fb4e3;

  /* ===== world artwork (tiles and tabs, no images needed): dusk skies, one glow per world ===== */
  --art-shade: linear-gradient(180deg, transparent 35%, rgba(3, 2, 8, .55));
  --art-osnabrueck: radial-gradient(120% 100% at 90% 0%, rgba(255, 138, 122, .85), transparent 60%), linear-gradient(160deg, #a2588f 0%, #43296f 50%, #120b26 100%);

  /* ===== motion: pressing and hovering anything you can tap (components.css, end) ===== */
  --press-sm: .93;                 /* buttons, chips, segments, menu items: squeeze to … */
  --press-lg: .985;                /* big things (tiles, tabs, rows): squeeze a little less */
  --ease-bounce: cubic-bezier(.34, 1.9, .55, 1);   /* the release overshoots a little, then settles */
  --page-in: .32s; --page-out: .14s;              /* a page coming in / going out */
  --rise-time: .55s; --rise-step: .06s;           /* cards rising in on a page, one after another */
  --bounce-time: .42s;
  --lift-sm: -1px; --lift-lg: -2px;                /* hover (mouse / trackpad only) */
  --hover-bright: 1.1;

  /* ===== spacing scale ===== */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 28px;

  /* ===== shape ===== */
  --r-sm: 10px; --r: 14px; --r-lg: 18px; --r-xl: 24px; --r-pill: 999px;
  --shadow: 0 10px 34px color-mix(in srgb, var(--shade) 45%, transparent);

  /* ===== touch: nothing you tap is smaller than this ===== */
  --tap: 48px;
  --tap-lg: 56px;
  --tap-xl: 64px;
  --round: 60px;          /* round HUD buttons */
  --hud-border: 1.5px;    /* the frame of every HUD surface (panels, minimap, round buttons, toast) */
  --round-sm: var(--tap); /* the round buttons the FAB opens: a bit smaller, never under the tap size */

  /* ===== type ===== */
  --font-digits: "DSEG7", var(--font);   /* HUD numbers: a 7-segment display (loaded in main.js) */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-xs: 12px; --fs-sm: 14px; --fs: 16px; --fs-lg: 19px; --fs-xl: 26px;
  --icon-gap: .3em;        /* extra room between an icon and the words after it, in running text */

  /* ===== device safe areas (notches, home bar) ===== */
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
@media (max-width: 700px), (max-height: 500px) {
  :root { --round: 52px; --fs-xl: 22px; }
}
