/* =========================================================
   Útulek Modřany – redakční vzhled
   Barvy a písma dodává kód přes --brand-*, zde jen odvozeniny.
   ========================================================= */

: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.5rem;
  --space-2xl: 4rem;

  /* velikosti písma */
  --fs-h1: clamp(1.875rem, 1.4rem + 2vw, 3rem);
  --fs-h2: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  --fs-h3: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --fs-card: clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem);
  --fs-body: 1.0625rem;
  --fs-small: 0.875rem;

  /* odvozené odstíny */
  --c-surface-2: color-mix(in srgb, var(--brand-bg) 60%, var(--brand-surface));
  --c-bg-deep: color-mix(in srgb, var(--brand-bg) 88%, var(--brand-text));
  --c-line: var(--brand-border);
  --c-line-strong: color-mix(in srgb, var(--brand-border) 70%, var(--brand-text));
  --c-primary-hover: color-mix(in srgb, var(--brand-primary) 82%, var(--brand-text));
  --c-primary-soft: color-mix(in srgb, var(--brand-primary) 10%, var(--brand-bg));
  --c-accent-hover: color-mix(in srgb, var(--brand-accent) 80%, var(--brand-text));
  --c-link-hover: color-mix(in srgb, var(--brand-primary) 75%, var(--brand-text));
  --c-header-line: color-mix(in srgb, var(--brand-header-text) 22%, transparent);
  --c-footer-line: color-mix(in srgb, var(--brand-footer-text) 25%, transparent);

  /* stíny */
  --shadow-soft: 0 6px 18px rgba(38, 32, 23, 0.1);
  --shadow-header: 0 4px 16px rgba(0, 0, 0, 0.18);
  --shadow-popup: 0 18px 48px rgba(0, 0, 0, 0.28);

  --ease: 0.2s ease;
}

html {
  scroll-padding-top: 6rem;
  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: var(--fs-body);
  line-height: 1.7;
  font-size-adjust: from-font;
  -webkit-font-smoothing: antialiased;
  accent-color: var(--brand-accent);
  caret-color: var(--brand-accent);
}

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

img {
  max-width: 100%;
  height: auto;
}

/* ---------- Nadpisy ---------- */
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); }
h2 { font-size: var(--fs-h2); }
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 var(--ease), text-decoration-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}

a:hover {
  color: var(--c-link-hover);
}

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

/* ---------- Hlavička (přilepená) ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--brand-header-bg);
  color: var(--brand-header-text);
  box-shadow: var(--shadow-header);
}

.header__inner {
  padding-top: var(--space-md);
  padding-bottom: var(--space-md);
}

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

.logo__name {
  font-family: var(--brand-font-heading);
}

.header .logo:hover,
.header .header__logo:hover {
  color: var(--brand-header-text);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

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

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

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

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

.header .nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

/* ---------- Lišta rubrik ---------- */
.tray {
  background: var(--brand-surface);
  border-bottom: 1px solid var(--c-line);
}

.tray a {
  color: var(--brand-text);
  text-decoration: none;
  font-size: var(--fs-small);
  font-weight: 600;
  padding: var(--space-sm) var(--space-md);
  display: inline-block;
}

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

.tray__more-button {
  background: transparent;
  color: var(--brand-text);
  border: 0;
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
}

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

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

/* ---------- 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-size: 1.375rem;
  display: block;
  padding: var(--space-sm) var(--space-md);
}

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

.smallnav__close {
  background: transparent;
  border: 0;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--brand-radius);
}

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

.smallnav__close:hover {
  background: var(--c-bg-deep);
}

/* ---------- Hledání ---------- */
.search-form form {
  display: flex;
  gap: var(--space-xs);
}

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

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

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

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

/* ---------- Karty článků (bez rámečku, oddělené linkou) ---------- */
.article {
  background: transparent;
  border-bottom: 1px solid var(--c-line);
  padding-bottom: var(--space-md);
}

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

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

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

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

.article__perex {
  color: var(--brand-muted);
  font-size: 0.9688rem;
  line-height: 1.6;
}

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

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

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

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

/* ---------- Horní bloky ---------- */
.top .article__title a {
  color: var(--brand-text);
}

/* ---------- Rubriky na úvodní stránce ---------- */
.bottom__title {
  font-size: var(--fs-h2);
  border-bottom: 2px solid var(--brand-primary);
  padding-bottom: var(--space-xs);
}

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

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

/* ---------- Text článku ---------- */
.text {
  background: transparent;
}

.text__title {
  font-size: var(--fs-h1);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

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

.text__body {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--brand-text);
}

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

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

.text__body h2 {
  margin-top: 2.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 ul,
.text__body ol {
  padding-left: 1.5em;
}

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

.text__body li::marker {
  color: var(--brand-primary);
}

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

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

.text__body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  background: var(--brand-surface);
  font-size: 0.9688rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

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

.text__body thead th,
.text__body tr:first-child th {
  background: var(--c-primary-soft);
  color: var(--brand-text);
  font-weight: 700;
}

.text__body table tr:first-child td {
  background: var(--c-primary-soft);
  font-weight: 700;
}

.text__body thead + tbody tr:first-child td {
  background: transparent;
  font-weight: inherit;
}

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

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

.table-of-content a {
  color: var(--brand-text);
  text-decoration: none;
}

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

.text__info {
  border-top: 1px solid var(--c-line);
  color: var(--brand-muted);
  font-size: var(--fs-small);
}

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

.text__info a:hover {
  color: var(--c-link-hover);
  text-decoration: underline;
}

.text .author {
  border-radius: var(--brand-radius);
}

/* ---------- Ukazatel č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(--brand-accent);
      transform-origin: 0 50%;
      transform: scaleX(0);
      animation: reading-progress-grow linear both;
      animation-timeline: scroll(root);
    }
  }
}

@keyframes reading-progress-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---------- Stránkování ---------- */
.pagination a,
.pagination li {
  font-variant-numeric: tabular-nums;
}

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

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

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

/* ---------- Pravý panel a spodní panel ---------- */
.sidebar h3:not(.article__title) {
  font-size: 1.25rem;
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-md);
  border-bottom: 2px solid var(--brand-primary);
}

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

.sidebar > div,
.sidebar .nav,
.sidebar .tags,
.sidebar .promo,
.sidebar .authors {
  background: transparent;
}

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

.sidebar .nav a,
.sidebar .authors a,
.sidebar .promo a {
  color: var(--brand-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--c-line);
}

.sidebar .nav a:hover,
.sidebar .authors a:hover,
.sidebar .promo a:hover {
  color: var(--brand-primary);
}

.sidebar svg {
  flex: none;
  stroke: currentColor;
  width: 18px;
  height: 18px;
}

.sidebar .tags li {
  display: inline-block;
  margin: 0 var(--space-2xs) var(--space-2xs) 0;
}

.sidebar .tags a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  background: var(--brand-surface);
  color: var(--brand-text);
  border: 1px solid var(--c-line);
  border-radius: var(--brand-radius);
  padding: 0.25rem 0.75rem;
  text-decoration: none;
  font-size: var(--fs-small);
  transition: color var(--ease), border-color var(--ease);
}

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

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

.sidebar .article__title {
  font-size: 1rem;
  line-height: 1.3;
}

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

.prefooter .nav a {
  text-decoration: none;
}

/* ---------- Patička ---------- */
.footer {
  background: var(--brand-footer-bg);
  color: var(--brand-footer-text);
  font-size: var(--fs-small);
  line-height: 1.6;
}

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

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

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

/* ---------- Popup ---------- */
.popup {
  background: var(--brand-surface);
  color: var(--brand-text);
  border-radius: var(--brand-radius);
  box-shadow: var(--shadow-popup);
}

.popup #close,
.popup button {
  background: transparent;
  color: var(--brand-text);
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  border-radius: var(--brand-radius);
}

.popup #close:hover {
  color: var(--brand-primary);
  background: var(--c-bg-deep);
}

/* ---------- Kontejnerové dotazy pro karty ---------- */
.sidebar,
.content {
  container-type: inline-size;
}

@container (max-width: 360px) {
  .article__title {
    font-size: 1.0625rem;
  }
}

/* ---------- Pohyb ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !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; }
