/* Template preview window (resource pages).
   Phone: the preview on top, then name and download without scrolling.
   Desktop: preview left, a narrow column right with the download at the top. */

#templateModal .ts-modal-panel{height:100dvh;max-height:100dvh}
#templateModal .ts-modal-preview{flex:1 1 0%;min-height:46dvh}
#templateModal .ts-modal-info{
  flex:none;max-height:48dvh;overflow-y:auto;overscroll-behavior:contain;
  display:flex;flex-direction:column;gap:.75rem;
  padding:.875rem 1rem calc(1rem + env(safe-area-inset-bottom));
  border-top:1px solid #e2e8f0;background:#fff;
}

@media(min-width:640px){
  #templateModal .ts-modal-panel{height:min(90vh,880px);max-height:92vh}
}
@media(min-width:768px){
  #templateModal .ts-modal-preview{flex:none;width:64%;min-height:0}
  #templateModal .ts-modal-info{
    width:36%;max-height:none;border-top:0;border-left:1px solid #e2e8f0;
    gap:1rem;padding:1.5rem 1.5rem 1.25rem;
  }
  /* keeps the name clear of the close button */
  #templateModal .ts-modal-head{padding-right:2.75rem}
}

/* Name block */
#templateModal .ts-modal-set{
  margin:0 0 .25rem;font-size:.75rem;font-weight:600;letter-spacing:.04em;
  text-transform:uppercase;color:#64748b;
}
#templateModal .ts-modal-name{
  margin:0;font-size:1.125rem;line-height:1.25;font-weight:700;color:#0f172a;
  overflow-wrap:anywhere;
}
#templateModal .ts-modal-meta{
  margin-top:.5rem;display:flex;flex-wrap:wrap;align-items:center;gap:.375rem .5rem;
  font-size:.8125rem;color:#64748b;
}
#templateModal .ts-modal-types .js-modal-file-types{display:inline-flex;flex-wrap:wrap;gap:.375rem}
#templateModal .ts-modal-badge{
  display:inline-flex;align-items:center;border-radius:999px;padding:.125rem .625rem;
  font-size:.75rem;font-weight:700;color:#7c2d12;background:#ffedd5;
  box-shadow:inset 0 0 0 1px rgba(194,65,12,.25);
}
#templateModal [hidden]{display:none!important}

/* Download block */
#templateModal .ts-modal-cta{display:flex;flex-direction:column;gap:.5rem}
#templateModal .ts-modal-action{
  display:flex;align-items:center;justify-content:center;gap:.5rem;
  min-height:3rem;width:100%;border-radius:.75rem;padding:.75rem 1rem;
  font-size:.9375rem;font-weight:700;color:#fff;background:#0b8543;
  text-decoration:none;transition:background-color .15s ease;
}
#templateModal .ts-modal-action:hover{background:#076a35}
#templateModal .ts-modal-action:focus-visible,
#templateModal .ts-modal-pack:focus-visible{outline:2px solid #0b8543;outline-offset:2px}
#templateModal .ts-modal-hint{margin:0;font-size:.8125rem;line-height:1.4;color:#64748b;text-align:center}
#templateModal .ts-modal-pack{
  display:flex;align-items:center;justify-content:space-between;gap:.5rem;
  min-height:2.75rem;border-radius:.75rem;padding:.625rem .875rem;
  font-size:.875rem;font-weight:600;color:#0f172a;background:#f8fafc;
  box-shadow:inset 0 0 0 1px #e2e8f0;text-decoration:none;
  transition:background-color .15s ease,box-shadow .15s ease;
}
#templateModal .ts-modal-pack:hover{background:#f1f5f9;box-shadow:inset 0 0 0 1px #cbd5e1}
#templateModal .ts-modal-pack svg{flex:none;color:#64748b}

#templateModal .ts-modal-desc{
  margin:0;font-size:.875rem;line-height:1.55;color:#475569;
  display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4;overflow:hidden;
}

@media(min-width:768px){
  #templateModal .ts-modal-name{font-size:1.375rem}
}

/* Preview: zoom and gallery arrows */
#templateModal .js-modal-zoom-viewport{touch-action:none;cursor:zoom-in;z-index:1}
#templateModal .js-modal-zoom-viewport.is-zoomed{cursor:grab}
#templateModal .js-modal-zoom-viewport.is-panning{cursor:grabbing}
#templateModal .js-modal-zoom-stage{transform-origin:center center;transition:transform .05s linear}
#templateModal .js-modal-zoom-stage.is-animating{transition:transform .2s ease-out}
#templateModal .js-modal-prev{left:.625rem;right:auto;z-index:30}
#templateModal .js-modal-next{right:.625rem;left:auto;z-index:30}
#templateModal .js-modal-thumbnail{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain}

/* The promo bar sits above the window; hide it while a preview is open. */
html.ts-modal-open #ts-promo{visibility:hidden;pointer-events:none}

@media(prefers-reduced-motion:reduce){
  #templateModal .ts-modal-action,#templateModal .ts-modal-pack,
  #templateModal .js-modal-zoom-stage{transition:none}
}
