/* ==========================================================
   OSS magazín – "terminal editorial"
   Tmavý inkoustový slate, zelený "terminálový" akcent,
   jantarový doplněk. Rám webu je výrazný, text článku klidný.
   ========================================================== */

:root {
  color-scheme: dark;

  /* Barvy */
  --color-bg: #0f1612;
  --color-bg-alt: #151f19;
  --color-surface: #1a261f;
  --color-surface-2: #22322a;
  --color-border: #2f4538;
  --color-text: #e8efe9;
  --color-text-soft: #a9bcb0;
  --color-primary: #3ddc84;
  --color-primary-dark: #2bb668;
  --color-primary-ink: #07210f;
  --color-accent: #ffb547;
  --color-accent-ink: #2a1a00;
  --color-link: #7ff0b0;
  --color-overlay: rgba(6, 12, 8, 0.82);
  --color-header-bg: rgba(15, 22, 18, 0.92);
  --color-selection: #3ddc84;
  --color-progress: #ffb547;

  /* Typografie */
  --font-heading: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-ui: "Space Grotesk", system-ui, sans-serif;
  --fs-base: 1.0625rem;
  --fs-small: 0.875rem;
  --fs-xs: 0.8125rem;
  --fs-h1: clamp(1.9rem, 1.2rem + 3vw, 3.25rem);
  --fs-h2: clamp(1.45rem, 1.1rem + 1.4vw, 2.1rem);
  --fs-h3: clamp(1.2rem, 1rem + 0.7vw, 1.5rem);
  --fs-card: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  --lh-body: 1.78;
  --lh-heading: 1.18;

  /* Mezery */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4.5rem;

  /* Tvary */
  --radius-sm: 4px;
  --radius-md: 10px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --border-width: 1.5px;

  /* Stíny */
  --shadow-card: 0 6px 18px rgba(0, 0, 0, 0.28);
  --shadow-card-hover: 0 16px 34px rgba(0, 0, 0, 0.42);
  --shadow-header: 0 10px 24px rgba(0, 0, 0, 0.35);
  --shadow-popup: 0 24px 60px rgba(0, 0, 0, 0.6);

  /* Gradienty */
  --gradient-hero: linear-gradient(135deg, #123222 0%, #0f1612 55%, #1d2a12 100%);
  --gradient-cover: linear-gradient(180deg, rgba(6, 12, 8, 0) 40%, rgba(6, 12, 8, 0.85) 100%);
  --gradient-accent: linear-gradient(120deg, #3ddc84, #ffb547);
  --gradient-glow: radial-gradient(60% 80% at 85% 0%, rgba(61, 220, 132, 0.18), rgba(61, 220, 132, 0) 70%);

  /* Animace */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --duration-fast: 0.18s;
  --duration-base: 0.28s;

  /* Layout */
  --container: 1240px;
  --reading-width: 68ch;
  --header-height: 68px;
  --gutter: 1.25rem;
}

/* ---------- Reset a základ ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-padding-top: calc(var(--header-height) + 1rem);
  scrollbar-color: var(--color-primary-dark) var(--color-bg-alt);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  background-image: var(--gradient-glow);
  background-repeat: no-repeat;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-size-adjust: from-font;
  line-height: var(--lh-body);
  accent-color: var(--color-primary);
  caret-color: var(--color-primary);
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; display: block; }
ul { margin: 0; padding: 0; list-style: none; }
p { margin: 0 0 var(--space-md); }

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-size-adjust: from-font;
  font-weight: 700;
  line-height: var(--lh-heading);
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0 0 var(--space-sm);
  color: var(--color-text);
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

a {
  color: var(--color-link);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), box-shadow var(--duration-base) var(--ease);
}
a:hover { color: var(--color-accent); }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- Wrapper ---------- */
.wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.wrapper > .main { flex: 1 0 auto; }

/* ---------- Hlavička (sticky) ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-header-bg);
  backdrop-filter: blur(10px);
  border-bottom: var(--border-width) solid var(--color-border);
  container-type: scroll-state;
  container-name: site-header;
}

.header__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-sm) var(--gutter);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  transition: padding var(--duration-base) var(--ease), box-shadow var(--duration-base) var(--ease);
}

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

.header__logo {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}
.header__logo a {
  display: inline-flex;
  align-items: center;
  color: var(--color-primary);
}
.header__logo a::before {
  content: "";
}
.header__logo a:hover { color: var(--color-accent); }
.header__logo img { width: 160px; height: auto; max-height: 48px; object-fit: contain; }

.header__toggle {
  display: none;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-primary);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.header__toggle svg { stroke: currentColor; }
.header__toggle:hover { background: var(--color-surface-2); border-color: var(--color-primary); }

/* ---------- Navigace v hlavičce ---------- */
.header .nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  justify-content: flex-end;
}
.header .nav a {
  display: inline-block;
  min-height: 36px;
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--color-text);
  border-radius: var(--radius-pill);
  border: var(--border-width) solid transparent;
}
.header .nav a:hover {
  color: var(--color-primary-ink);
  background: var(--color-primary);
}

/* Tray menu */
.tray {
  background: var(--color-bg-alt);
  border-bottom: var(--border-width) solid var(--color-border);
}
.tray__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-xs) var(--gutter);
  overflow-x: auto;
}
.tray ul { display: flex; gap: var(--space-xs); white-space: nowrap; }
.tray a {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  min-height: 32px;
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  color: var(--color-text-soft);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
}
.tray a:hover { color: var(--color-primary-ink); background: var(--color-accent); border-color: var(--color-accent); }

/* ---------- Mobilní menu (pouze display) ---------- */
.smallnav {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--color-overlay);
  backdrop-filter: blur(6px);
  padding: var(--space-xl) var(--gutter);
  overflow-y: auto;
}
.smallnav__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.smallnav__close svg { stroke: var(--color-primary-ink); }
.smallnav ul { display: grid; gap: var(--space-xs); margin-top: var(--space-xl); }
.smallnav a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
}
.smallnav a:hover { background: var(--color-primary); color: var(--color-primary-ink); }

/* ---------- Top sekce (hero) ---------- */
.top {
  background: var(--gradient-hero);
  border-bottom: var(--border-width) solid var(--color-border);
  padding: var(--space-lg) 0;
}
.top__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  gap: var(--space-md);
  grid-template-columns: 1fr;
}
.top-news { padding-block: var(--space-xl); }

.top .article {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* ---------- Karty článků ---------- */
.article {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform var(--duration-base) var(--ease), box-shadow var(--duration-base) var(--ease), border-color var(--duration-base) var(--ease);
  container-type: inline-size;
}
.article:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--color-primary);
}

.article__image { margin: 0; }
.article__image a { display: block; overflow: hidden; }
.article__image img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--color-surface-2);
  transition: transform var(--duration-base) var(--ease);
}
.article:hover .article__image img { transform: scale(1.04); }

.article__title {
  margin: var(--space-md) var(--space-md) var(--space-xs);
  font-size: var(--fs-card);
  line-height: 1.25;
}
.article__title a { color: var(--color-text); }
.article__title a:hover { color: var(--color-primary); }

.article__perex {
  margin: 0 var(--space-md) var(--space-sm);
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--color-text-soft);
}

.article__category,
.article__date {
  margin: 0 var(--space-md) var(--space-xs);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--color-text-soft);
}
.article__category a {
  display: inline-block;
  padding: 2px var(--space-xs);
  color: var(--color-primary-ink);
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.article__category a:hover { background: var(--color-accent); color: var(--color-accent-ink); }
.article__date { margin-bottom: var(--space-md); }
.article__category:last-child { margin-bottom: var(--space-md); }

/* ---------- Layout main ---------- */
.main { padding: var(--space-lg) 0 var(--space-2xl); }
.main__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  gap: var(--space-xl);
  grid-template-columns: minmax(0, 1fr);
}
.content { min-width: 0; }

.page-title,
.section-title {
  position: relative;
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  margin: 0 0 var(--space-lg);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border-radius: var(--radius-md);
  transform: rotate(-1deg);
}

/* Výpis článků */
.articles {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: 1fr;
}

/* Spodní bloky */
.bottom { margin-bottom: var(--space-xl); }
.bottom__title {
  display: inline-block;
  margin: 0 0 var(--space-md);
  padding: var(--space-2xs) var(--space-md);
  background: var(--color-primary);
  border-radius: var(--radius-pill);
}
.bottom__title a { color: var(--color-primary-ink); }
.bottom__title a:hover { color: var(--color-accent-ink); }
.bottom__inner {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: 1fr;
}

/* ---------- Vyhledávání ---------- */
.search-form {
  grid-column: 1 / -1;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}
.search-form form { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.search-form input[type="text"] {
  flex: 1 1 220px;
  min-height: 44px;
  padding: var(--space-xs) var(--space-md);
  font: inherit;
  font-family: var(--font-ui);
  color: var(--color-text);
  background: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
}
.search-form input[type="text"]::placeholder { color: var(--color-text-soft); }
.search-form input[type="submit"] {
  min-height: 44px;
  padding: var(--space-xs) var(--space-lg);
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--color-primary-ink);
  background: var(--color-primary);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.search-form input[type="submit"]:hover { background: var(--color-accent); transform: translateY(-2px); }

/* ---------- Článek (klidný čtecí sloupec) ---------- */
.text { max-width: 100%; }

.text__title {
  max-width: 24ch;
  margin: 0 0 var(--space-md);
  font-size: var(--fs-h1);
  letter-spacing: -0.03em;
}

.text__cover { margin: 0 0 var(--space-lg); }
.text__cover img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-2);
}

.text__body {
  max-width: var(--reading-width);
  font-size: 1.1rem;
  line-height: var(--lh-body);
  color: var(--color-text);
}
.text__body p { text-wrap: pretty; }
.text__body h2 { margin-top: 2.4em; margin-bottom: 0.9em; }
.text__body h3 { margin-top: 2em; margin-bottom: 0.8em; }
.text__body h4 { margin-top: 1.8em; margin-bottom: 0.7em; }

.text__body a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}
.text__body a:hover { color: var(--color-accent); text-decoration-thickness: 2.5px; }

.text__body ul,
.text__body ol { margin: 0 0 var(--space-md); padding-left: 1.5rem; }
.text__body ul { list-style: disc; }
.text__body ol { list-style: decimal; }
.text__body li { margin-bottom: var(--space-xs); }

.text__body img {
  border-radius: var(--radius-md);
  margin: var(--space-md) 0;
}

.text__body blockquote {
  margin: var(--space-lg) 0;
  padding: var(--space-xs) 0 var(--space-xs) var(--space-md);
  border-left: 3px solid var(--color-primary);
  font-style: italic;
  color: var(--color-text-soft);
}

.text__body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding: 0.1em 0.4em;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
}
.text__body pre {
  overflow-x: auto;
  padding: var(--space-md);
  background: var(--color-bg-alt);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
}
.text__body pre code { padding: 0; background: none; }

/* Tabulky – text vlevo, na úzkém displeji posuvné */
.text table,
.text__body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: var(--space-lg) 0;
  font-size: var(--fs-small);
  font-variant-numeric: tabular-nums;
}
.text table th,
.text table td {
  min-width: 8rem;
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--color-border);
}
.text table thead th,
.text table tr:first-child th,
.text table tr:first-child td {
  background: var(--color-surface-2);
  font-family: var(--font-ui);
  font-weight: 700;
}
.text table tbody tr:nth-child(even) td { background: var(--color-bg-alt); }

/* Obsah článku */
.table-of-content {
  margin: 0 0 var(--space-lg);
  padding: var(--space-md);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--fs-small);
}
.table-of-content > span {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-primary);
}
.table-of-content ul,
.table-of-content ol { padding-left: 1.2rem; margin: 0; }
.table-of-content ul { list-style: disc; }
.table-of-content ol { list-style: decimal; }
.table-of-content li { margin-bottom: var(--space-2xs); }

/* Informace pod článkem */
.text__info {
  max-width: var(--reading-width);
  margin-top: var(--space-xl);
  padding: var(--space-md);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  color: var(--color-text-soft);
}
.text__info p { margin: 0 0 var(--space-xs); }
.text__info p:last-child { margin-bottom: 0; }

/* Stránka autora */
.text--author .text__body { display: block; }
.text--author .author,
.text__body img.author {
  float: left;
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-pill);
  border: 3px solid var(--color-primary);
  margin: 0 var(--space-md) var(--space-sm) 0;
}

/* ---------- Ukazatel průběhu čtení ---------- */
.reading-progress { display: none; }

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .reading-progress {
      display: block;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: 4px;
      z-index: 60;
      background: var(--color-progress);
      transform-origin: left center;
      transform: scaleX(0);
      animation: reading-progress linear both;
      animation-timeline: scroll(root);
    }
    @keyframes reading-progress {
      from { transform: scaleX(0); }
      to { transform: scaleX(1); }
    }
  }
}

/* ---------- Sidebar ---------- */
.sidebar {
  container-type: inline-size;
  align-self: start;
  padding: var(--space-md);
  background: var(--color-bg-alt);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
}
.sidebar h3 {
  margin: var(--space-lg) 0 var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--color-primary);
  font-size: 1.15rem;
}
.sidebar > h3:first-child { margin-top: 0; }

.sidebar .nav ul,
.sidebar .authors,
.sidebar .promo { display: grid; gap: var(--space-2xs); }
.sidebar .nav a,
.sidebar .authors a {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 36px;
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  color: var(--color-text);
  background: var(--color-surface);
  border-radius: var(--radius-md);
}
.sidebar .nav a:hover,
.sidebar .authors a:hover { background: var(--color-primary); color: var(--color-primary-ink); }

.sidebar .article {
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  padding: var(--space-xs);
  border-radius: var(--radius-md);
  box-shadow: none;
}
.sidebar .article__image { flex: 0 0 96px; }
.sidebar .article__image img { width: 96px; height: 72px; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); }
.sidebar .article:hover { transform: none; }
.sidebar .article__title {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.3;
}

.tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.tags a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 32px;
  padding: var(--space-2xs) var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--color-text);
  background: var(--color-surface-2);
  border: var(--border-width) dashed var(--color-border);
  border-radius: var(--radius-pill);
}
.tags a svg { width: 14px; height: 14px; }
.tags a:hover { background: var(--color-accent); color: var(--color-accent-ink); border-color: var(--color-accent); }

.promo li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--fs-small);
  background: var(--color-surface);
  border-radius: var(--radius-md);
}

.nav svg, .authors svg, .tags svg, .promo svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

/* ---------- Prefooter ---------- */
.prefooter {
  background: var(--color-bg-alt);
  border-top: var(--border-width) solid var(--color-border);
  padding: var(--space-xl) 0;
}
.prefooter__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: 1fr;
  background: transparent;
  border: 0;
}

/* ---------- Stránkování ---------- */
.pagination { margin-top: var(--space-xl); }
.pagination ul { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; }
.pagination li {
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  color: var(--color-text-soft);
}
.pagination a,
.pagination__active {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
}
.pagination a { color: var(--color-text); background: var(--color-surface); }
.pagination a:hover { background: var(--color-primary); color: var(--color-primary-ink); border-color: var(--color-primary); }
.pagination__active {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border-color: var(--color-accent);
  font-weight: 700;
}

/* ---------- Patička ---------- */
.footer {
  background: var(--color-bg);
  border-top: 3px solid var(--color-primary);
  padding: var(--space-lg) 0;
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  color: var(--color-text-soft);
}
.footer__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.footer p { margin: 0 0 var(--space-xs); }

/* ---------- Popup ---------- */
.popup {
  display: none;
  position: fixed;
  right: var(--space-md);
  bottom: var(--space-md);
  z-index: 120;
  max-width: min(420px, calc(100vw - 2rem));
  padding: var(--space-lg) var(--space-md) var(--space-md);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popup);
}
.popup #close {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  min-width: 36px;
  min-height: 36px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.popup #close:hover { background: var(--color-accent); color: var(--color-accent-ink); }

/* ---------- Komponenty podle šířky kontejneru ---------- */
@container (min-width: 520px) {
  .article__title { font-size: 1.5rem; }
}

/* ---------- Tablet ---------- */
@media (min-width: 768px) {
  :root { --gutter: 2rem; --header-height: 76px; }

  .top__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .articles,
  .bottom__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prefooter__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .top-news .top__inner .article:first-child { grid-column: 1 / -1; }
  .top-news .top__inner .article:first-child .article__title { font-size: var(--fs-h2); }
}

@media (max-width: 767px) {
  .header__toggle { display: flex; }
  .header .nav { display: none; }
  .text__title { max-width: none; }
  .text--author .author,
  .text__body img.author { float: none; margin: 0 0 var(--space-md); }
}

/* ---------- Desktop ---------- */
@media (min-width: 1100px) {
  .main__inner { grid-template-columns: minmax(0, 1fr) 320px; }
  .main__inner .search-form { grid-column: 1 / -1; }

  .sidebar { position: sticky; top: calc(var(--header-height) + var(--space-md)); }

  .top__inner { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .top-news .top__inner .article:first-child { grid-column: span 2; }

  .articles,
  .bottom__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prefooter__inner { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* Asymetrický rytmus ve výpisu: každá šestá karta přes celou šířku */
  .articles .article:nth-child(6n + 1) { grid-column: 1 / -1; }
  .articles .article:nth-child(6n + 1) .article__image img { aspect-ratio: 21 / 9; }
}

/* ---------- Omezený pohyb ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .article:hover,
  .article:hover .article__image img { transform: none; }
}

/* 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; }
