/* ==========================================================================
   Da-Ag Global Logistics - shared UI layer
   Loaded last on every page (after the page's own <style>), so it only ADDS polish:
   feedback, motion, focus, touch comfort. Selectors use :where() (zero specificity) and the
   individual `scale` / `translate` properties, so they never fight a page's own layout or
   transforms. Remove the <link> and the page looks exactly as before.
   ========================================================================== */

:root {
  --dgl-navy: #002868;
  --dgl-navy-deep: #001a45;
  --dgl-red: #bf0a30;
  --dgl-green: #16a34a;
  --dgl-ease: cubic-bezier(.22, 1, .36, 1);        /* decelerating: things arrive smoothly   */
  --dgl-spring: cubic-bezier(.34, 1.56, .64, 1);   /* slight overshoot: things feel physical */
  --dgl-lift: 0 14px 34px rgba(0, 40, 104, .16);
}

/* ---- Base ---------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
/* :where() keeps this at zero specificity: a page that already sets these keeps its own value */
:where(body) {
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;                      /* a stray wide element can never create sideways scroll */
  animation: dgl-page-in .45s var(--dgl-ease) both;
}
@keyframes dgl-page-in { from { opacity: 0; } to { opacity: 1; } }
:where(img, video, canvas, iframe) { max-width: 100%; }
:where(img) { height: auto; }
:where(::selection) { background: rgba(191, 10, 48, .18); }

/* ---- Keyboard focus: always visible, never for mouse/touch ---------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid rgba(0, 40, 104, .55);
  outline-offset: 2px;
}
:where(.dark, [data-theme="dark"]) :where(a, button, input, select, textarea):focus-visible { outline-color: rgba(255, 255, 255, .8); }

/* ---- Controls: every press answers back ----------------------------------- */
:where(button, [role="button"], a[class*="btn"], [class*="-btn"], [class*="btn-"], .nav-cta, .cta) {
  transition: scale .16s var(--dgl-spring), translate .25s var(--dgl-ease), box-shadow .25s var(--dgl-ease),
              filter .2s, background-color .2s, color .2s, border-color .2s, opacity .2s;
  touch-action: manipulation;            /* no 300ms tap delay, no accidental double-tap zoom */
}
:where(button:not(:disabled), [role="button"], a[class*="btn"], [class*="-btn"], [class*="btn-"]):active { scale: .965; }
@media (hover: hover) {
  :where(button:not(:disabled), a[class*="btn"], [class*="btn-"], .nav-cta):hover { filter: brightness(1.05) saturate(1.05); }
}
:where(button:disabled, [aria-disabled="true"]) { cursor: not-allowed; }

/* Busy state: add .dgl-busy to any button; JS helper dglBusy(btn, true|false) */
.dgl-busy { position: relative; pointer-events: none; color: transparent !important; }
.dgl-busy > * { visibility: hidden; }
.dgl-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 1.15em; height: 1.15em;
  border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  animation: dgl-spin .7s linear infinite;
}
@keyframes dgl-spin { to { rotate: 360deg; } }

/* ---- Inputs ---------------------------------------------------------------- */
:where(input, select, textarea) { transition: border-color .2s, box-shadow .25s var(--dgl-ease), background-color .2s; }
:where(input, select, textarea):focus { box-shadow: 0 0 0 4px rgba(0, 40, 104, .12); }
:where(input:user-valid:not([type="checkbox"]):not([type="radio"]):not([type="search"]):not(:placeholder-shown)) { border-color: rgba(22, 163, 74, .55); }
:where(input:user-invalid, select:user-invalid, textarea:user-invalid) { border-color: rgba(220, 38, 38, .6); animation: dgl-shake .32s var(--dgl-ease); }
@keyframes dgl-shake { 20% { translate: -4px 0; } 40% { translate: 4px 0; } 60% { translate: -3px 0; } 80% { translate: 2px 0; } }

/* ---- Cards: gentle lift on hover-capable devices ---------------------------- */
:where(.stat-card, .chart-card, .section-card, .recent-card, .delivery-card, .office-card, .scope-card, .info-card,
       .withdraw-card, .transactions-card, .rider-card, .job-card, .zone-card, .feature-card, .team-card, .faq-item) {
  transition: translate .35s var(--dgl-ease), box-shadow .35s var(--dgl-ease), border-color .25s;
}
@media (hover: hover) {
  :where(.stat-card, .chart-card, .delivery-card, .office-card, .scope-card, .info-card, .rider-card, .job-card, .zone-card, .feature-card, .team-card):hover {
    translate: 0 -4px;
    box-shadow: var(--dgl-lift);
  }
}

/* ---- Live status: a soft radar ring on anything in motion ------------------- */
:where(.status-badge.in_transit, .status-badge.picked_up, .status-badge.out_for_delivery, [data-live="true"]) {
  animation: dgl-ring 2s ease-out infinite;
}
@keyframes dgl-ring {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 38%, transparent); }
  70%  { box-shadow: 0 0 0 10px color-mix(in srgb, currentColor 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 0%, transparent); }
}
.dgl-live-dot { display: inline-block; width: .55em; height: .55em; border-radius: 50%; background: var(--dgl-green); margin-right: .45em; animation: dgl-ring 1.8s ease-out infinite; color: var(--dgl-green); vertical-align: middle; }

/* ---- Skeleton loading (use instead of "Loading...") ------------------------- */
.dgl-skeleton {
  color: transparent !important; border-radius: 8px; user-select: none; pointer-events: none;
  background: linear-gradient(100deg, #eceff5 30%, #f8fafd 50%, #eceff5 70%) 0 0 / 300% 100%;
  animation: dgl-shimmer 1.3s linear infinite;
}
.dgl-skeleton > * { visibility: hidden; }
@keyframes dgl-shimmer { to { background-position: -300% 0; } }

/* ---- Scroll progress + scroll reveal ----------------------------------------- */
#dgl-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 2147483000; pointer-events: none;
  background: linear-gradient(90deg, var(--dgl-navy), var(--dgl-red));
  transform-origin: 0 50%; transform: scaleX(0); opacity: 0; transition: opacity .25s;
}
html.dgl-js .dgl-reveal { opacity: 0; translate: 0 22px; transition: opacity .7s var(--dgl-ease), translate .7s var(--dgl-ease); transition-delay: calc(var(--dgl-i, 0) * 70ms); }
html.dgl-js .dgl-reveal.dgl-in { opacity: 1; translate: 0 0; }

/* ---- Confetti + success pop ------------------------------------------------------- */
#dgl-confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2147483001; }
.dgl-pop { animation: dgl-pop .55s var(--dgl-spring) both; }
@keyframes dgl-pop { 0% { scale: .6; opacity: 0; } 100% { scale: 1; opacity: 1; } }

/* ---- Touch comfort ------------------------------------------------------------------ */
@media (pointer: coarse) {
  /* 16px stops iOS from zooming the page when a field is focused */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea { font-size: 16px !important; }
}
/* small controls get a bigger invisible hit area (classes are added by dgl-ui.js on touch devices only) */
.dgl-hit::before, .dgl-hit-after::after { content: ""; position: absolute; inset: -9px; }
.dgl-hit-rel { position: relative; }
@supports (padding: max(0px)) {
  :where([class*="bottom-nav"], [class*="bottom-bar"], .install-banner, #installBanner) { padding-bottom: max(env(safe-area-inset-bottom), 0px); }
}
:where(.dgl-table-scroll) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Respect people who ask for less motion --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  html.dgl-js .dgl-reveal { opacity: 1; translate: 0 0; }
  #dgl-confetti { display: none; }
}
@media print { #dgl-progress, #dgl-confetti { display: none !important; } body { animation: none; } }

/* ---- Small phones (320-420px): the shared public-site header must fit -------------- */
@media (max-width: 420px) {
  .nav-inner { padding-left: 14px; padding-right: 14px; gap: 10px; }
  .nav-logo img { height: 40px; }
  .nav-tagline { letter-spacing: 1px; font-size: .46rem; white-space: nowrap; }
  .nav-right { gap: 8px; min-width: 0; flex-shrink: 0; }
  .nav-cta { white-space: nowrap; }
}
@media (max-width: 360px) {
  .nav-logo { max-width: 46vw; }
  .nav-tagline { display: none; }
  .nav-cta { padding: 6px 10px !important; }
}

/* Long unbroken strings (emails, tracking numbers, URLs) wrap instead of pushing the page wider */
:where(.contact-btn, .tracking-number, .email, [class*="email"]) { overflow-wrap: anywhere; max-width: 100%; }
.contact-btn { text-align: center; }

/* ---- Typography: Inter everywhere; money and counters use fixed-width digits so they never jitter --------- */
:where(body) { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-optical-sizing: auto; }
:where(h1, h2, h3, .stat-value, .dgl-num, [data-count], .bar-total, .amount, .price, .delivery-amount, .balance, [class*="amount"], [class*="price"]) { font-variant-numeric: tabular-nums lining-nums; }
:where(h1, h2) { text-wrap: balance; }
:where(p, li) { text-wrap: pretty; }

/* secondary "switch account type" line under sign-up forms */
.dgl-switch { margin-top: 10px; }

/* ---- Charts (assets/js/dgl-charts.js) ---- */
.dgl-chart-box { position: relative; width: 100%; height: 300px; }
@media (max-width: 640px) { .dgl-chart-box { height: 250px; } }
.dgl-chart-off { margin: 18px 0; padding: 18px; text-align: center; font-size: .85rem; font-weight: 600; color: #8a9bb5; background: #f5f8ff; border: 1px dashed #cfdaee; border-radius: 14px; }

/* ---- Narrow-screen safety: flex/grid children may shrink below their content width -------------------------- */
:where(.search-box) > :where(input) { min-width: 0; }
:where(.search-box) > :where(button) { flex-shrink: 0; }
@media (max-width: 900px) { .contact-grid { grid-template-columns: minmax(0, 1fr); } }
:where(.contact-grid) > * { min-width: 0; }

/* tablets: the About page's scrolling text window deserves more height than a phone's */
@media (min-width: 641px) and (max-width: 992px) { .about-text-side { max-height: 440px !important; } .about-image-side { max-height: 260px !important; } }
