/* ==========================================================================
   Tali Design System — Layout & Navigation Shell
   ========================================================================== */

.app-shell {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  background-color: var(--bg-canvas);
}

@media (min-width: 520px) {
  body {
    background-color: var(--bg-desktop-frame);
  }

  .app-shell {
    max-width: var(--app-max-width);
    border-left: 1px solid var(--border-hairline);
    border-right: 1px solid var(--border-hairline);
    box-shadow: 0 0 48px rgba(28, 28, 30, 0.06);
  }
}

/* Glass Surface */
.glass-surface {
  background-color: var(--bg-glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

/* Auth Container */
.auth-root {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(var(--space-6) + var(--safe-top)) var(--space-4) calc(var(--space-6) + var(--safe-bottom));
}

/* Main Authenticated Shell */
.main-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Sticky Glass Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: calc(var(--header-height) + var(--safe-top));
  padding: var(--safe-top) var(--space-4) 0;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
}

/* Main Content Area */
.app-main {
  flex: 1;
  width: 100%;
  padding: var(--space-4) var(--space-4) calc(var(--nav-height) + var(--safe-bottom) + var(--space-8));
}

/* View Panels & Transition */
.view-panel {
  display: none;
  opacity: 0;
  transform: translateY(6px);
}

.view-panel.is-active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: view-enter var(--duration-normal) var(--ease-spring) both;
}

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fixed Glass Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding: var(--space-1) var(--space-2) var(--safe-bottom);
  border-top: 1px solid var(--border-hairline);
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
}

.bottom-nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  transition:
    color var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-spring),
    background-color var(--duration-fast) var(--ease-standard);
}

.bottom-nav-item:active {
  transform: scale(0.94);
}

.bottom-nav-item.is-active {
  color: var(--text-primary);
}

.bottom-nav-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
}

.bottom-nav-icon svg {
  width: 22px;
  height: 22px;
  transition: transform var(--duration-normal) var(--ease-bounce);
}

.bottom-nav-item.is-active .bottom-nav-icon svg {
  transform: translateY(-1px) scale(1.04);
  stroke-width: 2.1;
}

.bottom-nav-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.bottom-nav-badge {
  position: absolute;
  top: -1px;
  right: -4px;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background-color: var(--status-adjustment-accent);
  border: 1.5px solid var(--bg-canvas);
}

/* Floating Notification Regions */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-3));
  transform: translateX(-50%);
  width: calc(100% - var(--space-8));
  max-width: calc(var(--app-max-width) - var(--space-8));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

/* 認証ゲート画面などボトムナビ非表示時は上部に配置し主CTAと重ならないようにする */
.app-shell:has(#main-shell[hidden]) .toast-region,
.toast-region--top {
  top: max(16px, var(--safe-top));
  bottom: auto;
}

.app-shell:has(#main-shell[hidden]) .toast-pill,
.toast-region--top .toast-pill {
  transform: translateY(-10px) scale(0.96);
}

.app-shell:has(#main-shell[hidden]) .toast-pill.is-visible,
.toast-region--top .toast-pill.is-visible {
  transform: translateY(0) scale(1);
}

.live-pill-region {
  position: fixed;
  left: 50%;
  top: calc(var(--header-height) + var(--safe-top) + var(--space-2));
  transform: translateX(-50%);
  width: calc(100% - var(--space-8));
  max-width: calc(var(--app-max-width) - var(--space-8));
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.modal-root {
  position: relative;
  z-index: 80;
}
