/* ============================================
   layout.css — 앱 껍데기, 화면 전환, 하단 탭 바
   ============================================ */

.app-shell {
  width: 100%;
  min-width: 0;
  min-height: 100dvh;
  max-width: min(100%, var(--app-max-width));
  margin-left: auto;
  margin-right: auto;
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  position: relative;
}

.app-shell.has-profile-bg {
  background-image: linear-gradient(
      var(--profile-bg-overlay),
      var(--profile-bg-overlay)
    ),
    var(--profile-bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.app-shell > .app-header,
.app-shell > .app-main {
  position: relative;
  z-index: 1;
}

/* 홈 .tasks-greeting 과 동일한 탭 타이틀 여백 (쇼핑~설정·메모) */
:root {
  --tab-title-pad-inline: var(--space-4);
  --tab-title-pad-before: var(--space-2);
  --tab-title-pad-after: var(--space-2);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  flex-shrink: 0;
  padding-top: calc(var(--safe-top) + var(--tab-title-pad-before));
  padding-bottom: 0;
  padding-left: var(--tab-title-pad-inline);
  padding-right: var(--tab-title-pad-inline);
  display: flex;
  align-items: flex-start;
  background: var(--color-bg);
  border-bottom: none;
  box-shadow: none;
  color: var(--color-text);
}

.app-shell[data-active-tab="tasks"] .app-header {
  display: none;
}

/* 홈 인사말(.tasks-greeting)과 동일 타이포·여백 */
.app-header__title {
  margin: 0;
  padding-top: var(--tab-title-pad-after);
  font-size: var(--text-greeting);
  font-weight: var(--font-bold);
  line-height: var(--line-height-relaxed);
  color: var(--color-text);
  word-break: keep-all;
}

/* layout v13: .app-main flex 열 — 탭 패널 높이 전달 (메모 absolute 자식 대응) */
.app-main {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-4);
  padding-bottom: calc(
    var(--tab-bar-height) + var(--safe-bottom) + var(--space-4)
  );
}

.tab-panel[hidden],
.tab-panel:not(.is-active) {
  display: none !important;
}

.tab-panel.is-active {
  display: flex;
  flex-direction: column;
}

.tab-placeholder {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--color-text-muted);
}

.tab-placeholder__icon {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

.tab-placeholder__title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.tab-placeholder__desc {
  font-size: var(--text-sm);
  line-height: var(--line-height-relaxed);
}

.app-shell > .tab-bar,
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin-left: auto;
  margin-right: auto;
  width: min(100%, var(--app-max-width));
  max-width: 100%;
  z-index: var(--z-tab-bar);
  height: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
  display: flex;
  background: var(--color-bg-elevated);
  border-top: var(--border-width) solid var(--color-border-subtle);
  box-shadow: none;
}

.tab-bar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap-tab-item);
  min-height: var(--touch-target-min);
  transition: color var(--transition-fast);
}

.tab-bar__icon {
  font-size: var(--text-lg);
  line-height: var(--line-height-tight);
}

.tab-bar__label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  letter-spacing: var(--letter-spacing-tight);
}

/* ============================================
   반응형: 모바일(≤480) · 큰 모바일(481~768) · 태블릿(769+)
   1025px+ 별도 레이아웃 없음 · 폰트 크기 유지
   ============================================ */

/* 태블릿(769px~, 브라우저): 콘텐츠 폭 600px + 양옆 프레임 그라데이션 */
@media (min-width: 769px) and (display-mode: browser) {
  :root {
    --app-max-width: var(--app-max-width-tablet);
  }

  html {
    background-color: var(--color-bg-frame);
    background-image:
      radial-gradient(
        ellipse 70% 55% at 12% 45%,
        color-mix(in srgb, var(--color-accent) 7%, transparent) 0%,
        transparent 58%
      ),
      radial-gradient(
        ellipse 70% 55% at 88% 55%,
        color-mix(in srgb, var(--color-accent) 6%, transparent) 0%,
        transparent 58%
      );
    background-attachment: fixed;
  }
}

/* PWA 설치(standalone/fullscreen): 풀 너비 — 태블릿 확장보다 우선 */
@media (display-mode: standalone), (display-mode: fullscreen) {
  :root {
    --app-max-width: none;
  }

  html {
    background-color: var(--color-bg);
    background-image: none;
  }

  .app-shell,
  .tab-bar,
  .task-sheet,
  .sub-sheet__panel,
  .shop-modal {
    max-width: none;
    width: 100%;
  }
}

/* 모달·시트 열림: 탭바 여백 제거(베이지 레이어가 시트 CTA를 가리지 않게) */
body.modal-open .app-shell {
  padding-bottom: 0;
}

/* app-shell 직속 바텀 시트 — 전체 뷰포트 기준 fixed */
.app-shell > .task-sheet,
.app-shell > .sub-sheet {
  z-index: var(--z-overlay);
}

/* 모달·시트 열림: iOS 스타일로 탭 바·FAB 숨김 */
body.modal-open .tab-bar {
  display: none;
}

body.modal-open .app-fab {
  display: none !important;
}

/* 1025px+ 데스크톱: 태블릿(또는 PWA) 레이아웃 그대로 */
