/* mobile-sheet.css — 모바일 시트 컴포넌트 (Bottom Sheet) 공통 */
/* 학습지·문장·연령별 필수 단어 등 여러 모바일 화면에서 공유 */
/* 599px 이하 폰 폭에서 시트 활성. 600px 이상 데스크톱 기본 UI에는 영향 0 */

/* ==========================================================================
   좁은 화면 레이아웃 — 시트 활성
   ========================================================================== */
@media screen and (max-width: 599px) {
  .m-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .m-sheet-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .m-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 31;
    background: var(--bg-white);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
  }
  .m-sheet.is-open {
    transform: translateY(0);
  }

  .m-sheet-handle {
    width: 48px;
    height: 5px;
    background: var(--text-light);
    opacity: 0.4;
    border-radius: 3px;
    margin: 12px auto 8px;
    flex-shrink: 0;
  }

  .m-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 16px 10px;
    border-bottom: 1px solid var(--border-light);
  }
  .m-sheet-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    flex-shrink: 0;
  }
  .m-sheet-close {
    /* X 버튼: 닫기 명시적 트리거. 백드롭/swipe down/뒤로가기와 병행. */
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
  }
  .m-sheet-close:active {
    background: var(--bg-cream);
    color: var(--text-primary);
  }

  /* 핸들 영역 — swipe down 가능하게 더 넓은 터치 영역 */
  .m-sheet-handle {
    cursor: grab;
    touch-action: none; /* JS swipe 핸들러가 처리 */
  }
  .m-sheet-handle::before {
    /* 보이지 않는 터치 영역 확장 (핸들 위·좌·우로 24px씩) */
    content: '';
    position: absolute;
    inset: -16px -32px;
  }
  .m-sheet-handle {
    position: relative;
  }

  .m-sheet-body {
    flex: 1;
    overflow-y: auto;
  }
}

/* ==========================================================================
   600px 이상 데스크톱 환경 — 시트 컴포넌트 자체가 hidden (안전장치)
   ========================================================================== */
@media (min-width: 600px) {
  .m-sheet,
  .m-sheet-backdrop {
    display: none !important;
  }
}

@media screen and (min-width: 600px) and (max-width: 899px) {
  .m-sheet {
    left: 50%;
    right: auto;
    width: min(920px, calc(100vw - 32px));
    transform: translate(-50%, 100%);
  }
  .m-sheet.is-open {
    transform: translate(-50%, 0);
  }
}

/* ==========================================================================
   인쇄 — 시트를 일반 블록으로 풀어서 panel 콘텐츠가 잘리지 않게
   ========================================================================== */
@media print {
  /* 시트는 fixed + max-height + overflow 였음. 인쇄에서는 자연 흐름으로 */
  .m-sheet {
    position: static !important;
    max-height: none !important;
    transform: none !important;
    transition: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: white !important;
    display: block !important;
  }
  .m-sheet-body {
    overflow: visible !important;
    flex: none !important;
  }
  /* 시트 chrome (핸들·헤더·백드롭) 인쇄 X */
  .m-sheet-handle,
  .m-sheet-header,
  .m-sheet-backdrop {
    display: none !important;
  }
}
