/* =====================================================================
   VM Sport — uusi header / mega / search (design system portti)
   ---------------------------------------------------------------------
   Lähde: vm-sport-design-system/project/ui_kits/web/{styles.css,
   service-mega.css} + colors_and_type.css. Kaikki luokat .vm-* —
   ei kollisioi teeman vanhojen tyylien kanssa. Reset jätetty pois.
   Desktop ≥992px. Mobiilissa (<992px) tämä koko header piiloon ja
   vanha navbar-mobile.php-dock hoitaa navigaation.
   ===================================================================== */

/* ---------- Tokenit (vain headerin tarvitsemat) -------------------- */
:root {
  /* Surfaces & FG */
  --vm-bg:              #ffffff;
  --vm-bg-subtle:       #f5f6f4;
  --vm-bg-card:         #f0f0f0;
  --vm-bg-utility:      #0d2b3c;
  --vm-fg:              #000000;
  --vm-fg-muted:        #5a5a5a;
  --vm-fg-subtle:       #707070;
  --vm-fg-on-inverse:   #ffffff;
  --vm-border:          #d1d1d1;
  --vm-border-subtle:   #dedede;
  /* Brand & status */
  --vm-brand:           #2D5C87;
  --vm-brand-deep:      #0d2b3c;
  --vm-accent-cool:     #73C1BD;
  --vm-workbike:        #006e68;
  --vm-sale:            #b72a00;
  /* Type */
  --vm-font-body:       "work-sans", "Work Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --vm-fs-12:           0.75rem;
  --vm-fs-13:           0.8125rem;
  --vm-fs-14:           0.875rem;
  --vm-fs-15:           0.9375rem;
  --vm-fs-24:           1.5rem;
  --vm-tracking-eyebrow:0.12em;
  --vm-tracking-tight:  -0.01em;
  /* Layout & motion */
  --vm-container:       1280px;
  --vm-radius-2:        4px;
  --vm-radius-pill:     999px;
  --vm-shadow-3:        0 12px 28px rgba(13,43,60,.12);
  --vm-ease-out:        cubic-bezier(0.22, 0.61, 0.36, 1);
  --vm-dur-fast:        120ms;
  --vm-dur-base:        200ms;
}

/* ---------- Mobile gate: desktop-only --------------------------------
   Mobiilissa koko uusi header piiloon, vanha navbar-mobile (dock)
   hoitaa. Toteuttaja: PHP-templatessa kääritään myös vanha desktop
   header .vm-legacy-hidden-desktop -luokkaan. */
.vm-utility,
.vm-header { display: none; }
@media (min-width: 992px) {
  .vm-utility, .vm-header { display: block; }
}

/* ---------- Utility strip ----------------------------------------- */
.vm-utility {
  background: var(--vm-bg-utility);
  color: var(--vm-fg-on-inverse);
  font-family: var(--vm-font-body);
  font-size: var(--vm-fs-12);
  padding: 8px 0;
  position: relative;
  /* Korkeampi kuin .vm-header (sticky, z-index 15), jotta
     lang-picker-dropdown näkyy headerin päällä. */
  z-index: 30;
}
.vm-utility-inner {
  max-width: var(--vm-container);
  margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
}
.vm-utility a { color: rgba(255,255,255,0.85); text-decoration: none; }
.vm-utility a:hover { color: #fff; }
.vm-utility .left { opacity: 0.85; }
.vm-utility .vm-utility-dot {
  display: inline-block; width: 8px; height: 8px;
  background: #4FBA00; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.vm-utility .right { display: flex; gap: 18px; align-items: center; }
.vm-utility .right .workbike { color: var(--vm-accent-cool); font-weight: 600; }

/* Kielivalitsin (utility-stripin oikealla puolella) */
.vm-lang-picker { position: relative; }
.vm-lang-picker-trigger {
  background: transparent; border: 0; padding: 0;
  color: rgba(255,255,255,0.85);
  font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: color var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-lang-picker-trigger:hover,
.vm-lang-picker[aria-expanded="true"] .vm-lang-picker-trigger { color: #fff; }
.vm-lang-picker-trigger svg {
  transition: transform var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-lang-picker.open .vm-lang-picker-trigger svg { transform: rotate(180deg); }
.vm-lang-picker-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--vm-bg); color: var(--vm-fg);
  list-style: none; margin: 0; padding: 6px 0;
  min-width: 140px;
  border: 1px solid var(--vm-border-subtle);
  box-shadow: var(--vm-shadow-3);
  z-index: 20;
  display: none;
}
.vm-lang-picker.open .vm-lang-picker-menu { display: block; }
.vm-lang-picker-menu li { margin: 0; padding: 0; list-style: none; }
.vm-lang-picker-menu a {
  display: block; padding: 8px 16px;
  color: var(--vm-fg); text-decoration: none;
  font-family: var(--vm-font-body); font-size: var(--vm-fs-13); font-weight: 500;
  letter-spacing: 0; text-transform: none;
  transition: background var(--vm-dur-fast) var(--vm-ease-out),
              color var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-lang-picker-menu a:hover { background: var(--vm-bg-subtle); color: var(--vm-brand); }
.vm-lang-picker-menu a[aria-current="true"] { color: var(--vm-brand); font-weight: 600; }

/* ---------- Header main row --------------------------------------- */
.vm-header {
  background: var(--vm-bg);
  border-bottom: 1px solid var(--vm-border-subtle);
  position: sticky; top: 0; z-index: 15;
  font-family: var(--vm-font-body);
  color: var(--vm-fg);
}
.vm-header-main {
  max-width: var(--vm-container);
  margin: 0 auto;
  padding: 18px 24px;
  display: flex; align-items: center; gap: 32px;
}
/* Logo: vmsport_logo() tulostaa #site-logo > a > img */
.vm-header #site-logo { display: block; flex-shrink: 0; }
.vm-header #site-logo a { display: block; }
.vm-header #site-logo img { height: 36px; width: auto; display: block; }
.vm-header-logo { height: 36px; width: auto; display: block; }
.vm-header-search-wrap { flex: 1; position: relative; }

/* ---------- Search input ------------------------------------------ */
.vm-header-search {
  display: flex; align-items: center;
  background: var(--vm-bg-card);
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-2);
  padding: 10px 16px;
  gap: 10px;
  transition: border-color var(--vm-dur-fast) var(--vm-ease-out),
              background var(--vm-dur-fast) var(--vm-ease-out),
              box-shadow var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-header-search:focus-within,
.vm-header-search.open {
  border-color: var(--vm-brand);
  background: var(--vm-bg);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--vm-brand) 14%, transparent);
}
.vm-header-search .vm-icon { color: var(--vm-fg-muted); flex-shrink: 0; display: inline-flex; }
.vm-header-search input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-family: var(--vm-font-body); font-size: var(--vm-fs-15);
  color: var(--vm-fg); min-width: 0;
}
.vm-header-search input::placeholder { color: var(--vm-fg-subtle); }
.vm-header-search-clear {
  background: var(--vm-border-subtle); border: 0;
  width: 22px; height: 22px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  color: var(--vm-fg-muted); cursor: pointer; flex-shrink: 0;
  transition: background var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-header-search-clear:hover { background: var(--vm-border); color: var(--vm-fg); }
.vm-header-search.has-value .vm-header-search-clear { display: flex; }

/* ---------- Search dropdown --------------------------------------- */
.vm-search-scrim {
  position: fixed; inset: 0;
  background: rgba(13,43,60,0.35);
  z-index: 9; display: none;
  animation: vm-fade-in 200ms var(--vm-ease-out);
}
.vm-search-scrim.open { display: block; }
@keyframes vm-fade-in { from { opacity: 0; } to { opacity: 1; } }

.vm-search-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  background: var(--vm-bg);
  border: 1px solid var(--vm-border);
  box-shadow: var(--vm-shadow-3);
  z-index: 12; max-height: 70vh; overflow-y: auto;
  display: none;
}
.vm-search-dropdown.open { display: block; }
.vm-search-section { padding: 16px 18px; border-bottom: 1px solid var(--vm-border-subtle); }
.vm-search-section:last-child { border-bottom: 0; }
.vm-search-section-title {
  font-weight: 700; font-size: var(--vm-fs-12);
  letter-spacing: var(--vm-tracking-eyebrow); text-transform: uppercase;
  color: var(--vm-fg-muted); margin-bottom: 10px;
}
.vm-search-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.vm-search-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--vm-bg-card); border: 1px solid var(--vm-border-subtle);
  color: var(--vm-brand-deep); font-size: var(--vm-fs-13);
  padding: 6px 12px; border-radius: var(--vm-radius-pill);
  cursor: pointer; text-decoration: none;
  transition: all var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-search-chip:hover { background: var(--vm-brand); color: #fff; border-color: var(--vm-brand); }
.vm-search-cats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.vm-search-cat {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--vm-bg-subtle);
  text-decoration: none; color: var(--vm-brand-deep);
  font-weight: 600; font-size: var(--vm-fs-13);
  transition: background var(--vm-dur-fast) var(--vm-ease-out),
              color var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-search-cat:hover { background: var(--vm-brand); color: #fff; }
.vm-search-cat .vm-icon { flex-shrink: 0; }

/* Relevanssi-live-results: plugin laittaa kontin body:n alle.
   Sijainti (top/left) hoituu pluginin JS:llä inputin offsetista —
   me annetaan vain visuaalinen ulkoasu. */
.relevanssi-live-search-results {
  background: var(--vm-bg);
  border: 1px solid var(--vm-border);
  box-shadow: var(--vm-shadow-3);
  max-height: 70vh; overflow-y: auto;
  z-index: 13;
  font-family: var(--vm-font-body);
  color: var(--vm-fg);
}
.relevanssi-live-search-results.relevanssi-live-search-results-showing { display: block; }
.relevanssi-live-search-results .ajax-results { padding: 0; }
.relevanssi-live-search-result-status { display: none; }

/* Tuotekortti hakudropdownissa — pakota grid, koska <a> on default inline
   ja plugin-CSS .relevanssi-live-search-result a { display:block } voi
   muuten yliajaa. Nostettu spesifisyys + !important kriittisille. */
.ajax-results a.vm-search-result,
.vm-search-results a.vm-search-result {
  display: grid !important;
  grid-template-columns: 56px 1fr auto !important;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--vm-fg);
  border-bottom: 1px solid var(--vm-border-subtle);
  transition: background var(--vm-dur-fast) var(--vm-ease-out);
}
.ajax-results a.vm-search-result:hover,
.vm-search-results a.vm-search-result:hover {
  background: var(--vm-bg-subtle);
}
.ajax-results a.vm-search-result:last-of-type { border-bottom: 0; }

.vm-search-result-img {
  width: 56px; height: 56px;
  background: var(--vm-bg-card);
  display: flex; align-items: center; justify-content: center;
  padding: 4px;
  flex-shrink: 0;
}
.vm-search-result-img img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.vm-search-result-body { min-width: 0; }
.vm-search-result-name {
  font-weight: 600;
  font-size: var(--vm-fs-14);
  line-height: 1.3;
  margin: 2px 0;
  color: var(--vm-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vm-search-result-meta {
  font-size: var(--vm-fs-12);
  color: var(--vm-fg-muted);
}

/* Brand-eyebrow tuotekortissa (haku-dropdown) */
.vm-prod-brand, .vm-search-result-brand {
  font-weight: 700;
  font-size: var(--vm-fs-12);
  letter-spacing: var(--vm-tracking-eyebrow);
  text-transform: uppercase;
  color: var(--vm-fg-muted);
  margin-bottom: 2px;
}

/* Tuotehinta-HTML (WC sale-rakenne) — sale punainen, was läpiviiva */
.vm-search-result-price .woocommerce-Price-amount { font-weight: 700; color: var(--vm-fg); white-space: nowrap; }
.vm-search-result-price del { color: var(--vm-fg-muted); font-weight: 400; margin-right: 4px; font-size: var(--vm-fs-13); }
.vm-search-result-price ins { background: transparent; text-decoration: none; }
.vm-search-result-price ins .woocommerce-Price-amount { color: var(--vm-sale); }

/* Näytä kaikki -CTA */
.vm-search-all {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--vm-brand-deep); color: #fff;
  text-decoration: none;
  font-family: var(--vm-font-body); font-weight: 600; font-size: var(--vm-fs-14);
  transition: background var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-search-all:hover { background: var(--vm-brand); color: #fff; }

.vm-search-empty {
  padding: 32px 18px; text-align: center;
  color: var(--vm-fg-muted);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.vm-search-empty-hint { font-size: var(--vm-fs-13); }

/* ---------- Header actions (vertaa/tili/kori) --------------------- */
.vm-header-actions { display: flex; gap: 20px; align-items: center; }
.vm-icon-btn {
  background: transparent; border: 0;
  display: flex; flex-direction: column; align-items: center;
  color: var(--vm-fg); font-family: var(--vm-font-body);
  font-weight: 600; font-size: var(--vm-fs-12);
  gap: 4px; position: relative; text-decoration: none;
  cursor: pointer;
}
.vm-icon-btn:hover { color: var(--vm-brand); }
.vm-icon-btn .badge {
  position: absolute; top: -4px; right: -10px;
  background: var(--vm-sale); color: #fff;
  border-radius: var(--vm-radius-pill);
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; line-height: 1;
}

/* ---------- Nav row ----------------------------------------------- */
.vm-nav-wrap { position: relative; }
.vm-nav {
  max-width: var(--vm-container);
  margin: 0 auto; padding: 0 24px;
  display: flex; gap: 22px;
  font-family: var(--vm-font-body); font-weight: 600;
  font-size: var(--vm-fs-12);
  letter-spacing: var(--vm-tracking-eyebrow);
  text-transform: uppercase;
  color: var(--vm-brand-deep);
  white-space: nowrap; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none;
  list-style: none; margin-bottom: 0;
}
.vm-nav::-webkit-scrollbar { display: none; }
.vm-nav > li { display: inline-flex; align-items: stretch; }
.vm-nav a, .vm-mega-trigger {
  color: inherit; text-decoration: none;
  padding: 14px 0;
  border-bottom: 2px solid transparent;
  transition: all var(--vm-dur-fast) var(--vm-ease-out);
  flex-shrink: 0;
  background: transparent; border-top: 0; border-left: 0; border-right: 0;
  font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.vm-nav a:hover, .vm-mega-trigger:hover,
.vm-mega-trigger[aria-expanded="true"] {
  color: var(--vm-brand); border-bottom-color: var(--vm-brand);
}
.vm-nav .sale > a   { color: var(--vm-sale); }
.vm-nav .workbike > a { color: var(--vm-workbike); }
.vm-mega-trigger .chev { transition: transform var(--vm-dur-fast) var(--vm-ease-out); }
.vm-mega-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* ---------- Mega menu --------------------------------------------- */
.vm-mega-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(13,43,60,0.25);
  z-index: 11; opacity: 0; pointer-events: none;
  transition: opacity var(--vm-dur-base) var(--vm-ease-out);
}
.vm-mega-backdrop.open { opacity: 1; pointer-events: auto; }

.vm-mega {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--vm-bg);
  border-top: 1px solid var(--vm-border-subtle);
  box-shadow: 0 18px 40px rgba(13,43,60,0.15);
  z-index: 12; display: none;
}
.vm-mega.open { display: block; animation: vm-mega-in 220ms var(--vm-ease-out); }
@keyframes vm-mega-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.vm-mega-inner {
  max-width: var(--vm-container); margin: 0 auto;
  padding: 32px 24px 28px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 36px 32px;
}
.vm-mega-col h4 {
  font-family: var(--vm-font-body); font-weight: 700;
  font-size: var(--vm-fs-12); letter-spacing: var(--vm-tracking-eyebrow);
  text-transform: uppercase; color: var(--vm-brand);
  margin: 0 0 12px; padding-bottom: 8px;
  border-bottom: 2px solid var(--vm-brand);
}
.vm-mega-col ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.vm-mega-col a {
  display: block; padding: 6px 0;
  color: var(--vm-fg); text-decoration: none;
  font-family: var(--vm-font-body); font-size: var(--vm-fs-14);
  transition: color var(--vm-dur-fast) var(--vm-ease-out),
              padding var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-mega-col a:hover { color: var(--vm-brand); padding-left: 4px; }
.vm-mega-col a.all { font-weight: 700; color: var(--vm-brand-deep); }
.vm-mega-col a.all:hover { color: var(--vm-brand); }

/* Mega promo tile */
.vm-mega-promo {
  background: var(--vm-bg-utility); color: #fff;
  padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  background-size: cover; background-position: center;
  background-blend-mode: overlay;
  position: relative; overflow: hidden;
  min-height: 240px; justify-content: flex-end;
  text-decoration: none;
}
.vm-mega-promo::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(13,43,60,0.2) 0%, rgba(13,43,60,0.85) 100%);
}
.vm-mega-promo > * { position: relative; z-index: 1; }
.vm-mega-promo .eyebrow {
  color: var(--vm-accent-cool);
  font-weight: 700; font-size: var(--vm-fs-12);
  letter-spacing: var(--vm-tracking-eyebrow);
  text-transform: uppercase;
}
.vm-mega-promo h3 {
  font-family: var(--vm-font-body); font-weight: 700;
  font-size: var(--vm-fs-24); color: #fff;
  margin: 0; letter-spacing: var(--vm-tracking-tight);
}
.vm-mega-promo p {
  color: rgba(255,255,255,0.92);
  font-size: var(--vm-fs-13); line-height: 1.5;
  margin: 0;
}
.vm-mega-promo .vm-btn {
  display: inline-block;
  background: var(--vm-brand); color: #fff;
  padding: 10px 16px;
  font-weight: 700; font-size: var(--vm-fs-13);
  align-self: flex-start;
  text-decoration: none; border: 0;
  transition: background var(--vm-dur-fast) var(--vm-ease-out);
}
.vm-mega-promo .vm-btn:hover { background: var(--vm-brand-deep); }

/* Body blur (vain main + footer, ei muut komponentit jotka eivät vielä portattu) */
.vm-mega-open #content,
.vm-mega-open #main,
.vm-mega-open footer,
.vm-mega-open .site-footer {
  filter: blur(6px);
  pointer-events: none;
  transition: filter var(--vm-dur-base) var(--vm-ease-out);
}

@media (max-width: 1100px) {
  .vm-mega-inner { grid-template-columns: repeat(3, 1fr); }
}
