/**
 * Site-wide responsive styles (shared header, navigation and footer).
 *
 * The original layout is a rigid 984px design. Below the desktop breakpoint
 * the fixed widths, absolute positioning and floats are linearised so the
 * page fits narrow viewports. Homepage-specific responsive rules live in
 * timeline.css.
 */

/* Hamburger toggle - hidden on desktop, shown below the breakpoint. */
.nav-toggle {
  display: none;
  -webkit-appearance: none;
  appearance: none;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.nav-toggle__icon,
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  transition: transform 0.2s ease, background 0.2s ease;
}

.nav-toggle__icon {
  position: relative;
}

.nav-toggle__icon::before,
.nav-toggle__icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle__icon::before {
  top: -7px;
}

.nav-toggle__icon::after {
  top: 7px;
}

.menu.is-open .nav-toggle__icon {
  background: transparent;
}

.menu.is-open .nav-toggle__icon::before {
  transform: translateY(7px) rotate(45deg);
}

.menu.is-open .nav-toggle__icon::after {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mirror of the sidebar/section menu, injected into the hamburger panel by
   theme.js. Hidden on desktop; only shown inside the open mobile menu (see
   the media query below). */
.mobile-sidebar-menu {
  display: none;
}

@media (max-width: 1023px) {
  /* Keep the page exactly viewport-wide and flush-left; never allow a stray
     element to force horizontal scrolling or push the content sideways. */
  html,
  body {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  /* html is the viewport scroller, so hiding its horizontal overflow clips any
     stray bleed without side effects. On body we use clip, not hidden: hidden
     forces overflow-y to compute as auto, which turns body into a second scroll
     container nested inside html (the "scroll within a scroll"). clip leaves
     overflow-y visible, so body never becomes a scroller. */
  html {
    overflow-x: hidden;
  }

  body {
    overflow-x: clip;
  }

  .all,
  #page {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }

  /* The top gradient strip is the header's background, not a page-wide one. */
  body {
    background-image: none;
  }

  /* Page containers: drop the fixed 984px width. */
  .header,
  .menu,
  #main_menu,
  #content,
  .footer {
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
  }

  #col-main,
  #col-left {
    width: auto !important;
    max-width: 100%;
    float: none;
  }

  /* Comfortable side gutters so content does not touch the screen edges. */
  #content {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Header: stop absolute positioning, let the logo flow. Taller on mobile.
     The gradient strip now scrolls with the header (no longer a body bg). */
  .header {
    height: auto;
    padding: 22px 16px 18px;
    background: url("../img/bg-body.jpg") top left repeat-x;
  }

  #header .logo {
    position: static;
    width: auto;
    height: auto;
  }

  #header .logo img {
    width: auto;
    max-width: 220px;
    height: auto;
  }

  #header .serviceMenu {
    position: static;
    margin: 8px 0 0;
  }

  #header .serviceMenu ul li {
    float: none;
    display: inline-block;
    padding: 0 16px 0 0;
  }

  /* Decorative coin emblem - drop it on narrow screens. */
  img#head-znak {
    display: none;
  }

  /* Navigation: collapse behind the hamburger (toggle aligned right). */
  .nav-toggle {
    display: flex;
    width: -moz-fit-content;
    width: fit-content;
    margin-left: auto;
    margin-right: 8px;
  }

  #main_menu {
    height: auto;
    background: none;
    padding: 0;
  }

  #main_menu #nav {
    display: none;
  }

  .menu.is-open #main_menu #nav {
    display: block;
  }

  /* width is set inline (px) by the desktop menu script - override it. */
  #main_menu #nav > li {
    float: none;
    display: block;
    width: 100% !important;
    height: auto;
    background: none;
    padding: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }

  #main_menu #nav > li > a {
    float: none;
    display: block;
    width: 100%;
    height: auto;
    padding: 14px 16px;
    box-sizing: border-box;
  }

  /* Footer: unfloat the columns and let them stack. */
  .footer {
    padding: 0 16px;
  }

  .footer .footer-line,
  .footer .inner-wrap,
  .footer .w780,
  .footer .w200,
  .footer .fl-left,
  .footer .fl-right,
  #footer .copyright,
  #footer .serviceLinks {
    float: none !important;
    width: auto !important;
  }

  #footer .copyright ul li,
  #footer .serviceMenu ul li {
    float: none;
    display: inline-block;
  }

  /* Breadcrumb: drop the fixed 984px width and align with the content
     gutters instead of letting it run off the side of the viewport. */
  .location-bar {
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Start with the content on narrow screens: hide the sidebar column so the
     user no longer scrolls past its long menu to reach the actual content.
     The menu is mirrored into the hamburger panel (.mobile-sidebar-menu). */
  #col-left {
    display: none;
  }

  /* Sidebar menu mirror: shown below the main menu when the hamburger panel
     is open, styled to match the dark mobile menu. */
  .menu.is-open .mobile-sidebar-menu {
    display: block;
  }

  .mobile-sidebar-menu__label {
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* Selectors are prefixed with #main_menu to outweigh the floated desktop
     menu rules (#main_menu ul li / a), which would otherwise collapse this
     list and let the links escape the dark menu panel. */
  #main_menu .mobile-sidebar-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    float: none;
    width: 100%;
  }

  #main_menu .mobile-sidebar-menu li {
    float: none;
    display: block;
    width: 100%;
    height: auto;
    padding: 0;
    background: none;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }

  #main_menu .mobile-sidebar-menu li a {
    float: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    width: 100%;
    box-sizing: border-box;
    height: auto;
    padding: 12px 16px;
    color: #fff;
    text-decoration: none;
  }

  #main_menu .mobile-sidebar-menu__text {
    flex: 1 1 auto;
    min-width: 0;
  }

  #main_menu .mobile-sidebar-menu__date {
    display: block;
    font-size: 10px;
    opacity: 0.75;
  }

  #main_menu .mobile-sidebar-menu__name {
    display: block;
  }

  /* Third-level items (mirrored only under the active section, see theme.js):
     indent and tint them so they read as a deeper level rather than as
     siblings of the main section items. They carry no date/timeline bar. */
  #main_menu .mobile-sidebar-menu__sub {
    background: rgba(0, 0, 0, 0.2);
  }

  #main_menu .mobile-sidebar-menu__sub li {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  #main_menu .mobile-sidebar-menu__sub li a {
    padding-left: 40px;
    font-size: 13px;
    opacity: 0.85;
  }

  /* Marker so the hierarchy is clear at a glance, not by indent alone. */
  #main_menu .mobile-sidebar-menu__sub li a::before {
    content: "–";
    flex: 0 0 auto;
    opacity: 0.6;
  }

  /* Timeline bar: keep the desktop visual, pinned to a static 131px width and
     aligned to the right. On very narrow screens it wraps onto its own line
     (flex-wrap) and never exceeds the viewport. */
  #main_menu .mobile-sidebar-menu .bar {
    flex: 0 0 131px;
    margin-left: auto;
    max-width: 100%;
    position: relative;
    height: 7px;
    background: #fff;
    /* Fully round the track. On the dark menu the square white background
       would otherwise show past the rounded mask; overflow clips the fill. */
    border-radius: 4px;
    overflow: hidden;
  }

  #main_menu .mobile-sidebar-menu .mask {
    display: block;
    width: 131px;
    height: 7px;
    position: absolute;
    top: 0;
    left: 0;
    background: url("../img/document-menu-bar-mask.gif") no-repeat;
  }

  #main_menu .mobile-sidebar-menu .interval {
    display: block;
    height: 7px;
    background: url("../img/png/document-menu-bar.png") repeat-x;
  }

  /* Page head (grey title band): drop the fixed 729px width so the heading
     and subtitle wrap inside the viewport instead of overflowing sideways. */
  #page-head {
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
  }

  #page-head h1.title,
  #page-head p.subtitle {
    overflow-wrap: break-word;
  }
}

/* From a typical phone width down, the sidebar-menu timeline bar drops onto
   its own line below the label: the text takes the full row, so the bar
   (still right-aligned via margin-left:auto) wraps underneath. */
@media (max-width: 580px) {
  #main_menu .mobile-sidebar-menu__text {
    flex-basis: 100%;
  }
}

/* Photogallery (fgallery): the original layout had a fixed 729px width and
   was clipped inside #col-main below ~750px (the "na konec" link and part of
   the gallery disappeared). These rules let the component shrink with its
   container; per-slide width is recomputed by JS (slider.js layout()) from
   the live viewport, so the pixel-based slider stays in sync on resize. */
.fgallery {
  max-width: 100%;
}

.fgallery .wrapper {
  /* border-box + width:729px keeps the inner width at 700px on desktop
     (identical to before), while max-width:100% shrinks the whole component
     - padding included - on narrow screens. */
  width: 729px;
  max-width: 100%;
  box-sizing: border-box;
}

#col-main .fgallery .slide h2,
#col-main .fgallery .slide p {
  width: auto;
}

.fgallery .slide .slide-photo {
  max-width: 100%;
}

.fgallery .slide .slide-photo img {
  max-width: 100%;
  height: auto;
}
