/* ===========================================================
   Nepravidelník — čistý, literární design v sépiovém duchu.
   =========================================================== */

:root {
  /* Dark (default) */
  --bg: #141008;
  --paper: #1c160e;
  --ink: #ecdfbf;
  --ink-soft: #c9b894;
  --muted: #a69475;
  --accent: #d8a866;
  --rule: #3a2e1b;
  --banner-bg: rgba(20, 16, 8, 0.85);
  --banner-border: rgba(236, 223, 191, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);

  --font-display: "Cormorant Garamond", "Georgia", serif;
  --font-body: "EB Garamond", "Georgia", serif;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --measure: 34rem;
  --banner-h: 60px;
  --banner-h-compact: 40px;
}

[data-theme="light"] {
  --bg: #ffffff;
  --paper: #faf7f0;
  --ink: #111111;
  --ink-soft: #333333;
  --muted: #6b6b6b;
  --accent: #8a5a2c;
  --rule: #d9cdb4;
  --banner-bg: rgba(255, 255, 255, 0.88);
  --banner-border: rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--banner-h) + 8px);
  -webkit-text-size-adjust: 100%;

  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.65;
  font-feature-settings: "liga", "kern", "onum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

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

/* ---------- Banner ---------- */

.banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--banner-h);
  padding: 0 clamp(16px, 4vw, 28px);
  display: flex;
  align-items: center;
  gap: 16px;

  font-family: var(--font-ui);
  font-size: 0.875rem;
  letter-spacing: 0.01em;

  background: var(--banner-bg);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--banner-border);
  z-index: 50;

  transition: height 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.banner.is-compact {
  height: var(--banner-h-compact);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  transition: font-size 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.banner.is-compact .brand-name { font-size: 0.85rem; }

.theme-toggle {
  margin-left: auto;
  margin-right: 0;
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 180ms ease, opacity 180ms ease;
}

.theme-toggle:hover { color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-toggle .icon {
  width: 18px;
  height: 18px;
  display: block;
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }

[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }

.autor {
  text-decoration: none;
  color: var(--muted);
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  transition: color 200ms ease;
  white-space: nowrap;
  line-height: 1;
  font-family: var(--font-display);
}

.autor:hover { color: var(--accent); }

.autor-label {
  color: var(--muted);
  /* Reveal quickly — appears as soon as banner starts expanding. */
  transition: opacity 80ms ease 0ms, max-width 140ms ease 0ms, margin-right 140ms ease 0ms;
  display: inline-block;
  max-width: 4em;
  overflow: hidden;
  font-family: var(--font-display);
  font-style: italic;
}

.banner.is-compact .autor-label {
  opacity: 0;
  max-width: 0;
  margin-right: -6px;
  /* Graceful fade-out when collapsing. */
  transition: opacity 240ms ease, max-width 260ms ease, margin-right 260ms ease;
}

.autor-name {
  color: var(--ink);
  font-weight: 600;
  font-size: 1.2rem;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
  transition: font-size 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.banner.is-compact .autor-name { font-size: 0.85rem; }

@media (max-width: 420px) {
  .autor-label { display: none; }
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  min-height: clamp(460px, 78vh, 720px);
  padding: calc(var(--banner-h) + 48px) 24px 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  isolation: isolate;
}

.hero-art {
  position: absolute;
  inset: 0;
  background-image: url("assets/image.png");
  background-size: cover;
  background-position: center 30%;
  z-index: -2;
  filter: saturate(85%) contrast(102%);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 85% 65% at 50% 55%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 75%),
    linear-gradient(180deg, rgba(20,16,8,0.35) 0%, rgba(20,16,8,0.3) 80%, var(--bg) 100%);
}

[data-theme="light"] .hero::before {
  background:
    radial-gradient(ellipse 85% 65% at 50% 55%, rgba(20,16,8,0.05) 0%, rgba(20,16,8,0.35) 75%),
    linear-gradient(180deg, rgba(20,16,8,0.2) 0%, rgba(20,16,8,0.2) 100%);
}

.hero-inner {
  position: relative;
  color: #f5e9cb;
  text-shadow: 0 2px 24px rgba(0,0,0,0.55);
  max-width: 720px;
}

.hero-kicker {
  margin: 0 0 18px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #e8d5a7;
  opacity: 0.9;
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(3rem, 10vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: #f8eccd;
}

.hero-sub {
  margin: 18px 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  color: #e8d5a7;
}

.hero-scroll {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 50px;
  transition: opacity 200ms ease;
  opacity: 0.9;
}

.hero-scroll svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hero-scroll .tip {
  fill: var(--accent);
  stroke: none;
}

.hero-scroll .stem {
  stroke: var(--rule);
  stroke-width: 1;
  fill: none;
  transition: stroke 200ms ease;
}

.hero-scroll:hover { opacity: 1; }
.hero-scroll:hover .stem { stroke: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- Obsah (TOC) ---------- */

.toc {
  max-width: 48rem;
  margin: 0 auto;
  padding: 56px 24px 8px;
  text-align: center;
}

.toc-label {
  margin: 0 0 18px;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
}

.toc-list a {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink-soft);
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
  transition: color 180ms ease, border-color 180ms ease;
}

.toc-list a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.toc-roman {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

/* ---------- Kniha ---------- */

.book {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 64px 24px 96px;
}

.loading {
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

/* --- Předmluva --- */

.preface {
  margin: 24px 0 72px;
  padding: 28px 4px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  text-align: center;
}

.preface-label {
  margin: 0 0 14px;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--muted);
}

.preface-body {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.7;
  color: var(--ink-soft);
}

.preface-body p + p { margin-top: 0.6em; }

/* --- Kapitola --- */

.chapter {
  margin: 96px 0 48px;
  text-align: center;
}

.chapter:first-of-type { margin-top: 24px; }

.chapter-roman {
  display: block;
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(4rem, 14vw, 7rem);
  line-height: 0.9;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.chapter-title {
  margin: 14px 0 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.7rem, 4vw, 2.25rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.chapter-ornament {
  display: block;
  margin: 22px auto 0;
  width: 48px;
  height: 1px;
  background: var(--rule);
  position: relative;
}

.chapter-ornament::before,
.chapter-ornament::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.chapter-ornament::before { left: 0; }
.chapter-ornament::after { left: 100%; }

/* --- Báseň --- */

.poem {
  margin: 56px 0;
  padding-top: 8px;
}

.poem-title {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.625rem;
  line-height: 1.25;
  color: var(--ink);
  text-align: left;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.poem-title-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.poem-title-link:hover { color: var(--accent); }

.poem-rule {
  width: 28px;
  height: 1px;
  margin: 12px 0 22px;
  background: var(--rule);
}

.poem-share {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 4px 6px;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  border-radius: 4px;

  opacity: 0;
  transform: translateY(-1px);
  pointer-events: none;
  transition: opacity 220ms ease, color 180ms ease, transform 220ms ease;
}

.poem-share svg {
  width: 18px;
  height: 18px;
  display: block;
}

.poem-share:hover,
.poem-share:focus-visible { color: var(--accent); outline: none; }

.poem:hover .poem-share,
.poem:focus-within .poem-share,
.poem.is-revealed .poem-share,
.poem:target .poem-share {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.poem-share-toast {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
  white-space: nowrap;
}

.poem.is-copied .poem-share-toast {
  opacity: 1;
  transform: none;
}

.poem.is-failed .poem-share-toast {
  opacity: 1;
  transform: none;
  color: #b4593d;
}

/* Anchor highlight when navigated via URL hash */
.poem:target > .poem-title .poem-title-link {
  color: var(--accent);
}

.poem-body p {
  margin: 0 0 1.1em;
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--ink);
  hanging-punctuation: first last;
}

.poem-body p:last-child { margin-bottom: 0; }

/* Decorative fancy drop-style for prose-heavy poems */
.poem.is-prose .poem-body p {
  text-align: justify;
  hyphens: auto;
}

/* Stanza breaks (via <br> inside paragraphs we may get for verse). */
.poem-body p br { display: inline; }

.stanza {
  margin: 0 0 1.2em;
}

.stanza p {
  margin: 0;
  line-height: 1.55;
}

.stanza p + p { margin-top: 0.08em; }

.stanza + .stanza {
  margin-top: 1.3em;
}

/* --- Section rule --- */

.chapter-end {
  display: block;
  width: 60%;
  max-width: 240px;
  height: 1px;
  margin: 64px auto 0;
  background: linear-gradient(90deg, transparent 0%, var(--rule) 50%, transparent 100%);
  border: 0;
}

/* ---------- Footer ---------- */

.foot {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 24px 80px;
  text-align: center;
  color: var(--muted);
}

.foot-sub {
  display: block;
  margin: 0 auto;
  max-width: 30rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- Responsive tweaks ---------- */

@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  .book { padding: 48px 20px 80px; }
  .poem { margin: 44px 0; }
  .chapter { margin: 72px 0 36px; }
  .toc { padding: 40px 20px 8px; }
  .toc-list { gap: 6px 16px; }
  .toc-list a { font-size: 1rem; }

  .hero-art { background-position: 28% 30%; }
}

@media (min-width: 900px) {
  .book { padding: 88px 24px 120px; }
}

/* Print */
@media print {
  .banner, .hero-scroll, .toc, .foot { display: none; }
  .hero { min-height: auto; padding: 24px 0 0; }
  .hero-art, .hero::before { display: none; }
  .hero-inner { color: #000; text-shadow: none; }
  body { background: #fff; color: #000; }
  .book { max-width: 100%; padding: 0 24px; }
}
