/* Styles for shared/drawer.js. Load after student.css / tutor.css. Only applies to portrait phones and short
   landscape phones; desktop and tablet layouts are untouched. */

.qr-drawer-scrim,
.qr-drawer-fab {
  display: none;
}

@media (max-width: 820px) and (orientation: portrait), (max-height: 500px) and (orientation: landscape) {
  /* ---------- floating button + dimmed backdrop ---------- */
  .qr-drawer-fab {
    position: fixed;
    z-index: 55;
    right: calc(14px + env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--sq-blue);
    color: #fff;
    font-family: var(--sq-font);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(18, 38, 63, 0.28);
    cursor: pointer;
    touch-action: manipulation;
  }

  body.qr-drawer-open .qr-drawer-fab {
    visibility: hidden;
  }

  .qr-drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: block;
    background: rgba(18, 38, 63, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s ease, visibility 0s 0.24s;
  }

  .qr-drawer-scrim.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.24s ease;
  }

  .sq-toast {
    z-index: 70;
  }

  /* ---------- the details panel becomes the drawer ---------- */
  .sq-app .sq-detail {
    position: fixed;
    z-index: 61;
    inset: 40px 0 0 0;
    flex: none;
    width: auto;
    height: auto;
    border: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 24px rgba(18, 38, 63, 0.2);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.24s ease, visibility 0s 0.24s;
  }

  .sq-app .sq-detail[data-sheet="open"] {
    transform: none;
    visibility: visible;
    transition: transform 0.24s ease;
  }

  /* the handle slot is a Close button here */
  .sq-detail .qr-sheet-handle {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border: 0;
    background: transparent;
    color: var(--sq-blue);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
  }

  .sq-app .sq-detail-head {
    padding: 0 16px 12px;
    border-bottom: 0;
    background: #fff;
  }

  .sq-head-meta {
    display: block;
  }

  .sq-app .sq-detail-body {
    overflow-y: auto;
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--sq-border);
  }

  /* ---------- document area: full width, zoom controls clear of the floating button ---------- */
  .sq-doc .qr-zoom {
    display: flex;
    right: auto;
    left: 14px;
    bottom: 14px;
  }

  .sq-doc .qr-doc-scroll {
    padding-bottom: 72px;
  }

  /* keep the question list on the left as a vertical column */
  .sq-main {
    flex-direction: row;
  }

  .sq-rail {
    flex-direction: column;
    width: 52px;
    gap: 14px;
    padding: 12px 0 72px 9px;
    overflow-x: hidden;
    overflow-y: auto;
    border-bottom: 0;
    box-shadow: 0 12px 24px rgba(18, 38, 63, 0.03);
  }
}

/* short landscape phones: the drawer slides in from the right instead of covering the whole screen */
@media (max-height: 500px) and (orientation: landscape) {
  .sq-app .sq-detail {
    inset: 0 0 0 auto;
    width: clamp(300px, 55vw, 460px);
    border-radius: 16px 0 0 16px;
    box-shadow: -8px 0 24px rgba(18, 38, 63, 0.2);
    transform: translateX(105%);
    padding-right: env(safe-area-inset-right);
  }

  .sq-app .sq-detail[data-sheet="open"] {
    transform: none;
  }

  .sq-app .sq-detail-body {
    padding: 10px 12px 20px;
    font-size: 14px;
  }

  .sq-rail {
    width: 48px;
    gap: 8px;
    padding: 8px 0 72px 6px;
  }
}
