/* Admin-only landscape gate and compact-landscape usability.
   Scoped to :is(body.is-admin, body.is-product-builder, body.is-lo-editor) so student/guest learning, staff "תצוגה כתלמיד"
   (body.is-product-preview) and public pages are never affected. */

.admin-rotate-gate { display: none; }

@media (orientation: portrait) and (max-width: 1024px) {
  body.is-admin:not(.is-product-builder):not(.is-lo-editor):not(.is-product-preview) .admin-rotate-gate {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 4000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 28px;
    text-align: center;
    background: linear-gradient(160deg, #eef4ff 0%, #f6f3ff 100%);
    color: #003a7d;
    font-family: "Heebo", "Rubik", "Noto Sans Hebrew", sans-serif;
  }
  body.is-admin:not(.is-product-builder):not(.is-lo-editor):not(.is-product-preview) .admin-rotate-gate .rotate-icon {
    font-size: 64px;
    line-height: 1;
    animation: adminRotateHint 2.4s ease-in-out infinite;
  }
  body.is-admin:not(.is-product-builder):not(.is-lo-editor):not(.is-product-preview) .admin-rotate-gate .rotate-title {
    font-size: 21px;
    font-weight: 800;
    margin: 0;
  }
  body.is-admin:not(.is-product-builder):not(.is-lo-editor):not(.is-product-preview) .admin-rotate-gate .rotate-sub {
    font-size: 15px;
    font-weight: 600;
    color: #4a5b8c;
    margin: 0;
  }
}

@keyframes adminRotateHint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
@media (prefers-reduced-motion: reduce) {
  .admin-rotate-gate .rotate-icon { animation: none !important; }
}

/* Landscape on short screens (phones/small tablets): keep management dialogs
   inside the viewport with internal scrolling and reachable action rows. */
@media (orientation: landscape) and (max-height: 560px) {
  :is(body.is-admin, body.is-product-builder, body.is-lo-editor) dialog,
  :is(body.is-admin, body.is-product-builder, body.is-lo-editor) .product-modal-card {
    max-height: calc(100dvh - 16px) !important;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  :is(body.is-admin, body.is-product-builder, body.is-lo-editor) .lo-card,
  :is(body.is-admin, body.is-product-builder, body.is-lo-editor) .lo-card.is-editor {
    max-height: calc(100dvh - 12px) !important;
  }
  :is(body.is-admin, body.is-product-builder, body.is-lo-editor) .product-modal-actions,
  :is(body.is-admin, body.is-product-builder, body.is-lo-editor) .admin-actions-row,
  :is(body.is-admin, body.is-product-builder, body.is-lo-editor) .lo-card > footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 8px;
    padding-bottom: 8px;
    z-index: 2;
  }
  :is(body.is-admin, body.is-product-builder, body.is-lo-editor) .students-table-scroll {
    max-height: calc(100dvh - 220px);
  }
}

/* Responsive overlays opened inside the dashboard (e.g. student card / add-student dialog) are exempt
   while open; the gate returns automatically when they close. */
body:has(dialog[open]) .admin-rotate-gate { display: none !important; }
