/* ==========================================================
   Juventutem magazín – redakční vzhled
   Barvy a písma dodává --brand-*; zde jen odvozené hodnoty.
   ========================================================== */

:root {
  color-scheme: light;

  /* mezery */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.25rem;
  --space-xl: 3.5rem;

  /* velikosti písma */
  --fs-h1: clamp(1.9rem, 1.4rem + 2vw, 3rem);
  --fs-h2: clamp(1.4rem, 1.2rem + 0.9vw, 2rem);
  --fs-h3: clamp(1.1rem, 1.02rem + 0.35vw, 1.3rem);
  --fs-card: clamp(1.1rem, 1.04rem + 0.3vw, 1.3rem);
  --fs-body: clamp(1.0625rem, 1.03rem + 0.15vw, 1.1875rem);
  --fs-small: 0.875rem;

  /* odvozené odstíny */
  --c-surface-2: color-mix(in srgb, var(--brand-surface) 60%, var(--brand-border));
  --c-line: var(--brand-border);
  --c-line-strong: color-mix(in srgb, var(--brand-text) 22%, var(--brand-border));
  --c-primary-hover: color-mix(in srgb, var(--brand-primary) 80%, var(--brand-text));
  --c-primary-soft: color-mix(in srgb, var(--brand-primary) 10%, var(--brand-bg));
  --c-footer-muted: color-mix(in srgb, var(--brand-footer-text) 72%, var(--brand-footer-bg));
  --c-footer-line: color-mix(in srgb, var(--brand-footer-text) 22%, var(--brand-footer-bg));
  --c-shade: rgba(0, 0, 0, 0.55);

  /* stíny */
  --shadow-header: 0 6px 20px -8px rgba(23, 34, 38, 0.28);
  --shadow-pop: 0 12px 32px rgba(23, 34, 38, 0.2);

  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --t-fast: 0.2s;
  --header-h: 4.5rem;
}

/* ---------- Základ ---------- */

html {
  scroll-padding-top: calc(var(--header-h) + 1rem);
  scrollbar-color: var(--brand-primary) var(--brand-surface);
}

body {
  margin: 0;
  background: var(--brand-bg);
  color: var(--brand-text);
  font-family: var(--brand-font-body);
  font-size: var(--fs-body);
  font-size-adjust: from-font;
  line-height: 1.7;
  accent-color: var(--brand-accent);
  caret-color: var(--brand-accent);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--brand-primary);
  color: var(--brand-on-primary);
}

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--brand-radius);
}

a {
  color: var(--brand-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--t-fast) var(--ease);
}

a:hover {
  color: var(--brand-accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 3px;
}

h1, h2, h3, h4 {
  font-family: var(--brand-font-heading);
  font-weight: var(--brand-heading-weight);
  font-size-adjust: from-font;
  line-height: 1.2;
  color: var(--brand-text);
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p {
  text-wrap: pretty;
}

/* ---------- Hlavička ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  container-type: scroll-state;
  container-name: site-header;
  background: var(--brand-header-bg);
  color: var(--brand-header-text);
  border-bottom: 1px solid var(--c-line);
}

.header__inner {
  padding-block: var(--space-xs);
  transition: padding var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

@supports (container-type: scroll-state) {
  @container site-header scroll-state(stuck: top) {
    .header__inner {
      box-shadow: var(--shadow-header);
    }
  }
}

.header__logo,
.logo {
  color: var(--brand-header-text);
  font-family: var(--brand-font-heading);
  font-weight: var(--brand-heading-weight);
  font-size: 1.375rem;
  line-height: 1.1;
  text-decoration: none;
}

@media (min-width: 768px) {
  .header__logo,
  .logo {
    font-size: 1.625rem;
  }
}

.logo__mark {
  color: var(--brand-primary);
}

.logo__name {
  color: var(--brand-header-text);
}

.logo__tld {
  font-size: 0.7em;
  color: var(--brand-muted);
  white-space: nowrap;
}

.header__toggle {
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-2xs);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--brand-radius);
  background: transparent;
  color: var(--brand-header-text);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.header__toggle svg {
  stroke: currentColor;
  display: block;
}

.header__toggle:hover {
  background: var(--brand-surface);
  border-color: var(--brand-primary);
}

/* menu v hlavičce / liště */

.nav ul,
.tray__inner ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav a {
  color: var(--brand-header-text);
  text-decoration: none;
  font-weight: 500;
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--brand-radius);
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}

.nav a:hover {
  color: var(--brand-primary);
  background: var(--c-primary-soft);
}

/* lišta rubrik pod hlavičkou */

.tray {
  background: var(--brand-bg);
  border-bottom: 1px solid var(--c-line);
}

.tray__inner a {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  color: var(--brand-text);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--brand-radius);
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}

.tray__inner a:hover {
  color: var(--brand-primary);
  background: var(--c-primary-soft);
}

/* mobilní menu */

.smallnav {
  background: var(--brand-bg);
  color: var(--brand-text);
}

.smallnav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.smallnav a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--brand-text);
  font-family: var(--brand-font-heading);
  font-size: 1.25rem;
  text-decoration: none;
  border-bottom: 1px solid var(--c-line);
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}

.smallnav a:hover {
  color: var(--brand-primary);
  background: var(--brand-surface);
}

.smallnav__close {
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-2xs);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--brand-radius);
  background: var(--brand-bg);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}

.smallnav__close svg {
  stroke: var(--brand-text);
  display: block;
}

.smallnav__close:hover {
  border-color: var(--brand-primary);
}

/* ---------- Vyhledávání ---------- */

.search-form form {
  display: flex;
  gap: var(--space-2xs);
}

.search-form input[type="text"] {
  flex: 1;
  min-height: 44px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--brand-radius);
  background: var(--brand-bg);
  color: var(--brand-text);
  font: inherit;
}

.search-form input[type="submit"] {
  min-height: 44px;
  padding: 0 var(--space-md);
  border: 0;
  border-radius: var(--brand-radius);
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease);
}

.search-form input[type="submit"]:hover {
  background: var(--c-primary-hover);
}

/* ---------- Karty článků ---------- */

.article {
  container-type: inline-size;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--c-line);
  padding-bottom: var(--space-md);
}

.article__image {
  margin: 0 0 var(--space-xs);
}

.article__image a {
  display: block;
}

.article__image img {
  display: block;
  width: 100%;
  object-fit: cover;
  border-radius: var(--brand-radius);
}

.article__title {
  margin: 0 0 var(--space-2xs);
  font-size: var(--fs-card);
  line-height: 1.25;
}

.article__title a {
  color: var(--brand-text);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}

.article__title a:hover {
  color: var(--brand-primary);
}

.article__perex {
  margin: 0 0 var(--space-2xs);
  color: var(--brand-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.article__category {
  margin: 0 0 var(--space-2xs);
  font-size: var(--fs-small);
  color: var(--brand-muted);
}

.article__category a {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: var(--brand-radius);
  background: var(--brand-accent);
  color: var(--brand-on-accent);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--t-fast) var(--ease);
}

.article__category a:hover {
  background: color-mix(in srgb, var(--brand-accent) 82%, var(--brand-text));
  color: var(--brand-on-accent);
}

.article__date {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--brand-muted);
  font-variant-numeric: tabular-nums;
}

@container (max-width: 260px) {
  .article__title {
    font-size: 1.05rem;
  }
  .article__perex {
    display: none;
  }
}

/* ---------- Výpisy a rubriky ---------- */

.articles {
  display: grid;
}

h1 {
  margin-block: 0 var(--space-md);
}

.bottom__title {
  margin: 0 0 var(--space-sm);
  padding-bottom: var(--space-2xs);
  border-bottom: 2px solid var(--brand-text);
  font-size: var(--fs-h2);
}

.bottom__title a {
  color: var(--brand-text);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}

.bottom__title a:hover {
  color: var(--brand-primary);
}

.bottom {
  margin-bottom: var(--space-lg);
}

/* horní bloky (pokud se zobrazí) */

.top .article {
  border-bottom: 1px solid var(--c-line);
}

.top-news .article__title {
  font-size: calc(var(--fs-card) * 1.1);
}

/* ---------- Strana článku ---------- */

.text__title {
  margin: 0 0 var(--space-md);
  font-size: var(--fs-h1);
  line-height: 1.12;
  letter-spacing: -0.01em;
}

.text__cover {
  margin: 0 0 var(--space-md);
}

.text__cover img {
  display: block;
  width: 100%;
  object-fit: cover;
  border-radius: var(--brand-radius);
}

.text__body {
  font-size: var(--fs-body);
  line-height: 1.8;
}

.text__body > *:not(table):not(img):not(iframe):not(.table-of-content) {
  max-width: 68ch;
}

.text__body p {
  margin-block: 0 var(--space-sm);
}

.text__body h2 {
  margin: 2em 0 0.7em;
}

.text__body h3 {
  margin: 1.8em 0 0.6em;
}

.text__body a {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}

.text__body a:hover {
  text-decoration-thickness: 2px;
}

.text__body ul,
.text__body ol {
  padding-left: 1.4em;
  margin-block: 0 var(--space-sm);
}

.text__body li {
  margin-bottom: var(--space-2xs);
}

.text__body blockquote {
  margin: var(--space-md) 0;
  padding: var(--space-2xs) var(--space-md);
  border-left: 3px solid var(--brand-primary);
  border-radius: 0;
  font-family: var(--brand-font-heading);
  font-size: 1.15em;
  font-style: italic;
  color: var(--brand-text);
}

.text__body img.author,
.text__body .author {
  float: left;
  width: min(240px, 40%);
  margin: 0 var(--space-md) var(--space-sm) 0;
}

.text__body iframe {
  display: block;
  max-width: 100%;
  margin-block: var(--space-md);
  border-radius: var(--brand-radius);
}

/* tabulky */

.text table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin-block: var(--space-md);
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.5;
}

.text th,
.text td {
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--c-line);
  text-align: left;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

.text table tr:first-child th,
.text table tr:first-child td {
  background: var(--brand-surface);
  font-weight: 700;
}

/* obsah článku */

.table-of-content {
  max-width: 68ch;
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--brand-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--brand-radius);
  font-size: 0.95rem;
  line-height: 1.55;
}

.table-of-content > span {
  display: block;
  margin-bottom: var(--space-2xs);
  font-family: var(--brand-font-heading);
  font-weight: var(--brand-heading-weight);
  font-size: 1.15rem;
}

.table-of-content ul,
.table-of-content ol {
  margin: 0;
  padding-left: 1.2em;
}

.table-of-content a {
  text-decoration: none;
}

.table-of-content a:hover {
  text-decoration: underline;
}

/* informace pod článkem */

.text__info {
  max-width: 68ch;
  margin-top: var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--c-line);
  color: var(--brand-muted);
  font-size: var(--fs-small);
}

.text__info p {
  margin: 0 0 var(--space-3xs);
}

.text__info a {
  color: var(--brand-primary);
}

/* ---------- Stránkování ---------- */

.pagination {
  margin-top: var(--space-lg);
}

.pagination ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  align-items: center;
}

.pagination li {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-2xs);
  color: var(--brand-muted);
}

.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--space-xs);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--brand-radius);
  color: var(--brand-text);
  text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.pagination a:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: var(--c-primary-soft);
}

.pagination__active {
  border-radius: var(--brand-radius);
  background: var(--brand-primary);
  color: var(--brand-on-primary) !important;
  font-weight: 700;
}

/* ---------- Spodní panel a panel (widgety) ---------- */

.prefooter {
  background: var(--brand-surface);
  border-top: 1px solid var(--c-line);
  padding-block: var(--space-lg);
}

.sidebar h3:not(.article__title),
.prefooter h3:not(.article__title) {
  margin: 0 0 var(--space-xs);
  padding-bottom: var(--space-2xs);
  border-bottom: 2px solid var(--brand-text);
  font-size: var(--fs-h3);
}

.sidebar ul,
.prefooter ul {
  list-style: none;
  margin: 0 0 var(--space-md);
  padding: 0;
}

.sidebar li,
.prefooter li {
  border-bottom: 1px solid var(--c-line);
}

.sidebar li a,
.prefooter li a {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 24px;
  padding: var(--space-2xs) 0;
  color: var(--brand-text);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}

.sidebar li a:hover,
.prefooter li a:hover {
  color: var(--brand-primary);
}

.sidebar svg,
.prefooter svg {
  flex: none;
  width: 18px;
  height: 18px;
  stroke: var(--brand-primary);
}

.sidebar .article,
.prefooter .article {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: var(--space-xs);
  align-items: center;
  padding-block: var(--space-xs);
  border-bottom: 1px solid var(--c-line);
}

.sidebar .article__image,
.prefooter .article__image {
  margin: 0;
}

.sidebar .article__title,
.prefooter .article__title {
  margin: 0;
  font-size: 1rem;
}

.promo div,
.promo a {
  line-height: 1.5;
}

.similar {
  min-width: 0;
}

/* ---------- Patička ---------- */

.footer {
  background: var(--brand-footer-bg);
  color: var(--brand-footer-text);
  padding-block: var(--space-lg);
  font-size: var(--fs-small);
  line-height: 1.6;
}

.footer p {
  margin: 0 0 var(--space-2xs);
  color: var(--c-footer-muted);
}

.footer a {
  color: var(--brand-footer-text);
  text-decoration: underline;
}

.footer a:hover {
  color: var(--brand-footer-text);
  text-decoration-thickness: 2px;
}

/* ---------- Popup ---------- */

.popup {
  display: none;
  position: fixed;
  inset: auto var(--space-sm) var(--space-sm) auto;
  z-index: 100;
  max-width: min(420px, calc(100vw - 2rem));
  padding: var(--space-md);
  background: var(--brand-bg);
  color: var(--brand-text);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--brand-radius);
  box-shadow: var(--shadow-pop);
}

.popup #close {
  position: absolute;
  top: var(--space-3xs);
  right: var(--space-3xs);
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--brand-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease);
}

.popup #close:hover {
  color: var(--brand-accent);
}

/* ---------- Pohyb ---------- */

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

/* Template::addOverflowGuard: dlouhé slovo nebo doména v titulku nepřeteče úzký sloupec ani kartu */
:where(body) { overflow-wrap: break-word; }
:where(h1, h2, h3, h4, h5, h6, .article__title, .sidebar a) { overflow-wrap: anywhere; }
