/* Styles for the rich-text blocks from the CMS (public/admin/bloki.js).
   Loaded by the site (src/layouts/Uklad.astro) and by the CMS preview.
   Mobile first: everything stacks and uses the full width below 720px. */

:root {
  --blok-odstep: 28px;
  --blok-rdza: #b3241b;
  --blok-zloto: #e8a33a;
  --blok-linia: #3a332c;
  --blok-panel: rgb(29 26 23 / 0.88);
  --blok-przytlumiony: #a39b8c;
}

.proza {
  overflow-wrap: anywhere;
  --obraz-max: 550px; /* the widest an image in the text is ever shown */
}

/* Body text is justified (even right edge), with Polish hyphenation so the gaps between words
   stay small on phones. Text an admin aligned with the alignment button keeps that alignment
   (inline style), decorative text keeps its own, and the main page stays centred. */
.proza :is(p, li, dd, blockquote) {
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
}

.proza [align='center'] {
  text-align: center;
}

.proza [align='right'] {
  text-align: right;
}

.proza .blok-tekst :is(p, li),
.glowna .proza :is(p, li, dd, blockquote) {
  text-align: inherit;
}

.proza .blok-galeria__podpis {
  text-align: center;
}

.proza img {
  max-width: min(100%, var(--obraz-max));
  height: auto;
}

/* An image on its own line (not inside a block) is centred. */
.proza :is(p, a) > img:only-child {
  display: block;
  margin-inline: auto;
}

/* ---------- shared figure look ---------- */

.blok-obraz-tekst__obraz,
.blok-obraz {
  margin: 0;
}

.blok-obraz-tekst__obraz img,
.blok-obraz img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border-radius: 4px;
  border: 1px solid var(--blok-linia);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.45);
}

/* Tall (portrait) photos must not fill a whole phone screen. */
.blok-obraz-tekst__obraz img,
.blok-obraz img {
  width: auto;
  max-width: 100%;
  max-height: 70vh;
  margin-inline: auto;
}

.blok-obraz-tekst figcaption,
.blok-obraz figcaption {
  margin-top: 6px;
  color: var(--blok-przytlumiony);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ---------- 1. Obraz z tekstem ---------- */

.blok-obraz-tekst {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: var(--blok-odstep) 0;
}

.blok-obraz-tekst__tekst > :first-child {
  margin-top: 0;
}

.blok-obraz-tekst__tekst > :last-child {
  margin-bottom: 0;
}

@media (min-width: 720px) {
  .blok-obraz-tekst {
    flex-direction: row;
    align-items: flex-start;
    gap: 28px;
  }

  .blok-obraz-tekst[data-strona='prawo'] {
    flex-direction: row-reverse;
  }

  .blok-obraz-tekst__obraz {
    flex: 0 0 40%;
    max-width: var(--obraz-max, 550px);
  }

  .blok-obraz-tekst[data-rozmiar='maly'] .blok-obraz-tekst__obraz {
    flex-basis: 32%;
  }

  .blok-obraz-tekst[data-rozmiar='duzy'] .blok-obraz-tekst__obraz {
    flex-basis: 50%;
  }

  .blok-obraz-tekst__tekst {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* ---------- 2. Obraz ---------- */

.blok-obraz {
  max-width: var(--obraz-max, 550px);
  margin: var(--blok-odstep) auto;
}

@media (min-width: 720px) {
  .blok-obraz[data-rozmiar='maly'] {
    width: 40%;
  }

  .blok-obraz[data-rozmiar='sredni'] {
    width: 65%;
  }

  .blok-obraz[data-wyrownanie='lewo'] {
    margin-left: 0;
  }

  .blok-obraz[data-wyrownanie='prawo'] {
    margin-right: 0;
  }

  .blok-obraz[data-wyrownanie='srodek'] figcaption {
    text-align: center;
  }
}

/* ---------- 3. Galeria w treści ---------- */

/* Rows are centred, also the last, incomplete one. */
.blok-galeria {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: var(--blok-odstep) 0;
}

.blok-galeria a {
  display: block;
  flex: 0 0 calc(50% - 4px);
}

@media (min-width: 720px) {
  .blok-galeria a {
    flex-basis: 11rem;
  }
}

.blok-galeria img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  margin: 0;
  border-radius: 4px;
}

.blok-galeria__podpis {
  flex: 0 0 100%;
  margin: 2px 0 0;
  text-align: center;
  color: var(--blok-przytlumiony);
  font-size: 0.9rem;
}

/* ---------- 4. Ramka ---------- */

.blok-ramka {
  margin: var(--blok-odstep) 0;
  padding: 16px 18px;
  background: var(--blok-panel);
  border: 1px solid var(--blok-linia);
  border-left: 5px solid var(--blok-rdza);
  border-radius: 4px;
}

.blok-ramka__tytul {
  margin: 0 0 8px;
  font-family: 'Rubik Dirt', 'Rubik', system-ui, sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
  line-height: 1.25;
}

.blok-ramka__tekst > :first-child {
  margin-top: 0;
}

.blok-ramka__tekst > :last-child {
  margin-bottom: 0;
}

.blok-ramka[data-styl='rdza'] {
  background:
    radial-gradient(ellipse at 100% 0%, rgb(140 50 20 / 0.35), transparent 55%),
    linear-gradient(160deg, rgb(110 30 18 / 0.55), rgb(40 18 12 / 0.9));
  border-color: #6b2a17;
  border-left-color: var(--blok-rdza);
}

.blok-ramka[data-styl='ostrzezenie'] {
  position: relative;
  padding-top: 26px;
  background: rgb(40 34 12 / 0.9);
  border-color: #5c4a14;
  border-left-color: var(--blok-zloto);
}

.blok-ramka[data-styl='ostrzezenie']::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  border-radius: 0 4px 0 0;
  background: repeating-linear-gradient(-45deg, var(--blok-zloto) 0 12px, #141210 12px 24px);
}

.blok-ramka[data-styl='ostrzezenie'] .blok-ramka__tytul {
  color: var(--blok-zloto);
}

.blok-ramka[data-styl='notatka'] {
  border-left-color: var(--blok-przytlumiony);
}

/* Ramka with an image: above the text, or beside it from 720px (stacked on phones). */
.blok-ramka__obraz {
  margin: 0 0 14px;
}

.blok-ramka__obraz img {
  display: block;
  width: auto;
  max-width: min(100%, var(--obraz-max, 550px));
  max-height: 60vh;
  margin: 0 auto;
  border-radius: 4px;
  border: 1px solid var(--blok-linia);
}

@media (min-width: 720px) {
  .blok-ramka[data-obraz='lewo'],
  .blok-ramka[data-obraz='prawo'] {
    display: grid;
    grid-template-columns: minmax(0, 35%) minmax(0, 1fr);
    column-gap: 22px;
    align-items: start;
  }

  .blok-ramka[data-obraz='prawo'] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 35%);
  }

  .blok-ramka[data-obraz] .blok-ramka__tytul {
    grid-column: 1 / -1;
  }

  .blok-ramka[data-obraz='lewo'] .blok-ramka__obraz,
  .blok-ramka[data-obraz='prawo'] .blok-ramka__obraz {
    margin: 0;
  }

  .blok-ramka[data-obraz='prawo'] .blok-ramka__obraz {
    grid-column: 2;
    grid-row: 2;
  }

  .blok-ramka[data-obraz='prawo'] .blok-ramka__tekst {
    grid-column: 1;
    grid-row: 2;
  }
}

/* ---------- 5. Dokument ---------- */

.blok-dokument {
  max-width: 40rem;
  margin: var(--blok-odstep) auto;
  padding: 22px 18px;
  color: #2b2219;
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 1rem;
  line-height: 1.55;
  background-color: #e6dbc2;
  background-image:
    radial-gradient(ellipse at 12% 18%, rgb(150 110 60 / 0.25), transparent 40%),
    radial-gradient(ellipse at 88% 80%, rgb(130 90 50 / 0.3), transparent 45%),
    radial-gradient(circle at 70% 25%, rgb(120 80 40 / 0.12), transparent 20%),
    linear-gradient(180deg, #ece3cd, #ddd0b3);
  border-radius: 2px;
  box-shadow:
    0 10px 24px rgb(0 0 0 / 0.5),
    inset 0 0 40px rgb(120 85 45 / 0.25);
}

@media (min-width: 720px) {
  .blok-dokument {
    padding: 32px 40px;
    transform: rotate(-0.4deg);
  }
}

.blok-dokument a {
  color: #7a1c12;
}

.blok-dokument__tytul {
  margin: 0 0 16px;
  font-size: 1.2rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.blok-dokument__tekst > :first-child {
  margin-top: 0;
}

.blok-dokument__podpis {
  margin: 20px 0 0;
  text-align: right;
}

/* ---------- 6. Tekst ozdobny ---------- */

.blok-tekst {
  margin: 20px 0;
  line-height: 1.3;
}

.blok-tekst > :first-child {
  margin-top: 0;
}

.blok-tekst > :last-child {
  margin-bottom: 0;
}

.blok-tekst[data-czcionka='rubik'] {
  font-family: 'Rubik', system-ui, sans-serif;
}

.blok-tekst[data-czcionka='rubik-dirt'] {
  font-family: 'Rubik Dirt', 'Rubik', system-ui, sans-serif;
  letter-spacing: 0.03em;
}

.blok-tekst[data-czcionka='special-elite'] {
  font-family: 'Special Elite', 'Courier New', monospace;
}

.blok-tekst[data-rozmiar='normalny'] {
  font-size: 1.1rem;
  line-height: 1.6;
}

.blok-tekst[data-rozmiar='duzy'] {
  font-size: clamp(1.4rem, 5vw, 2rem);
}

.blok-tekst[data-rozmiar='bardzo-duzy'] {
  font-size: clamp(1.8rem, 8vw, 3.2rem);
  line-height: 1.15;
}

.blok-tekst[data-wyrownanie='lewo'] {
  text-align: left;
}

.blok-tekst[data-wyrownanie='srodek'] {
  text-align: center;
}

.blok-tekst[data-wyrownanie='prawo'] {
  text-align: right;
}

/* ---------- tables and lines in rich text ---------- */

.proza hr {
  margin: var(--blok-odstep) 0;
  border: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blok-rdza), transparent);
}

/* ---------- 7. Obrazy obok siebie (2 or 3 in a row; stacked on phones) ---------- */

.blok-obok {
  display: grid;
  gap: 14px;
  margin: var(--blok-odstep) 0;
}

@media (min-width: 720px) {
  .blok-obok[data-liczba='2'] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .blok-obok[data-liczba='3'] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.blok-obok figure {
  width: 100%;
  max-width: var(--obraz-max, 550px);
  margin: 0 auto;
}

.blok-obok img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  margin: 0;
  border-radius: 4px;
  border: 1px solid var(--blok-linia);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.45);
}

.blok-obok figcaption {
  margin-top: 6px;
  color: var(--blok-przytlumiony);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ---------- 8. Mapa Google ---------- */

.blok-mapa {
  margin: var(--blok-odstep) 0;
}

.blok-mapa iframe {
  display: block;
  width: 100%;
  height: 450px;
  border: 1px solid var(--blok-linia);
  border-radius: 4px;
}

.blok-mapa[data-wysokosc='mala'] iframe {
  height: 300px;
}

.blok-mapa[data-wysokosc='duza'] iframe {
  height: min(650px, 80vh);
}

.blok-mapa__blad {
  padding: 12px 16px;
  border-left: 4px solid var(--blok-zloto);
  background: var(--blok-panel);
}
