/*--------------------------------------------------------------
# Ukázky z povídek – sdílený vzhled
#
# Používá se na dvou místech a v obou musí vypadat úplně stejně:
#   1) modal na /povidky a /en/short-stories
#   2) samostatné stránky /ukazka/* a /en/excerpt/*
# Typografie ukázky je proto v .ukazka-content a nic ji neduplikuje.
#
# Ukázka se nescrolluje, ale listuje: text teče do sloupců širokých
# přesně jako okno ukázky a listování je posun o jeden sloupec.
# Sazbu tedy dělá prohlížeč sám při každé změně velikosti i na mobilu.
--------------------------------------------------------------*/

/* --- tlačítka u karet povídek --- */
#povidky .ukazka-trigger {
  cursor: pointer;
  transition: color .2s ease;
}

#povidky .ukazka-trigger:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.story-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.2rem;
  border: 1px solid #000;
  background-color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: inherit;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}

.story-links a:hover {
  background-color: #000;
  border-color: #000;
  color: #fff;
}

.story-links a.lnk-forendors:hover {
  background-color: #111;
  border-color: #111;
}

/* --- modal --- */
#ukazka-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#ukazka-modal.open { display: flex; }

/* Výška je pevná: strana ukázky = jedno okno, ne libovolně dlouhý svitek. */
#ukazka-modal .ukazka-dialog {
  background: var(--background-color, #fff);
  color: var(--default-color, #212529);
  width: 100%;
  max-width: 680px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  border: 1px solid #000;
  overflow: hidden;
}

@supports (height: 100dvh) {
  #ukazka-modal .ukazka-dialog { height: 85dvh; }
}

#ukazka-modal .ukazka-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.15rem 3rem;
  border-bottom: 1px solid #cfcfcf;
  flex: 0 0 auto;
}

#ukazka-modal .ukazka-head h3 { margin: 0; font-size: 1.3rem; text-align: center; }

#ukazka-modal .ukazka-close {
  display: block;
  text-decoration: none;
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  opacity: 0.6;
  transition: opacity .2s ease;
}

#ukazka-modal .ukazka-close:hover { opacity: 1; }

#ukazka-modal .ukazka-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1.5rem;
  overflow-y: auto;
}

/* dokud se text stahuje, ať dialog neposkočí z prázdna do plna */
#ukazka-modal .ukazka-body.is-loading { min-height: 8rem; }

#ukazka-modal .ukazka-loading {
  margin: 2.5rem 0;
  text-align: center;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.45;
}

/* --- listování ---
   Třídu .is-paged nasazuje ukazka.js: bez JavaScriptu zůstane ukázka
   normálně scrollovací a lišta se stránkami se vůbec neukáže. */
#ukazka-modal .ukazka-body.is-paged { overflow: hidden; }

.ukazka-body.is-paged .ukazka-pages {
  height: 100%;
  column-fill: auto;
  transition: transform .3s ease;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .ukazka-body.is-paged .ukazka-pages { transition: none; }
}

.ukazka-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex: 0 0 auto;
  padding: 0.65rem 1rem;
  border-top: 1px solid #cfcfcf;
}

.ukazka-pager[hidden] { display: none; }

.ukazka-pager button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid #000;
  background: #fff;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, opacity .2s ease;
}

.ukazka-pager button:hover:not(:disabled) { background: #000; color: #fff; }

.ukazka-pager button:disabled { opacity: 0.25; cursor: default; }

.ukazka-pageno {
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

/* --- typografie ukázky (modal i samostatná stránka) ---
   Písmo je Spectral, tedy totéž, čím povídku sází Substack – ať je
   čtení na webu a na Substacku stejný zážitek. Nikde jinde na webu
   se tenhle font nepoužívá. */
.ukazka-content {
  font-family: "Spectral", Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
}

.ukazka-content p {
  margin-bottom: 1rem;
  text-align: justify;
  text-indent: 1.5em;
  line-height: 1.7;
  orphans: 2;
  widows: 2;
}

.ukazka-content p.dlg {
  position: relative;
  text-indent: 0;
  padding-left: 2em;
}

.ukazka-content p.dlg::before {
  content: "\201C";
  position: absolute;
  left: 0.1em;
  top: 0.15em;
  font-size: 1.7em;
  font-weight: 700;
  line-height: 1;
  opacity: 0.55;
}

.ukazka-content .ukazka-verse {
  margin: 0 0 1rem;
  padding-left: 1.2em;
  border-left: 2px solid rgba(128, 128, 128, 0.3);
  font-style: italic;
  line-height: 1.6;
  opacity: 0.85;
  break-inside: avoid;
}

.ukazka-content p.ukazka-scene {
  text-indent: 0;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
  margin: 2.5rem 0 1.5rem;
  break-after: avoid;
}

.ukazka-content > :first-child { margin-top: 0; }

/* poslední odstavec bez spodní mezery – ta by uměla přetéct do dalšího
   sloupce a udělat před odkazy prázdnou stranu */
.ukazka-content > :last-child { margin-bottom: 0; }

/* předěl scény (--- ve zdrojovém textu) */
.ukazka-content hr.ukazka-break {
  width: 3.5rem;
  margin: 2rem auto;
  border: none;
  border-top: 1px solid rgba(128, 128, 128, 0.45);
  opacity: 1;
}

/* světopisný rámeček (- [i] ve zdrojovém textu) */
.ukazka-content .ukazka-box {
  margin: 1.75rem 0;
  padding: 1.25rem 1.5rem;
  border: 1px solid rgba(128, 128, 128, 0.35);
  background: rgba(128, 128, 128, 0.05);
  font-size: 0.92rem;
}

.ukazka-content .ukazka-box p {
  text-indent: 0;
  margin-bottom: 0.75rem;
  orphans: 2;
  widows: 2;
}

.ukazka-content .ukazka-box p:last-child { margin-bottom: 0; }

/* rámeček se smí zlomit přes dvě strany, ale ne hned pod nadpisem */
.ukazka-content .ukazka-box p.ukazka-box-title {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
  break-after: avoid;
}

/* --- patička ukázky: poslední strana ---
   Odkazy nikde nedrží pod textem, čtenář je najde až na konci ukázky.
   Ve scrollovacím fallbacku (bez JS) prostě uzavírají text. */
.ukazka-foot {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid #cfcfcf;
  font-size: 0.9rem;
}

.ukazka-body.is-paged .ukazka-foot {
  break-before: column;
  -webkit-column-break-before: always;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 0.5rem;
  border-top: none;
}

.ukazka-body.is-paged .ukazka-foot::before {
  content: "";
  width: 3.5rem;
  height: 1px;
  margin: 0 auto 1.75rem;
  background: rgba(128, 128, 128, 0.45);
}

.ukazka-foot-lead {
  margin: 0 0 0.85rem;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.ukazka-foot-opts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.ukazka-foot-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  line-height: 1.5;
  text-align: left;
}

.ukazka-foot-opt i {
  flex-shrink: 0;
  font-size: 1.15rem;
  margin-top: 0.1em;
  opacity: 0.85;
}

.ukazka-foot-link {
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  transition: color .2s ease;
}

.ukazka-foot-opt .ukazka-foot-link:hover { color: #000; }

/*--------------------------------------------------------------
# Stránka ukázky (/ukazka/*, /en/excerpt/*)
#
# Není to jiná stránka: je to rozcestník povídek s modalem, který už
# přišel otevřený ze serveru. Proto tady nejsou žádné vlastní tvary —
# jen zámek rolování, aby se pozadí pod otevřeným náhledem nehýbalo
# i bez JavaScriptu.
--------------------------------------------------------------*/
body.ukazka-open { overflow: hidden; }

@media (max-width: 575px) {
  #ukazka-modal { padding: 0.75rem; }
  #ukazka-modal .ukazka-dialog { height: 100%; }
  #ukazka-modal .ukazka-head { padding: 0.9rem 2.75rem; }
  #ukazka-modal .ukazka-head h3 { font-size: 1.1rem; }
  #ukazka-modal .ukazka-body { padding: 1.15rem 1.1rem; }
  .ukazka-content { font-size: 1rem; }
  .ukazka-pager { padding: 0.5rem 0.75rem; gap: 0.75rem; }
}
