/* ==========================================================================
   Ergo Rehab: base styles, layout helpers, header, mobile menu, footer.
   Mobile first. Every value comes from tokens.css.
   ========================================================================== */

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--slate);
  background: var(--white);
  overflow-wrap: break-word;
}
img, svg { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4 { margin: 0 0 var(--sp-4); color: var(--navy); line-height: var(--lh-head); font-weight: var(--fw-bold); letter-spacing: var(--tracking-head); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-4); }
ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.25em; }
a { color: var(--navy); text-underline-offset: 0.15em; }
a:hover { color: var(--steel-text); }
button { font: inherit; }

/* Yellow ring + dark inner ring: visible on white (10:1 dark ring) and on navy (5.5:1 yellow) */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px var(--navy-dark); border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* --- Helpers -------------------------------------------------------------- */
.container { width: 100%; max-width: calc(var(--container) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--sp-4); top: -100px; z-index: 100; padding: var(--sp-2) var(--sp-4); background: var(--white); color: var(--navy); font-weight: var(--fw-semi); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--sp-2); }
.icon { width: 1em; height: 1em; flex: none; fill: currentColor; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: var(--sp-2) var(--sp-5);
  border: 2px solid var(--navy); border-radius: var(--radius-pill);
  background: var(--navy); color: var(--white);
  font-weight: var(--fw-semi); font-size: var(--fs-base); line-height: 1.2; text-decoration: none;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.btn:hover { background: var(--navy-dark); border-color: var(--navy-dark); color: var(--white); }
.btn--light { background: var(--white); color: var(--navy); border-color: var(--white); }
.btn--light:hover { background: var(--stone); border-color: var(--stone); color: var(--navy); }

/* --- Top bar (navy strip above the header, as on the old site) ------------ */
.topbar { background: var(--navy); color: var(--white); font-size: var(--fs-sm); }
.topbar__list { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-1) var(--sp-5); margin: 0; padding: var(--sp-2) 0; list-style: none; }
.topbar__item { display: flex; align-items: center; gap: var(--sp-2); }
.topbar a { color: var(--white); text-decoration: none; display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 32px; }
.topbar a:hover { color: var(--stone); text-decoration: underline; }
.topbar .icon { color: var(--stone); }
.topbar__label { color: var(--stone); }
.topbar__address { display: none; }
@media (min-width: 1025px) {
  .topbar__list { justify-content: flex-start; }
  .topbar__address { display: flex; margin-left: auto; }
}

/* --- Header ---------------------------------------------------------------- */
.site-header { position: relative; z-index: 50; background: var(--white); box-shadow: 0 1px 0 var(--linen); }
.site-header__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding-block: var(--sp-3); }
.site-logo { display: block; width: var(--header-logo-w); flex: none; }
.site-logo img { width: 100%; }

/* Hamburger: navy square, white bars (old site) */
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: var(--radius-sm);
  background: var(--navy); color: var(--white); cursor: pointer;
}
.nav-toggle:hover { background: var(--navy-dark); }
.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
  display: block; width: 22px; height: 2px; background: currentColor; border-radius: 2px; transition: transform var(--ease), opacity var(--ease);
}
.nav-toggle__bars { position: relative; }
.nav-toggle__bars::before, .nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle__bars::before { top: -7px; }
.nav-toggle__bars::after { top: 7px; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { transform: translateY(-7px) rotate(-45deg); }

/* Menu: mobile = navy panel under the header (old site's mobile menu was navy with white links) */
.site-nav { display: none; }
.site-nav.is-open { display: block; position: absolute; left: 0; right: 0; top: 100%; background: var(--navy); box-shadow: var(--shadow); max-height: calc(100vh - 100%); overflow-y: auto; }
.nav-list, .subnav { list-style: none; margin: 0; padding: 0; }
.nav-list { padding: var(--sp-2) var(--gutter) var(--sp-5); }
.nav-list > li { border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.nav-link, .subnav-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: var(--tap); padding: var(--sp-2) 0; border: 0; background: none;
  color: var(--white); font-size: var(--fs-base); font-weight: var(--fw-medium); text-align: left; text-decoration: none; cursor: pointer;
}
.nav-link:hover, .subnav-toggle:hover { color: var(--stone); }
.nav-link[aria-current="page"], .subnav-toggle[data-current="true"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.35em; }
.subnav-toggle .icon { width: 12px; height: 12px; transition: transform var(--ease); }
.subnav-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.subnav { display: none; padding: 0 0 var(--sp-2) var(--sp-4); }
.subnav.is-open { display: block; }
.subnav .nav-link { font-size: var(--fs-sm); }
.nav-cta { margin-top: var(--sp-4); border: 0 !important; }
.nav-cta .btn { width: 100%; background: var(--white); border-color: var(--white); color: var(--navy); }
.nav-cta .btn:hover { background: var(--stone); border-color: var(--stone); color: var(--navy); }

/* Desktop menu: navy links on white, hover steel, Services dropdown = navy rounded panel (old site) */
@media (min-width: 1025px) {
  .nav-toggle { display: none; }
  .site-nav, .site-nav.is-open { display: block; position: static; background: none; box-shadow: none; max-height: none; overflow: visible; }
  .nav-list { display: flex; align-items: center; gap: var(--sp-1); padding: 0; }
  .nav-list > li { position: relative; border: 0; }
  .nav-link, .subnav-toggle { width: auto; padding: var(--sp-3) var(--sp-4); color: var(--navy); font-size: 1rem; gap: var(--sp-2); }
  .nav-link:hover, .subnav-toggle:hover { color: var(--steel-text); }
  .subnav {
    position: absolute; top: calc(100% + 4px); left: 0; padding: var(--sp-2) 0; white-space: nowrap;
    background: var(--navy); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  }
  .subnav .nav-link { color: var(--white); padding: var(--sp-2) var(--sp-5); font-size: 1rem; }
  .subnav .nav-link:hover { color: var(--stone); }
  /* open on hover too (old site), with a bridge so the pointer can reach the panel */
  .has-sub:hover > .subnav { display: block; }
  .subnav::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
  .nav-cta { margin: 0 0 0 var(--sp-3); }
  .nav-cta .btn { width: auto; background: var(--navy); border-color: var(--navy); color: var(--white); }
  .nav-cta .btn:hover { background: var(--navy-dark); border-color: var(--navy-dark); color: var(--white); }
}

/* --- Footer (navy, logo + tagline, Working Hours, Contact; as old site) ------ */
.site-footer { background: var(--navy); color: var(--white); padding-top: var(--sp-8); }
.site-footer a { color: var(--white); }
.site-footer a:hover { color: var(--stone); }
.footer-grid { display: grid; gap: var(--sp-7); text-align: center; }
.footer-brand img { width: min(300px, 80%); margin-inline: auto; }
.footer-tagline { margin: var(--sp-4) 0 0; font-weight: var(--fw-heavy); font-size: var(--fs-base); }
.footer-title { margin: 0 0 var(--sp-4); color: var(--white); font-size: var(--fs-lg); font-weight: var(--fw-semi); }
.footer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.footer-list li { display: flex; align-items: flex-start; justify-content: center; gap: var(--sp-3); }
.footer-list .icon { margin-top: 0.35em; color: var(--stone); }
.footer-contact { font-weight: var(--fw-semi); }
.footer-contact a { text-decoration: none; }
.footer-contact a:hover { text-decoration: underline; }
.footer-contact .footer-note { display: block; font-weight: var(--fw-regular); font-size: var(--fs-sm); }
.footer-bottom { margin-top: var(--sp-7); padding-block: var(--sp-5); border-top: 1px solid rgba(255, 255, 255, 0.15); font-size: var(--fs-xs); text-align: center; color: var(--stone); }
.footer-bottom p { margin: 0; }

@media (min-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; text-align: left; align-items: start; }
  .footer-brand { grid-column: 1 / -1; text-align: center; }
  .footer-list li { justify-content: flex-start; }
}
@media (min-width: 1025px) {
  .footer-grid { grid-template-columns: 1.1fr 1fr 1.2fr; gap: var(--sp-7); }
  .footer-brand { grid-column: auto; text-align: left; }
  .footer-brand img { margin-inline: 0; width: 100%; max-width: 280px; }
}

/* --- Motion: scroll reveal + button hover (site-wide) ----------------------
   Content is only hidden when site.js has added .js-motion to <html>, which it
   does only if the visitor has NOT asked for reduced motion. No JS = no hiding. */
@media (prefers-reduced-motion: no-preference) {
  .js-motion [data-reveal] {
    opacity: 0; transform: translateY(24px);
    transition: opacity 600ms ease, transform 600ms cubic-bezier(.2, .7, .2, 1);
    transition-delay: var(--reveal-delay, 0ms);
  }
  .js-motion [data-reveal="left"]  { transform: translateX(-32px); }
  .js-motion [data-reveal="right"] { transform: translateX(32px); }
  .js-motion [data-reveal].is-visible { opacity: 1; transform: none; }

  .btn { transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(20, 46, 105, 0.25); }
}
.nowrap { white-space: nowrap; }
/* Slide-in elements start offset sideways; never let that cause sideways scrolling.
   clip (not hidden) keeps position: sticky working inside <main>. */
main { overflow-x: clip; }
