/*
 * PE-Class v11651 — authoritative iPad landscape shell
 *
 * The common foundation owns iPad identification through data-pe-ipados.
 * Current 11-inch iPads expose a 1408px landscape CSS viewport, so a 1366px
 * desktop-era upper bound must not decide whether the left rail exists.
 */
@media (min-width:769px){
  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide) .pe87Shell{
    display:grid!important;
    grid-template-columns:225px minmax(0,1fr)!important;
    min-height:calc(100dvh - 76px)!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide) .pe87Side{
    position:sticky!important;
    z-index:50!important;
    top:76px!important;
    width:225px!important;
    min-width:225px!important;
    max-width:225px!important;
    height:calc(100dvh - 76px)!important;
    padding:13px 11px!important;
    border-right:1px solid #d9e1ea!important;
    border-bottom:0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    background:#fff!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide) .sideTabs{
    display:flex!important;
    flex-direction:column!important;
    width:100%!important;
    min-width:0!important;
    gap:8px!important;
    overflow:visible!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide) .sideTabs .tab{
    width:100%!important;
    min-width:0!important;
    height:44px!important;
    padding:0 12px!important;
    font-size:14px!important;
    white-space:normal!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide) .sideTree{
    display:block!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide) .pe87Main{
    min-width:0!important;
    padding:12px!important;
  }
}

/*
 * 현재 선택 메뉴는 레거시 iPad/Fold 규칙의 흰 배경보다 우선한다.
 * aria-current는 상태 재렌더링 뒤에도 선택 탭을 명시적으로 식별한다.
 */
html[data-pe-shell="11646"] .pe87Side .sideTabs > .tab.active,
html[data-pe-shell="11646"] .pe87Side .sideTabs > .tab[aria-current="page"]{
  border-color:#2f455a!important;
  background:#2f455a!important;
  color:#fff!important;
  box-shadow:0 5px 14px rgba(31,45,61,.16)!important;
}

html[data-pe-shell="11646"] .pe87Side .sideTabs > .tab.active .sideTabIcon,
html[data-pe-shell="11646"] .pe87Side .sideTabs > .tab[aria-current="page"] .sideTabIcon{
  background:rgba(255,255,255,.14)!important;
}

/*
 * Fold7 펼침 화면의 진도표/수행평가 트리:
 * 현재 학기 선택 동작은 유지하고, "현재" 안내 문구만 표시하지 않는다.
 */
html[data-pe-fold-wide="true"]:is(
  [data-pe-tab="progress"],
  [data-pe-tab="calendar"],
  [data-pe-tab="assessment"]
) .pe87Side .treeSemester.current > .treeCurrentBadge,
html.pe87FoldWide:is(
  [data-pe-tab="progress"],
  [data-pe-tab="calendar"],
  [data-pe-tab="assessment"]
) .pe87Side .treeSemester.current > .treeCurrentBadge{
  display:none!important;
}

/*
 * iPad 11-inch landscape — PAPS / 학생 관리 연도 아코디언 간격.
 *
 * sideTree의 기본 gap 6px에 4px를 더해, 반별 진도표와 수행평가 관리에서
 * 검증된 체감 10px 간격을 동일하게 사용한다. Fold/PC/모바일에는 적용하지
 * 않으며, 펼친 연도의 반 목록과 다음 연도 사이 간격도 같은 값으로 맞춘다.
 */
@media (min-width:769px) and (max-width:1440px) and (orientation:landscape){
  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide):not([data-pe-fold-wide="true"]):is(
    [data-pe-tab="paps"],
    [data-pe-tab="students"]
  ) .pe87Side .sideTree > .treeYear + .treeIndent{
    margin-top:4px!important;
    margin-bottom:4px!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide):not([data-pe-fold-wide="true"]):is(
    [data-pe-tab="paps"],
    [data-pe-tab="students"]
  ) .pe87Side .sideTree > .treeYear + .treeYear{
    margin-top:4px!important;
  }
}

/*
 * Fold7 펼침 화면 — 전역 헤더의 페인트 경계와 설정 카드 곡률.
 *
 * 화면 내부의 sticky 표 머리글/컨트롤은 그대로 유지하되, 전역 헤더보다
 * 위에 그려지지 않도록 데스크톱 셸과 동일한 레이어 우선순위를 부여한다.
 * 홈 화면·모바일·iPad·일반 PC에는 적용하지 않는다.
 */
@media (min-width:769px) and (max-width:1200px){
  html[data-pe-fold-wide="true"] .pe87Top,
  html.pe87FoldWide .pe87Top{
    z-index:5000!important;
  }

  html[data-pe-fold-wide="true"] .settingsC .settingsCHomeEditors > .settingsCBrandCard,
  html.pe87FoldWide .settingsC .settingsCHomeEditors > .settingsCBrandCard{
    border-radius:10px!important;
  }
}

/*
 * iPad 11-inch 가로 — 헤더 고정 및 좌·우 독립 스크롤.
 *
 * body 자체를 스크롤 컨테이너로 사용하지 않고, 헤더 아래 셸을 고정한 뒤
 * 사이드바와 본문에 각각 별도의 스크롤 컨텍스트를 부여한다. Fold와
 * 일반 데스크톱에는 적용하지 않는다.
 */
@media (min-width:769px) and (max-width:1440px) and (orientation:landscape){
  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide):not([data-pe-fold-wide="true"]),
  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide):not([data-pe-fold-wide="true"]) body{
    width:100%!important;
    height:100dvh!important;
    min-height:0!important;
    overflow:hidden!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide):not([data-pe-fold-wide="true"]) .pe87Top{
    position:fixed!important;
    inset:0 0 auto 0!important;
    width:100%!important;
    height:76px!important;
    z-index:5000!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide):not([data-pe-fold-wide="true"]) .pe87Shell{
    position:fixed!important;
    inset:76px 0 0 0!important;
    display:grid!important;
    grid-template-columns:225px minmax(0,1fr)!important;
    width:auto!important;
    height:auto!important;
    min-height:0!important;
    overflow:hidden!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide):not([data-pe-fold-wide="true"]) .pe87Side{
    position:relative!important;
    top:auto!important;
    width:225px!important;
    height:100%!important;
    min-height:0!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch!important;
  }

  html[data-pe-ipados="true"][data-pe-orientation="landscape"]:not(.pe87FoldWide):not([data-pe-fold-wide="true"]) .pe87Main{
    width:auto!important;
    height:100%!important;
    min-width:0!important;
    min-height:0!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch!important;
  }
}
