/* Laptop — większe strefy kliknięcia na pierwszym rozwidleniu lasu.
   Tylko precyzyjny kursor i szerokości typowe dla laptopa. */
@media (min-width: 601px) and (max-width: 1600px) and (hover: hover) and (pointer: fine) {
  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty .droga-do-archiwum {
    display: block !important;
    position: fixed !important;
    left: 11% !important;
    top: 51% !important;
    width: 28vw !important;
    height: 24vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 30000 !important;
    pointer-events: auto !important;
  }

  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty .droga-do-redakcji {
    display: block !important;
    position: fixed !important;
    left: 94% !important;
    top: 55% !important;
    width: 22vw !important;
    height: 26vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 30000 !important;
    pointer-events: auto !important;
  }

  /* Archiwum — laptop. TOM I–V zatwierdzone. */
  body.archiwum-aktywne .tom1-archiwum,
  body.archiwum-aktywne .tom2-archiwum,
  body.archiwum-aktywne .tom3-archiwum,
  body.archiwum-aktywne .tom4-archiwum,
  body.archiwum-aktywne .tom5-archiwum,
  body.archiwum-aktywne .tom6-archiwum,
  body.archiwum-aktywne .tom7-archiwum,
  body.archiwum-aktywne .tom8-archiwum,
  body.archiwum-aktywne .tom9-archiwum,
  body.archiwum-aktywne .tom10-archiwum,
  body.archiwum-aktywne .tom11-archiwum,
  body.archiwum-aktywne .tom12-archiwum {
    display: block !important;
    position: fixed !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    cursor: pointer !important;
    z-index: 30000 !important;
    pointer-events: auto !important;
  }

  /* TOM I — książka trzymana przez skrzata. */
  body.archiwum-aktywne .tom1-archiwum {
    left: 36.8% !important;
    top: 30% !important;
    width: 4.6% !important;
    height: 27% !important;
  }

  /* TOM II–V — zatwierdzone pozycje. */
  body.archiwum-aktywne .tom2-archiwum  { left: 42.2% !important; top: 38% !important; width: 2.1% !important; height: 24% !important; }
  body.archiwum-aktywne .tom3-archiwum  { left: 44.2% !important; top: 38% !important; width: 2.4% !important; height: 24% !important; }
  body.archiwum-aktywne .tom4-archiwum  { left: 47.9% !important; top: 38% !important; width: 2.4% !important; height: 24% !important; }
  body.archiwum-aktywne .tom5-archiwum  { left: 51.6% !important; top: 38% !important; width: 2.4% !important; height: 24% !important; }

  /* TOM VI–XII — skalibrowane z widocznych ramek na screenie użytkownika. */
  body.archiwum-aktywne .tom6-archiwum  { left: 53.6% !important; top: 38% !important; width: 2.2% !important; height: 24% !important; }
  body.archiwum-aktywne .tom7-archiwum  { left: 56.4% !important; top: 38% !important; width: 2.2% !important; height: 24% !important; }
  body.archiwum-aktywne .tom8-archiwum  { left: 59.3% !important; top: 38% !important; width: 2.2% !important; height: 24% !important; }
  body.archiwum-aktywne .tom9-archiwum  { left: 62.2% !important; top: 38% !important; width: 2.2% !important; height: 24% !important; }
  body.archiwum-aktywne .tom10-archiwum { left: 65.0% !important; top: 38% !important; width: 2.2% !important; height: 24% !important; }
  body.archiwum-aktywne .tom11-archiwum { left: 67.8% !important; top: 38% !important; width: 2.2% !important; height: 24% !important; }
  body.archiwum-aktywne .tom12-archiwum { left: 70.6% !important; top: 38% !important; width: 2.2% !important; height: 24% !important; }

  /* Archiwum — pióro powrotu do lasu na laptopie. */
  body.archiwum-aktywne .powrot-z-archiwum {
    display: block !important;
    position: fixed !important;
    left: 61% !important;
    top: 83% !important;
    width: 24vw !important;
    height: 22vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 40000 !important;
    pointer-events: auto !important;
  }

  /* Redakcja — Zapis 23: tylko właściwy pergamin, bez kałamarza obok. */
  body.wnetrze-redakcji-aktywne .pergamin-redakcji {
    display: block !important;
    position: fixed !important;
    left: 50% !important;
    top: 61% !important;
    width: 18vw !important;
    height: 18vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 35000 !important;
    pointer-events: auto !important;
  }

  /* Redakcja — powrót do Archiwum na szyldzie KRONIKARZ LASU. */
  body.wnetrze-redakcji-aktywne .powrot-do-lasu-z-redakcji {
    display: block !important;
    position: fixed !important;
    left: 81% !important;
    top: 17% !important;
    width: 24vw !important;
    height: 18vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 36000 !important;
    pointer-events: auto !important;
  }

  /* Nowe, osobne wyjście z Redakcji do Lasu. */
  .powrot-do-lasu-z-redakcji-pioro {
    display: none !important;
  }

  body.wnetrze-redakcji-aktywne .powrot-do-lasu-z-redakcji-pioro {
    display: block !important;
    position: fixed !important;
    left: 78.5% !important;
    top: 55% !important;
    width: 7vw !important;
    height: 21vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) rotate(22deg) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 40000 !important;
    pointer-events: auto !important;
  }

  /* Na planszy Pomysły to samo miejsce należy do powrotu Pomysły -> Redakcja. */
  body.wnetrze-redakcji-aktywne.pomysly-redakcja-aktywne .powrot-do-lasu-z-redakcji-pioro {
    display: none !important;
    pointer-events: none !important;
  }

  /* Na planszy Zapisy pióro Redakcja -> Las nie może przykrywać właściwego powrotu. */
  body.wnetrze-redakcji-aktywne.tom8-redakcja-aktywny .powrot-do-lasu-z-redakcji-pioro {
    display: none !important;
    pointer-events: none !important;
  }

  /* Zapisy w trakcie — istniejący powrót do Redakcji ponad warstwami laptopa. */
  body.tom8-redakcja-aktywny .powrot-z-tom8 {
    z-index: 41000 !important;
    pointer-events: auto !important;
  }

  /* Laptop — właściwe przypisanie zatwierdzonych pól: Szkice=TOM VII, Zapisy=TOM VIII. */
  body.wnetrze-redakcji-aktywne .tom7-redakcja {
    left: 40.5% !important;
    top: 46% !important;
    width: 8% !important;
    height: 11% !important;
    z-index: 61 !important;
  }

  body.wnetrze-redakcji-aktywne .tom8-redakcja {
    left: 51% !important;
    top: 47% !important;
    width: 13% !important;
    height: 11% !important;
    z-index: 62 !important;
  }

  /* MAC — TOM VII: tylko pozycja hotspotu „Powrót do Archiwum”. */
  body.otwarty-tom
  .tom-panel[data-panel-tom="7"].aktywny
  .powrot-archiwum-hotspot {
    top: 27% !important;
  }

  /* MAC — TOM VIII: tylko pozycja hotspotu „Powrót do Archiwum”. */
  body.otwarty-tom
  .tom-panel[data-panel-tom="8"].aktywny
  .powrot-archiwum-hotspot {
    top: 29% !important;
  }

}

/* MAC / duży desktop — droga do Archiwum tylko na neutralnym rozwidleniu lasu. */
@media (width > 1600px) and (hover: hover) and (pointer: fine) {
  .droga-do-archiwum {
    display: none !important;
    pointer-events: none !important;
  }

  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty .droga-do-archiwum {
    display: block !important;
    position: fixed !important;
    left: 11% !important;
    top: 51% !important;
    width: 28vw !important;
    height: 24vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 30000 !important;
    pointer-events: auto !important;
  }
}

/* MAC / large desktop — preserve the calibrated Redakcja -> Las feather.
   Only the plain interior owns this target; overlays use their own returns. */
@media (width > 1600px) and (hover: hover) and (pointer: fine) {
  body.wnetrze-redakcji-aktywne:not(.pergamin-redakcji-aktywny):not(.tom7-redakcja-aktywny):not(.tom8-redakcja-aktywny):not(.pomysly-redakcja-aktywne):not(.otwarty-tom):not(.otwarty-zapis)
  .powrot-do-lasu-z-redakcji-pioro {
    display: block !important;
    position: fixed !important;
    left: 78.5% !important;
    top: 55% !important;
    width: 7vw !important;
    height: 21vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) rotate(22deg) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 40000 !important;
    pointer-events: auto !important;
  }
}

/* MAC / large desktop — right road only on the neutral forest fork. */
@media (width > 1600px) and (hover: hover) and (pointer: fine) {
  .droga-do-redakcji {
    display: none !important;
    pointer-events: none !important;
  }

  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty .droga-do-redakcji {
    display: block !important;
    position: fixed !important;
    left: 94% !important;
    top: 55% !important;
    width: 22vw !important;
    height: 26vh !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 30000 !important;
    pointer-events: auto !important;
  }
}

/* MAC — Zapisy overlay owns its return; the plain interior Archive sign
   must not receive clicks through the upper book area of this scene. */
@media (min-width: 601px) and (hover: hover) and (pointer: fine) {
  body.wnetrze-redakcji-aktywne.tom8-redakcja-aktywny
  .powrot-do-lasu-z-redakcji {
    display: none !important;
    pointer-events: none !important;
  }

  /* Contain-relative target on the feather only: source image rectangle
     x=1168..1456, y=688..752 in the 1536 × 1024 scene. */
  body.wnetrze-redakcji-aktywne.tom8-redakcja-aktywny .powrot-z-tom8 {
    --zapisy-image-width: min(100vw, calc(100vh * 1536 / 1024));
    --zapisy-image-height: min(100vh, calc(100vw * 1024 / 1536));
    display: block !important;
    position: fixed !important;
    left: calc(50vw + var(--zapisy-image-width) * 0.3541666667) !important;
    top: calc(50vh + var(--zapisy-image-height) * 0.203125) !important;
    width: calc(var(--zapisy-image-width) * 0.1875) !important;
    height: calc(var(--zapisy-image-height) * 0.0625) !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translate(-50%, -50%) !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    z-index: 41000 !important;
    pointer-events: auto !important;
  }
}

/* Desktop-pointer crossroads: existing targets centred on the approved
   feathers in the unchanged 1672 x 941 contain scene. */
@media (min-width: 601px) and (hover: hover) and (pointer: fine) {
  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty :is(.droga-do-archiwum, .droga-do-redakcji) {
    --crossroads-hit-width: min(100vw, calc(100vh * 1672 / 941));
    --crossroads-hit-height: min(100vh, calc(100vw * 941 / 1672));
    /* 96px minimum; grow with the scene to cover the rotated feather + margin. */
    width: max(96px, calc(var(--crossroads-hit-width) * 0.08)) !important;
    height: max(96px, calc(var(--crossroads-hit-width) * 0.08)) !important;
  }

  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty .droga-do-archiwum {
    /* Match the existing left feather centre; the image itself does not move. */
    left: calc(50vw + var(--crossroads-hit-width) * -0.3863636364) !important;
    top: calc(50vh + var(--crossroads-hit-height) * 0.2247608927 - var(--crossroads-hit-width) * 0.0418660287) !important;
  }

  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty .droga-do-redakcji {
    /* Match the existing right feather centre. */
    left: calc(50vw + var(--crossroads-hit-width) * 0.3612440191) !important;
    top: calc(50vh + var(--crossroads-hit-height) * 0.1780021254) !important;
  }

  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty > :is(.mac-crossroads-left-feather, .mac-crossroads-right-feather) {
    transition: filter 0.18s ease;
  }

  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty:has(.droga-do-archiwum:is(:hover, :focus-visible)) > .mac-crossroads-left-feather,
  body:not([class*="aktyw"]):not(.otwarty-tom):not(.otwarty-zapis)
  .wejscie.otwarty:has(.droga-do-redakcji:is(:hover, :focus-visible)) > .mac-crossroads-right-feather {
    filter: brightness(1.12) drop-shadow(0 0 3px rgba(244, 225, 167, 0.28));
  }
}

/* Desktop-pointer — Redakcja active-language pass.
   No crossroads selectors here. Active targets use a restrained brightness cue;
   the three desk folders get a small symbolic feather. */
@media (min-width: 601px) and (hover: hover) and (pointer: fine) {
  body.redakcja-aktywna .drzwi-wnetrze,
  body.wnetrze-redakcji-aktywne .powrot-do-lasu-z-redakcji,
  body.wnetrze-redakcji-aktywne .powrot-do-lasu-z-redakcji-pioro,
  body.wnetrze-redakcji-aktywne .pergamin-redakcji,
  body.wnetrze-redakcji-aktywne .tom7-redakcja,
  body.wnetrze-redakcji-aktywne .tom8-redakcja,
  body.wnetrze-redakcji-aktywne .pomysly-redakcja {
    transition: filter 0.2s ease !important;
  }

  body.redakcja-aktywna .drzwi-wnetrze:hover,
  body.redakcja-aktywna .drzwi-wnetrze:focus-visible,
  body.wnetrze-redakcji-aktywne .powrot-do-lasu-z-redakcji:hover,
  body.wnetrze-redakcji-aktywne .powrot-do-lasu-z-redakcji:focus-visible,
  body.wnetrze-redakcji-aktywne .powrot-do-lasu-z-redakcji-pioro:hover,
  body.wnetrze-redakcji-aktywne .powrot-do-lasu-z-redakcji-pioro:focus-visible,
  body.wnetrze-redakcji-aktywne .pergamin-redakcji:hover,
  body.wnetrze-redakcji-aktywne .pergamin-redakcji:focus-visible,
  body.wnetrze-redakcji-aktywne .tom7-redakcja:hover,
  body.wnetrze-redakcji-aktywne .tom7-redakcja:focus-visible,
  body.wnetrze-redakcji-aktywne .tom8-redakcja:hover,
  body.wnetrze-redakcji-aktywne .tom8-redakcja:focus-visible,
  body.wnetrze-redakcji-aktywne .pomysly-redakcja:hover,
  body.wnetrze-redakcji-aktywne .pomysly-redakcja:focus-visible {
    filter: brightness(1.38) drop-shadow(0 0 5px rgba(244, 225, 167, 0.42)) !important;
  }

  /* Zapis 23: the clickable area follows the small pointing feather,
     not the parchment sheet. */
  html body.wnetrze-redakcji-aktywne .pergamin-redakcji {
    /* Preserve the existing feather calibration in 1672 x 941 scene units.
       Higher specificity defeats the later stage6-geometry.css rectangle. */
    --editorial-image-width: min(100vw, calc(100vh * 1672 / 941));
    --editorial-image-height: min(100vh, calc(100vw * 941 / 1672));
    position: fixed !important;
    left: calc(50vw + var(--editorial-image-width) * 0.115) !important;
    --zapis23-hotspot-y-offset: calc(var(--editorial-image-height) * 0.04);
    top: calc(50vh + var(--editorial-image-height) * 0.11 + var(--zapis23-hotspot-y-offset)) !important;
    width: calc(var(--editorial-image-width) * 0.055) !important;
    height: calc(var(--editorial-image-height) * 0.12) !important;
    transform: translate(-50%, -50%) rotate(-18deg) !important;
  }

}


/* Desktop-only road -> door transition.
   Existing hover rules and other scene transitions remain untouched. */
@media (min-width: 601px) and (hover: hover) and (pointer: fine) {
  body.desktop-editorial-door-transition .wejscie {
    transition: none !important;
  }

  .desktop-editorial-door-curtain {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    background: #070a08;
    pointer-events: none;
  }
  .desktop-editorial-door-curtain.is-covering {
    animation: desktop-editorial-door-cover 650ms ease both;
  }
  .desktop-editorial-door-curtain.is-revealing {
    animation: desktop-editorial-door-reveal 850ms ease both;
  }
  @keyframes desktop-editorial-door-cover {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  @keyframes desktop-editorial-door-reveal {
    from { opacity: 1; }
    to { opacity: 0; }
  }

}
