/* PH: continuous paper, consistent margins, original illustrations. */
@media screen {
  body.ph-kreslene-menu.ph-visual-polish {
    --ph-polish-width: min(1400px, calc(var(--phkm-viewport-width, 100vw) - 96px));
    --phkm-page-width: var(--ph-polish-width) !important;
    --ph-wide-width: var(--ph-polish-width) !important;
    --ph-polish-inset: 32px;
  }

  body.ph-visual-polish #wrapper {
    position: relative;
    z-index: 1;
    isolation: isolate;
    background: transparent !important;
  }
  body.ph-visual-polish #wrapper::before {
    content: "";
    display: block;
    position: absolute;
    z-index: -1;
    pointer-events: none;
    top: 18px;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: var(--ph-polish-width);
    box-sizing: border-box;
    background: #f8f3e7 url("/wp-content/plugins/ph-visual-polish/assets/paper.svg") center top / 1800px 1000px repeat;
    border-inline: 1px solid #73664730;
    box-shadow: 0 8px 28px #43372512;
    outline: none;
  }
  body.ph-visual-polish .phbp-canvas { --phbp-frame-width: var(--ph-polish-width); }

  /* The substrate belongs to the outer sheet, not to nested template wrappers. */
  body.ph-visual-polish #wrapper :is(#inner-wrap, #primary, #main.site-main, .content-container, .content-wrap, article.single-entry, .entry-content-wrap, .entry-content) {
    background: transparent !important;
    box-shadow: none !important;
  }
  body.ph-visual-polish:not(.home) #wrapper #inner-wrap .content-container {
    width: var(--ph-polish-width) !important;
    max-width: none !important;
    padding-inline: 0 !important;
    margin-inline: auto !important;
  }

  /* One illustrated header. Feather only the paper's outer perimeter. */
  body.ph-visual-polish #wrapper #masthead.phkm-standalone-header {
    width: var(--ph-polish-width) !important;
    margin: 18px auto 0 !important;
    padding: 22px var(--ph-polish-inset) 18px !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  body.ph-visual-polish #wrapper .ph-home-board-v146 {
    width: var(--ph-polish-width) !important;
    max-width: none !important;
    margin-top: 18px !important;
    margin-bottom: 0 !important;
    padding-inline: var(--ph-polish-inset) !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  body.ph-visual-polish #wrapper #masthead.phkm-standalone-header::before,
  body.ph-visual-polish #wrapper .ph-home-board-v146 #masthead::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    z-index: -1;
    pointer-events: none;
    inset: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    width: auto !important;
    height: auto !important;
    background: transparent url("/wp-content/plugins/ph-kreslene-menu/assets/media/ph-paper-header-v146.webp") center top / 100% auto no-repeat !important;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 20px, #000 calc(100% - 20px), transparent), linear-gradient(to bottom, #000 75%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to right, transparent, #000 20px, #000 calc(100% - 20px), transparent), linear-gradient(to bottom, #000 75%, transparent);
    mask-composite: intersect;
  }
  body.ph-visual-polish #wrapper .ph-home-board-v146 #masthead::before {
    inset: -22px calc(-1 * var(--ph-polish-inset)) -18px !important;
  }

  /* Consistent horizontal rhythm on every existing page template. */
  body.ph-visual-polish #wrapper #inner-wrap :is(.ph-realizace-page, #ph-rady.ph-rady-dossier, .ph-city-shell, #main.ph-contact-dossier, .ph-partners-page, #ph-masterpieces.phmp-dossier, .pht2) {
    width: var(--ph-polish-width) !important;
    max-width: none !important;
    margin-left: calc(50% - var(--ph-polish-width) / 2) !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  body.ph-visual-polish #wrapper :is(.ph-realizace-page, #ph-rady.ph-rady-dossier, #main.ph-contact-dossier, #ph-masterpieces.phmp-dossier)::before,
  body.ph-visual-polish #wrapper :is(.ph-realizace-page, #ph-rady.ph-rady-dossier, #main.ph-contact-dossier, #ph-masterpieces.phmp-dossier)::after {
    content: none !important;
    display: none !important;
  }

  /* Existing chapter rules are enough; stop repeating the header drawing. */
  body.ph-visual-polish #wrapper .phc-hero,
  body.ph-visual-polish #wrapper .ph-realizace-page > .ph-realizace-intro,
  body.ph-visual-polish #wrapper #ph-rady.ph-rady-dossier > .ph-intro,
  body.ph-visual-polish #wrapper .ph-city-shell .phr-page {
    background: transparent !important;
  }
  body.ph-visual-polish #wrapper #ph-masterpieces .phmp-dossier-hero::after,
  body.ph-visual-polish #wrapper .pht2 .pht2-intro {
    background: transparent !important;
  }
  body.ph-visual-polish #wrapper .ph-partners-page {
    box-sizing: border-box;
    padding: 32px var(--ph-polish-inset) 40px;
  }

  /* City artwork keeps its complete composition and has no empty side columns. */
  body.ph-visual-polish.ph-city-active #wrapper .phr-hero {
    margin: 0;
    padding: 0;
    background: transparent !important;
    border-bottom: 4px solid #f5b400;
  }
  body.ph-visual-polish.ph-city-active #wrapper .phr-hero img {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    object-fit: contain !important;
    transform: none !important;
  }
  body.ph-visual-polish.ph-city-active #wrapper .ph-city-shell {
    margin-bottom: 0 !important;
    overflow: hidden;
  }
  body.ph-visual-polish.ph-city-active #wrapper > #inner-wrap > #ph-poptavka,
  body.ph-visual-polish.ph-city-active #wrapper #inner-wrap > .phif-section {
    box-sizing: border-box;
    width: var(--ph-polish-width) !important;
    margin: 0 auto !important;
    background: transparent !important;
    padding-top: 64px;
  }

  /* Restore the continuous home paper where later legacy patches painted panels. */
  body.ph-visual-polish.home #wrapper #post-12 :is(.ph-clean-paper-v145, .ph-partner-mat-v145, .ph-partner-sheet-v145, .ph-home-regions) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  body.ph-visual-polish #wrapper :is(a, button, summary, input, select, textarea):focus-visible {
    outline: 3px solid #216d8d !important;
    outline-offset: 4px;
  }
  body.ph-visual-polish #wrapper #masthead .phkm-phtube-item:is(.current-menu-item, .current_page_item) .phkm-phtube-label b,
  body.ph-visual-polish #wrapper #masthead a:is([aria-current="page"], .is-current, :hover, :focus-visible) .phkm-phtube-label b {
    color: #151513 !important;
  }
}
@media screen and (min-width: 781px) and (max-width: 1100px) {
  body.ph-kreslene-menu.ph-visual-polish {
    --ph-polish-width: calc(var(--phkm-viewport-width, 100vw) - 48px);
    --ph-polish-inset: 24px;
  }
}
@media screen and (max-width: 780px) {
  body.ph-kreslene-menu.ph-visual-polish {
    --ph-polish-width: calc(var(--phkm-viewport-width, 100vw) - 32px);
    --ph-polish-inset: 16px;
  }
  body.ph-visual-polish #wrapper::before { top: 5px; box-shadow: 0 5px 16px #4337250d; }
  body.ph-visual-polish #wrapper #masthead.phkm-standalone-header {
    margin-top: 5px !important;
    padding: 12px var(--ph-polish-inset) 14px !important;
  }
  body.ph-visual-polish #wrapper .ph-home-board-v146 {
    margin-top: 5px !important;
    padding: 12px var(--ph-polish-inset) 14px !important;
  }
  body.ph-visual-polish #wrapper .ph-home-board-v146 #masthead::before {
    inset: -12px calc(-1 * var(--ph-polish-inset)) -14px !important;
  }
  body.ph-visual-polish #wrapper .ph-partners-page { padding-top: 24px; }
}
