/* ===== iOS 18 设计系统基础样式 ===== */

/* CSS变量定义 - iOS 18色彩系统 */
:root {
  /* 主色调 */
  --primary-blue: #007AFF;
  --primary-blue-dark: #0051D5;
  --primary-blue-light: #5AC8FA;
  
  /* 系统背景色 */
  --system-background: #FFFFFF;
  --system-background-dark: #000000;
  --secondary-background: #F2F2F7;
  --secondary-background-dark: #1C1C1E;
  --tertiary-background: #FFFFFF;
  --tertiary-background-dark: #2C2C2E;
  
  /* 分组背景色 */
  --grouped-background: #F2F2F7;
  --grouped-background-dark: #000000;
  --grouped-secondary-background: #FFFFFF;
  --grouped-secondary-background-dark: #1C1C1E;
  
  /* 标签颜色 */
  --label-primary: #000000;
  --label-primary-dark: #FFFFFF;
  --label-secondary: #3C3C43;
  --label-secondary-dark: #EBEBF5;
  --label-tertiary: #3C3C43;
  --label-tertiary-dark: #EBEBF5;
  --label-quaternary: #3C3C43;
  --label-quaternary-dark: #EBEBF5;
  
  /* 分隔符颜色 */
  --separator: #3C3C43;
  --separator-dark: #54545A;
  --opaque-separator: #C6C6C8;
  --opaque-separator-dark: #38383A;
  
  /* 天气主题渐变色 */
  --sunny-gradient: linear-gradient(135deg, #FFD60A 0%, #FF8500 100%);
  --sunny-gradient-light: linear-gradient(135deg, #FFEB3B 0%, #FFC107 100%);
  --windy-gradient: linear-gradient(135deg, #48CAE4 0%, #0077B6 100%);
  --windy-gradient-light: linear-gradient(135deg, #81D4FA 0%, #29B6F6 100%);
  --rainy-gradient: linear-gradient(135deg, #495057 0%, #212529 100%);
  --rainy-gradient-light: linear-gradient(135deg, #78909C 0%, #546E7A 100%);
  --snowy-gradient: linear-gradient(135deg, #E9ECEF 0%, #ADB5BD 100%);
  --snowy-gradient-light: linear-gradient(135deg, #F5F5F5 0%, #E0E0E0 100%);
  
  /* 阴影系统 */
  --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-large: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
  
  /* 圆角系统 */
  --radius-small: 6px;
  --radius-medium: 12px;
  --radius-large: 16px;
  --radius-xl: 20px;
  --radius-full: 50%;
  
  /* 间距系统 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  
  /* 字体系统 */
  --font-family-display: -apple-system, SF Pro Display, system-ui, sans-serif;
  --font-family-text: -apple-system, SF Pro Text, system-ui, sans-serif;
  --font-family-mono: SF Mono, Monaco, monospace;
  
  /* 字体大小 */
  --font-size-caption2: 11px;
  --font-size-caption1: 12px;
  --font-size-footnote: 13px;
  --font-size-subheadline: 15px;
  --font-size-callout: 16px;
  --font-size-body: 17px;
  --font-size-headline: 17px;
  --font-size-title3: 20px;
  --font-size-title2: 22px;
  --font-size-title1: 28px;
  --font-size-large-title: 34px;
  
  /* 动画时长 */
  --animation-fast: 0.15s;
  --animation-normal: 0.25s;
  --animation-slow: 0.35s;
  --animation-slower: 0.5s;
  
  /* 缓动函数 */
  --easing-default: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --easing-in: cubic-bezier(0.42, 0, 1, 1);
  --easing-out: cubic-bezier(0, 0, 0.58, 1);
  --easing-in-out: cubic-bezier(0.42, 0, 0.58, 1);
  --easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 深色模式变量覆盖 */
@media (prefers-color-scheme: dark) {
  :root {
    --current-background: var(--system-background-dark);
    --current-secondary-background: var(--secondary-background-dark);
    --current-tertiary-background: var(--tertiary-background-dark);
    --current-label-primary: var(--label-primary-dark);
    --current-label-secondary: var(--label-secondary-dark);
    --current-separator: var(--separator-dark);
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --current-background: var(--system-background);
    --current-secondary-background: var(--secondary-background);
    --current-tertiary-background: var(--tertiary-background);
    --current-label-primary: var(--label-primary);
    --current-label-secondary: var(--label-secondary);
    --current-separator: var(--separator);
  }
}

/* ===== 基础重置和标准化 ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family-text);
  font-size: var(--font-size-body);
  font-weight: 400;
  line-height: 1.47;
  letter-spacing: -0.43px;
  color: var(--current-label-primary);
  background-color: var(--current-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ===== 字体样式类 ===== */
.typography-large-title {
  font-family: var(--font-family-display);
  font-size: var(--font-size-large-title);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0.37px;
}

.typography-title1 {
  font-family: var(--font-family-display);
  font-size: var(--font-size-title1);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: 0.36px;
}

.typography-title2 {
  font-family: var(--font-family-display);
  font-size: var(--font-size-title2);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0.35px;
}

.typography-title3 {
  font-family: var(--font-family-display);
  font-size: var(--font-size-title3);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.38px;
}

.typography-headline {
  font-family: var(--font-family-text);
  font-size: var(--font-size-headline);
  font-weight: 600;
  line-height: 1.29;
  letter-spacing: -0.41px;
}

.typography-body {
  font-family: var(--font-family-text);
  font-size: var(--font-size-body);
  font-weight: 400;
  line-height: 1.29;
  letter-spacing: -0.41px;
}

.typography-callout {
  font-family: var(--font-family-text);
  font-size: var(--font-size-callout);
  font-weight: 400;
  line-height: 1.31;
  letter-spacing: -0.32px;
}

.typography-subheadline {
  font-family: var(--font-family-text);
  font-size: var(--font-size-subheadline);
  font-weight: 400;
  line-height: 1.33;
  letter-spacing: -0.24px;
}

.typography-footnote {
  font-family: var(--font-family-text);
  font-size: var(--font-size-footnote);
  font-weight: 400;
  line-height: 1.38;
  letter-spacing: -0.08px;
}

.typography-caption1 {
  font-family: var(--font-family-text);
  font-size: var(--font-size-caption1);
  font-weight: 400;
  line-height: 1.33;
  letter-spacing: 0px;
}

.typography-caption2 {
  font-family: var(--font-family-text);
  font-size: var(--font-size-caption2);
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.07px;
}

/* ===== 主应用容器 ===== */
.weather-app {
  min-height: 100vh;
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 50%, #6c5ce7 100%);
  background-attachment: fixed;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* 添加动态背景效果 */
.weather-app::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(120, 180, 255, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 120, 180, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 40% 80%, rgba(180, 255, 120, 0.3) 0%, transparent 50%);
  animation: backgroundShift 20s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes backgroundShift {
  0%, 100% { opacity: 0.6; transform: scale(1) rotate(0deg); }
  33% { opacity: 0.8; transform: scale(1.1) rotate(2deg); }
  66% { opacity: 0.4; transform: scale(0.9) rotate(-1deg); }
}

/* ===== 标题栏样式 ===== */
.app-header {
  position: relative;
  z-index: 10;
  margin-bottom: var(--spacing-xl);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-medium);
}

.location-info .location-title {
  font-family: var(--font-family-display);
  font-size: var(--font-size-title1);
  font-weight: 700;
  color: white;
  margin-bottom: var(--spacing-xs);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.location-info .location-subtitle {
  font-family: var(--font-family-text);
  font-size: var(--font-size-subheadline);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
}

.current-time {
  text-align: right;
}

.time-display {
  font-family: var(--font-family-display);
  font-size: var(--font-size-title2);
  font-weight: 600;
  color: white;
  display: block;
  margin-bottom: var(--spacing-xs);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.date-display {
  font-family: var(--font-family-text);
  font-size: var(--font-size-footnote);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
}

/* ===== 主要内容区域 ===== */
.main-content {
  flex: 1;
  position: relative;
  z-index: 5;
}

/* ===== 页脚样式 ===== */
.app-footer {
  margin-top: var(--spacing-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-large);
  position: relative;
  z-index: 10;
}

.refresh-button {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--primary-blue);
  color: white;
  border: none;
  border-radius: var(--radius-medium);
  font-family: var(--font-family-text);
  font-size: var(--font-size-callout);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--animation-normal) var(--easing-default);
  will-change: transform, background-color;
}

.refresh-button:hover {
  background: var(--primary-blue-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-medium);
}

.refresh-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-small);
}

.refresh-button:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.refresh-icon {
  font-size: 18px;
  transition: transform var(--animation-slow) var(--easing-default);
}

.refresh-button:hover .refresh-icon {
  transform: rotate(180deg);
}

.last-updated {
  font-family: var(--font-family-text);
  font-size: var(--font-size-footnote);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
}

/* ===== 加载指示器 ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--animation-normal) var(--easing-default);
}

.loading-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-large);
  padding: var(--spacing-xl);
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--primary-blue-light);
  border-top: 3px solid var(--primary-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== 无障碍访问增强 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .weather-app::before {
    animation: none;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  .header-content,
  .app-footer {
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.8);
  }
  
  .refresh-button {
    border: 2px solid white;
  }
}

/* 焦点可见性增强 */
*:focus {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

/* ===== 工具类 ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.invisible {
  visibility: hidden !important;
}

.opacity-0 {
  opacity: 0 !important;
}