/* ไปกัน! — design tokens v2: clean · minimal · bright white · violet → blue · liquid glass.
   Every color/radius/shadow/space in the app MUST come from here.
   Legacy names (--mint --sky --sun --berry --grape --cocoa --leaf + "-soft") are kept and
   remapped to the new palette so older feature CSS keeps working. */

:root {
  color-scheme: light;

  /* surfaces */
  --bg: #F5F6FB;
  --bg-2: #EEF0F8;
  --surface: #FFFFFF;
  --surface-2: #F8F9FD;
  --surface-sunk: #F1F2F8;
  --line: #E9EAF3;
  --line-strong: #DADCEA;

  /* liquid glass */
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(255, 255, 255, 0.25);
  --glass-blur: blur(22px) saturate(180%);

  /* ink */
  --ink: #16142D;
  --ink-2: #5E5C78;
  --ink-3: #6C6A87;        /* secondary text: >= 4.5:1 on --surface, --bg and --bg-2 */
  --ink-4: #9C9BB4;        /* decorative only (needles, dashed outlines, route tints) — never for text */
  --ink-inverse: #FFFFFF;

  /* brand */
  --primary: #6B4EFF;
  --primary-strong: #5838F2;
  --primary-soft: #EFEBFF;
  --primary-ink: #FFFFFF;
  --blue: #3D7BFF;
  --blue-soft: #E8EFFF;
  --grad-brand: linear-gradient(135deg, #7B5CFF 0%, #5A6BFF 50%, #3D8BFF 100%);
  --grad-brand-soft: linear-gradient(135deg, #F2EEFF 0%, #E9F1FF 100%);
  --grad-glow: radial-gradient(60% 50% at 20% 0%, rgba(123, 92, 255, 0.16), transparent 70%),
               radial-gradient(50% 40% at 100% 10%, rgba(61, 139, 255, 0.14), transparent 70%);

  /* category palette (fg + soft tile bg) */
  --violet: #6B4EFF;  --violet-soft: #EFEBFF;
  --indigo: #4F55E3;  --indigo-soft: #E9EAFF;
  --sky: #3D7BFF;     --sky-soft: #E8EFFF;
  --cyan: #12A9CF;    --cyan-soft: #E1F6FB;
  --mint: #12B47D;    --mint-soft: #E0F6EE;
  --leaf: #2FAE5C;    --leaf-soft: #E3F5E8;
  --sun: #F2A10F;     --sun-soft: #FFF4DB;
  --orange: #FF7A3D;  --orange-soft: #FFEEE4;
  --berry: #F0457A;   --berry-soft: #FFE8EF;
  --grape: #9A5BF5;   --grape-soft: #F3EAFF;
  --cocoa: #E0743A;   --cocoa-soft: #FFEFE5;
  --slate: #6A6F8E;   --slate-soft: #EEEFF5;

  --sun-ink: #A86A00;
  --toast-bg: rgba(22, 20, 45, 0.88); --toast-ink: #FFFFFF;
  --scrim: rgba(10, 9, 24, 0.86);
  --ok: #12B47D;
  --warn: #F2A10F;
  --danger: #EF4459;
  --danger-soft: #FFE9EC;
  --info: #3D7BFF;

  /* navigation (Google/Apple-like functional colors) */
  --nav-green: #188038; --nav-green-2: #188038;   /* solid, not a gradient (research: formal, Google-like) */
  --nav-green-night: #0F5C2E; --nav-green-night-2: #0F5C2E;
  --nav-blue: #1A73E8; --nav-blue-2: #1557B0; --nav-blue-dark: #8AB4F8;
  --nav-red: #EF4459;
  --nav-eta: #148046; --nav-eta-dark: #4ADE80;
  --nav-shield-bg: #FFFFFF; --nav-shield-ink: #148046;

  /* map route lines (non-"maps" styles) */
  --route-main: #6B4EFF;
  --route-alt: #B7B9D3;
  --route-casing: #FFFFFF;
  --route-done: #12B47D;

  /* type */
  --font-display: "LINE Seed Sans TH", system-ui, -apple-system, "Segoe UI", "Leelawadee UI", "Noto Sans Thai", sans-serif;
  --font-body: "LINE Seed Sans TH", system-ui, -apple-system, "Segoe UI", "Leelawadee UI", "Noto Sans Thai", sans-serif;
  --font-emoji: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --font-num: "Inter", "LINE Seed Sans TH", system-ui, -apple-system, sans-serif;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: clamp(1.25rem, 1.12rem + 0.55vw, 1.5rem);
  --fs-2xl: clamp(1.55rem, 1.3rem + 1vw, 2rem);
  --fs-3xl: clamp(2rem, 1.6rem + 1.8vw, 2.75rem);

  /* shape — iOS-like continuous corners */
  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-pill: 999px;

  /* soft, cool, diffuse shadows */
  --shadow-1: 0 1px 2px rgba(22, 20, 60, 0.04), 0 4px 14px rgba(22, 20, 60, 0.05);
  --shadow-2: 0 2px 6px rgba(22, 20, 60, 0.05), 0 14px 34px rgba(44, 34, 120, 0.10);
  --shadow-3: 0 10px 24px rgba(22, 20, 60, 0.08), 0 30px 70px rgba(44, 34, 120, 0.18);
  --shadow-btn: 0 8px 22px rgba(91, 64, 255, 0.30);
  --shadow-glass: 0 8px 32px rgba(44, 34, 120, 0.12);
  --focus-ring: 0 0 0 4px rgba(107, 78, 255, 0.22);

  /* spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* layout */
  --gutter: 16px;
  --nav-h: 64px;                    /* floating tab bar height */
  --nav-gap: 12px;                  /* distance of the floating bar from the screen edge */
  --nav-space: calc(var(--nav-h) + var(--nav-gap) * 2 + var(--safe-bottom)); /* room to leave at page bottom */
  --rail-w: 96px;
  --panel-w: clamp(340px, 34vw, 440px);
  --header-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-bounce: cubic-bezier(.2, .8, .2, 1);   /* formal: no overshoot (kept for compatibility) */
  --dur: 180ms;

  /* topic heroes (header cards, css/base.css .hero + js/core/hero.js): 3-stop gradient (a b c), two mesh
     glows (g1 g2) and the tint of the ambient shadow (sh). Every stop and glow keeps white text >= 4.5:1
     (worst case ~5.6:1; ~4.4:1+ for 90% white on a glass tile). */
  --hero-home-a: #5536E0; --hero-home-b: #4146D2; --hero-home-c: #2853BE; --hero-home-g1: #7436C4; --hero-home-g2: #1B58B0; --hero-home-sh: rgba(72, 54, 214, .42);
  --hero-plan-a: #1D55C9; --hero-plan-b: #0B66BC; --hero-plan-c: #07699A; --hero-plan-g1: #2463D6; --hero-plan-g2: #08739E; --hero-plan-sh: rgba(11, 102, 188, .40);   /* azure: the map */
  --hero-time-a: #4230B0; --hero-time-b: #3236A6; --hero-time-c: #213A8C; --hero-time-g1: #6038C0; --hero-time-g2: #2A44A0; --hero-time-sh: rgba(58, 44, 170, .40);   /* midnight indigo: the clock */
  --hero-money-a: #0B655C; --hero-money-b: #0C694B; --hero-money-c: #1C6631; --hero-money-g1: #0B6860; --hero-money-g2: #1A6E3A; --hero-money-sh: rgba(12, 105, 75, .38);
  --hero-stamps-a: #A51D55; --hero-stamps-b: #B2284A; --hero-stamps-c: #AA370B; --hero-stamps-g1: #B11D70; --hero-stamps-g2: #A5440B; --hero-stamps-sh: rgba(178, 40, 74, .36);
  --hero-summary-a: #7A20B4; --hero-summary-b: #6A28C4; --hero-summary-c: #5634CC; --hero-summary-g1: #9126B0; --hero-summary-g2: #5A30CF; --hero-summary-sh: rgba(106, 40, 196, .40);
  /* ink + glass on top of a hero (white family) */
  --hero-on: #FFFFFF;
  --hero-on-2: rgba(255, 255, 255, .92);      /* secondary text: still >= 4.5:1 on every stop and tile */
  --hero-glass: rgba(255, 255, 255, .09);
  --hero-glass-hi: rgba(255, 255, 255, .14);
  --hero-line: rgba(255, 255, 255, .22);
  --hero-spec: rgba(255, 255, 255, .55);      /* 1px specular top edge */
  --hero-art: rgba(255, 255, 255, .26);       /* decorative line art (drawn at low opacity) */
  --hero-inner: rgba(8, 4, 40, .22);          /* inner shadow at the bottom of glass parts */
  --hero-shade: #0A0820;                      /* darkens tinted ink sitting on white inside a hero */
  --hero-ok: #A8F0CF; --hero-warn: #FFE08A; --hero-bad: #FFC6CF;   /* status tints that read on every hero */
  --hero-zigzag: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8'%3E%3Cpath d='M0 7L7 1L14 7' fill='none' stroke='%23fff' stroke-opacity='.3' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E");
  --hero-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");

  /* hero v3 "map card" (css/base.css .hero + js/core/hero.js): stylised map colours, tooltip bubble, wave */
  --map-land: #ECEFF7; --map-water: #CFE0FF; --map-park: #D3EEDD; --map-minor: #DCE0EC;
  --map-road: #FFFFFF; --map-road-casing: #D3D8E7;
  --map-route: #6B4EFF; --map-route-casing: #FFFFFF;
  --bubble-bg: #16142D; --bubble-ink: #FFFFFF;
  --wave-a: #5B3EF0; --wave-b: #3F5FE6;      /* white text on both >= 5:1 */
  --wave-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='26' viewBox='0 0 360 26' preserveAspectRatio='none'%3E%3Cpath d='M0 13C45 1 135 1 180 13S315 25 360 13V26H0Z'/%3E%3C/svg%3E");
  --ok-ink: #0B7A55; --danger-ink: #C42840; --primary-ink-soft: #5838F2;   /* text on the -soft tints (>= 4.5:1) */
  --shadow-hero: 0 1px 2px rgba(22, 20, 60, 0.04), 0 10px 30px -12px rgba(44, 34, 120, 0.16);
  --shadow-hero-hi: 0 2px 4px rgba(22, 20, 60, 0.05), 0 18px 40px -14px rgba(44, 34, 120, 0.24);
}

@media (min-width: 600px) { :root { --gutter: 20px; } }
@media (min-width: 1024px) { :root { --gutter: 28px; } }
@media (min-width: 900px) { :root { --nav-space: var(--sp-6); } }

/* ---------- dark: deep indigo night + dark glass ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E0D1F; --bg-2: #131230;
    --surface: #18172F; --surface-2: #1E1C3A; --surface-sunk: #131229;
    --line: rgba(255,255,255,0.08); --line-strong: rgba(255,255,255,0.14);
    --glass: rgba(30, 28, 62, 0.58); --glass-strong: rgba(30, 28, 62, 0.8); --glass-border: rgba(255,255,255,0.10);
    --glass-edge: inset 0 1px 0 rgba(255,255,255,0.10), inset 0 -1px 0 rgba(255,255,255,0.03);
    --ink: #F3F2FF; --ink-2: #B6B4D8; --ink-3: #8E8CB8; --ink-4: #7D7BA6;
    --primary: #8C74FF; --primary-strong: #7B60FF; --primary-soft: #2A2358;
    --blue-soft: #1B2752; --violet-soft: #2A2358; --indigo-soft: #23255A; --sky-soft: #1B2752; --cyan-soft: #13323F;
    --mint-soft: #123329; --leaf-soft: #17321F; --sun-soft: #352A12; --orange-soft: #3A2318; --berry-soft: #3A1B2A;
    --grape-soft: #2F2152; --cocoa-soft: #39251A; --slate-soft: #24243A; --danger-soft: #3D1A22; --sun-ink: #F5C35A; --toast-bg: rgba(46, 43, 88, 0.92);
    --grad-brand-soft: linear-gradient(135deg, #231E4B 0%, #1A2550 100%);
    --grad-glow: radial-gradient(60% 50% at 20% 0%, rgba(123, 92, 255, 0.28), transparent 70%),
                 radial-gradient(50% 40% at 100% 10%, rgba(61, 139, 255, 0.20), transparent 70%);
    --route-alt: #5D5B85; --route-casing: #0E0D1F;
    --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    --shadow-2: 0 2px 6px rgba(0,0,0,.3), 0 14px 34px rgba(0,0,0,.4);
    --shadow-3: 0 10px 24px rgba(0,0,0,.35), 0 30px 70px rgba(0,0,0,.55);
    --shadow-glass: 0 8px 32px rgba(0,0,0,.45);
    /* deeper hero variants for the night theme */
    --hero-home-a: #3A27A6; --hero-home-b: #2D3399; --hero-home-c: #1B3E8C; --hero-home-g1: #5A2A99; --hero-home-g2: #164C99; --hero-home-sh: rgba(70, 48, 220, .30);
    --hero-plan-a: #133C92; --hero-plan-b: #0A4886; --hero-plan-c: #064B6C; --hero-plan-g1: #17449E; --hero-plan-g2: #065676; --hero-plan-sh: rgba(20, 110, 220, .30);
    --hero-time-a: #2C1F80; --hero-time-b: #232578; --hero-time-c: #172660; --hero-time-g1: #3E2590; --hero-time-g2: #1C2C70; --hero-time-sh: rgba(90, 70, 230, .30);
    --hero-money-a: #084C45; --hero-money-b: #0A4F39; --hero-money-c: #164E26; --hero-money-g1: #0A5852; --hero-money-g2: #2D5A15; --hero-money-sh: rgba(10, 120, 90, .26);
    --hero-stamps-a: #7A1640; --hero-stamps-b: #851E38; --hero-stamps-c: #7F2908; --hero-stamps-g1: #881657; --hero-stamps-g2: #893C0B; --hero-stamps-sh: rgba(200, 40, 90, .24);
    --hero-summary-a: #561680; --hero-summary-b: #4A1B8C; --hero-summary-c: #3D2491; --hero-summary-g1: #681A7E; --hero-summary-g2: #3F2290; --hero-summary-sh: rgba(110, 60, 230, .30);
    --hero-glass: rgba(255, 255, 255, .09); --hero-glass-hi: rgba(255, 255, 255, .14); --hero-line: rgba(255, 255, 255, .16);
    --hero-spec: rgba(255, 255, 255, .34); --hero-art: rgba(255, 255, 255, .2); --hero-inner: rgba(0, 0, 0, .34);
    --map-land: #1A1936; --map-water: #1B2A57; --map-park: #17302B; --map-minor: #23224A;
    --map-road: #2B2A52; --map-road-casing: #201F42; --map-route: #9A86FF; --map-route-casing: #0E0D1F;
    --bubble-bg: #F3F2FF; --bubble-ink: #16142D;
    --ok-ink: #5FE0B0; --danger-ink: #FF8C9C; --primary-ink-soft: #B5A6FF;
    --shadow-hero: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px -12px rgba(0,0,0,.5);
    --shadow-hero-hi: 0 2px 4px rgba(0,0,0,.3), 0 18px 40px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E0D1F; --bg-2: #131230;
  --surface: #18172F; --surface-2: #1E1C3A; --surface-sunk: #131229;
  --line: rgba(255,255,255,0.08); --line-strong: rgba(255,255,255,0.14);
  --glass: rgba(30, 28, 62, 0.58); --glass-strong: rgba(30, 28, 62, 0.8); --glass-border: rgba(255,255,255,0.10);
  --glass-edge: inset 0 1px 0 rgba(255,255,255,0.10), inset 0 -1px 0 rgba(255,255,255,0.03);
  --ink: #F3F2FF; --ink-2: #B6B4D8; --ink-3: #8E8CB8; --ink-4: #7D7BA6;
  --primary: #8C74FF; --primary-strong: #7B60FF; --primary-soft: #2A2358;
  --blue-soft: #1B2752; --violet-soft: #2A2358; --indigo-soft: #23255A; --sky-soft: #1B2752; --cyan-soft: #13323F;
  --mint-soft: #123329; --leaf-soft: #17321F; --sun-soft: #352A12; --orange-soft: #3A2318; --berry-soft: #3A1B2A;
  --grape-soft: #2F2152; --cocoa-soft: #39251A; --slate-soft: #24243A; --danger-soft: #3D1A22; --sun-ink: #F5C35A; --toast-bg: rgba(46, 43, 88, 0.92);
  --grad-brand-soft: linear-gradient(135deg, #231E4B 0%, #1A2550 100%);
  --grad-glow: radial-gradient(60% 50% at 20% 0%, rgba(123, 92, 255, 0.28), transparent 70%),
               radial-gradient(50% 40% at 100% 10%, rgba(61, 139, 255, 0.20), transparent 70%);
  --route-alt: #5D5B85; --route-casing: #0E0D1F;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  --shadow-2: 0 2px 6px rgba(0,0,0,.3), 0 14px 34px rgba(0,0,0,.4);
  --shadow-3: 0 10px 24px rgba(0,0,0,.35), 0 30px 70px rgba(0,0,0,.55);
  --shadow-glass: 0 8px 32px rgba(0,0,0,.45);
  /* deeper hero variants for the night theme (same values as the prefers-color-scheme block above) */
  --hero-home-a: #3A27A6; --hero-home-b: #2D3399; --hero-home-c: #1B3E8C; --hero-home-g1: #5A2A99; --hero-home-g2: #164C99; --hero-home-sh: rgba(70, 48, 220, .30);
  --hero-plan-a: #133C92; --hero-plan-b: #0A4886; --hero-plan-c: #064B6C; --hero-plan-g1: #17449E; --hero-plan-g2: #065676; --hero-plan-sh: rgba(20, 110, 220, .30);
  --hero-time-a: #2C1F80; --hero-time-b: #232578; --hero-time-c: #172660; --hero-time-g1: #3E2590; --hero-time-g2: #1C2C70; --hero-time-sh: rgba(90, 70, 230, .30);
  --hero-money-a: #084C45; --hero-money-b: #0A4F39; --hero-money-c: #164E26; --hero-money-g1: #0A5852; --hero-money-g2: #2D5A15; --hero-money-sh: rgba(10, 120, 90, .26);
  --hero-stamps-a: #7A1640; --hero-stamps-b: #851E38; --hero-stamps-c: #7F2908; --hero-stamps-g1: #881657; --hero-stamps-g2: #893C0B; --hero-stamps-sh: rgba(200, 40, 90, .24);
  --hero-summary-a: #561680; --hero-summary-b: #4A1B8C; --hero-summary-c: #3D2491; --hero-summary-g1: #681A7E; --hero-summary-g2: #3F2290; --hero-summary-sh: rgba(110, 60, 230, .30);
  --hero-glass: rgba(255, 255, 255, .09); --hero-glass-hi: rgba(255, 255, 255, .14); --hero-line: rgba(255, 255, 255, .16);
  --hero-spec: rgba(255, 255, 255, .34); --hero-art: rgba(255, 255, 255, .2); --hero-inner: rgba(0, 0, 0, .34);
  --map-land: #1A1936; --map-water: #1B2A57; --map-park: #17302B; --map-minor: #23224A;
  --map-road: #2B2A52; --map-road-casing: #201F42; --map-route: #9A86FF; --map-route-casing: #0E0D1F;
  --bubble-bg: #F3F2FF; --bubble-ink: #16142D;
  --ok-ink: #5FE0B0; --danger-ink: #FF8C9C; --primary-ink-soft: #B5A6FF;
  --shadow-hero: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px -12px rgba(0,0,0,.5);
  --shadow-hero-hi: 0 2px 4px rgba(0,0,0,.3), 0 18px 40px -14px rgba(0,0,0,.6);
}
