/* Layout - sanfen-h5-native */

/* App shell */
#app {
  max-width: var(--app-max-width);
  margin: 0 auto;
  background: var(--bg);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding-bottom: calc(var(--tab-bar-height) + var(--space-lg) + var(--safe-bottom));
}

/* Page content container */
#page-content {
  width: 100%;
  min-height: 100vh;
}

/* Page fade-in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page {
  animation: fadeIn 250ms ease forwards;
}

/* ========================================
   Header - unified hero gradient
   ======================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, #4F8BFF 0%, #2563EB 50%, #1D4ED8 100%);
  color: var(--text-on-primary);
  padding: calc(var(--safe-top) + var(--space-xl)) var(--space-xl) var(--space-xl);
  overflow: hidden;
  border-radius: 0 0 28px 28px;
  box-shadow: 0 8px 24px -8px rgba(29, 78, 216, 0.35);
}

/* Decorative blurred orbs for visual depth */
.header::before,
.header::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.header::before {
  width: 240px;
  height: 240px;
  top: -90px;
  right: -70px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 70%);
  filter: blur(10px);
}

.header::after {
  width: 180px;
  height: 180px;
  bottom: -60px;
  left: -50px;
  background: radial-gradient(circle, rgba(147, 197, 253, 0.35) 0%, rgba(147, 197, 253, 0) 70%);
  filter: blur(8px);
}

.header__top {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
}

.header__title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header__title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.4px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header__subtitle {
  font-size: 12.5px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.2px;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header__date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.header__date svg {
  width: 13px;
  height: 13px;
  opacity: 0.9;
}

.header__icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #ffffff;
  cursor: pointer;
  padding: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.header__icon-btn:active {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(0.94);
}

.header__icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Compact header for sub-pages (no subtitle, smaller title) */
.header--compact {
  padding: calc(var(--safe-top) + var(--space-lg)) var(--space-lg) var(--space-lg);
  border-radius: 0 0 24px 24px;
}

.header--compact .header__top {
  align-items: center;
  gap: 8px;
}

.header--compact .header__title-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header--compact .header__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}

.header--compact .header__icon-btn {
  width: 34px;
  height: 34px;
}

/* Variant: header with integrated tabs (community, news) */
.header__tabs {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 6px;
  margin-top: var(--space-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.header__tabs::-webkit-scrollbar {
  display: none;
}

.header__tab {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.header__tab:active {
  background: rgba(255, 255, 255, 0.22);
}

.header__tab--active {
  background: #ffffff;
  color: var(--primary);
  border-color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Variant: header with integrated profile (mine page) */
.header__profile {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: var(--space-lg);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.header__profile:active {
  background: rgba(255, 255, 255, 0.24);
}

.header__profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff 0%, #DBEAFE 100%);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.header__profile-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header__profile-name {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.2;
}

.header__profile-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.2;
}

.header__profile-arrow {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
}

.header__profile-arrow svg {
  width: 16px;
  height: 16px;
}

/* Safe-area helpers */
.safe-top {
  padding-top: calc(var(--safe-top) + var(--space-lg));
}

.safe-bottom {
  padding-bottom: calc(var(--safe-bottom) + var(--space-lg));
}

/* Desktop preview frame (optional, mirrors mockup presentation) */
@media (min-width: 480px) {
  body {
    background: var(--desktop-preview-bg);
  }

  #app {
    margin: var(--space-xl) auto;
    border-radius: 40px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.15), 0 10px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
  }
}
