/* ==========================================================================
   Vlastní typografie a pergamenový styl pro Dlouhomilov Wiki
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700;800;900&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,800;1,400;1,600&display=swap');

:root {
  --bg-parchment: #fcf9f2;
  --border-parchment: #e7dfcc;
  --ink-primary: #1c1917;
  --ink-secondary: #57534e;
  --accent-amber: #92400e;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #fdfbf7;
  color: var(--ink-primary);
}

.font-heading {
  font-family: 'Cinzel', Georgia, serif;
}

.font-serif-body {
  font-family: 'Playfair Display', Georgia, serif;
}

/* Pergamenový efekt karet */
.parchment-card {
  background-color: #ffffff;
  background-image: radial-gradient(#fcf8ed 1px, transparent 1px), radial-gradient(#faf5e4 1px, #ffffff 1px);
  background-size: 40px 40px;
  background-position: 0 0, 20px 20px;
  border-color: var(--border-parchment);
  box-shadow: 0 4px 15px -2px rgba(120, 53, 15, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.parchment-card:hover {
  box-shadow: 0 10px 25px -3px rgba(120, 53, 15, 0.08), 0 4px 10px -2px rgba(0, 0, 0, 0.04);
}

/* Značka domu na mapě */
.custom-house-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #92400e;
  color: #ffffff;
  font-weight: 800;
  font-size: 11px;
  border-radius: 9999px;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-house-marker:hover {
  transform: scale(1.22) translateY(-2px);
  background-color: #78350f;
  z-index: 1000 !important;
}

.custom-house-marker.featured {
  background-color: #b91c1c;
  border-color: #fef08a;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.3), 0 4px 12px rgba(0, 0, 0, 0.4);
  font-size: 13px;
}

.custom-house-marker.active {
  background-color: #1e3a8a !important;
  border-color: #93c5fd !important;
  transform: scale(1.3) translateY(-3px);
  box-shadow: 0 0 0 4px rgba(30, 58, 138, 0.4), 0 6px 16px rgba(0, 0, 0, 0.45);
  z-index: 1000 !important;
}

/* Stylizované polygony budov na mapě */
.building-polygon-1834-masonry {
  stroke-dasharray: none;
  transition: all 0.25s ease;
  cursor: pointer;
}
.building-polygon-1834-masonry:hover {
  fill: #ef4444 !important;
  fill-opacity: 0.9 !important;
  stroke: #7f1d1d !important;
  stroke-width: 3.5px !important;
}

.building-polygon-1834-wooden {
  stroke-dasharray: 4 2;
  transition: all 0.25s ease;
  cursor: pointer;
}
.building-polygon-1834-wooden:hover {
  fill: #fbbf24 !important;
  fill-opacity: 0.9 !important;
  stroke: #78350f !important;
  stroke-width: 3px !important;
}

.building-polygon-modern {
  transition: all 0.25s ease;
  cursor: pointer;
}
.building-polygon-modern:hover {
  fill: #3b82f6 !important;
  fill-opacity: 0.65 !important;
  stroke: #1e40af !important;
  stroke-width: 3.5px !important;
}

.building-label-icon {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #78350f;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  color: #78350f;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  pointer-events: none;
}

/* Animace pulzujícího vybraného stavení */
@keyframes buildingPulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(185, 28, 28, 0.7)); }
  50% { transform: scale(1.04); filter: drop-shadow(0 0 12px rgba(220, 38, 38, 0.9)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(185, 28, 28, 0.7)); }
}

.building-highlight-active {
  animation: buildingPulse 2s infinite ease-in-out;
  stroke: #fef08a !important;
  stroke-width: 4px !important;
}

/* Přepis archivních textů */
.transcription-box {
  background-color: #fcf9ee;
  border-left: 3px solid #b45309;
  font-family: 'Playfair Display', Georgia, serif;
}

/* Grafická časová osa */
.timeline-era-bar {
  display: flex;
  width: 100%;
  height: 26px;
  border-radius: 9999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
  font-weight: 700;
  text-align: center;
  line-height: 26px;
  color: white;
}

.era-monarchy { background: linear-gradient(90deg, #78350f, #92400e); }
.era-dualism { background: linear-gradient(90deg, #9a3412, #c2410c); }
.era-csr { background: linear-gradient(90deg, #1e3a8a, #2563eb); }
.era-modern { background: linear-gradient(90deg, #065f46, #059669); }

.visual-timeline-nodes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.visual-timeline-card {
  background: white;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 12px 14px;
  position: relative;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.visual-timeline-card:hover {
  transform: translateY(-2px);
  border-color: #f97316;
  box-shadow: 0 6px 14px rgba(249, 115, 22, 0.12);
}

/* Modální okno Archivního prohlížeče (Lightbox) */
.archive-viewer-backdrop {
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
}

.archive-scan-container {
  overflow: auto;
  max-height: calc(85vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #1e293b;
  border-radius: 12px;
  cursor: grab;
}

.archive-scan-container:active {
  cursor: grabbing;
}

.archive-scan-img {
  transition: transform 0.2s ease-out;
  transform-origin: center center;
  max-width: 100%;
  height: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Tiskové úpravy */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  header, #map, .no-print, button, input, .blend-control-panel {
    display: none !important;
  }
  #house-detail-container {
    display: block !important;
    width: 100% !important;
  }
  .parchment-card {
    box-shadow: none !important;
    border: 1px solid #cccccc !important;
    background: #ffffff !important;
  }
}

/* Side-by-Side a GCP kalibrační styly */
.gcp-marker-ref {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #0284c7;
  color: #ffffff;
  font-weight: 800;
  font-size: 11px;
  border-radius: 9999px;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.4), 0 4px 10px rgba(0,0,0,0.3);
  cursor: pointer;
  animation: pulseBlue 2s infinite;
}

.gcp-marker-hist {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #dc2626;
  color: #ffffff;
  font-weight: 800;
  font-size: 11px;
  border-radius: 9999px;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.4), 0 4px 10px rgba(0,0,0,0.3);
  cursor: pointer;
  animation: pulseRed 2s infinite;
}

@keyframes pulseBlue {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes pulseRed {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ==========================================================================
   Komiksová kronika údolí (Hybridní ilustrace + HTML/CSS bubliny)
   ========================================================================== */

.comic-page-sheet {
  background: linear-gradient(180deg, #fffdf8 0%, #fcf7eb 100%);
  border: 2px solid #78350f;
  border-radius: 18px;
  box-shadow: 0 12px 28px -6px rgba(69, 26, 3, 0.14), inset 0 0 0 4px #fef3c7;
  padding: 20px;
  position: relative;
}

.comic-panel-card {
  background: #ffffff;
  border: 3px solid #292524;
  border-radius: 12px;
  box-shadow: 5px 5px 0px #451a03;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.comic-panel-card:hover {
  transform: translateY(-3px);
  box-shadow: 7px 8px 0px #78350f;
}

.comic-narrator-box {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-bottom: 2.5px solid #292524;
  padding: 10px 14px;
  font-family: 'Merriweather', 'Playfair Display', Georgia, serif;
  font-size: 12.5px;
  line-height: 1.5;
  color: #1c1917;
  position: relative;
}

.comic-artwork-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background-color: #292524;
  overflow: hidden;
}

.comic-artwork-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.comic-panel-card:hover .comic-artwork-stage img {
  transform: scale(1.025);
}

/* Dialogové bubliny přímo nad ilustrací nebo v dialogovém pásu */
.comic-bubbles-layer {
  background: #faf5e8;
  border-top: 2.5px solid #292524;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .comic-bubbles-layer.two-bubbles {
    grid-template-columns: 1fr 1fr;
  }
}

.comic-speech-bubble {
  position: relative;
  background: #ffffff;
  border: 2px solid #1c1917;
  border-radius: 16px;
  padding: 9px 12px;
  box-shadow: 2px 3px 0px rgba(28, 25, 23, 0.85);
  font-size: 12px;
  line-height: 1.42;
  color: #1c1917;
}

.comic-speech-bubble::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 18px;
  border-width: 0 8px 9px;
  border-style: solid;
  border-color: #1c1917 transparent;
  display: block;
  width: 0;
}

.comic-speech-bubble::after {
  content: "";
  position: absolute;
  top: -6px;
  left: 20px;
  border-width: 0 6px 7px;
  border-style: solid;
  border-color: #ffffff transparent;
  display: block;
  width: 0;
}

.comic-speech-bubble.bubble-right::before {
  left: auto;
  right: 18px;
}

.comic-speech-bubble.bubble-right::after {
  left: auto;
  right: 20px;
}

.comic-speaker-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #92400e;
  margin-bottom: 2px;
}

/* Tisk komiksu (brožura A4) */
@media print {
  body.printing-comic header,
  body.printing-comic #mapa-section,
  body.printing-comic #atlas-map-section,
  body.printing-comic #obyvatele-section,
  body.printing-comic #badatelsky-pruvodce,
  body.printing-comic footer,
  body.printing-comic #story-stats-grid,
  body.printing-comic #story-toc-container,
  body.printing-comic #story-chapters-wrapper,
  body.printing-comic #story-facts-wrapper,
  body.printing-comic .comic-no-print {
    display: none !important;
  }
  body.printing-comic #pribeh-section,
  body.printing-comic #story-comic-wrapper {
    display: block !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-comic .comic-page-sheet {
    page-break-after: always;
    break-after: page;
    box-shadow: none !important;
    border: 2px solid #000 !important;
    margin-bottom: 16px;
  }
}


/* ==========================================================================
   Mobilní responzivita (Mobile-First vylepšení, tabulky -> karty, mapa, lišty)
   ========================================================================== */

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Skrytí posuvníku u horizontálně posuvných mobilních lišt */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Responzivní výška interaktivní mapy */
#map,
#map-hist {
  height: 360px !important;
  z-index: 10;
}

@media (min-width: 640px) {
  #map,
  #map-hist {
    height: 460px !important;
  }
}

@media (min-width: 1024px) {
  #map,
  #map-hist {
    height: 600px !important;
  }
}

/* Mobilní úpravy komiksu a časové osy */
@media (max-width: 639px) {
  .comic-page-sheet {
    padding: 12px;
    border-radius: 14px;
  }

  .visual-timeline-nodes {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .timeline-era-bar {
    height: 22px;
    line-height: 22px;
    font-size: 9px;
  }

  /* Převod širokých datových tabulek na přehledné čitelné karty na telefonech */
  table.mobile-responsive-table {
    display: block;
    width: 100%;
  }

  table.mobile-responsive-table thead {
    display: none;
  }

  table.mobile-responsive-table tbody {
    display: block;
    width: 100%;
    padding: 8px;
    background-color: #fdfbf7;
  }

  table.mobile-responsive-table tbody tr {
    display: block;
    background-color: #ffffff;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(120, 53, 15, 0.06);
  }

  table.mobile-responsive-table tbody tr:last-child {
    margin-bottom: 0;
  }

  table.mobile-responsive-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 5px 0 !important;
    border-bottom: 1px dashed #fef3c7;
    text-align: right;
    max-width: none !important;
    white-space: normal !important;
  }

  table.mobile-responsive-table tbody td:first-child {
    display: block;
    text-align: left;
    padding-top: 0 !important;
    padding-bottom: 8px !important;
    margin-bottom: 4px;
    border-bottom: 1px solid #fde68a;
    font-size: 13px;
  }

  table.mobile-responsive-table tbody td:last-child {
    border-bottom: none;
    padding-bottom: 0 !important;
  }

  table.mobile-responsive-table tbody td[data-label]::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #78350f;
    text-align: left;
    flex-shrink: 0;
    max-width: 42%;
  }

  table.mobile-responsive-table tbody td.mobile-stack-cell {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 4px;
  }

  table.mobile-responsive-table tbody td.mobile-stack-cell[data-label]::before {
    max-width: 100%;
  }
}
