/* ==========================================================================
   MILEX d.o.o. — COMPONENTS
   Header, navigation, buttons, cards, breadcrumb, footer, preloader,
   AI assistant widget, back-to-top. Page-specific layout lives in home.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Button
   -------------------------------------------------------------------------- */

.c-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 22px 40px;
  border: 0;
  background: var(--milex-blue);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: var(--fs-btn);
  font-weight: 600;
  line-height: 1;
  letter-spacing: var(--tracking-btn);
  text-transform: uppercase;
  text-align: center;
  transition: background var(--t-fast) var(--ease);
}

.c-btn:hover,
.c-btn:focus-visible { background: var(--milex-blue-dark); }

/* Header / footer call to action — 256×44 in the reference. It must never be
   squeezed into a two-line label by a narrow header row. */
.c-btn--cta {
  flex: 0 0 auto;
  min-width: 256px;
  min-height: 44px;
  padding: 14px 24px;
  white-space: nowrap;
}

/* The recurring "VIŠE" button — 250×48 in the reference. */
.c-btn--narrow {
  min-width: 250px;
  padding: 16px 40px;
}

/* The wide button under the category grid. */
.c-btn--wide {
  width: min(100%, 752px);
  padding: 22px 40px;
}

/* --------------------------------------------------------------------------
   2. Header
   -------------------------------------------------------------------------- */

/* A normal block element. It scrolls away with the page, as on the reference
   site — no sticky positioning, no scroll listener, no offset compensation
   anywhere else in the stylesheet. */
/* min-height reserves the box before js/components/header.js fills it. Without
   it the empty <header> is 0px tall at first paint and <main> slides down the
   moment the markup arrives — a ~0.23 layout shift on every page. */
.c-header {
  background: var(--paper);
  min-height: var(--header-h);
}

.c-header__inner {
  display: flex;
  align-items: center;
  gap: 40px;
  padding-block: 28px 26px;
}

.c-header__brand {
  flex: 0 0 auto;
  display: block;
  line-height: 0;
}

.c-header__logo {
  width: 134px;
  height: 70px;
}

.c-header__aside {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 40px;
  min-width: 0;
}

.c-header__top {
  display: flex;
  align-items: center;
  gap: 32px;
}

/* Phone ---------------------------------------------------------------- */

.c-header__phone {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.c-header__phone:hover { color: var(--milex-blue); }

.c-header__phone svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: var(--milex-blue);
}

/* Language switcher ----------------------------------------------------- */

.c-lang {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.c-lang__btn {
  padding: 4px 2px;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1;
  color: var(--muted-text);
  transition: color var(--t-fast) var(--ease);
}

.c-lang__btn:hover { color: var(--milex-blue-light); }

.c-lang__btn.is-active {
  font-weight: 700;
  color: var(--milex-blue);
}

.c-lang__sep {
  color: var(--muted);
  line-height: 1;
}

/* Primary navigation ---------------------------------------------------- */

.c-nav__list {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.c-nav__link {
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}

.c-nav__link:hover { color: var(--milex-blue); }

/* The page you are on, in both nav and footer. aria-current is the hook: the
   attribute already carries the meaning, so no parallel class can fall out of
   step with it. "page" is the exact page, "true" a section you are inside —
   the section reads lighter than the destination itself. */
.c-nav__link[aria-current="page"],
.c-mobile-menu__link[aria-current="page"] { color: var(--milex-blue); }

.c-nav__link[aria-current="true"],
.c-mobile-menu__link[aria-current="true"] { color: var(--milex-blue-light); }

.c-footer__link[aria-current="page"] { color: var(--milex-blue-light); }

/* Hamburger ------------------------------------------------------------- */

.c-burger {
  display: none;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--ink);
}

.c-burger svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}

/* Mobile overlay menu --------------------------------------------------- */

/* Full-viewport, with its own bar. The header is not sticky, so there is no
   fixed strip to sit beneath and the burger is covered once the overlay is
   open — hence the dedicated close button inside it. */
.c-mobile-menu {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity var(--t-media) var(--ease),
              transform var(--t-media) var(--ease);
}

/* Closed state is carried by the inert attribute rather than
   visibility:hidden: an element part-way through a visibility transition
   cannot take focus, which silently broke moving focus to the close button. */
.c-mobile-menu[inert] { opacity: 0; }

.c-mobile-menu.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.c-mobile-menu__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: var(--header-h);
  padding-inline: var(--gutter);
  border-bottom: 1px solid var(--hairline);
}

.c-mobile-menu__close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--ink);
}

.c-mobile-menu__close svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}

.c-mobile-menu__body {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 32px var(--gutter) 60px;
}

.c-mobile-menu__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.c-mobile-menu__link {
  display: block;
  padding: 14px 0;
  font-size: var(--fs-lead);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--hairline);
}

.c-mobile-menu__link:hover { color: var(--milex-blue); }

/* Contact row inside the overlay. This is the only place the phone number is
   reachable once the header bar drops it below 400px. */
.c-mobile-menu__phone {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-lead);
  font-weight: 600;
  color: var(--milex-blue);
}

.c-mobile-menu__phone svg {
  width: 22px;
  height: 22px;
  fill: var(--milex-blue);
}

.c-mobile-menu__lang {
  display: flex;
  gap: 14px;
  padding-top: 8px;
}

.c-mobile-menu__lang .c-lang__btn {
  padding: 8px 4px;
  font-size: var(--fs-lead);
}

/* --------------------------------------------------------------------------
   3. Breadcrumb block (page title + trail)
   -------------------------------------------------------------------------- */

.c-pagehead { padding-block: 40px 34px; }

/* Category templates need more air between the trail and the first card row. */
.c-pagehead--spaced { padding-bottom: 60px; }

.c-pagehead__title { color: var(--ink); }

.c-pagehead__trail {
  margin-top: 6px;
  font-size: var(--fs-body);
  color: var(--muted-text);
}

.c-pagehead__trail ol {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.c-pagehead__trail li + li::before {
  content: "/";
  margin-right: 8px;
  color: var(--muted-text);
}

.c-pagehead__trail a:hover { color: var(--milex-blue); }

/* The homepage has no trail; the markup stays for inner pages. */
.c-pagehead__trail:empty { display: none; }

/* --------------------------------------------------------------------------
   4. Card (category + article)
   The single card implementation for the whole site: the homepage grid, the
   /prodajni-program/ grid and the article carousel all use it.

   The card — not the photograph — owns the size. The ratio lives on .c-card
   itself and the image is stretched to fill it, so a portrait source and a
   landscape source produce boxes of exactly the same height. .c-card__media is
   a <span>, and an inline box ignores aspect-ratio and percentage heights
   entirely, so it is explicitly promoted to a block.
   -------------------------------------------------------------------------- */

.c-card {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  /* Painted before the photograph arrives, so the slot never flashes white. */
  background: var(--milex-blue-100);
}

.c-card__media {
  display: block;
  height: 100%;
  overflow: hidden;
}

.c-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform var(--t-slow) var(--ease);
}

.c-card:hover .c-card__img,
.c-card:focus-visible .c-card__img { transform: scale(1.03); }

/* Flush to the bottom edge. min-height holds the reference 90px for a
   one-line title; the padding lets a two- or three-line title grow the bar
   downwards inside the card without changing the card's outer height. */
.c-card__bar {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  min-height: 90px;
  padding: 18px 24px;
  background: var(--ink-overlay);
}

.c-card__title {
  font-family: var(--font-body);
  font-size: var(--fs-h3-fluid);
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
  color: var(--paper-soft);
}

/* Article variant — wider crop, sentence case. */
.c-card--article { aspect-ratio: 16 / 10; }
.c-card--article .c-card__title { text-transform: none; }

/* --------------------------------------------------------------------------
   5. Footer
   -------------------------------------------------------------------------- */

.c-footer {
  background: var(--ink);
  color: var(--paper-soft);
}

.c-footer__inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 40px;
  row-gap: 56px;
  padding-block: 96px 80px;
}

.c-footer__brand {
  display: block;
  line-height: 0;
  margin-bottom: 40px;
}

.c-footer__logo {
  width: 153px;
  height: 80px;
}

.c-footer__address {
  font-style: normal;
  line-height: var(--lh);
}

.c-footer__address a:hover { color: var(--milex-blue-light); }

.c-footer__phone-label { font-weight: 700; }

.c-footer__legal {
  margin-top: 18px;
  font-size: var(--fs-small);
  color: var(--ink-on-dark-muted);
}

.c-footer__list {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.c-footer__link {
  font-weight: 600;
  text-transform: uppercase;
  color: var(--paper-soft);
}

.c-footer__link:hover { color: var(--milex-blue-light); }

.c-footer__col--actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 40px;
}

.c-footer__social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--paper-soft);
  transition: color var(--t-fast) var(--ease);
}

.c-footer__social:hover { color: var(--milex-blue-light); }

.c-footer__social svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* Bottom bar ------------------------------------------------------------ */

.c-footer__bar {
  border-top: 1px solid rgba(248, 248, 248, .12);
  font-size: var(--fs-small);
  color: var(--ink-on-dark-muted);
}

.c-footer__bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  padding-block: 28px;
}

.c-footer__bar-links {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
}

.c-footer__bar a:hover { color: var(--paper-soft); }

/* --------------------------------------------------------------------------
   6. Preloader
   -------------------------------------------------------------------------- */

.c-preloader {
  position: fixed;
  inset: 0;
  z-index: var(--z-preloader);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 34px;
  background: var(--milex-blue);
  opacity: 1;
  transition: opacity var(--t-slow) var(--ease);
}

.c-preloader.is-hiding { opacity: 0; }
.c-preloader[hidden] { display: none; }

.c-preloader__logo {
  width: 153px;
  height: 80px;
}

.c-preloader__logo.u-animated {
  animation: milex-pulse 1.4s ease-in-out infinite;
}

@keyframes milex-pulse {
  0%, 100% { opacity: .6; }
  50%      { opacity: 1; }
}

.c-preloader__bar {
  width: 180px;
  height: 2px;
  overflow: hidden;
  background: rgba(248, 248, 248, .25);
}

.c-preloader__bar-fill {
  display: block;
  width: 30%;
  height: 100%;
  background: var(--paper-soft);
  transition: width var(--t-slow) var(--ease);
}

/* --------------------------------------------------------------------------
   7. AI assistant widget (bottom left)
   -------------------------------------------------------------------------- */

.c-ai {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: var(--z-widget);
}

.c-ai__launcher {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  background: var(--milex-blue);
  color: var(--paper);
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}

.c-ai__launcher:hover {
  background: var(--milex-blue-dark);
  transform: translateY(-2px);
}

.c-ai__launcher svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* Panel ----------------------------------------------------------------- */

.c-ai__panel {
  position: absolute;
  bottom: 76px;
  left: 0;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: 540px;
  max-height: calc(100vh - 124px);
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--t-media) var(--ease),
              transform var(--t-media) var(--ease);
}

/* The closed panel is taken out of the tab order and the accessibility tree
   with the inert attribute rather than visibility:hidden — an element mid-way
   through a visibility transition cannot receive focus, which made opening the
   panel silently fail to move focus into it. */
.c-ai__panel[inert] { opacity: 0; }

.c-ai__panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.c-ai__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--milex-blue);
  color: var(--paper);
}

.c-ai__mark {
  width: 46px;
  height: 24px;
  flex: 0 0 auto;
}

.c-ai__title {
  flex: 1 1 auto;
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.3;
}

.c-ai__close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--paper);
  transition: background var(--t-fast) var(--ease);
}

.c-ai__close:hover { background: var(--milex-blue-dark); }

.c-ai__close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Message log ----------------------------------------------------------- */

.c-ai__log {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px;
  overflow-y: auto;
}

.c-ai__msg {
  max-width: 88%;
  padding: 12px 16px;
  font-size: var(--fs-btn);
  line-height: 1.6;
}

.c-ai__msg--bot {
  align-self: flex-start;
  background: var(--paper-grey);
  color: var(--ink);
}

.c-ai__msg--user {
  align-self: flex-end;
  background: var(--milex-blue);
  color: var(--paper);
}

/* Typing indicator ------------------------------------------------------ */

.c-ai__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 16px;
  background: var(--paper-grey);
}

.c-ai__typing span {
  width: 6px;
  height: 6px;
  background: var(--muted);
}

.c-ai__typing.u-animated span {
  animation: milex-typing 1.1s ease-in-out infinite;
}

.c-ai__typing span:nth-child(2) { animation-delay: .18s; }
.c-ai__typing span:nth-child(3) { animation-delay: .36s; }

@keyframes milex-typing {
  0%, 60%, 100% { opacity: .25; }
  30%           { opacity: 1; }
}

/* Question chips -------------------------------------------------------- */

.c-ai__chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 14px;
  border-top: 1px solid var(--hairline-strong);
  padding-top: 14px;
}

.c-ai__chip {
  padding: 11px 14px;
  background: var(--milex-blue-100);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-btn);
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}

.c-ai__chip:hover {
  background: var(--milex-blue);
  color: var(--paper);
}

.c-ai__foot {
  padding: 12px 16px;
  border-top: 1px solid var(--hairline-strong);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted-text);
}

.c-ai__foot a {
  color: var(--milex-blue);
  font-weight: 600;
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   8. Back to top (bottom right)
   -------------------------------------------------------------------------- */

.c-totop {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-widget);
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: var(--milex-blue);
  color: var(--paper);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity var(--t-media) var(--ease),
              transform var(--t-media) var(--ease),
              visibility var(--t-media) var(--ease),
              background var(--t-fast) var(--ease);
}

.c-totop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.c-totop:hover { background: var(--milex-blue-dark); }

.c-totop svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}

/* --------------------------------------------------------------------------
   9. No-JavaScript fallback bar
   The header and footer are rendered by JS, so a scriptless visitor gets the
   contact details and the full menu from this strip instead.
   -------------------------------------------------------------------------- */

.c-noscript {
  padding: 20px var(--gutter);
  background: var(--milex-blue-100);
  font-size: var(--fs-small);
  line-height: 1.8;
}

.c-noscript p + p { margin-top: 8px; }

.c-noscript a {
  margin-right: 20px;
  font-weight: 600;
  color: var(--milex-blue);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   10. Component responsive rules
   -------------------------------------------------------------------------- */

@media (max-width: 1439px) {
  .c-nav__list { gap: 14px; }
  .c-header__top { gap: 24px; }
}

@media (max-width: 1199px) {
  .c-nav__link { font-size: 14px; }
  .c-nav__list { gap: 12px; }
  .c-btn--cta { min-width: 200px; }
}

/* 992–1119px: the last stretch before the hamburger. Eight uppercase Serbian
   menu items have to stay on one row here, so the whole header row tightens. */
@media (max-width: 1119px) {
  .c-header__inner { gap: 24px; }
  .c-header__top { gap: 18px; }
  .c-header__aside { gap: 30px; }
  .c-nav__link { font-size: 13px; }
  .c-nav__list { gap: 11px; }
  .c-btn--cta { min-width: 180px; }
}

/* Below 992px the nav collapses into the overlay. */
@media (max-width: 991px) {
  .c-header__inner {
    align-items: center;
    gap: 20px;
    padding-block: 12px;
    min-height: var(--header-h);
  }

  .c-header__logo { width: 115px; height: 60px; }

  .c-header__aside {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
  }

  .c-header__top { gap: 20px; }
  .c-nav { display: none; }

  /* Scoped to the header — the overlay keeps its own switcher. */
  .c-header__top .c-lang { display: none; }

  .c-burger { display: grid; }

  .c-footer__inner {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 48px;
    padding-block: 64px 56px;
  }
}

@media (max-width: 767px) {
  .c-header__phone-number { display: none; }

  .c-header__phone {
    width: 44px;
    height: 44px;
    justify-content: center;
    gap: 0;
  }

  .c-btn--cta {
    min-width: 0;
    padding: 13px 18px;
    font-size: 13px;
  }

  .c-footer__inner { grid-template-columns: 1fr; }
  .c-footer__col--actions { gap: 28px; }
  .c-footer__bar-inner { justify-content: flex-start; }

  .c-card__bar { min-height: 74px; padding: 14px 18px; }

  .c-ai { bottom: 16px; left: 16px; }
  .c-ai__launcher { width: 52px; height: 52px; }
  .c-ai__launcher svg { width: 24px; height: 24px; }

  .c-ai__panel {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 80px;
    width: auto;
    height: min(540px, calc(100vh - 112px));
  }

  .c-totop { bottom: 16px; right: 16px; width: 46px; height: 46px; }
}

@media (max-width: 479px) {
  .c-btn,
  .c-btn--narrow,
  .c-btn--wide { width: 100%; }

  /* The header row is a fixed budget: logo + phone + CTA + burger must all fit
     across ~280–440px of content, so every piece steps down together. */
  .c-btn--cta {
    width: auto;
    min-width: 0;
    padding: 10px 12px;
    font-size: 11px;
    letter-spacing: .02em;
  }

  .c-header__inner,
  .c-header__aside,
  .c-header__top { gap: 8px; }

  .c-header__logo { width: 92px; height: 48px; }

  .c-header__phone,
  .c-burger { width: 38px; height: 38px; }

  .c-header__phone svg { width: 18px; height: 18px; }
  .c-burger svg { width: 22px; height: 22px; }
}

/* Under 400px the header row genuinely runs out of room. The phone drops out
   of the bar rather than crushing the CTA — the overlay menu carries it. */
@media (max-width: 399px) {
  .c-header__top .c-header__phone { display: none; }
}
