/* ============================================================
   lib/styles/global.css — Total Solutions Global Base Styles
   Layer 2: Resets, base typography, document styles, and
   foundational utilities. Consumes tokens.css. Loaded after
   tokens.css in app shell.
   ============================================================ */


/* ==========================================================================
   1. RESET & NORMALIZE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


html {
  font-size: 100%;
  line-height: 1.5;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


body {
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  color: var(--color-body);
  background-color: var(--color-background);
  overflow-x: hidden;
}


/* ==========================================================================
   2. TYPOGRAPHY HIERARCHY
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading);
  margin-bottom: var(--space-4);
  color: var(--color-heading);
}


h1 {
  font-size: var(--font-size-display);
}
h2 {
  font-size: var(--font-size-h1);
}
h3 {
  font-size: var(--font-size-h2);
}
h4 {
  font-size: var(--font-size-h3);
}


p {
  margin-bottom: var(--space-3);
  max-width: 72ch;
}


ul, ol {
  margin-bottom: var(--space-3);
  padding-left: var(--space-6);
}


li {
  margin-bottom: var(--space-1);
}


small, .text-sm {
  font-size: var(--font-size-caption);
  color: var(--color-text-muted);
}


/* ==========================================================================
   3. LINKS
   ========================================================================== */
/* Apply default link styles ONLY if the link is NOT a button */
a:not([class*="btn"]) {
  color: var(--color-link);
  text-decoration: none;
  transition: color var(--motion-transition-interactive);
}


a:not([class*="btn"]):hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}


a:not([class*="btn"]):focus-visible {
  outline: var(--border-width-medium) solid var(--color-primary);
  outline-offset: var(--space-1);
  border-radius: var(--radius-sm);
}


/* Base reset for buttons that happen to be anchor tags */
a[class*="btn"] {
  text-decoration: none;
}


/* ==========================================================================
   4. IMAGES & MEDIA
   ========================================================================== */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}


img[loading="lazy"] {
  loading: lazy;
}


/* ==========================================================================
   5. FORMS & INTERACTIVES
   ========================================================================== */
input, textarea, select, button {
  font: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}


button {
  cursor: pointer;
  background: none;
  border: none;
}


input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: var(--border-width-medium) solid var(--color-primary);
  outline-offset: var(--space-1);
  border-radius: var(--radius-sm);
}


/* Base interactive transitions */
a,
button,
[role="button"],
[role="link"],
input,
textarea,
select {
  transition:
    color var(--motion-transition-interactive),
    background-color var(--motion-transition-interactive),
    border-color var(--motion-transition-interactive),
    box-shadow var(--motion-transition-interactive),
    opacity var(--motion-transition-interactive),
    transform var(--motion-transition-interactive);
}


/* ==========================================================================
   6. LISTS & TABLES
   ========================================================================== */
ul[role="list"], ol[role="list"] {
  list-style: none;
  padding: 0;
}


table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
}


/* ==========================================================================
   7. SELECTION & HIGHLIGHTS
   ========================================================================== */
::selection {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}


/* ==========================================================================
   8. SCROLLBAR
   ========================================================================== */
@media (hover: hover) {
  ::-webkit-scrollbar {
    width: 0.5rem;
  }

  ::-webkit-scrollbar-track {
    background: var(--color-surface-subtle);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--color-text-muted);
    border-radius: var(--radius-pill);
  }
}


/* ==========================================================================
   9. UTILITY CLASSES — BRAND ALIGNMENT
   ========================================================================== */


/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* Visually hidden but focusable (skip links) */
.sr-only:focusable:focus {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}


/* Typography utilities */
.text-heading { font-family: var(--font-heading); }
.text-serif { font-family: var(--font-serif); }
.text-mono { font-family: var(--font-mono); }


/* Spacing utilities */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }


.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }


.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }


.px-1 { padding-left: var(--space-1); padding-right: var(--space-1); }
.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-5 { padding-left: var(--space-5); padding-right: var(--space-5); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.px-8 { padding-left: var(--space-8); padding-right: var(--space-8); }


.py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-5 { padding-top: var(--space-5); padding-bottom: var(--space-5); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }
.py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }


/* Display */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }


/* Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-stretch { align-items: stretch; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }


/* Width */
.w-full { width: 100%; }
.max-w-container { max-width: var(--container-md); }


/* Container */
.container {
  width: 100%;
  max-width: var(--container-lg);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}


/* Overflow */
.overflow-hidden { overflow: hidden; }


/* Pointer */
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }


/* Position */
.sticky { position: sticky; }
.top-0 { top: 0; }


/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}


/* NoScript fallback */
.noscript-fallback {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16);
  color: var(--color-text-primary);
}


.noscript-fallback h1 {
  color: var(--color-brand-trust-navy);
  margin-bottom: var(--space-4);
}