/* ============================================ */
/*   CSS custom properties                       */
/* ============================================ */
:root {
  --max-width: 1200px;
  --paragraph-max-width: 65ch;

  /* Barvy */
  --color-header-bg: white;
  --color-body: #222;
  --color-body-bg: #fff;
  /* --color-highlight: #D32E3F; */
  --color-highlight: #dd5f5e;
  --color-topmenu-bg: black;
  --color-topmenu: white;
  --color-divider: #ccc;
  --color-menu-title-bg: var(--color-highlight);
  /* --color-footer-divider: #47BCCA; */ 
  /* --color-footer-divider: #f4c8c1; */ 
  --color-footer-divider: var(--color-highlight);

  /* Stíny */
  --shadow-card: 0 4px 12px -2px rgba(0, 0, 0, 0.15);

  /* Typografie */
  --font-base: "Moderat", Arial, Helvetica, sans-serif;
  --font-size-base: 1rem;
  --line-height-base: 1.6;

  /* Mezery */
  --space-xs: 0.25rem;
  --space-s:  0.5rem;
  --space-m:  1rem;
  --space-l:  1.5rem;
  --space-xl: 3rem;

  /* Poloměry */
  --radius-s: 4px;
  --radius-m: 8px;

  /* Výška top menu (JS doplní skutečnou hodnotu) */
  --topmenu-h: 3rem;
}


/* ============================================ */
/*   Fonty                                       */
/* ============================================ */
@font-face {
  font-family: "Moderat";
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/Moderat-Regular-1.woff2) format("woff2");
}
@font-face {
  font-family: "Moderat";
  font-weight: 500;
  font-display: swap;
  src: url(/fonts/Moderat-Medium-1.woff2) format("woff2");
}
@font-face {
  font-family: "Moderat";
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/Moderat-Bold-1.woff2) format("woff2");
}
@font-face {
  font-family: "Moderat";
  font-weight: 900;
  font-display: swap;
  src: url(/fonts/Moderat-Black-1.woff2) format("woff2");
}


/* ============================================ */
/*   CSS reset                                   */
/* ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


/* ============================================ */
/*   Základní elementy                           */
/* ============================================ */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-body);
  background-color: var(--color-body-bg);
  margin: 0 auto;
  padding-top: var(--topmenu-h);
}

a {
  text-decoration: none;
  color: #0055cc;
}
a:hover,
a:focus {
  text-decoration: underline;
}

img,
video {
  height: auto;
  display: block;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

td:not(:last-child) {
  padding-right: var(--space-m);
}
th {
  text-align: left;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

h1:first-child {
  margin-top: 0;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p, ul, ol, blockquote {
  margin-bottom: var(--space-m);
}

p {
  max-width: var(--paragraph-max-width);
}

.card {
  border: 1px solid var(--color-divider);
  padding: var(--space-m);
  max-width: var(--paragraph-max-width);

  p:last-child {
    margin-bottom: 0;
  }
}

strong { font-weight: 600; }
em     { font-style: italic; }

input, button, textarea, select {
  font: inherit;
  line-height: inherit;
  color: inherit;
}


/* ============================================ */
/*   Layout                                      */
/* ============================================ */
header {
  background-color: var(--color-header-bg);
  box-shadow: var(--shadow-card);
  position: sticky;
  top: var(--topmenu-h, 0);
  z-index: 999;
}

header.top {
  top: 0;
  transform: translateY(0);
  transition: transform 0.3s ease;
}

nav {
  width: 100%;
  margin: 0;
  padding: 0;
}

.nav-container {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-s) var(--space-m);
  display: flex;
  justify-content: space-between;
  align-items: center;

  a,
  a:visited {
    color: inherit;
  }
}

main.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-m);
  /* padding-top: calc(var(--space-m) + var(--topmenu-h)); /1* ← přidat *1/ */
}

img.logo {
  max-height: 5rem;
  height: auto;
}

.warning {
  border: 1px solid var(--color-highlight);
  padding: var(--space-m);
  margin-bottom: var(--space-m);
}

mark.secondary{
  background-color: var(--color-body-bg);
  border-bottom: 3px solid var(--color-highlight);
  font-weight: bold;
  font-size: 1.2rem;
}

.visually-hidden {
  visibility: hidden;
  font-size: 0;
  margin: 0; 
  padding: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    z-index: 1000;
    padding: .5rem 1rem;
    background: white;
    border: 1px solid black;
}

.page-with-image {
  display: grid;
  /* Na desktopu vedle sebe, na mobilu pod sebou */
  grid-template-columns: 1fr 1fr;
  gap: var(--space-l);
  .page-image img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-s);
  }
}


/* ============================================ */
/*   Navigační menu                              */
/* ============================================ */
.menu {
  display: flex;
  gap: var(--space-m);
  list-style: none;
  margin: 0;
  padding: 0;
}

.mainmenu {
  .has-breadcrumbs {
    border-bottom: 1px solid var(--color-divider);
  }

  button {
    all: unset;
    display: inline-block;
    cursor: pointer;

    img {
      height: 1em;
      display: inline-flex;
      align-items: flex-end;
      vertical-align: middle;
    }
  }

  .menu {
    font-size: 1.2rem;
    font-weight: 700;

    li {
      position: relative;
    }

    li:last-child .submenu,
    li:nth-last-child(2) .submenu {
      left: auto;
      right: 0;
    }
  }

  .submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    background: white;
    list-style: none;
    margin: 0;
    padding: var(--space-s);
    font-size: 1rem;
    font-weight: normal;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: 1001;

    li + li {
      margin-top: 0.5em;
    }

    li.menuitem::before {
      content: url("/img/threedots.svg");
    }

    li.section-title {
      background-color: var(--color-menu-title-bg);
      font-weight: bold;
      text-align: center;
      color: white;
    }

  }

  /* Otevření submenu na desktopu hoveru / focusu */
  @media (min-width: 901px) {
    li:hover .submenu,
    li:focus-within .submenu {
      min-width: 300px;
      display: block;
    }
  }

  /* Otevření submenu třídou .open (desktop i mobil) */
  .menu > li.open > .submenu {
    display: block;
  }
}

/* Hamburger – skrytý na desktopu */
.mainmenu button.hamburger {
  all: unset;
  display: none;
  font-size: 2rem;
  cursor: pointer;
}


/* ============================================ */
/*   Top menu                                    */
/* ============================================ */
.topmenu {
  background-color: var(--color-topmenu-bg);
  color: var(--color-topmenu);
  padding: 0.2em 0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topmenu-h);
  transform: translateY(0);
  transition: transform 0.3s ease;
  z-index: 1000;

  .nav-container {
    justify-content: flex-end;
  }

  span {
    border-right: 1px solid var(--color-topmenu);
    margin: 0 var(--space-s);
    padding-right: var(--space-s);
    height: 1.5em;

    &:last-child {
      border-right: none;
      margin-right: 0;
      padding-right: 0;
    }
  }

  .langswitcher * {
    display: inline;
    width: auto;
  }

  @media (max-width: 900px) {
    font-size: clamp(0.8rem, 2vw, 1rem); /* plynulé zmenšování podle šířky viewportu */
    height: auto;

    span{overflow: hidden; white-space: nowrap;}
  }

}

.topmenu.hidden {
  transform: translateY(calc(-1 * var(--topmenu-h)));
}


/* ============================================ */
/*   Drobečková navigace                         */
/* ============================================ */
.breadcrumb {
  font-size: 1.1rem;
  overflow-x: auto;

  ul {
    list-style: none;
   display: flex;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: var(--space-s);
    padding: 0;
    margin: 0;
    font-size: 0.9em;
  }

  li::after {
    content: "›";
    margin-left: var(--space-s);
    color: #555;
  }

  li:last-child::after {
    content: "";
  }

  img {
    display: inline;
    height: 1em;
    vertical-align: -0.2ch;
  }
}


/* ============================================ */
/*   Quick links                                 */
/* ============================================ */
.quick-links {
  box-shadow: var(--shadow-card);
  /* Na desktopu se přizpůsobí obsahu, na mobilu zabere celou šířku */
  width: 100%;
  max-width: fit-content;
  margin: var(--space-m) auto;
  padding: var(--space-s);
  /* Horizontální scroll je omezen na tento element, ne na celou stránku */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--color-body) var(--color-body-bg);
  /* Zabrání přesahu obsahu mimo tento box */
  white-space: nowrap;

  .quicklink {
    display: inline-block;
    padding: var(--space-s) var(--space-m);
    background-color: white;
    border-radius: var(--radius-s);
    margin: var(--space-s);
    font-weight: 500;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
    vertical-align: middle;

    img {
      vertical-align: middle;
      margin: 0 auto;
      text-align: center;
      height: 2.5rem;
    }

    a,
    a:visited {
      color: inherit;
      font-weight: bold;
    }
    @media (max-width: 900px) {
      font-size: clamp(0.6rem, 2vw, 1rem); /* plynulé zmenšování podle šířky viewportu */
    }
  }

  .quicklink + .quicklink {
    border-left: 1px solid var(--color-divider);
    border-radius: 0;
    transition: none;
  }
}


/* ============================================ */
/*   Rollup sekce                                */
/* ============================================ */
.rollup {
  padding-bottom: 1ch;
  /* margin-top: var(--space-xl); */

  img {
    max-width: 100%;
  }
}


/* ============================================ */
/*   Aktuality (.news)                           */
/* ============================================ */
.news {
  /* Flexbox místo inline-block: zalamuje se přirozeně na menších obrazovkách */
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-m);

  /* h2 a archive-link zabírají celý řádek, ostatní flex-itemy se řadí vedle sebe */
  h2,
  .closed,
  .archive-link {
    width: 100%;
    text-align: center;
  }

  .news-item {
    /* Minimální šířka zajišťuje, že se sloupce nezmenší pod čitelnou hodnotu */
    flex: 1 1 260px;
    min-width: 0;           /* bez tohoto by flex-item mohl přetékat */
    vertical-align: top;
    overflow: hidden;
    transition: all 0.3s ease;

    h3 {
      margin-top: 0;
      margin-bottom: var(--space-s);
      font-size: 1rem;
    }

    .date {
      font-size: 0.9rem;
    }

    summary::-webkit-details-marker {
      display: none;
    }

    summary {
      list-style: none;
      cursor: pointer;
      outline: none;
    }

    .read-more-btn {
      text-decoration: underline;
      font-size: 0.8rem;
    }

    &:not([open]) {
      max-height: 23rem;
    }

    &[open] {
      max-height: 90rem;

      .read-more-btn {
        display: none;
      }
    }
  }

  /* Oddělovač – jen mezi sousedními položkami a jen na desktopu */
  @media (min-width: 601px) {
    .news-item + .news-item {
      border-left: 1px solid var(--color-divider);
      padding-left: var(--space-s);
    }
  }

}

.closed{
  &:has(b) {
    border: 1px solid var(--color-highlight);
  }
  width: fit-content;
  b{display: block; width: 100%; background-color:  var(--color-highlight); color: white; padding: 0 3rem; font-size: 1.2rem;}
 }

/* ============================================ */
/*   Otevírací doby (.opening)                   */
/* ============================================ */
.opening {
  /* Flexbox místo inline-block: tabulky se zalamují na menších obrazovkách */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-l);
  margin-bottom: var(--space-xl);

  /* Tyto prvky zabírají celý řádek samostatně, centrovaně */
  h2,
  .closed,
  .planned_closing {
    width: 100%;
    text-align: center;
    margin-bottom: 0;
  }

  h2 {
    margin-bottom: 2rem;
  }

  .prov_doba_container {
    table{ 
      text-align: left;
      vertical-align: top;
      /* Pevná min-width zabrání zbytečnému zmáčknutí */
      min-width: 160px;

      caption {
        width: fit-content;
      }
      th {
        font-weight: normal;
        font-size: 1rem;
        padding-right: var(--space-m);
      }
    }
  }
  /* @media (min-width: 601px) { */
  /*   table + table, caption + caption { */
  /*     border-left: 1px solid var(--color-divider); */
  /*     padding-left: var(--space-s); */
  /*   } */
  /* } */
  @media (min-width: 601px) {
    .prov_doba_container  + .prov_doba_container {
      border-left: 1px solid var(--color-divider);
      padding-left: var(--space-s);
    }
  }
  @media (max-width: 600px) {
    justify-content: flex-start;
  }
}

.opening h2, .news h2 {
  font-size: 2rem;
}


/* ============================================ */
/*   Sdílené styly odkazů (archiv, uzavírky)     */
/* ============================================ */
.planned_closing,
.archive-link {
  font-size: 1.2rem;

  a {
    color: var(--color-body);
    text-decoration: underline;
    text-decoration-thickness: 3px;
    text-decoration-color: var(--color-footer-divider);
  }

  a:hover {
    text-decoration-color: var(--color-body);
  }
}


/* ============================================ */
/*   Zápatí                                      */
/* ============================================ */
footer {
  border-top: 5px solid var(--color-footer-divider);

  img {
    display: inline;
    height: 1em;
    vertical-align: middle;
  }

  div {
    vertical-align: bottom;
  }

  div.column div {
    margin-top: var(--space-s);
  }

  address {
    font-style: normal;
  }

  .copyright {
    font-size: 1rem;
    color: white;
    padding: var(--space-m);
    background-color: black;
    text-align: center;
  }

  @media (max-width: 600px) {
    .nav-container {
      display: block;
    }
  }
}

/* ============================================ */
/*   Vyhledávání                                */
/* ============================================ */

.tabs.searchbox {
    display: flex;
    flex-wrap: wrap;
    max-width: 30rem;
}

/* schovat radio buttony */
.tabs.searchbox > input[type="radio"] {
    position: absolute;
    left: -9999px;
}

/* vzhled záložek */
.tabs.searchbox > label {
    padding: .5em 1em;
    cursor: pointer;
    border: 1px solid #ccc;
    border-bottom: none;
    background: #eee;
    margin-right: .2em;
}

/* aktivní záložka */
.tabs.searchbox > input:checked + label {
    background: white;
    font-weight: bold;
}

/* obsah záložek */
.tabs.searchbox > div {
    display: none;
    width: 100%;
    padding: 1em;
    border: 1px solid #ccc;
    order: 99;
}

/* zobrazit obsah aktivní záložky */
.tabs.searchbox > input:checked + label + div {
    display: block;
}

.tabs.searchbox > input:checked + label {
    position: relative;
    z-index: 1;
}

.tabs.searchbox > input:checked + label::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: white;
}

.searchbox input[type="image"] {
  background-color: var(--color-body);
  padding: 0.5em;
  margin: 0;
  margin-left: 0.5em;
  vertical-align: bottom;
}

img[src="/img/search.svg"] {
  height: 1em;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}


/* ============================================ */
/*   Mobilní navigace (max 900px)                */
/* ============================================ */
@media (max-width: 900px) {
  img.logo {
    max-height: 3rem;
    height: auto;
  }

  .mainmenu button.hamburger {
    display: inline-block;
  }

  /* Hlavní menu je schované, otevírá se třídou .open */
  .menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 2000;
    background: white;
    box-shadow: var(--shadow-card);
  }

  .menu.open {
    display: flex;
  }

  /* Mobilní submenu se stackuje svisle */
  .mainmenu .submenu {
    display: none;
    position: static;
    z-index: 2100;
    box-shadow: none;
    padding-left: var(--space-m);
  }

  .mainmenu .menu > li.open > .submenu {
    display: block;
  }

  /* Quick links: na mobilu zabere celou šířku a lze scrollovat jen tento box */
  .quick-links {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;

    img {
      height: 1.5rem;
    }
  }
  .page-with-image {
    grid-template-columns: 1fr;
    .page-image img {
      display: none;
    }
  }
}


/* ============================================ */
/*   Trik: ikona externího odkazu                */
/* ============================================ */
a[href^="http"]:not([href*="knihovna.pedf.cuni.cz"])::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-left: 0.25em;
  background: currentColor;
  -webkit-mask: url("/img/external-link.svg") no-repeat center / contain;
  mask: url("/img/external-link.svg") no-repeat center / contain;
}
