/* ================================================================
   layout.css — 响应式布局 + 导航系统
   ================================================================ */

/* === 容器 === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md) calc(var(--nav-height) + var(--space-md) + env(safe-area-inset-bottom, 0px));
  position: relative;
  z-index: 1;
}

/* === 启动页 === */
.launch-page {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6750A4 0%, #7D5260 50%, #625B71 100%);
  transition: opacity var(--duration-extra-long) var(--ease-emphasized),
              visibility var(--duration-extra-long) var(--ease-emphasized);
}

.launch-page.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.launch-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 30%, rgba(255,255,255,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 70% 70%, rgba(255,255,255,0.08) 0%, transparent 50%);
  pointer-events: none;
}

.launch-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #FFFFFF;
}

.launch-icon {
  font-size: 72px;
  margin-bottom: var(--space-lg);
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.2));
  animation: launchFloat 3s var(--ease-standard) infinite;
}

@keyframes launchFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.launch-title {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: var(--space-xs);
  text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.launch-subtitle {
  font-size: var(--text-title-medium);
  opacity: 0.85;
  margin-bottom: var(--space-2xl);
  letter-spacing: 6px;
}

.launch-progress {
  width: 260px;
  margin: 0 auto var(--space-2xl);
}

.launch-progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.launch-progress-fill {
  height: 100%;
  background: rgba(255,255,255,0.9);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 1s var(--ease-emphasized);
}

.launch-progress-text {
  font-size: var(--text-label-medium);
  opacity: 0.75;
}

.launch-btn {
  padding: 16px 64px;
  background: rgba(255,255,255,0.95);
  color: #6750A4;
  border: none;
  border-radius: var(--radius-full);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  box-shadow: var(--elevation-4);
  transition: transform 0.2s var(--ease-standard),
              box-shadow 0.2s var(--ease-standard);
  -webkit-user-select: none;
  user-select: none;
}

.launch-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--elevation-5);
}

.launch-btn:active {
  transform: translateY(0) scale(0.97);
}

/* === 主页面 === */
.main-page {
  display: none;
  opacity: 0;
  padding-top: var(--space-lg);
  transition: opacity var(--duration-medium) var(--ease-standard);
}

.main-page.visible {
  display: block;
  opacity: 1;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-bottom: var(--space-lg);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--md-outline-variant);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.brand-icon {
  font-size: 28px;
}

.brand-text h1 {
  font-size: var(--text-title-medium);
  font-weight: 600;
  color: var(--md-on-background);
  line-height: 1.3;
}

.brand-text p {
  font-size: var(--text-label-small);
  color: var(--md-on-surface-variant);
}

.search-trigger {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease-standard);
}

.search-trigger:hover {
  background: var(--md-surface-container-highest);
}

/* === 桌面端顶部导航 === */
.desktop-nav {
  display: none;
  align-items: center;
  gap: var(--space-xs);
  background: var(--md-surface-container-high);
  border-radius: var(--radius-full);
  padding: 4px;
}

.dnav-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: var(--text-label-large);
  font-weight: 500;
  border-radius: var(--radius-full);
  transition: all 0.2s var(--ease-standard);
}

.dnav-btn:hover {
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
}

.dnav-btn.active {
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: var(--elevation-1);
}

/* === 底部导航 === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  background: var(--md-surface-container);
  border-top: 1px solid var(--md-outline-variant);
  padding-bottom: env(safe-area-inset-bottom, 0);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--elevation-2);
  -webkit-user-select: none;
  user-select: none;
}

.bn-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--md-on-surface-variant);
  font-size: var(--text-label-small);
  font-weight: 500;
  transition: color 0.2s var(--ease-standard);
  min-height: 44px;
  position: relative;
}

.bn-btn.active {
  color: var(--md-primary);
}

.bn-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--md-primary);
  border-radius: 0 0 3px 3px;
}

.bn-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bn-btn.active .bn-icon {
  fill: var(--md-primary-container);
  stroke: var(--md-primary);
}

/* === 页面内容 === */
.page-content {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s var(--ease-standard),
              transform 0.25s var(--ease-standard);
}

.page-content.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* === FAB悬浮按钮 === */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-md) + env(safe-area-inset-bottom, 0px));
  right: var(--space-md);
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: var(--radius-full);
  border: none;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  box-shadow: var(--elevation-3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  transition: transform 0.2s var(--ease-standard),
              box-shadow 0.2s var(--ease-standard);
  animation: fabPulse 2s var(--ease-standard) infinite;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: var(--elevation-4);
}

.fab:active {
  transform: scale(0.94);
}

.fab svg {
  fill: var(--md-on-primary-container);
}

@keyframes fabPulse {
  0%, 100% { box-shadow: var(--elevation-3), 0 0 0 0 rgba(103, 80, 164, 0.4); }
  50% { box-shadow: var(--elevation-3), 0 0 0 12px rgba(103, 80, 164, 0); }
}

@keyframes pomCelebrate {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* === 弹窗 === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
  opacity: 0;
  transition: opacity 0.25s var(--ease-standard);
}

.modal-overlay.active {
  display: block;
  opacity: 1;
}

.modal-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 2001;
  display: none;
  opacity: 0;
  transition: opacity 0.25s var(--ease-standard),
              transform 0.25s var(--ease-emphasized);
}

.modal-container.active {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* === 命令面板 === */
.command-palette {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -10%) scale(0.95);
  z-index: 3000;
  display: none;
  opacity: 0;
  transition: opacity 0.2s var(--ease-standard),
              transform 0.2s var(--ease-emphasized);
}

.command-palette.active {
  display: block;
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@media (max-width: 767px) {
  .command-palette {
    top: 16px;
    left: 12px;
    right: 12px;
    transform: none;
  }
  .command-palette.active {
    transform: none;
  }
}

/* === Toast === */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-md);
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

/* === 响应式 === */
@media (min-width: 768px) {
  .desktop-nav { display: flex; }
  .bottom-nav { display: none; }
  .container {
    padding: 0 var(--space-lg) var(--space-lg);
  }
  .fab {
    bottom: var(--space-lg);
  }
  .brand-text h1 {
    font-size: var(--text-title-large);
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-sm) calc(var(--nav-height) + var(--space-sm) + env(safe-area-inset-bottom, 0px));
  }
  .header {
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-md);
  }
  .brand-text h1 {
    font-size: var(--text-label-large);
  }
  .launch-title {
    font-size: 32px;
  }
  .launch-btn {
    padding: 14px 48px;
    font-size: 16px;
  }
}

@media (max-width: 360px) {
  .brand-icon { display: none; }
  .brand-text h1 { font-size: var(--text-label-medium); }
}

/* ================================================================
   番茄钟面板
   ================================================================ */

.pom-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 2500;
  width: 420px;
  max-width: 100vw;
  background: var(--md-surface-container);
  border-left: 1px solid var(--md-outline-variant);
  box-shadow: var(--elevation-5);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s var(--ease-emphasized);
}

.pom-panel.open {
  transform: translateX(0);
}

.pom-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--md-outline-variant);
  flex-shrink: 0;
}

.pom-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.pom-timer-ring {
  position: relative;
  width: 220px;
  height: 220px;
}

.pom-timer-ring svg {
  transform: rotate(-90deg);
}

.pom-timer-bg {
  fill: none;
  stroke: var(--md-surface-container-highest);
  stroke-width: 8;
}

.pom-timer-progress {
  fill: none;
  stroke: var(--md-primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}

.pom-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.pom-timer-time {
  font-size: 42px;
  font-weight: 700;
  color: var(--md-on-surface);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pom-timer-label {
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-top: 4px;
}

.pom-mode-btns {
  display: flex;
  gap: 8px;
  width: 100%;
}

.pom-mode-btn {
  flex: 1;
  padding: 12px 8px;
  border: 2px solid var(--md-outline-variant);
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s var(--ease-standard);
  font-family: inherit;
}

.pom-mode-btn:hover {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
}

.pom-mode-btn.selected {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.pom-mode-btn .pom-mode-time {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.pom-mode-btn .pom-mode-label {
  font-size: 11px;
  color: var(--md-on-surface-variant);
  margin-top: 2px;
}

.pom-config {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pom-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.pom-actions .btn {
  flex: 1;
}

.pom-celebration {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pom-celebration-icon {
  font-size: 56px;
  animation: pomCelebrate 0.5s ease;
}

.pom-celebration-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--md-on-surface);
}

.pom-celebration-detail {
  font-size: 13px;
  color: var(--md-on-surface-variant);
  line-height: 1.6;
}

.pom-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2499;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease-standard);
}

.pom-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 767px) {
  .pom-panel {
    width: 100vw;
  }
  .pom-timer-ring {
    width: 180px;
    height: 180px;
  }
  .pom-timer-time {
    font-size: 36px;
  }
}