/* ==========================================================================
   Útulek Modřany – redakční vzhled
   Barvy a písma dodává --brand-*; zde jen odvozené hodnoty a vzhled.
   ========================================================================== */

:root {
  color-scheme: light;

  /* mezery */
  --space-3xs: 0.25rem;
  --space-2xs: 0.375rem;
  --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) 60%, var(--brand-surface));
  --c-tint: color-mix(in srgb, var(--brand-primary) 8%, var(--brand-bg));
  --c-tint-strong: color-mix(in srgb, var(--brand-primary) 16%, var(--brand-bg));
  --c-line: var(--brand-border);
  --c-line-strong: color-mix(in srgb, var(--brand-text) 28%, var(--brand-bg));
  --c-primary-dark: color-mix(in srgb, var(--brand-primary) 80%, black);
  --c-link: color-mix(in srgb, var(--brand-primary) 82%, black);
  --c-link-hover: color-mix(in srgb, var(--brand-primary) 60%, black);
  --c-muted-on-footer: 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-header-line: color-mix(in srgb, var(--brand-header-text) 14%, var(--brand-header-bg));
  --c-scrim: rgba(0, 0, 0, 0.55);

  /* stíny */
  --shadow-header: 0 6px 20px rgba(38, 32, 23, 0.1);
  --shadow-popup: 0 12px 40px rgba(38, 32, 23, 0.28);
  --shadow-soft: 0 4px 14px rgba(38, 32, 23, 0.08);

  /* velikosti písma */
  --fs-h1: clamp(1.875rem, 1.4rem + 2vw, 3rem);
  --fs-h2: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --fs-h3: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  --fs-body: clamp(1.0625rem, 1.03rem + 0.15vw, 1.1875rem);
  --fs-small: 0.875rem;
  --fs-tiny: 0.8125rem;

  /* ostatní */
  --measure: 68ch;
  --ease: cubic-bezier(0.25, 0.6, 0.3, 1);
  --header-h: 4.5rem;
}

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

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;
  -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;
  border-radius: var(--brand-radius);
}

a {
  color: var(--c-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease);
}

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

: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;
  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); }
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-header-line);
}

.header__inner {
  padding-block: var(--space-sm);
  transition: padding 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

@supports (container-type: scroll-state) {
  @container site-header scroll-state(stuck: top) {
    .header__inner {
      padding-block: var(--space-2xs);
      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;
  white-space: nowrap;
  color: var(--brand-muted);
}

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

.header__toggle svg {
  stroke: currentColor;
}

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

/* menu v hlavičce (varianta logo) */
.header .nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.header .nav a {
  display: inline-block;
  padding: var(--space-2xs) var(--space-sm);
  color: var(--brand-header-text);
  font-size: var(--fs-small);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--brand-radius);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.header .nav a:hover {
  background: var(--c-tint);
  color: var(--c-primary-dark);
}

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

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

.tray__inner a {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  color: var(--brand-text);
  font-size: var(--fs-small);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

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

/* ---------- Mobilní menu ---------- */
.smallnav {
  background: var(--brand-surface);
  color: var(--brand-text);
}

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

.smallnav a {
  display: block;
  padding: var(--space-md) var(--space-lg);
  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: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.smallnav a:hover {
  background: var(--c-tint);
  color: var(--c-primary-dark);
}

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

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

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

.search-form input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: var(--space-xs) var(--space-md);
  background: var(--brand-surface);
  color: var(--brand-text);
  font: inherit;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--brand-radius);
  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);
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: var(--brand-radius);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

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

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

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

.article__image a {
  display: block;
}

.article__image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--brand-radius);
}

.article__title {
  margin: 0 0 var(--space-2xs);
  font-size: var(--fs-h3);
  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(--c-link);
}

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

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

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

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

.article__date {
  margin: 0;
  color: var(--brand-muted);
  font-size: var(--fs-tiny);
}

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

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

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

/* ---------- Horní blok (pokud se zobrazí) ---------- */
.top .article {
  border-bottom: 0;
}

.top-news .article__title a {
  color: var(--brand-text);
}

/* ---------- Výpis ---------- */
.content > h1,
.articles + .pagination {
  margin-top: var(--space-lg);
}

.content > h2 {
  margin-top: var(--space-xl);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--brand-text);
}

/* ---------- Stránkování ---------- */
.pagination ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pagination a,
.pagination li {
  font-size: var(--fs-small);
}

.pagination a {
  display: inline-block;
  min-width: 2.25rem;
  padding: var(--space-2xs) var(--space-sm);
  color: var(--brand-text);
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--brand-radius);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

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

.pagination__active {
  display: inline-block;
  min-width: 2.25rem;
  padding: var(--space-2xs) var(--space-sm);
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  font-weight: 700;
  text-align: center;
  border-radius: var(--brand-radius);
}

/* ---------- Pravý panel ---------- */
.sidebar h3:not(.article__title) {
  margin: var(--space-lg) 0 var(--space-sm);
  padding-bottom: var(--space-xs);
  font-size: var(--fs-h3);
  border-bottom: 2px solid var(--brand-text);
}

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

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

.sidebar .nav a,
.sidebar .authors a {
  display: block;
  padding: var(--space-2xs) 0;
  color: var(--brand-text);
  font-size: var(--fs-small);
  text-decoration: none;
  border-bottom: 1px solid var(--c-line);
  transition: color 0.2s var(--ease), padding 0.2s var(--ease);
}

.sidebar .nav a:hover,
.sidebar .authors a:hover {
  color: var(--c-link);
}

.sidebar .tags a {
  display: inline-block;
  margin: 0 var(--space-3xs) var(--space-3xs) 0;
  padding: var(--space-3xs) var(--space-sm);
  background: var(--brand-surface);
  color: var(--brand-text);
  font-size: var(--fs-tiny);
  text-decoration: none;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--brand-radius);
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

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

.sidebar .tags li {
  display: inline;
}

.sidebar .promo li {
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--c-line);
  font-size: var(--fs-small);
}

.sidebar .article {
  padding-block: var(--space-sm);
}

.sidebar .article__title {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.35;
}

/* ---------- Spodní panel (sloupce odkazů) ---------- */
.prefooter {
  background: var(--brand-surface);
  border-top: 1px solid var(--c-line);
  padding-block: var(--space-xl);
}

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

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

.prefooter .nav a,
.prefooter .tags a,
.prefooter .authors a {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) 0;
  color: var(--brand-text);
  font-size: var(--fs-small);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.prefooter .nav a:hover,
.prefooter .tags a:hover,
.prefooter .authors a:hover {
  color: var(--c-link);
}

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

.prefooter .promo li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2xs);
  padding: var(--space-2xs) 0;
  font-size: var(--fs-small);
}

.prefooter .article {
  padding-block: var(--space-xs);
}

.prefooter .article__title {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.35;
}

/* ---------- Detail článku ---------- */
.text__title {
  margin: 0 0 var(--space-md);
  font-size: var(--fs-h1);
  line-height: 1.12;
}

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

.text__cover img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--brand-radius);
}

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

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

.text__body h2 {
  margin: 2em 0 0.7em;
  font-size: var(--fs-h2);
  line-height: 1.2;
}

.text__body h3 {
  margin: 1.8em 0 0.6em;
  font-size: var(--fs-h3);
}

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

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

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

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

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

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

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

/* tabulky v článku */
.text__body table {
  display: block;
  max-width: 100%;
  margin: 1.5em 0;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: var(--fs-small);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.text__body th,
.text__body td {
  min-width: 7rem;
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--c-line-strong);
}

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

.text__body tbody tr:nth-child(even) td {
  background: var(--c-surface-2);
}

/* obsah článku */
.table-of-content {
  margin: 0 0 var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--brand-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--brand-radius);
}

.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: var(--fs-h3);
}

.table-of-content ul,
.table-of-content ol {
  margin: 0;
  padding-left: 1.2em;
  font-size: var(--fs-small);
}

/* informace pod článkem */
.text__info {
  max-width: var(--measure);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  color: var(--brand-muted);
  font-size: var(--fs-small);
  border-top: 1px solid var(--c-line);
}

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

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

/* autor */
.text__body img.author {
  float: left;
  width: 9rem;
  height: 9rem;
  margin: 0 var(--space-lg) var(--space-md) 0;
  object-fit: cover;
  border-radius: var(--brand-radius);
}

/* ---------- Ukazatel čtení (jen CSS) ---------- */
.reading-progress {
  display: none;
}

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .reading-progress {
      display: block;
      position: fixed;
      top: 0;
      left: 0;
      z-index: 60;
      width: 100%;
      height: 4px;
      background: var(--brand-accent);
      transform-origin: left center;
      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); }
}

/* ---------- Patička ---------- */
.footer {
  background: var(--brand-footer-bg);
  color: var(--brand-footer-text);
  padding-block: var(--space-xl);
  font-size: var(--fs-small);
}

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

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

.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(--c-line);
  border-radius: var(--brand-radius);
  box-shadow: var(--shadow-popup);
}

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

.popup #close:hover {
  background: var(--c-tint);
}

/* ---------- Komponenty podle šířky kontejneru ---------- */
@container (max-width: 15rem) {
  .article__title {
    font-size: var(--fs-small);
  }
  .article__perex {
    display: none;
  }
}

@container (min-width: 22rem) {
  .article__title {
    font-size: var(--fs-h2);
  }
}

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