/* Keep the full summary inside the engraving. If a tab needs more height,
   its card grows up from the available lower edge before it can hit the route. */
body[data-chapter] #station .panel {
  --foot-room:max(76px, 8.5dvh);
  --rise:min(0px, calc(100dvh - var(--foot-room) - var(--by) - 100%));
  --cap:clamp(24px, 3.5dvh, 42px);
  --jamb:clamp(18px, 2.1vw, 39px);
  --sill:clamp(17px, 2.3dvh, 28px);
  top:var(--by); bottom:auto; max-height:none; overflow:visible;
  transform:translate(var(--panel-x,0px), var(--rise));
}
body[data-chapter] #station .panel:is(.right,.left) {left:var(--bx)}
#station .panel > .panel-scroll {min-height:auto;overflow:visible;padding-bottom:4px}
#station .panel .topic-panel {display:flow-root;min-width:0}
#station .panel .topic-panel > :last-child {margin-bottom:0}
#station .panel .topic-panel > .mobile-preview:not(:last-child) {margin-bottom:8px}
#station .panel .panel-actions {margin-top:12px}
#station .panel .contact-links a {overflow-wrap:anywhere}
#station .panel .stat {min-width:0}
#station .panel .stats[data-count="4"] .stat.lead {grid-column:auto}
[data-chapter=social-media] #station .panel .stats[data-count="4"] strong {
  font-size:clamp(25px, 2.5vw, 42px);
}
[data-chapter=social-media] #station .panel .stats[data-count="4"] small {font-size:14px}
[data-chapter=social-media] #station .panel .plot {padding-top:8px;margin-bottom:8px}

@media (min-width:681px) {
  [data-chapter=liczby] #station .panel-scroll {
    display:grid; grid-template-columns:minmax(160px,1fr) auto;
    align-items:end;gap:12px 18px;
  }
  [data-chapter=liczby] #station .panel-scroll > :is(h2,.topic-picker) {margin:0}
  [data-chapter=liczby] #station .panel-scroll > .topic-panel {grid-column:1 / -1}
  [data-chapter=liczby] #station .stats[data-count="3"] {grid-template-columns:repeat(3,minmax(0,1fr))}
  [data-chapter=liczby] #station .stats .stat strong {font-size:clamp(29px,3.25vw,58px)}
}

@media (min-width:1000px) and (min-aspect-ratio:1/1) {
  [data-chapter=liczby] #station .panel {--bx:11.4vw;--by:57.4dvh;--bw:84.2vw}
  [data-chapter=social-media] #station .panel {--bx:5.4vw;--by:23.4dvh;--bw:39.3vw}
  [data-chapter=partnerzy] #station .panel {--bx:5.4vw;--by:15.5dvh;--bw:34.5vw}
}

@media (min-width:681px) and (max-width:999px), (min-width:681px) and (max-aspect-ratio:1/1) {
  [data-chapter=program] #station .panel {--by:13dvh}
  body[data-chapter=edycje] #station .panel,
  body[data-chapter=dla-sponsorow] #station .panel {
    top:auto; bottom:max(8dvh,76px); --rise:0px;
  }
  [data-chapter=dla-sponsorow] #station .panel {--bx:6.5vw;--bw:43vw}
  [data-chapter=social-media] #station .panel {--bx:6.7vw;--by:42.2dvh;--bw:58.9vw}
  [data-chapter=juwe-stories] #station .panel {--bx:3.7vw;--by:19.2dvh;--bw:32.7vw}
}
@media (max-width:680px) {
  body[data-chapter] #station .panel {
    --foot-room:max(83px,calc(72px + env(safe-area-inset-bottom)));
    --cap:clamp(20px,3.1dvh,30px);--jamb:clamp(13px,4vw,21px);--sill:clamp(13px,2dvh,21px);
  }
  [data-chapter=partnerzy] #station .panel {--bx:8vw;--bw:84vw;--by:49.8dvh}
  [data-chapter=social-media] #station .panel {--bx:4vw;--bw:92vw}
  [data-chapter=social-media] #station .panel .stats[data-count="4"] strong {font-size:clamp(25px,7.5vw,42px)}
  [data-chapter=juwe-stories] #station .panel .topic-panel {display:none}
  [data-chapter=liczby] #station .panel .stats[data-count="4"] strong {font-size:clamp(28px,8vw,38px)}
  body[data-chapter=juwe-stories] #station .panel {--by:min(82dvh,calc(100dvh - 134px));--cap:12px;--jamb:13px;--sill:10px}
}
@media (max-width:375px) and (max-height:740px) {
  body[data-chapter] #station .panel {--bw:94vw;--bx:3vw;--cap:17px;--sill:12px;--jamb:12px}
  #station .panel .topic-picker,#station .panel h2 {margin-bottom:7px}
  #station .panel :is(.stats,.panel-actions) {margin-block:6px}
  #station .panel .short-list {display:none}
  #station .panel .excerpt {font-size:15px;line-height:1.38}
}
@media (max-width:375px) and (max-height:650px) {
  [data-chapter=social-media] #station .panel .plot {margin:2px 0;padding-top:2px}
  [data-chapter=social-media] #station .panel .plot-key {margin-top:3px}
  [data-chapter=social-media] #station .panel .excerpt {font-size:14px}
}

/* On a low, wide screen retain two reading lanes (copy and artwork).
   Controls share the title row; the breakdown and its totals share a row. */
@media (min-aspect-ratio:3/2) and (max-height:550px) {
  body[data-chapter] #station .panel {
    --bx:max(2.5vw,env(safe-area-inset-left));--by:max(16dvh,60px);--bw:63vw;
    --foot-room:max(56px,calc(48px + env(safe-area-inset-bottom)));
    --cap:14px;--jamb:14px;--sill:10px;
    left:var(--bx);top:var(--by);bottom:auto;
    padding:18px 21px 14px;
    --rise:min(0px, calc(100dvh - var(--foot-room) - var(--by) - 100%));
  }
  #station .panel-scroll {
    display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:8px 9px;
  }
  #station .panel h2 {font-size:clamp(24px,3.4vw,35px);margin:0}
  #station .panel .topic-picker {margin:0}
  #station .panel .topic-picker .picker-label {display:none}
  #station .panel .topic-tab {min-height:34px;padding:5px 7px;font-size:15px}
  #station .panel .topic-tab[aria-selected=true]::before {width:5px}
  #station .panel .topic-panel {grid-column:1/-1}
  #station .panel p {font-size:15px;line-height:1.34}
  #station .panel .short-list {display:none}
  #station .panel .panel-actions {margin-top:7px;gap:8px}
  #station .panel .panel-actions .linkbtn {min-height:34px;padding:5px 8px;font-size:15px}
  [data-chapter=social-media] #station .panel .stats {grid-template-columns:repeat(3,minmax(0,1fr))}
  [data-chapter=social-media] #station .panel .stats[data-count="4"] {grid-template-columns:repeat(4,minmax(0,1fr))}
  [data-chapter=social-media] #station .panel .stats .stat.lead {grid-column:auto}
  #station .panel .stats .stat small {font-size:13px;line-height:1.2}
  #station .panel .plot-key {margin-top:2px}
  [data-chapter=juwe-stories] #station .panel .topic-panel:not(:has(.stories-collage)) {
    display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:center;gap:14px
  }
  [data-chapter=juwe-stories] #station .gallery-focus {margin:0;aspect-ratio:2.2;max-height:90px}
  [data-chapter=kontakt] #station .contact-links {display:flex;flex-wrap:wrap;gap:8px 16px;margin-block:5px}
  body:is([data-chapter=social-media],[data-chapter=liczby]) #station .panel {--bw:91vw;--bx:4.5vw}
  body[data-chapter=social-media] #station .topic-panel:has(.plot) {
    display:grid;grid-template-columns:1fr auto;gap:5px 14px;align-items:center
  }
  body[data-chapter=social-media] #station .stats {grid-column:1/-1;margin:0}
  body:is([data-chapter=social-media],[data-chapter=liczby]) #station .panel .stats[data-count] strong {font-size:clamp(22px,3.3vw,31px)}
  body[data-chapter=social-media] #station .panel .plot {border:0;margin:0;padding:0}
}

@media (max-width:680px) and (min-aspect-ratio:3/2) and (max-height:550px) {
  body[data-chapter] #station .panel {--foot-room:80px;--bx:4vw;--bw:92vw}
  body[data-chapter=juwe-stories] #station .panel {--by:55dvh}
  [data-chapter=juwe-stories] #station .panel .topic-panel {display:none}
  [data-chapter=liczby] #station .stats {grid-template-columns:repeat(4,minmax(0,1fr))}
  [data-chapter=liczby] #station .stats[data-count="3"] {grid-template-columns:repeat(3,minmax(0,1fr))}
  [data-chapter=liczby] #station .stat.lead {grid-column:auto}
}
@media (min-width:681px) and (max-width:999px) and (min-aspect-ratio:1/1) and (min-height:551px) {
  body:is([data-chapter=promocja],[data-chapter=partnerzy]) #station .panel {--bx:4vw;--bw:61vw;--by:21dvh}
  [data-chapter=program] #station .short-list {display:none}
}

@media (max-height:350px) and (min-aspect-ratio:3/2) {
  body[data-chapter] #station .panel {
    --foot-room:67px;--cap:9px;--jamb:10px;--sill:8px;
    padding:12px 16px 11px;
  }
  body[data-chapter] #station .panel .panel-scroll {gap:5px 8px}
  #station .panel .excerpt {font-size:14px;line-height:1.26}
  #station .panel .panel-actions {margin-top:4px}
  #station .panel .panel-actions .linkbtn,#station .panel .topic-tab {min-height:32px}
  #station .panel .stat-action,#station .panel .stat-action.lead {padding:4px 14px 4px 6px}
  body[data-chapter=social-media] #station .panel .stats small {font-size:12px}
  #station .panel .signature,#station .panel .contact-links {margin-block:3px}
}

@media (min-width:681px) and (max-width:760px) and (max-aspect-ratio:1/1) {
  [data-chapter=program] #station .short-list {display:none}
}
@media (orientation:landscape) and (min-aspect-ratio:3/2) and (max-height:550px) {
  body[data-chapter=juwe-stories] #station .panel {
    --bx:2.5vw;--bw:min(28vw,220px);--by:56dvh;
    --cap:11px;--jamb:9px;--sill:9px;padding:15px 10px 13px;
  }
  body[data-chapter=juwe-stories] #station .panel-scroll {
    display:flex;flex-direction:column;align-items:flex-start;gap:5px;
  }
  body[data-chapter=juwe-stories] #station .panel h2 {font-size:clamp(20px,3.4vw,28px);margin:0}
  body[data-chapter=juwe-stories] #station .panel :is(.topic-picker,.topic-panel,.panel-actions) {display:none}
  body[data-chapter=juwe-stories] #station .story-shortcut {
    display:block;font:600 12px/1.25 Montserrat,sans-serif;text-align:left;
    min-height:28px;text-decoration:underline;text-underline-offset:3px;padding:0;
  }
}
@media (max-width:340px) and (max-height:600px) and (orientation:portrait) {
  [data-chapter=social-media] #station .panel .picker-label {
    position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);
  }
}
@media (min-width:681px) and (max-width:750px) and (orientation:portrait) {
  [data-chapter=partnerzy] #station .panel-scroll {display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:10px}
  [data-chapter=partnerzy] #station .panel-scroll > :is(h2,.topic-picker) {margin:0}
  [data-chapter=partnerzy] #station .topic-panel {grid-column:1/-1}
}
@media (min-width:681px) and (min-aspect-ratio:3/2) and (max-height:550px) {
  body[data-chapter=festiwal] #station .panel {
    --by:54dvh;--bx:2.4vw;--bw:72vw;--cap:10px;--sill:8px;--jamb:12px;
    display:grid;grid-template-columns:minmax(145px,.66fr) minmax(0,1.34fr);
    align-content:center;align-items:center;gap:4px 14px;padding:12px 16px;
  }
  [data-chapter=festiwal] #station .panel-scroll {display:contents}
  [data-chapter=festiwal] #station .panel h2 {grid-area:1/1;font-size:clamp(23px,2.8vw,28px)}
  [data-chapter=festiwal] #station .panel .topic-panel {grid-area:1/2/3/3}
  [data-chapter=festiwal] #station .panel .panel-actions {grid-area:2/1;gap:4px;margin:0}
  [data-chapter=festiwal] #station .panel .linkbtn {padding:4px 6px;min-height:30px;font-size:14px;gap:5px}
  [data-chapter=festiwal] #station .panel .excerpt {font-size:14px;line-height:1.28}
}

@media (max-width:680px) and (orientation:portrait) {
  body[data-chapter=juwe-stories] #station .panel {
    --bw:clamp(132px,35vw,180px);--bx:calc((100% - var(--bw)) / 2);
    top:auto;bottom:calc(var(--foot-room) + 3px);
    transform:translateX(var(--panel-x,0px));padding:12px 12px 9px;
  }
  body[data-chapter=juwe-stories] #station .panel-scroll {
    display:flex;flex-direction:column;align-items:center;gap:0;padding:0;text-align:center;
  }
  body[data-chapter=juwe-stories] #station .panel h2 {font-size:23px;margin:0}
  body[data-chapter=juwe-stories] #station .story-shortcut {
    display:block;padding:4px 0;min-height:32px;white-space:nowrap;
  }
}
