:root {
  --green: #264036;
  --cream: #f4f0e6;
  --yellow: #e6b84a;
  --text: #232823;
  --muted: #697069;
  --line: #d9d7ce;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}
img { display: block; width: 100%; }
a { color: inherit; }

header {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 1280px);
  padding: 1.5rem 2.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, .22);
  color: white;
  transform: translateX(-50%);
}
.logo {
  color: white;
  font-size: .78rem;
  line-height: 1.05;
  letter-spacing: .06em;
  text-decoration: none;
  text-transform: uppercase;
}
.logo strong { font-size: 1rem; }
nav { display: flex; gap: 1.8rem; }
nav a {
  position: relative;
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
}
nav a::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -.45rem;
  left: 0;
  height: 2px;
  background: var(--yellow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .2s ease;
}
nav a:hover::after,
nav a:focus-visible::after { transform: scaleX(1); }

.hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: clamp(700px, 88svh, 900px);
  overflow: hidden;
  color: white;
  background: var(--green);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(18, 43, 34, .94) 0%, rgba(18, 43, 34, .78) 38%, rgba(18, 43, 34, .16) 72%, rgba(18, 43, 34, .06) 100%),
    linear-gradient(0deg, rgba(12, 28, 23, .46) 0%, transparent 42%);
}
.hero-text {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  width: min(calc(100% - 4rem), 1200px);
  margin: 0 auto;
  padding: 10rem 0 7rem;
}
.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  transform: scale(1.01);
}
.label {
  margin: 0 0 .8rem;
  color: #b05c3c;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
h1, h2 { margin: 0 0 1.25rem; font-family: Georgia, "Times New Roman", serif; font-weight: 400; line-height: 1.05; }
h1 { font-size: clamp(3rem, 6vw, 6rem); }
h2 { font-size: clamp(2.2rem, 4vw, 4rem); }
.hero h1 {
  max-width: 10ch;
  margin-bottom: 1.5rem;
  font-size: clamp(4rem, 7.2vw, 7rem);
  letter-spacing: -.035em;
  text-wrap: balance;
}
.lead {
  max-width: 31rem;
  margin: 0 0 2.25rem;
  color: rgba(255, 255, 255, .88);
  font-size: clamp(1.08rem, 1.5vw, 1.3rem);
}
.button {
  display: inline-block;
  padding: .95rem 1.45rem;
  border-radius: 999px;
  color: var(--green);
  background: var(--yellow);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 .8rem 2rem rgba(9, 28, 21, .2);
  transition: transform .2s ease, background-color .2s ease;
}
.button:hover { background: #f0c65c; transform: translateY(-2px); }
.button:focus-visible { outline: 3px solid white; outline-offset: 3px; }

.adoption {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: clamp(3rem, 8vw, 8rem);
  padding: 4rem max(2rem, calc((100vw - 1200px) / 2));
  background: var(--yellow);
}
.adoption h2 { margin: 0; font-size: clamp(2rem, 3.5vw, 3.5rem); }
.adoption-intro p { margin: 1rem 0 0; font-size: 1.15rem; }
.adoption form {
  display: grid;
  gap: .45rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, .72);
}
.adoption label { margin-top: .35rem; font-size: .85rem; font-weight: 700; }
.adoption input {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid rgba(38, 64, 54, .45);
  border-radius: 0;
  padding: .65rem .75rem;
  background: white;
  font: inherit;
}
.adoption input[readonly] { color: var(--green); background: var(--cream); font-weight: 700; }
.adoption button,
.dialog-actions button,
.dialog-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  border: 0;
  padding: .7rem 1rem;
  color: white;
  background: var(--green);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.adoption button { margin-top: .75rem; }
.form-note { margin: .6rem 0 0; color: #55513f; font-size: .82rem; }

.horses,
.about,
.contact {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(4.5rem, 8vw, 8rem) 2rem;
}
.horse-cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1.25rem; }
.horse-card {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: white;
  box-shadow: 0 .5rem 1.5rem rgba(38, 64, 54, .07);
}
.horse-card:nth-child(4) { grid-column: 2 / span 2; }
.horse-card:nth-child(5) { grid-column: 4 / span 2; }
.horse-photo {
  position: relative;
  height: clamp(17rem, 25vw, 21rem);
  flex: 0 0 auto;
  overflow: hidden;
  background: #e9e8e1;
}
.horse-photo img {
  display: block;
  width: 100%;
  height: 100%;
}
.horse-photo-backdrop {
  position: absolute;
  inset: 0;
  object-fit: cover;
  filter: blur(18px) brightness(.78);
  transform: scale(1.08);
}
.horse-photo-main {
  position: relative;
  z-index: 1;
  object-fit: contain;
  object-position: center;
}
.horse-card-content { padding: 1.25rem; }
.horse-card-content { flex: 1; }
.horse-card-content h3 { margin: 0 0 1rem; font-family: Georgia, "Times New Roman", serif; font-size: 1.8rem; font-weight: 400; }
.horse-qr {
  display: grid;
  place-items: center;
  width: 9rem;
  aspect-ratio: 1;
  border: 2px dashed var(--green);
  color: var(--green);
  background: white;
  font-size: 1.5rem;
  font-weight: 700;
}
.horse-qr-image {
  display: block;
  width: min(100%, 11rem);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: white;
}
.qr-zoom {
  display: block;
  width: fit-content;
  max-width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
}
.qr-zoom:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
#qr-dialog { width: min(92vw, 580px); max-height: 92vh; padding: 1.25rem; }
.qr-dialog-content { position: relative; display: grid; justify-items: center; gap: .75rem; }
.qr-dialog-content h2 { margin: .4rem 2.5rem 0; text-align: center; font-size: 1.35rem; }
#large-qr-image { width: min(100%, 500px); max-height: 76vh; object-fit: contain; }
#close-qr-dialog {
  position: absolute;
  top: -.75rem;
  right: -.5rem;
  z-index: 1;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  color: var(--green);
  background: var(--cream);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}
.horse-card-content p { margin: .5rem 0 1rem; color: var(--muted); font-size: .85rem; }
.select-horse {
  width: 100%;
  min-height: 2.8rem;
  border: 0;
  padding: .7rem 1rem;
  color: white;
  background: var(--green);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.note { margin: .8rem 0 0; color: var(--muted); font-size: .83rem; }

.about,
.contact { display: grid; grid-template-columns: .8fr 1.2fr; gap: clamp(3rem, 8vw, 8rem); }
.about { max-width: none; padding-inline: max(2rem, calc((100vw - 1200px) / 2)); background: var(--cream); }
.original-text { border-top: 1px solid var(--line); }
.original-text p { margin: 0; padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.original-text a { text-underline-offset: .2em; }

.gallery {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 8vw;
  gap: clamp(.45rem, 1vw, 1rem);
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 4rem);
  background: white;
}
.gallery img {
  height: 100%;
  min-height: 0;
  border-radius: .25rem;
  object-fit: cover;
}
.gallery img:nth-child(1) { grid-column: 1 / span 4; grid-row: 1 / span 3; }
.gallery img:nth-child(2) { grid-column: 5 / span 4; grid-row: 1 / span 5; }
.gallery img:nth-child(3) { grid-column: 9 / span 4; grid-row: 1 / span 4; }
.gallery img:nth-child(4) { grid-column: 1 / span 4; grid-row: 4 / span 5; }
.gallery img:nth-child(5) { grid-column: 5 / span 4; grid-row: 6 / span 5; }
.gallery img:nth-child(6) { grid-column: 9 / span 4; grid-row: 5 / span 3; }
.gallery img:nth-child(7) { grid-column: 9 / span 4; grid-row: 8 / span 3; }
.gallery img:nth-child(8) { grid-column: 1 / span 4; grid-row: 9 / span 2; }

.contact address { font-style: normal; font-size: 1.1rem; }
.contact address a { font-weight: 700; }

dialog {
  width: min(96vw, 900px);
  max-height: 96vh;
  overflow-y: auto;
  border: 0;
  padding: .8rem;
  background: #f8f5eb;
  box-shadow: 0 1.5rem 4rem rgba(6, 18, 14, .4);
}
dialog::backdrop { background: rgba(15, 24, 20, .72); }
#certificate-dialog { position: relative; }
.dialog-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  color: var(--green);
  background: var(--cream);
  font: 2rem/1 Arial, sans-serif;
  cursor: pointer;
}
.dialog-close:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.certificate {
  min-height: 590px;
  padding: .75rem;
  text-align: center;
  background:
    linear-gradient(rgba(249, 244, 228, .94), rgba(249, 244, 228, .94)),
    repeating-linear-gradient(45deg, rgba(38, 64, 54, .06) 0 1px, transparent 1px 8px);
}
.certificate-frame {
  position: relative;
  min-height: 565px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid #a98842;
  padding: 3.5rem clamp(2rem, 7vw, 5.5rem) 2.6rem;
  box-shadow:
    inset 0 0 0 .5rem #f8f1dc,
    inset 0 0 0 calc(.5rem + 1px) #a98842,
    inset 0 0 3rem rgba(72, 54, 20, .08);
}
.certificate-frame::before,
.certificate-frame::after {
  content: "";
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid #a98842;
  transform: rotate(45deg);
}
.certificate-frame::before { top: 1.15rem; left: 1.15rem; }
.certificate-frame::after { right: 1.15rem; bottom: 1.15rem; }
.certificate-label {
  margin: 0 0 1.25rem;
  color: #b05c3c;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.certificate-intro { margin: 0; color: #4f5a52; font-family: Georgia, "Times New Roman", serif; font-size: 1.02rem; font-style: italic; }
.certificate h2 {
  margin: .45rem 0 .65rem;
  color: #1d312a;
  font-size: clamp(2.5rem, 7vw, 4.7rem);
  line-height: 1;
}
.certificate-divider {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: min(19rem, 70%);
  margin: .5rem 0 1rem;
}
.certificate-divider::before,
.certificate-divider::after { content: ""; flex: 1; height: 1px; background: #a98842; }
.certificate-divider span {
  width: .55rem;
  height: .55rem;
  border: 1px solid #a98842;
  transform: rotate(45deg);
}
.certificate h3 {
  margin: .5rem 0 2.5rem;
  color: #9f4e34;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 6vw, 4.4rem);
  font-weight: 400;
  line-height: 1.05;
}
.certificate-footer {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: end;
  margin-top: auto;
  color: var(--green);
  font-size: .78rem;
}
.certificate-footer > div { display: flex; flex-direction: column; align-items: flex-start; }
.certificate-footer strong { letter-spacing: .02em; }
.certificate-footer p { margin: 0; text-align: right; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .75rem; padding-top: 1rem; }
.dialog-actions button {
  border: 0;
  padding: .85rem 1.2rem;
  color: white;
  background: var(--green);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem max(2rem, calc((100vw - 1200px) / 2));
  color: white;
  background: var(--green);
  font-size: .85rem;
}
footer p { margin: 0; }
.regional-support {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.regional-support span { color: rgba(255, 255, 255, .78); }
.supporter-logos {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.supporter-logos a {
  display: block;
  padding: .45rem .65rem;
  border-radius: .2rem;
  background: white;
}
.supporter-logos .region-karlovy { width: 9.5rem; }
.supporter-logos .region-sadov { width: 4.3rem; padding: .35rem; }
.supporter-logos img { display: block; width: 100%; height: auto; }
.supporter-logos .region-sadov img { max-height: 5.6rem; object-fit: contain; }

@media (max-width: 760px) {
  header { width: 100%; padding: 1rem 1.25rem; }
  nav a:not(:last-child) { display: none; }
  .hero { min-height: max(680px, 92svh); }
  .hero::before {
    background:
      linear-gradient(90deg, rgba(18, 43, 34, .91) 0%, rgba(18, 43, 34, .64) 66%, rgba(18, 43, 34, .2) 100%),
      linear-gradient(0deg, rgba(12, 28, 23, .58) 0%, transparent 48%);
  }
  .hero-text { width: 100%; margin: 0; padding: 8.5rem 1.25rem 5rem; }
  .hero h1 { max-width: 9ch; font-size: clamp(3.35rem, 15vw, 5rem); }
  .hero img { object-position: 68% 42%; }
  .adoption { grid-template-columns: 1fr; gap: 1rem; padding: 2.5rem 1.25rem; }
  .horses, .about, .contact { padding: 4.5rem 1.25rem; }
  .horse-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
  .horse-card, .horse-card:nth-child(4), .horse-card:nth-child(5) { grid-column: auto; }
  .horse-card:nth-child(5) { grid-column: 1 / -1; width: calc((100% - .85rem) / 2); justify-self: center; }
  .horse-photo { height: clamp(16rem, 42vw, 20rem); }
  .about, .contact { grid-template-columns: 1fr; }
  .horse-card-content { padding: 1rem; }
  .horse-card-content h3 { font-size: 1.55rem; }
  .horse-qr { width: min(100%, 8rem); }
  .gallery { display: block; padding: .5rem; }
  .gallery img { width: 100%; height: auto; margin-bottom: .5rem; border-radius: 0; }
  dialog { width: 96vw; padding: .35rem; }
  .certificate { min-height: 500px; padding: .45rem; }
  .certificate-frame { min-height: 480px; padding: 1.8rem 1.4rem 1.5rem; }
  .certificate-label { margin-bottom: .8rem; }
  .certificate h2 { font-size: clamp(2.35rem, 10vw, 3.2rem); }
  .certificate h3 { margin-bottom: 1.2rem; font-size: clamp(2.2rem, 9vw, 3rem); }
  .certificate-footer { grid-template-columns: 1fr; gap: 1rem; }
  .certificate-footer p { text-align: left; }
  .dialog-actions { flex-direction: column; }
  footer { display: grid; padding: 1.5rem 1.25rem; }
  .regional-support { align-items: flex-start; flex-direction: column; gap: .6rem; }
  .supporter-logos { align-items: flex-start; }
}

@media (max-width: 540px) {
  .horse-cards { grid-template-columns: 1fr; gap: 1rem; }
  .horse-card:nth-child(5) { grid-column: auto; width: auto; }
  .horse-photo { height: clamp(19rem, 88vw, 25rem); }
  .horse-card-content { padding: 1.15rem; }
  .horse-card-content h3 { font-size: 1.8rem; }
  .horse-qr { width: 9rem; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body > *:not(dialog) { display: none !important; }
  dialog {
    position: static;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }
  .dialog-actions { display: none; }
  .certificate { min-height: 180mm; padding: 0; }
  .certificate-frame { min-height: 180mm; }
}

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