/* ==========================================================================
   Železniční doprava a cesty – moderní redakční vzhled
   Barvy a písma dodává stránka přes --brand-*; zde jen vzhled.
   ========================================================================== */

:root {
  color-scheme: light;

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

  /* odvozené odstíny */
  --c-surface-2: color-mix(in srgb, var(--brand-bg) 55%, var(--brand-surface));
  --c-border-strong: color-mix(in srgb, var(--brand-text) 22%, var(--brand-border));
  --c-primary-hover: color-mix(in srgb, var(--brand-primary) 82%, var(--brand-text));
  --c-accent-hover: color-mix(in srgb, var(--brand-accent) 82%, var(--brand-text));
  --c-header-line: color-mix(in srgb, var(--brand-header-text) 18%, transparent);
  --c-header-hover: color-mix(in srgb, var(--brand-header-text) 10%, transparent);
  --c-footer-line: color-mix(in srgb, var(--brand-footer-text) 20%, transparent);
  --c-photo-shade: color-mix(in srgb, var(--brand-text) 78%, transparent);
  --c-selection: color-mix(in srgb, var(--brand-primary) 28%, var(--brand-surface));

  /* stíny */
  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 14px rgb(23 30 38 / 0.06);
  --shadow-card-hover: 0 2px 4px rgb(0 0 0 / 0.05), 0 10px 26px rgb(23 30 38 / 0.12);
  --shadow-header: 0 6px 18px rgb(0 0 0 / 0.22);
  --shadow-pop: 0 12px 32px rgb(23 30 38 / 0.18);

  /* velikosti písma */
  --fs-h1: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);
  --fs-h2: clamp(1.3rem, 1.05rem + 1vw, 1.8rem);
  --fs-h3: clamp(1.1rem, 1rem + 0.4vw, 1.3rem);
  --fs-card: clamp(1.02rem, 0.97rem + 0.25vw, 1.2rem);
  --fs-body: clamp(1.0625rem, 1.03rem + 0.15vw, 1.1875rem);
  --fs-small: 0.875rem;

  --ease: cubic-bezier(0.25, 0.6, 0.3, 1);
  --header-h: 4.25rem;
}

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

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

body {
  background: var(--brand-bg);
  color: var(--brand-text);
  font-family: var(--brand-font-body);
  font-size: 1rem;
  font-size-adjust: from-font;
  line-height: 1.6;
  caret-color: var(--brand-accent);
  accent-color: var(--brand-accent);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--c-selection);
  color: var(--brand-text);
}

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

h1 { font-size: var(--fs-h1); letter-spacing: -0.015em; }
h2 { font-size: var(--fs-h2); letter-spacing: -0.01em; }
h3 { font-size: var(--fs-h3); }

p { text-wrap: pretty; }

a {
  color: var(--brand-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

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

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

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

/* ---------- Hlavička (tmavá, přilepená) ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--brand-header-bg);
  color: var(--brand-header-text);
  border-bottom: 1px solid var(--c-header-line);
  box-shadow: var(--shadow-header);
}

.header__inner {
  min-height: var(--header-h);
}

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

.header__logo a,
.logo a {
  color: var(--brand-header-text);
  text-decoration: none;
}

.header__logo:hover,
.logo a:hover {
  color: var(--brand-header-text);
}

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

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

.header__toggle {
  background: transparent;
  color: var(--brand-header-text);
  border: 1px solid var(--c-header-line);
  border-radius: var(--brand-radius);
  min-width: 2.75rem;
  min-height: 2.75rem;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.header__toggle svg {
  stroke: var(--brand-header-text);
}

.header__toggle:hover {
  background: var(--c-header-hover);
  border-color: var(--brand-header-text);
}

/* menu v hlavičce (když je rubrikové menu u loga) */
.header .nav a {
  color: var(--brand-header-text);
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--brand-radius);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.header .nav a:hover {
  background: var(--c-header-hover);
  color: var(--brand-header-text);
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

/* ---------- Lišta rubrik pod hlavičkou ---------- */

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

.tray a {
  color: var(--brand-text);
  text-decoration: none;
  font-family: var(--brand-font-heading);
  font-weight: var(--brand-heading-weight);
  font-size: 0.975rem;
  padding: var(--space-sm) var(--space-md);
  transition: color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.tray a:hover {
  color: var(--brand-primary);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.45em;
}

.tray__more-button {
  background: transparent;
  color: var(--brand-text);
  border: 0;
  font: inherit;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}

.tray__more-button:hover {
  color: var(--brand-primary);
}

.tray__dropdown {
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  box-shadow: var(--shadow-pop);
}

.tray__dropdown a {
  color: var(--brand-text);
}

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

/* ---------- Mobilní menu ---------- */

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

.smallnav a {
  color: var(--brand-text);
  text-decoration: none;
  font-family: var(--brand-font-heading);
  font-weight: var(--brand-heading-weight);
  font-size: 1.2rem;
  padding: var(--space-sm) 0;
  display: block;
  border-bottom: 1px solid var(--brand-border);
}

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

.smallnav__close {
  background: transparent;
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  min-width: 2.75rem;
  min-height: 2.75rem;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

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

/* ---------- Hlavní plocha ---------- */

.wrapper,
.main,
.main__inner,
.content,
.top,
.articles {
  background: transparent;
}

.main {
  padding-block: var(--space-xl);
}

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

.article {
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  padding-bottom: var(--space-md);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.article:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-card-hover);
}

.article__image img {
  display: block;
  border-radius: 0;
}

.article__title,
.article__perex,
.article__category,
.article__date {
  margin-inline: var(--space-md);
}

.article__title {
  font-size: var(--fs-card);
  line-height: 1.25;
}

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

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

.article__perex {
  color: var(--brand-muted);
  font-size: 0.95rem;
}

.article__category {
  font-size: var(--fs-small);
}

.article__category a {
  display: inline-block;
  background: var(--brand-accent);
  color: var(--brand-on-accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: var(--brand-radius);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.article__category a:hover {
  background: var(--brand-primary);
  color: var(--brand-on-primary);
}

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

/* ---------- Horní blok (Titulní) ---------- */

.top .article {
  position: relative;
}

.top .article__title {
  font-size: clamp(1.15rem, 1rem + 0.8vw, 1.6rem);
}

.top .article:first-child .article__title {
  font-size: clamp(1.4rem, 1.1rem + 1.4vw, 2.25rem);
}

.top .article__perex {
  color: var(--brand-muted);
}

/* ---------- Sekce se zaoblením a titulky ---------- */

.bottom__title {
  font-size: var(--fs-h2);
  margin-bottom: var(--space-md);
}

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

.bottom__title a:hover {
  color: var(--brand-primary);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.content > h1,
.content > h2 {
  margin-block: var(--space-lg) var(--space-md);
}

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

.pagination a,
.pagination li {
  font-family: var(--brand-font-heading);
  font-variant-numeric: tabular-nums;
}

.pagination a {
  display: inline-block;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: var(--space-xs) var(--space-md);
  background: var(--brand-surface);
  color: var(--brand-text);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  text-decoration: none;
  text-align: center;
  line-height: 1.5;
}

.pagination a:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  box-shadow: var(--shadow-card);
}

.pagination__active {
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  border: 1px solid var(--brand-primary);
  border-radius: var(--brand-radius);
  font-weight: 700;
  padding: var(--space-xs) var(--space-md);
  min-width: 2.5rem;
  min-height: 2.5rem;
  text-align: center;
}

/* ---------- Článek ---------- */

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

.text__title {
  font-size: var(--fs-h1);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-lg);
}

.text__cover img {
  display: block;
  border-radius: var(--brand-radius);
}

.text__body {
  font-size: var(--fs-body);
  line-height: 1.8;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  padding: var(--space-xl) var(--space-lg);
}

.text__body p {
  margin-block: 0 1.15em;
}

.text__body h2 {
  margin-top: 2em;
  margin-bottom: 0.9em;
  font-size: var(--fs-h2);
}

.text__body h3 {
  margin-top: 1.8em;
  margin-bottom: 0.8em;
  font-size: var(--fs-h3);
}

.text__body a {
  color: var(--brand-primary);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}

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

.text__body ul,
.text__body ol {
  padding-left: 1.4em;
  margin-block: 0 1.15em;
}

.text__body li {
  margin-bottom: 0.4em;
}

.text__body img {
  border-radius: var(--brand-radius);
}

.text__body blockquote {
  margin: 1.5em 0;
  padding: var(--space-md) var(--space-lg);
  background: var(--c-surface-2);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  color: var(--brand-text);
  font-style: italic;
}

.text__body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin-block: 1.5em;
  font-size: 0.975rem;
  font-variant-numeric: tabular-nums;
}

.text__body th,
.text__body td {
  text-align: left;
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--brand-border);
  vertical-align: top;
}

.text__body tr:first-child th,
.text__body tr:first-child td {
  background: var(--c-surface-2);
  font-family: var(--brand-font-heading);
  font-weight: var(--brand-heading-weight);
}

.text__body code,
.text__body pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--c-surface-2);
  border-radius: var(--brand-radius);
}

.text__body code {
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}

.text__body pre {
  padding: var(--space-md);
  overflow-x: auto;
  border: 1px solid var(--brand-border);
}

.table-of-content {
  background: var(--c-surface-2);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
  font-size: 0.975rem;
  line-height: 1.5;
}

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

.table-of-content a {
  color: var(--brand-primary);
}

.text__info {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  color: var(--brand-muted);
  font-size: var(--fs-small);
}

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

.text__info a {
  color: var(--brand-primary);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

.text__date {
  font-variant-numeric: tabular-nums;
}

img.author {
  border-radius: var(--brand-radius);
  border: 1px solid var(--brand-border);
}

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

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

.search-form input[type="text"] {
  flex: 1 1 auto;
  min-height: 2.75rem;
  padding: var(--space-xs) var(--space-md);
  background: var(--brand-surface);
  color: var(--brand-text);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--brand-radius);
  font: inherit;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-form input[type="text"]:hover {
  border-color: var(--brand-primary);
}

.search-form input[type="submit"] {
  min-height: 2.75rem;
  padding: var(--space-xs) var(--space-lg);
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  border: 1px solid var(--brand-primary);
  border-radius: var(--brand-radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

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

/* ---------- Pravý panel ---------- */

.sidebar > *:not(.article):not(h3):not(nav):not(ul):not(div[id^="sklik"]) {
  max-width: 100%;
}

.sidebar h3:not(.article__title) {
  font-size: var(--fs-h3);
  margin-block: var(--space-lg) var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--brand-primary);
  color: var(--brand-text);
}

.sidebar h3:not(.article__title):first-child {
  margin-top: 0;
}

.sidebar .article {
  margin-bottom: var(--space-sm);
  padding: var(--space-sm);
  box-shadow: none;
}

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

.sidebar .nav ul,
.sidebar .tags,
.sidebar .promo,
.sidebar .authors {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar .nav a,
.sidebar .authors a {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  color: var(--brand-text);
  text-decoration: none;
  border-radius: var(--brand-radius);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.sidebar .nav a:hover,
.sidebar .authors a:hover {
  background: var(--brand-surface);
  color: var(--brand-primary);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.sidebar .tags a {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  background: var(--brand-surface);
  color: var(--brand-text);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  text-decoration: none;
  font-size: var(--fs-small);
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.sidebar .tags a:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.sidebar .promo li {
  margin-bottom: var(--space-xs);
}

/* ---------- Spodní panel nad patičkou ---------- */

.prefooter {
  background: var(--brand-surface);
  border-top: 1px solid var(--brand-border);
  color: var(--brand-text);
}

.prefooter__inner {
  padding-block: var(--space-xl);
}

.prefooter h3 {
  font-size: var(--fs-h3);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--brand-primary);
}

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

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

.prefooter a {
  color: var(--brand-text);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.prefooter a:hover {
  color: var(--brand-primary);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.prefooter svg {
  width: 1rem;
  height: 1rem;
  flex: none;
  stroke: var(--brand-primary);
}

.prefooter .nav a,
.prefooter .tags a,
.prefooter .authors a,
.prefooter .promo li {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding-block: var(--space-2xs);
}

.prefooter .article {
  box-shadow: none;
  padding: var(--space-sm);
  margin-bottom: var(--space-sm);
}

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

/* ---------- Patička (tmavá) ---------- */

.footer {
  background: var(--brand-footer-bg);
  color: var(--brand-footer-text);
  border-top: 1px solid var(--c-footer-line);
}

.footer__inner {
  padding-block: var(--space-xl);
  font-size: var(--fs-small);
}

.footer p {
  color: var(--brand-footer-text);
  margin-block: var(--space-2xs);
}

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

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

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

.popup {
  background: var(--brand-surface);
  color: var(--brand-text);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  box-shadow: var(--shadow-pop);
}

.popup button {
  background: transparent;
  color: var(--brand-text);
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  min-width: 2.5rem;
  min-height: 2.5rem;
  cursor: pointer;
  border-radius: var(--brand-radius);
  transition: color 0.2s var(--ease);
}

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

/* ---------- Komponenty podle šířky kontejneru ---------- */

.sidebar,
.prefooter__inner,
.bottom__inner,
.top__inner,
.articles {
  container-type: inline-size;
}

@container (max-width: 360px) {
  .article__title,
  .article__perex,
  .article__category,
  .article__date {
    margin-inline: var(--space-sm);
  }
  .article__title { font-size: 1rem; }
}

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