/* AGREX design layer: tokens, typography, layout, buttons, focus and form base.
   Loaded LAST in templates/base.html, so it wins over Bootstrap and the Front
   theme (theme.css). Reference: docs/design-tokens.md. Blocks are restyled in
   later steps; this file only sets the shared foundation. */

/* ---- Tokens ------------------------------------------------------------- */
:root {
  --agx-ink: #000000;
  --agx-text: #4A4C4B;
  --agx-muted: #717372;
  --agx-placeholder: #8D8F8E;
  --agx-disabled: #B8B9B9;
  --agx-line: #E3E3E3;
  --agx-input-line: #D6D6D6;
  --agx-surface: #F3F3F3;
  --agx-band: #E6F3F2;
  --agx-teal: #008A81;
  --agx-teal-rgb: 0, 138, 129;
  --agx-teal-hover: #00706A;
  --agx-gold: #E1AC25;
  --agx-teal-light: #D3EEEB;
  --agx-error: #B3261E;
  --agx-white: #FFFFFF;

  --agx-font: "Instrument Sans", "Instrument Sans Fallback", system-ui, sans-serif;

  --agx-radius-btn: 6px;
  --agx-radius-input: 8px;
  --agx-radius-media: 12px;
  --agx-radius-card: 14px;
  --agx-radius-panel: 16px;
  --agx-shadow-pop: 0 12px 32px -16px rgba(0, 0, 0, .25);

  --agx-content: 1152px;
  --agx-gutter: 20px;
  --agx-section: 48px;

  /* Older scale still used by header, menu and block CSS (header-glass.css,
     nav-dropdowns.css, services-raster.css, ...). */
  --agx-fs-12: 12px;
  --agx-fs-13: 13px;
  --agx-fs-14: 14px;
  --agx-fs-15: 15px;
  --agx-fs-16: 16px;
  --agx-fs-18: 18px;
  --agx-fs-24: 24px;
  --agx-fs-32: 32px;
  --agx-fs-40: 40px;
  --agx-space: 8px;
  /* Hover / pressed tone for rows, menu items and buttons on light surfaces */
  --agx-hover: rgba(29, 35, 39, 0.05);
  --agx-active: rgba(29, 35, 39, 0.08);

  /* Bootstrap follows the tokens. */
  --bs-body-font-family: var(--agx-font);
  --bs-font-sans-serif: var(--agx-font);
  --bs-body-color: var(--agx-text);
  --bs-body-bg: var(--agx-white);
  --bs-border-color: var(--agx-line);
  --bs-link-color: var(--agx-teal);
  --bs-link-color-rgb: var(--agx-teal-rgb);
  --bs-link-hover-color: var(--agx-teal-hover);
  --bs-link-hover-color-rgb: var(--agx-teal-rgb);
  --bs-primary: var(--agx-teal);
  --bs-primary-rgb: var(--agx-teal-rgb);
  --bs-emphasis-color: var(--agx-ink);
  --bs-secondary-color: var(--agx-muted);
  /* bg-dark / text-dark (footer, cards) were teal via SiteSettings.footer_bg_rgb;
     kept until the footer and blocks are restyled. */
  --bs-dark-rgb: var(--agx-teal-rgb);

  /* Fallback until JS measures the real header height on load/resize */
  --header-height: 60px;
  /* One offset shared by anchor jumps, scrollspy highlight and the sticky
     sidebar: header height + 20px breathing room. */
  --scroll-offset: calc(var(--header-height) + 20px);

  /* iPhone safe area (viewport-fit=cover in base.html): the page reaches
     under the notch, the rounded corners and the home indicator. 0 on every
     other device and in portrait at the sides. Variables, so the browser
     tests can simulate an inset. */
  --agx-safe-left: env(safe-area-inset-left, 0px);
  --agx-safe-right: env(safe-area-inset-right, 0px);
  --agx-safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 768px) {
  :root { --agx-gutter: 32px; --agx-section: 56px; }
}
@media (min-width: 992px) {
  :root { --agx-section: 88px; }
}
@media (min-width: 1200px) {
  :root { --agx-gutter: 64px; }
}

/* ---- Base --------------------------------------------------------------- */
html {
  /* In-page anchor jumps (e.g. scrollspy) land below the sticky header with
     20px breathing room, and scroll there smoothly. */
  scroll-padding-top: var(--scroll-offset);
  scroll-behavior: smooth;
  /* Below the page end (overscroll, home indicator area on phones): light
     teal like the bottom of the footer band; the page itself is white (body). */
  background-color: var(--agx-teal-light);
}
body {
  font-family: var(--agx-font);
  font-size: 17px;
  line-height: 1.55;
  color: var(--agx-text);
  background-color: var(--agx-white);
  /* landscape on an iPhone: keep content out of the notch side */
  padding-left: var(--agx-safe-left);
  padding-right: var(--agx-safe-right);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Long German compounds in narrow columns wrap instead of overflowing their
   column; below 768px they are hyphenated. */
main { overflow-wrap: break-word; }
@media (max-width: 767.98px) {
  main { hyphens: auto; }
}

/* Header stays in normal flow, pinned to the top, above page content */
#header {
  position: sticky;
  top: 0;
  z-index: 1020;
}
/* While the burger menu modal is open, drop the header shadow so it doesn't
   draw a divider line (that modal only, not the scrollspy sidebar collapse). */
body:has(#mobileModal.show) #header { box-shadow: none !important; }

/* ---- Typography --------------------------------------------------------- */
h1, .h1, h2, .h2, h3, .h3 {
  font-family: var(--agx-font);
  font-weight: 600;
  color: var(--agx-ink);
}
/* Page title (no hero) */
h1, .h1 { font-size: 32px; line-height: 1.1; letter-spacing: -0.015em; }
h2, .h2 { font-size: 26px; line-height: 1.2; letter-spacing: -0.012em; }
h3, .h3 { font-size: 18px; line-height: 1.3; letter-spacing: 0; }
/* Display: the hero title (css/blocks/hero.css) */
.agx-display { font-size: 38px; line-height: 1.08; letter-spacing: -0.015em; font-weight: 600; }
/* Headings never break inside a word: long words are hyphenated by the
   browser (dictionary from <html lang>), only words of 12+ letters with at
   least 5 letters on each side of the hyphen; lines are balanced. */
h1, h2 {
  overflow-wrap: normal;
  word-break: normal;
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-limit-chars: 12 5 5;
  -webkit-hyphenate-limit-before: 5;
  -webkit-hyphenate-limit-after: 5;
  text-wrap: balance;
}
@media (max-width: 575.98px) {
  h1, h1.agx-display { font-size: 32px; }
}
@media (min-width: 768px) {
  h1, .h1 { font-size: 44px; line-height: 1.08; }
  h2, .h2 { font-size: 32px; line-height: 1.15; }
  .agx-display { font-size: 58px; line-height: 1.04; }
}

.lead { font-size: 18px; line-height: 1.55; font-weight: 400; color: var(--agx-muted); }
small, .small, .agx-small { font-size: 15px; line-height: 1.55; }
.agx-caption, figcaption { font-size: 13px; line-height: 1.45; color: var(--agx-muted); }

/* Secondary text: muted, not the theme's forced black !important. */
.text-muted { color: var(--agx-muted) !important; }
/* Card headings: heading colour, not the theme's var(--bs-black). */
.card-title { color: var(--agx-ink); }

/* Strong text in body copy */
:is(.rich-text, main p, main li) :is(strong, b) { font-weight: 600; color: var(--agx-ink); }

/* Eyebrow (templates/includes/eyebrow.html) */
.agx-eyebrow {
  display: flex;
  align-items: center;
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--agx-muted);
}
.text-center > .agx-eyebrow,
.text-center .agx-eyebrow { justify-content: center; }
/* On dark backgrounds (tone="dark"): light grey. */
.agx-eyebrow--dark { color: var(--agx-disabled); }

body { font-synthesis: none; }
.site-nav__overview { font-weight: 500; }

/* Navigation (header) */
#header.site-head--glass .navbar-nav .nav-link,
.site-head__item {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--agx-ink);
}
#header.site-head--glass .navbar-nav .nav-link.active,
#header.site-head--glass .navbar-nav .nav-link:hover,
#header.site-head--glass .navbar-nav .nav-item.is-open > .nav-link,
.site-head__item:hover,
.site-head__item[aria-expanded="true"] { color: var(--agx-teal); }

/* Breadcrumb (includes/breadcrumb.html): 13px / 500, muted, "/" separators.
   The overlay variant on the hero keeps its light colours (theme.css). */
.site-breadcrumb { font-size: 13px; font-weight: 500; line-height: 1.4; }
.site-breadcrumb__sep { margin: 0 0.5rem; font-size: inherit; }
.site-breadcrumb:not(.site-breadcrumb--overlay) .site-breadcrumb__list > li,
.site-breadcrumb:not(.site-breadcrumb--overlay) a { color: var(--agx-muted); }
.site-breadcrumb:not(.site-breadcrumb--overlay) a:hover { color: var(--agx-teal); }
.site-breadcrumb:not(.site-breadcrumb--overlay) .site-breadcrumb__sep { color: var(--agx-disabled); }
.site-breadcrumb:not(.site-breadcrumb--overlay) .site-breadcrumb__current { color: var(--agx-ink); }

/* ---- Rich text ---------------------------------------------------------- */
.rich-text > :first-child { margin-top: 0; }
.rich-text > :last-child { margin-bottom: 0; }
.rich-text p { margin: 0 0 16px; }
.rich-text :is(ul, ol) { margin: 0 0 16px; padding-left: 20px; }
.rich-text li + li { margin-top: 8px; }
.rich-text h2 { margin-top: 2.5rem; margin-bottom: 1rem; }
.rich-text h3 { margin-top: 2rem; margin-bottom: 0.75rem; }
.rich-text h4 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
/* A heading straight after a heading reads as one unit (small gap only). */
.rich-text :is(h2, h3, h4, h5, h6) + :is(h2, h3, h4, h5, h6) { margin-top: 0.5rem; }
.rich-text a { color: var(--agx-teal); text-decoration: none; }
.rich-text a:hover { color: var(--agx-teal-hover); text-decoration: underline; }

/* Scrollspy chapter heading sits outside .rich-text; pair it with the first
   rich-text line below it as one unit. */
.scrollspy-heading { margin-bottom: 0.5rem; }

/* Services card titles: equal-height alignment only where they sit side by
   side (md+); no forced min-height on stacked mobile cards. */
@media (min-width: 768px) {
  .services-card-title { min-height: 45px; }
}

/* ---- Layout ------------------------------------------------------------- */
.container,
.container-lg,
.container-xl,
.container-xxl {
  max-width: calc(var(--agx-content) + 2 * var(--agx-gutter));
  padding-inline: var(--agx-gutter);
}
.agx-section { padding-block: var(--agx-section); }
.agx-rule { border: 0; border-top: 1px solid var(--agx-line); }

/* Images that carry width/height attributes (aspect-ratio hints against
   layout shift) keep scaling with their width. */
.card-img,
.card-img-top,
.carousel-item > img { height: auto; }

/* ---- Buttons ------------------------------------------------------------ */
.agx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px; /* 44px; long labels may wrap on narrow screens */
  max-width: 100%;
  padding: 0 20px;
  border: 1px solid var(--agx-teal);
  border-radius: var(--agx-radius-btn);
  background-color: var(--agx-teal);
  box-shadow: none;
  font-family: var(--agx-font);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  color: var(--agx-white);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.agx-btn:hover {
  border-color: var(--agx-teal-hover);
  background-color: var(--agx-teal-hover);
  color: var(--agx-white);
}
.agx-btn--secondary {
  border-color: var(--agx-line);
  background-color: var(--agx-white);
  font-weight: 500;
  color: var(--agx-ink);
}
.agx-btn--secondary:hover {
  border-color: var(--agx-line);
  background-color: var(--agx-surface);
  color: var(--agx-ink);
}
.agx-link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--agx-teal);
  text-decoration: none;
}
.agx-link-arrow:hover { color: var(--agx-teal-hover); }
.agx-btn svg,
.agx-link-arrow svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.agx-link-arrow svg { transition: transform 0.15s ease; }
.agx-link-arrow:hover svg { transform: translateX(2px); }

/* ---- Focus -------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.agx-btn:focus-visible,
.form-check-input:focus-visible {
  outline: 2px solid var(--agx-teal);
  outline-offset: 2px;
}

/* ---- Forms -------------------------------------------------------------- */
.form-control,
.form-select {
  min-height: 48px;
  border: 1px solid var(--agx-input-line);
  border-radius: var(--agx-radius-input);
  font-size: 16px;
  color: var(--agx-ink);
}
textarea.form-control { min-height: 120px; }
.form-control::placeholder { color: var(--agx-placeholder); opacity: 1; }
.form-control:focus,
.form-select:focus {
  border-color: var(--agx-teal);
  box-shadow: 0 0 0 3px var(--agx-band);
}
.form-control.is-invalid,
.form-select.is-invalid,
.was-validated .form-control:invalid,
.was-validated .form-select:invalid { border-color: var(--agx-error); }
.form-control:disabled,
.form-select:disabled { background-color: var(--agx-surface); color: var(--agx-disabled); }

.form-check-input[type="checkbox"] {
  width: 20px;
  height: 20px;
  border: 1px solid var(--agx-disabled);
  border-radius: 5px;
}
.form-check-input:checked {
  border-color: var(--agx-teal);
  background-color: var(--agx-teal);
}
.form-check-input:focus {
  border-color: var(--agx-teal);
  box-shadow: 0 0 0 3px var(--agx-band);
}
