/* =========================================================================
   IQ Projekt — styl.css
   Palette and background per ANALYZA.md §6.
   Green is an accent FIELD only: #7ED321 on white is 1.9:1 and fails WCAG,
   but with black on top it is 11.2:1. Green text uses the darkened variant.
   ========================================================================= */

:root {
  --zelena: #7ED321;
  --zelena-tmava: #4A7A14;   /* 5.1:1 on white — safe for text and links */
  --text: #14161a;
  --text-slaby: #5a6169;
  --bila: #fff;
  --ram: #e4e7e1;

  /* Background grid — variant A, 5 minor tiles per major tile */
  --mrizka-mala: 16px;
  --mrizka-velka: 80px;      /* = 5 × 16 */
  --cara-velka: #e7eae4;
  --cara-mala: #f3f5f1;

  color-scheme: light dark;

  --sirka: 1100px;
  --sirka-siroka: 1760px;    /* one-page layout, sized for 1920×1080 */
  --vyska-hlavicky: 6rem;    /* measured and overwritten by web.js */
  --sirka-textu: 68ch;
  --mezera: clamp(1rem, 3vw, 2rem);
  /* Inner edge of the content boxes (padding + 1px border), so the header
     lines up with the text in them: left = text card, right = slideshow. */
  --odsazeni-karty: clamp(1.25rem, 4vw, 2.75rem);
  --odsazeni-prezentace: clamp(.75rem, 1.5vw, 1.25rem);
}

/* -------------------------------------------------------------- dark mode
   Default follows the visitor's OS setting; the header button (tema.js) sets
   html[data-tema] to force either variant. A soft charcoal, not black:
   surfaces #2a2e33 on a #23272b page. Green text moves to a lighter tint
   (#8fd94a is ~8:1 on the surface); the green FIELD with black text stays.
   The two blocks below are identical on purpose: CSS cannot share a rule
   between a media query and an attribute selector without a preprocessor. */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="svetle"]) {
    --zelena-tmava: #8fd94a;
    --text: #e6e8ea;
    --text-slaby: #a7aeb5;
    --bila: #2a2e33;
    --ram: #414850;
    --cara-velka: #31363c;
    --cara-mala: #2d3237;
  }
  :root:not([data-tema="svetle"]) body { background-color: #23272b; }
  /* Light OpenStreetMap tiles would glare on a dark page. */
  :root:not([data-tema="svetle"]) .mapa img { filter: brightness(.78) contrast(1.05) saturate(.85); }
  :root:not([data-tema="svetle"]) .logo-svetle { display: none; }
  :root:not([data-tema="svetle"]) .logo-tmave { display: block; }
  :root:not([data-tema="svetle"]) .tema-prepinac .ikona-mesic { display: none; }
  :root:not([data-tema="svetle"]) .tema-prepinac .ikona-slunce { display: block; }
}

html[data-tema="tmave"] {
    --zelena-tmava: #8fd94a;
    --text: #e6e8ea;
    --text-slaby: #a7aeb5;
    --bila: #2a2e33;
    --ram: #414850;
    --cara-velka: #31363c;
    --cara-mala: #2d3237;
}
html[data-tema="tmave"] body { background-color: #23272b; }
html[data-tema="tmave"] .mapa img { filter: brightness(.78) contrast(1.05) saturate(.85); }
html[data-tema="tmave"] .logo-svetle { display: none; }
html[data-tema="tmave"] .logo-tmave { display: block; }
html[data-tema="tmave"] .tema-prepinac .ikona-mesic { display: none; }
html[data-tema="tmave"] .tema-prepinac .ikona-slunce { display: block; }

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);
  line-height: 1.65;
  color: var(--text);
  hyphens: auto;           /* long Czech compounds otherwise break narrow layouts */
  -webkit-hyphens: auto;

  /* Millimetre paper: fine grid, every fifth line stronger. */
  background-color: var(--bila);
  background-image:
    linear-gradient(var(--cara-velka) 1px, transparent 1px),
    linear-gradient(90deg, var(--cara-velka) 1px, transparent 1px),
    linear-gradient(var(--cara-mala) 1px, transparent 1px),
    linear-gradient(90deg, var(--cara-mala) 1px, transparent 1px);
  background-size:
    var(--mrizka-velka) var(--mrizka-velka),
    var(--mrizka-velka) var(--mrizka-velka),
    var(--mrizka-mala) var(--mrizka-mala),
    var(--mrizka-mala) var(--mrizka-mala);
  background-position: -1px -1px;
  background-attachment: fixed;
}

img { max-width: 100%; height: auto; }

a { color: var(--zelena-tmava); }
a:hover { text-decoration: none; }

:focus-visible {
  outline: 3px solid var(--zelena-tmava);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ layout */

.obal {
  max-width: var(--sirka);
  margin: 0 auto;
  padding-inline: var(--mezera);
}

main { padding-block: clamp(1.5rem, 4vw, 3rem) 4rem; }

.karta {
  background: var(--bila);
  border: 1px solid var(--ram);
  padding: var(--odsazeni-karty);
}

.karta + .karta { margin-top: var(--mezera); }

/* Prose never runs over the pattern and never over-long lines. The limit
   sits on the children so a tile grid inside the prose may run wider. */
.text > * { max-width: var(--sirka-textu); }

.text h2 {
  font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.8rem);
  line-height: 1.25;
  margin: 2rem 0 .6rem;
}
.text h2:first-child { margin-top: 0; }
.text h3 {
  font-size: clamp(1.1rem, 1rem + .6vw, 1.3rem);
  margin: 1.6rem 0 .4rem;
}
.text p { margin: 0 0 1rem; }
.text ul, .text ol { margin: 0 0 1rem; padding-left: 1.35rem; }
.text li { margin-bottom: .35rem; }
.text > :last-child { margin-bottom: 0; }

.hlaska {
  color: var(--text-slaby);
  font-style: italic;
}

/* ------------------------------------------------------------------ header */

.hlavicka {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bila);
  border-bottom: 1px solid var(--ram);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
}

.hlavicka .obal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: .9rem;
  padding-inline-start: calc(var(--mezera) + 1px + var(--odsazeni-karty));
  padding-inline-end: calc(var(--mezera) + 1px + var(--odsazeni-prezentace));
}

.logo { display: block; line-height: 0; }
.logo img { width: clamp(130px, 22vw, 180px); }
.logo-tmave { display: none; }

.tema-prepinac {
  width: 44px;
  height: 44px;              /* touch target */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  cursor: pointer;
}
.tema-prepinac:hover { border-color: var(--ram); }
.tema-prepinac .ikona-slunce { display: none; }

.menu {
  display: flex;
  gap: .35rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.menu a {
  display: block;
  padding: .55rem .9rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
  min-height: 44px;              /* touch target */
  display: flex;
  align-items: center;
}

.menu a:hover { border-color: var(--ram); }

/* Narrow screens: tighter links, pulled out by their own padding so the link
   TEXT (not its hover box) lines up with the logo and the content edge. */
@media (max-width: 600px) {
  .menu { gap: 0; flex-wrap: nowrap; margin-inline: -.5rem; }
  .menu a { padding-inline: .5rem; }
}

/* Green field with black text — the one place green is allowed to be large. */
.menu a[aria-current="page"] {
  background: var(--zelena);
  color: #000;
  border-color: var(--zelena);
}

/* ------------------------------------------------------------------ footer */

.paticka {
  background: var(--bila);
  border-top: 4px solid var(--zelena);
  padding-block: 2rem;
  font-size: .9rem;
  color: var(--text-slaby);
}

.paticka .obal {
  display: flex;
  gap: 1.5rem 2.5rem;
  flex-wrap: wrap;
  justify-content: space-between;
}

.paticka p { margin: 0 0 .3rem; }
.paticka strong { color: var(--text); }
.paticka .cookies { font-style: italic; }
.paticka .copyright { margin-top: .8rem; font-size: .85rem; opacity: .8; }

/* ---------------------------------------------------------------- one page */

.obal-siroky { max-width: var(--sirka-siroka); }

/* Narrow: one column, O nás → Projekty → Kontakty.
   Wide (≥1100px, i.e. every 16:9 desktop): prose on the left, the slideshow
   pinned on the right for the whole scroll. */
.jedna-stranka {
  display: grid;
  gap: var(--mezera);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "o-nas" "projekty" "kontakty";
}

.oddil-o-nas    { grid-area: o-nas; }
.prezentace     { grid-area: projekty; }
.oddil-kontakty { grid-area: kontakty; }

.jedna-stranka > section,
.jedna-stranka > aside { scroll-margin-top: calc(var(--vyska-hlavicky) + 1rem); }

@media (min-width: 1100px) {
  .jedna-stranka {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-areas: "o-nas projekty" "kontakty projekty";
    align-items: start;
  }

  .prezentace {
    position: sticky;
    top: calc(var(--vyska-hlavicky) + var(--mezera));
    /* Fill the viewport below the header: on 1920×1080 this is ~800×900,
       close to the 3:4 the portrait photos are shot in. */
    height: calc(100vh - var(--vyska-hlavicky) - 2 * var(--mezera));
    height: calc(100dvh - var(--vyska-hlavicky) - 2 * var(--mezera));
    min-height: 26rem;
  }
}

/* ------------------------------------------------------------ service tiles */

.text > .sluzby {
  max-width: none;
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: .75rem;
}

.sluzba {
  margin: 0;
  padding: .9rem 1rem 1rem;
  background: var(--bila);
  border: 1px solid var(--ram);
  border-top: 4px solid var(--zelena);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.text .sluzba { margin-bottom: 0; }

.sluzba-nazev {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.sluzba p {
  margin: 0;
  font-size: .9rem;
  line-height: 1.5;
  color: var(--text-slaby);
}

/* -------------------------------------------------------------- slideshow */

.prezentace {
  background: var(--bila);
  border: 1px solid var(--ram);
  padding: var(--odsazeni-prezentace);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.prezentace-nadpis {
  font-size: clamp(1.15rem, 1rem + .6vw, 1.4rem);
  line-height: 1.25;
  margin: 0 0 .75rem;
}

.prezentace > [data-obsah] {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.snimek {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  aspect-ratio: 4 / 3;       /* stacked layout; the sticky column overrides */
}

@media (min-width: 1100px) {
  .snimek { aspect-ratio: auto; }
}

.snimek-tlacitko {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: #1d2024;
  cursor: zoom-in;
  overflow: hidden;
  display: block;
}

/* The same photo, blurred, fills the bars left by object-fit: contain —
   portrait and landscape shots share one frame without cropping either. */
.snimek-pozadi {
  position: absolute;
  inset: -2rem;
  background: center / cover no-repeat;
  filter: blur(24px) brightness(.7);
}

.snimek-obrazek {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  display: block;
  transition: opacity .45s ease;
}

.snimek-obrazek.meni-se { opacity: 0; }
.snimek-obrazek[src=""] { visibility: hidden; }

.snimek-lupa {
  position: absolute;
  right: .6rem;
  bottom: .6rem;
  padding: .3rem .65rem;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: .8rem;
  opacity: 0;
  transition: opacity .2s ease;
}

.snimek-tlacitko:hover .snimek-lupa,
.snimek-tlacitko:focus-visible .snimek-lupa { opacity: 1; }

.snimek .sipka {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, .9);
  color: #14161a;            /* fixed: the button stays light in dark mode */
}
.snimek .sipka-vlevo { left: .5rem; }
.snimek .sipka-vpravo { right: .5rem; }

.snimek-popis {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 1rem;
  padding-top: .6rem;
  line-height: 1.4;
}

.snimek-popis p { margin: 0; }

/* Project description: long ones scroll inside the panel instead of pushing
   the photo off the sticky viewport-high card. */
.snimek-text {
  margin-top: .6rem;
  padding-top: .6rem;
  border-top: 1px solid var(--ram);
  max-height: 9.5rem;
  overflow-y: auto;
  font-size: .9rem;
  line-height: 1.45;
}
.snimek-text[hidden] { display: none; }
.snimek-text p { margin: 0 0 .6em; }
.snimek-text > :last-child { margin-bottom: 0; }

.snimek-projekt { font-weight: 600; }

.snimek-titulek {
  grid-column: 1;
  font-size: .875rem;
  color: var(--text-slaby);
}
.snimek-titulek[hidden] { display: none; }

.snimek-pocet {
  grid-column: 2;
  grid-row: 1;
  font-size: .85rem;
  color: var(--text-slaby);
  font-variant-numeric: tabular-nums;
}

.sipka {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;              /* touch target */
  border: 1px solid var(--ram);
  background: var(--bila);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sipka:hover:not(:disabled) { background: var(--zelena); border-color: var(--zelena); }
.sipka:disabled { opacity: .3; cursor: default; }
.sipka[hidden] { display: none; }

/* ---------------------------------------------------------------- lightbox */

/* Sized against the fixed containing block, never 100vw: vw includes the
   scrollbar width and would push the page into horizontal overflow.
   Height is dvh, not vh — phone landscape is only ~390px tall and vh is
   measured against the browser chrome being hidden. */
#lightbox {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

#lightbox::backdrop { background: rgba(0, 0, 0, .88); }

.lightbox-plocha {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-obrazek {
  max-width: calc(100% - 6rem);
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Caption overlays the image rather than stacking below it — in landscape
   there is no vertical room to stack. */
.lightbox-popis {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  margin: 0;
  padding: .75rem 4rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75) 40%);
  color: #fff;
  font-size: .92rem;
  text-align: center;
}
.lightbox-popis[hidden] { display: none; }

.lightbox-pocet {
  position: absolute;
  top: .6rem; left: 1rem;
  margin: 0;
  color: #fff;
  font-size: .85rem;
  opacity: .8;
}

.lightbox-tlacitko {
  position: absolute;
  border: 0;
  background: rgba(0, 0, 0, .5);
  color: #fff;
  cursor: pointer;
  width: 48px;
  height: 48px;
  font-size: 1.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-tlacitko:hover { background: var(--zelena); color: #000; }
.lightbox-tlacitko[hidden] { display: none; }

.lightbox-vlevo { left: .4rem; top: 50%; transform: translateY(-50%); }
.lightbox-vpravo { right: .4rem; top: 50%; transform: translateY(-50%); }
.lightbox-zavrit { right: .4rem; top: .4rem; font-size: 1.4rem; }

/* ---------------------------------------------------------------- contacts */

.kontakty-rozlozeni {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  align-items: flex-start;
}

.kontakty-rozlozeni > [data-obsah] { flex: 1 1 18rem; }

.kontakt-tabulka {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .45rem 1.5rem;
  margin: 0;
  max-width: 40rem;
}

.kontakt-tabulka dt {
  font-weight: 600;
  color: var(--text-slaby);
}

.kontakt-tabulka dd { margin: 0; }

@media (max-width: 420px) {
  .kontakt-tabulka { grid-template-columns: 1fr; gap: 0 0; }
  .kontakt-tabulka dt { margin-top: .7rem; }
}

.mapa { margin: 0; flex: 1 1 22rem; display: block; max-width: 34rem; }
.mapa img { border: 1px solid var(--ram); width: 100%; }
.mapa figcaption { font-size: .875rem; color: var(--text-slaby); padding-top: .4rem; }

/* ------------------------------------------------------------------- misc */

.preskocit {
  position: absolute;
  left: -9999px;
}
.preskocit:focus {
  left: .5rem; top: .5rem;
  z-index: 100;
  background: var(--zelena);
  color: #000;
  padding: .6rem 1rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .snimek-obrazek, .snimek-lupa { transition: none; }
}

@media print {
  body { background: none; }
  .hlavicka, .paticka, .prezentace, #lightbox { display: none; }
  .jedna-stranka { display: block; }
  .karta { border: 0; padding: 0; }
}
