/* ============================================================
   Cargoventra design tokens
   ------------------------------------------------------------
   Single source of truth for the whole product.

   Loaded by includes/header.php, dashboard_header.php and
   admin_header.php, because all three need the same palette and
   because inline styles in index.php, contact.php and
   book-shipment.php reference var(--cv-*) directly.

   Legacy names (--cv-navy, --cv-accent, ...) are kept as aliases so
   the ~9,600 lines of existing markup and the inline styles keep
   working. New code should prefer the semantic names.

   Direction: modern freight / tech. Sharp geometry, tight type scale,
   monospace for identifiers, denser layout, royal blue used as a fine
   accent against a deep navy ground.
   ============================================================ */

:root {
    /* ---- Brand: deep navy carries the identity, royal blue is the accent ----
      The accent used to be gold, then freight orange, and the primary
      emerald, then graphite. All of the legacy names are kept as aliases, so
      ~9,600 lines of markup and the inline styles keep working:
      --cv-navy still resolves to the primary and --cv-gold still resolves to
      the accent. New code should use the semantic names.

      The *-rgb channel triplets exist so that a translucent colour can be
      written once as rgba(var(--cv-primary-dark-rgb), .94). Before they
      existed, the three video overlays and every shadow hardcoded
      rgba(6, 48, 40, ...), which is --cv-primary-dark spelled out as
      decimal - so the overlays stayed emerald no matter what the palette
      said. That is the trap these tokens remove.

      CargoVentra brand colours:
        deep navy    #071A49   primary
        royal blue   #1265D8   secondary / accent
        white        #FFFFFF   surfaces and reversed text
        light grey   #E5E7EB   borders, dividers, subtle fills
        charcoal     #111827   body text

      Every derived value below is a tint or shade of those two, so the
      theme can be re-pointed by editing this block alone. */
    --cv-navy:        var(--cv-primary);         /* legacy alias */
    --cv-navy-dark:   var(--cv-primary-dark);    /* legacy alias */
    --cv-navy-light:  var(--cv-primary-light);   /* legacy alias */
    --cv-gold:        var(--cv-accent);          /* legacy alias: the accent is no longer gold */
    --cv-gold-dark:   var(--cv-accent-dark);
    --cv-gold-light:  var(--cv-accent-light);
    --cv-gold-ink:    var(--cv-accent-ink);
    --cv-gold-rgb:    var(--cv-accent-rgb);
    --cv-slate:       #5A6B84;                  /* legacy alias -> --cv-ink-muted */

    /* Deep navy. Saturated and dark, so it holds as a header/hero/band
       ground and reversed white text stays far above AA on all three. */
    --cv-primary:          #071A49;
    --cv-primary-dark:     #04102C;
    --cv-primary-light:    #123C8C;
    --cv-primary-rgb:      7, 26, 73;
    --cv-primary-dark-rgb: 4, 16, 44;
    --cv-primary-light-rgb: 18, 60, 140;

    /* Royal blue. #1265D8 measures 5.41:1 on #FFFFFF and 4.71:1 on
       --cv-surface-3, so the accent itself is already safe to set as link
       text on every light surface - unlike the orange it replaces, which
       sat at 3.04:1 and could not be used as body text at all. */
    --cv-accent:          #1265D8;
    --cv-accent-dark:     #0A4AA6;
    --cv-accent-light:    #5C9BE8;
    --cv-accent-rgb:      18, 101, 216;
    --cv-accent-dark-rgb: 10, 74, 166;
    --cv-accent-light-rgb: 92, 155, 232;

    /* Accent taken down further for the small text that the plain accent
       only just clears: 10.32:1 on #FFFFFF, 8.72:1 on --cv-surface-2,
       8.41:1 on --cv-surface-3. It covers the 11px section eyebrow, the 13px
       "Learn more" CTA and the 12px post date. Keep --cv-accent-dark for
       borders, fills and hover states, where the 3:1 non-text threshold is
       the relevant one. */
    --cv-accent-ink:   #083C8C;

    /* ---- Text on the dark bands ----
       These replace a family of hand-written hexes that were all tints of
       the old emerald primary (#C6DCD6, #BCD3CD, #B9D2CB, #A9C4BD,
       #93B5AC, #7C9A93, #CFE3DD), used for secondary text on the topbar,
       hero, section bands and dashboard sidebar. Left alone they would
       have been visibly green, so they are neutral greys that keep the same
       lightness ordering. The values are unchanged by the move to navy: a
       neutral grey set sits on a saturated navy at least as well as it sat
       on graphite, and the navy is darker, so every ratio below improved.

       Ratios against --cv-primary-dark, which is the darker of the two bands
       these sit on, 1 through 7:
         13.25, 12.24, 11.41, 10.69, 9.01, 6.86, 6.12
       Against --cv-primary (#071A49), the header band:
         11.80, 10.89, 10.16,  9.52, 8.02, 6.11, 5.45
       Both are asserted by tools/palette_contrast.php. */
    --cv-on-dark-1: #D4D9DE;
    --cv-on-dark-2: #CBD1D8;
    --cv-on-dark-3: #C4CAD2;
    --cv-on-dark-4: #BDC4CC;
    --cv-on-dark-5: #ADB4BE;
    --cv-on-dark-6: #949DA9;
    --cv-on-dark-7: #8A94A1;

    /* ---- Ink and surfaces ----
       --cv-ink was a green-black (#16211F) and --cv-ink-soft was visibly
       emerald (#2F4A45); both are now in the navy/charcoal family so body
       copy stops carrying a green cast against the new navy. */
    --cv-ink:          #111827;
    --cv-ink-soft:     #2A3550;
    --cv-ink-muted:    #5A6B84;

    /* Faint is the bottom of the ramp, so it sits at 3:1 rather than 4.5:1 -
       that is the WCAG threshold for non-text and for incidental text such as
       captions and timestamps. It was #8A97A8, which measured 2.97:1 on white
       and just missed. Darkened to #7E8A9C: 3.50:1 on white, and still 3.04:1
       on --cv-surface-3. Do not re-composite it with opacity on top; the
       stacked result drops under 1.7:1. */
    --cv-ink-faint:    #7E8A9C;

    --cv-surface:      #FFFFFF;
    --cv-surface-2:    #F4F7FB;
    --cv-surface-3:    #EAF0F4;
    --cv-border:       #E5E7EB;   /* legacy alias -> --cv-line */
    --cv-line:         #E5E7EB;
    --cv-line-strong:  #C9CFD6;

    /* ---- Status palette (data-forward UI) ----
       pending/transit/delivered/failed are semantic and deliberately left
       alone: amber, blue, green and red carry meaning that a monochrome
       brand palette would destroy. Only the blue family is re-pointed at
       the new accent so it no longer sits beside a second, unrelated
       blue. */
    --cv-status-pending:      #B8860B;
    --cv-status-pending-bg:   #FDF6E3;
    --cv-status-transit:      #1265D8;
    --cv-status-transit-bg:   #E8F0FD;
    --cv-status-delivered:    #1B7F52;
    --cv-status-delivered-bg: #E6F4EC;
    --cv-status-failed:       #B3261E;
    --cv-status-failed-bg:    #FBEBEA;
    --cv-status-info:         #5A6B84;
    --cv-status-info-bg:      #F0F3F7;

    /* ---- Bootstrap overrides (navy + royal blue) ---- */
    --bs-primary:   #071A49;
    --bs-primary-rgb: 7, 26, 73;
    --bs-success:   #1B7F52;
    --bs-success-rgb: 27, 127, 82;
    --bs-danger:    #B3261E;
    --bs-danger-rgb: 179, 38, 30;
    /* Was the freight orange. Bootstrap's warning is amber by convention and
       nothing in the brand palette supplies one, so it takes the same amber
       as --cv-status-pending rather than staying orange. */
    --bs-warning:   #B8860B;
    --bs-warning-rgb: 184, 134, 11;
    --bs-info:      #1265D8;
    --bs-info-rgb:  18, 101, 216;
    --bs-body-color: #111827;
    --bs-body-bg:    #FFFFFF;
    --bs-border-color: #E5E7EB;

    /* ---- Typography ---- */
    --cv-font-sans:  'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --cv-font-display: 'Poppins', 'Inter', system-ui, sans-serif;
    --cv-font-mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Modular type scale. Replaces ~19 ad-hoc font sizes. */
    --cv-fs-100:  .6875rem;  /* 11px micro label */
    --cv-fs-200:  .75rem;    /* 12px caption / table meta */
    --cv-fs-300:  .8125rem;  /* 13px small text */
    --cv-fs-400:  .875rem;   /* 14px dense body, table cell */
    --cv-fs-500:  .9375rem;  /* 15px default body */
    --cv-fs-600:  1rem;      /* 16px lead / h6 */
    --cv-fs-700:  1.125rem;  /* 18px h5 */
    --cv-fs-800:  1.375rem;  /* 22px h4 */
    --cv-fs-900:  1.75rem;   /* 28px h3 */
    --cv-fs-1000: 2.25rem;   /* 36px h2 */
    --cv-fs-1100: clamp(1.9rem, 3.4vw, 2.75rem); /* section headline */
    --cv-fs-hero:  clamp(1.9rem, 3.8vw, 3rem);   /* hero headline */

    --cv-lh-tight:  1.15;
    --cv-lh-snug:   1.35;
    --cv-lh-base:   1.55;
    --cv-lh-loose:  1.75;

    --cv-ls-tight:  -0.02em;
    --cv-ls-label:  0.08em;   /* uppercase eyebrow / status label */
    --cv-ls-mono:   0.02em;

    /* ---- Spacing scale (4px base) ---- */
    --cv-sp-0: 0;
    --cv-sp-1: .25rem;
    --cv-sp-2: .5rem;
    --cv-sp-3: .75rem;
    --cv-sp-4: 1rem;
    --cv-sp-5: 1.25rem;
    --cv-sp-6: 1.5rem;
    --cv-sp-8: 2rem;
    --cv-sp-10: 2.5rem;
    --cv-sp-12: 3rem;
    --cv-sp-16: 4rem;

    /* ---- Radii: sharp by design ---- */
    --cv-r-xs: 2px;   /* status dots, tick marks */
    --cv-r-sm: 4px;   /* default control */
    --cv-r:    5px;   /* cards, panels */
    --cv-r-md: 8px;   /* raised panels, media */
    --cv-r-lg: 12px;  /* dialogs */
    --cv-r-pill: 999px;
    --cv-radius: var(--cv-r); /* legacy alias -> --cv-r */

    /* ---- Elevation: low and crisp, not soft and cloudy ---- */
    --cv-shadow:    0 1px 2px rgba(var(--cv-primary-dark-rgb), .06), 0 1px 3px rgba(var(--cv-primary-dark-rgb), .04);
    --cv-shadow-md: 0 2px 4px rgba(var(--cv-primary-dark-rgb), .06), 0 4px 12px rgba(var(--cv-primary-dark-rgb), .06);
    --cv-shadow-lg: 0 8px 24px rgba(var(--cv-primary-dark-rgb), .10), 0 2px 6px rgba(var(--cv-primary-dark-rgb), .06);
    /* Focus indicator.
       This was rgba(accent, .35), which composites to #FACBB1 over a
       white field: 1.47:1. A focus ring only has to clear the 3:1
       non-text threshold, and that failed outright, so keyboard focus
       was effectively invisible on every form.

       Two tones instead, painted innermost-first, so at least one of
       them always clears 3:1 against whatever it sits next to:
         inner #FFFFFF against the dark fields (hero, dark bands) 18.8:1
         outer accent-dark against white pages and cards            8.3:1
       The first shadow in the list paints on top, so this is
       white 0-2px, accent-dark 2-5px. */
    --cv-ring: 0 0 0 2px #FFFFFF, 0 0 0 5px var(--cv-accent-dark);

    /* ---- Motion ---- */
    --cv-ease: cubic-bezier(.4, 0, .2, 1);
    --cv-dur-fast: 120ms;
    --cv-dur:      200ms;
    --cv-dur-slow: 320ms;

    /* ---- Layout ---- */
    --cv-sidebar-w: 232px;
    /* Misnamed since long ago: it is the navbar's min-height, not the top
       bar's, and both the public nav and the dashboard shell read it. Renaming
       it would touch three files for no gain, so the alias stands and the real
       top bar gets its own variable below. */
    --cv-topbar-h: 58px;
    --cv-shell-max: 1240px;

    /* ---- Header height ----
       The homepage hero fills the first screen, so it has to know how tall the
       header actually is - and that number is not a constant. The public header
       is a two-part stack: .topbar, which header.php renders d-none d-lg-block
       and so exists only from lg up, plus .main-nav, which is the sticky part.

       These are the no-JavaScript fallback. They are what the hero is sized
       from before, or instead of, assets/js/main.js measuring the stack and
       writing --cv-header-h back onto :root with the real figure. The token
       is declared here rather than hard-coded in the hero so there is one
       number to correct, and so the same value can drive scroll-padding.

       --cv-header-h        the whole stack at scroll 0: what the hero has to
                            clear to occupy the rest of the first screen.
       --cv-header-h-sticky just the sticky navbar: what an anchor target has
                            to clear, since only that part follows you down. */
    --cv-navbar-h: var(--cv-topbar-h);
    --cv-topbar-strip-h: 0px;
    --cv-header-h: calc(var(--cv-topbar-strip-h) + var(--cv-navbar-h) + 1px);
    --cv-header-h-sticky: calc(var(--cv-navbar-h) + 1px);
}

/* From lg the top bar is rendered, so the stack is one row taller. The 1px in
   --cv-header-h is .main-nav's border-bottom, which is part of its box. */
@media (min-width: 992px) {
    :root {
        /* py-2 top and bottom (8px each) around a 32px tap-target row. */
        --cv-topbar-strip-h: 49px;
    }
}

/* ============================================================
   Document-level invariants
   ------------------------------------------------------------
   These belong here rather than in style.css because all three shells
   load this file (header.php, dashboard_header.php, admin_header.php).
   Keeping them in the public layer meant the dashboards did not get them.
   ============================================================ */

html {
    scroll-behavior: smooth;

    /* The nav is sticky, so an in-page anchor used to scroll its target to the
       very top of the viewport and leave it sitting underneath the bar. This
       offsets by the sticky part of the header only - the top bar scrolls away
       and must not be counted twice. main.js overwrites --cv-header-h-sticky
       with the measured navbar height; the value here is the no-JS fallback. */
    scroll-padding-top: var(--cv-header-h-sticky);

    /* No page in the product may scroll sideways.
       AOS hard-codes a 100px offset for every fade direction and exposes
       no option to change it, so until an element animates it sits 100px
       outside the viewport. On the public pages that pushed
       document.scrollWidth past window.innerWidth at 768/1024/1280/1440;
       on the dashboards the same thing happened at every width. The
       offsets are reduced to 24px in style.css as well - this is the
       backstop, not the fix.

       clip rather than hidden: hidden establishes a scroll container,
       which silently disables position:sticky for the navbars. clip does
       not. It must be on <html>, not <body>: per CSS overflow
       propagation a value on body is lifted to the viewport only when
       html's own overflow is visible, and body is then computed as
       visible - so setting it on body does nothing at all. */
    overflow-x: clip;
}
