/* VanillaStories — motyw „literacki / editorial"
   Ciepły papier, atrament, jeden akcent (terakota). Serifowa typografia,
   hairline'owe linie zamiast puchatych cieni, dużo powietrza, kolumna do czytania.
   Wariant ciemny („nocny papier") w :root[data-theme="dark"] niżej. */

:root {
  --paper: #faf6ef;         /* ciepły krem */
  --surface: #fffdf9;       /* powierzchnia kart (odcina się od papieru) */
  --ink: #26221c;           /* ciepła prawie-czerń */
  --ink-soft: #776d61;      /* przygaszony atrament */
  --ink-faint: #a89c8c;     /* metadane, numery */
  --rule: #e6dccd;          /* linia włoskowa */
  --rule-strong: #d7cab6;
  --accent: #b0543a;        /* terakota */
  --accent-deep: #8d3e28;   /* hover */
  --accent-tint: #efe1d6;   /* delikatny wash pod cytatem */
  --shadow: 0 1px 2px rgba(38, 30, 20, .05), 0 18px 40px rgba(38, 30, 20, .07);
  --radius: 3px;
  --measure: 44rem;         /* szerokość kolumny do czytania */
  --font-head: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Newsreader", Georgia, "Times New Roman", serif;
  --font-label: "Fraunces", Georgia, serif;
}

/* --- wariant ciemny („nocny papier") --- */
:root[data-theme="dark"] {
  --paper: #1b1815;
  --surface: #262119;
  --ink: #ece4d6;
  --ink-soft: #a99e8e;
  --ink-faint: #7d7264;
  --rule: #332e26;
  --rule-strong: #443d32;
  --accent: #d98a6b;
  --accent-deep: #e8a487;
  --accent-tint: #2a221b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .30), 0 18px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.125rem;
  color: var(--ink);
  line-height: 1.72;
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-feature-settings: "kern", "liga", "onum", "pnum";
  transition: color .3s ease, background-color .3s ease;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* Widoczny focus dla nawigacji klawiaturą */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px;
}

/* „Przejdź do treści" — ukryty, pokazuje się przy fokusie z klawiatury */
.skip-link {
  position: absolute; left: 0; top: 0; z-index: 1200;
  background: var(--accent); color: var(--paper);
  padding: .6rem 1rem; border-radius: 0 0 6px 0;
  font-family: var(--font-label); font-size: .85rem;
  transform: translateY(-120%); transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); color: var(--paper); text-decoration: none; }

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.12;
  letter-spacing: -0.01em;
  font-optical-sizing: auto;
}

/* Długie niełamliwe ciągi (URL-e, dziwne tokeny) łamią się zamiast rozpychać layout */
.prose, .desc, h1, h2, h3 { overflow-wrap: break-word; }

/* Etykieta „small-caps": tracked-out, przygaszona */
.section-label, .meta, .author {
  font-family: var(--font-label);
}
.section-label {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 1rem;
}

/* --- nagłówek strony --- */
.site-header {
  border-bottom: 1px solid var(--rule);
  padding: 1.5rem 0;
}
.header-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.site-title { display: inline-block; }
.site-title:hover { text-decoration: none; }

/* Footer. body is a flex column with main flex:1, so this sits at the bottom
   of the viewport even on a short page instead of floating mid-screen. */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 4rem;
  padding: 1.5rem 0 2rem;
}
.footer-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.site-footer p {
  margin: 0;
  font-family: var(--font-label);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.logo-text {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.site-title:hover .logo-text { color: var(--accent); }

/* --- przełącznik motywu --- */
.theme-toggle {
  align-self: center;
  width: 2.2rem; height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  display: grid; place-items: center;
  padding: 0;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* --- główna kolumna --- */
main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3.5rem 1.5rem 4rem;
}

h1 { font-size: clamp(2rem, 5vw, 2.9rem); margin: 0 0 1rem; font-weight: 500; }

.empty {
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  color: var(--ink-soft);
  font-style: italic;
}
.empty a { font-style: normal; }

/* --- indeks opowiadań --- */
/* Nagłówek strony ukryty wizualnie — czytniki ekranu i SEO wciąż go widzą */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.story-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.1rem; }
.story-card {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  padding: 1.5rem 1.6rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 9px;
  transition: border-color .3s ease, background-color .3s ease;
}
.story-cover-link { flex: none; display: block; width: 130px; }
.story-card .cover {
  width: 100%; height: auto;      /* zachowuje proporcje — bez przycinania */
  display: block;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.story-card-body { min-width: 0; }
.story-card-body h2 { font-size: 1.6rem; margin: 0 0 .25rem; font-weight: 500; }
.story-card-body h2 a { color: var(--ink); }
.story-card-body h2 a:hover { color: var(--accent); text-decoration: none; }
.author {
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 .6rem;
  font-size: 1rem;
}
.desc { margin: .3rem 0 .7rem; color: var(--ink-soft); }
/* On the list a description is a teaser — the full text lives on the story page.
   Without this the 500-character blurbs make one card fill the whole screen. */
.story-card .desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta {
  color: var(--ink-faint);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0;
}

/* --- okruszki / powrót --- */
.breadcrumb { margin: 0 0 2rem; font-size: .95rem; }
.breadcrumb a {
  color: var(--ink-faint);
  font-family: var(--font-label);
  letter-spacing: .04em;
}
.breadcrumb a:hover { color: var(--accent); text-decoration: none; }

/* --- widok opowiadania --- */
.story-intro { margin-bottom: 3rem; }
.story-intro h1 { margin-top: 0; }
.cover-large {
  display: block;
  max-width: 100%;
  max-height: 360px;              /* pionowa: portret; pozioma: baner — bez przycinania */
  width: auto; height: auto;
  margin: 0 0 1.8rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.story-intro .desc { margin: 1rem 0 1.4rem; color: var(--ink); }

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--paper);
  font-family: var(--font-label);
  font-weight: 500;
  font-size: .82rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .7rem 1.4rem;
  border-radius: var(--radius);
  transition: background-color .2s ease;
}
.button:hover { background: var(--accent-deep); color: var(--paper); text-decoration: none; }

/* --- spis rozdziałów --- */
.contents { margin-top: 3rem; }
.chapter-list { list-style: none; padding: 0; margin: 0; counter-reset: ch; }
.chapter-list li { counter-increment: ch; }
.chapter-list li a {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 1.25rem;
}
.chapter-list li:last-child a { border-bottom: 1px solid var(--rule); }
.chapter-list li a::before {
  content: counter(ch, decimal-leading-zero);
  flex: none;
  font-family: var(--font-label);
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  min-width: 2.2rem;
  padding-top: .15rem;
  transition: color .2s ease;
}
.chapter-list li a:hover { color: var(--accent); text-decoration: none; }
.chapter-list li a:hover::before { color: var(--accent); }
.chapter-list li.empty { display: block; }
.chapter-list li.empty a::before { content: none; }

/* --- rozdział / treść --- */
.chapter-eyebrow {
  font-family: var(--font-label);
  font-size: .74rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 .7rem;
}
.chapter h1 { margin: 0 0 2rem; }
.chapter-image, .prose img {
  max-width: 100%; height: auto; display: block;
  margin: 2.2rem auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.chapter-image { margin-top: 0; }

/* Attribution under the chapter illustration — quiet enough not to compete
   with the prose, but always there. */
.chapter-figure { margin: 0 0 2.2rem; }
.chapter-figure .chapter-image { margin-bottom: .5rem; }
.image-source {
  text-align: right;
  font-family: var(--font-label);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.image-source a { color: var(--ink-faint); }
.image-source a:hover { color: var(--accent); text-decoration: none; }

.prose { font-size: 1.15rem; line-height: 1.78; }
.prose p { margin: 0 0 1.35rem; }
.prose blockquote {
  border: none;
  border-left: 2px solid var(--accent);
  background: var(--accent-tint);
  margin: 1.8rem 0;
  padding: 1rem 1.4rem;
  color: var(--ink);
  font-style: italic;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose h2, .prose h3 { color: var(--ink); margin: 2.4rem 0 1rem; font-weight: 500; }
.prose h2 { font-size: 1.6rem; }
.prose h3 { font-size: 1.3rem; }
.prose a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; text-decoration-color: var(--rule-strong); }
.prose a:hover { text-decoration-color: var(--accent); }
.prose hr { border: none; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* --- nawigacja między rozdziałami --- */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1.2rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.chapter-nav a {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  max-width: 48%;
  color: var(--ink);
}
.chapter-nav a:hover { text-decoration: none; color: var(--accent); }
.chapter-nav a.prev { justify-content: center; }
/* „Next" jako wyraźne CTA — użytkownik prawie zawsze chce czytać dalej */
.chapter-nav a.next {
  text-align: right; margin-left: auto; align-items: flex-end;
  border: 1px solid var(--rule-strong);
  border-radius: 9px;
  padding: .85rem 1.15rem;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
.chapter-nav a.next:hover { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }
.chapter-nav a.next .nav-label { color: var(--accent); }
.nav-label {
  font-family: var(--font-label);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.nav-title { font-family: var(--font-head); font-size: 1.1rem; line-height: 1.3; }

/* --- pasek postępu czytania --- */
.reading-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: 1100; pointer-events: none; background: transparent;
}
.reading-progress > i {
  display: block; height: 100%;
  background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%;
  will-change: transform;
}

/* --- przycisk „do góry" --- */
.to-top {
  position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 1050;
  width: 2.8rem; height: 2.8rem; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--rule-strong);
  background: var(--surface); color: var(--ink-soft);
  box-shadow: var(--shadow); cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.to-top[hidden] { display: none; }
.to-top:hover { color: var(--accent); border-color: var(--accent); }

/* --- klikalne obrazki: kursor „powiększ" --- */
.cover-large, .chapter-image, .prose img { cursor: zoom-in; }
.prose a img { cursor: pointer; }

/* --- lightbox (powiększenie obrazka) --- */
.vs-lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: 4vmin;
  background: rgba(26, 22, 18, .84);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  cursor: zoom-out;
}
.vs-lightbox.is-open { display: flex; }
.vs-lightbox-img {
  max-width: 100%; max-height: 100%;
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  animation: vs-lb-in .2s ease;
}
@keyframes vs-lb-in {
  from { transform: scale(.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.vs-lightbox-close {
  position: fixed; top: 1rem; right: 1.2rem;
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3);
  cursor: pointer;
  background: transparent; color: #fff;
  font-size: 1.5rem; line-height: 1;
  transition: border-color .2s ease;
}
.vs-lightbox-close:hover { border-color: #fff; }

/* --- responsywność --- */
@media (max-width: 560px) {
  body { font-size: 1.06rem; }
  main { padding: 2.5rem 1.3rem 3rem; }
  .cover-large { max-height: 280px; }
  .story-card { gap: 1.2rem; padding: 1.1rem 1.2rem; }
  .story-cover-link { width: 88px; }
  .story-card-body h2 { font-size: 1.35rem; }
  .story-card .desc { -webkit-line-clamp: 4; }
  .chapter-nav { flex-direction: column; gap: 1.5rem; }
  .chapter-nav a, .chapter-nav a.next { max-width: 100%; text-align: left; align-items: flex-start; }
  .to-top { right: .9rem; bottom: .9rem; }
}

/* --- szanuj preferencję ograniczonego ruchu --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
