/* common.css - PWA global styles */
:root {
  --primary: #2d5a4a;
  --primary-light: #3d7a5e;
  --primary-dark: #1a3d2e;
  --secondary: #b83a2a;
  --secondary-light: #d4583e;
  --accent: #c4a265;
  --accent-light: #d4b87a;
  --bg: #f0ebe3;
  --bg-warm: #e8e0d4;
  --card: #faf7f2;
  --card-border: #d4c8b8;
  --text: #2c2c2c;
  --text-secondary: #6b6b6b;
  --text-ink: #1a1a1a;
  --border: #d8d0c4;
  --border-dark: #a89880;
  --shadow: 0 2px 8px rgba(60, 40, 20, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background-color: var(--bg-warm);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'STKaiti', 'KaiTi', 'SimSun', 'Microsoft YaHei', serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Desktop phone-frame layout with ad sidebars */
.app-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 24px 16px;
  gap: 24px;
}

.phone-frame {
  width: 100%;
  max-width: 390px;
  min-height: 760px;
  max-height: calc(100vh - 48px);
  background-color: #1a1a1a;
  position: relative;
  border-radius: 48px;
  box-shadow:
    0 0 0 10px #2a2a2a,
    0 0 0 12px rgba(255, 255, 255, 0.08),
    0 24px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phone-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 28px;
  background: #1a1a1a;
  border-radius: 0 0 20px 20px;
  z-index: 10;
}

.phone-frame::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  z-index: 11;
}

.page-ink-bg {
  flex: 1;
  background-color: var(--bg);
  min-height: 0;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.page-ink-bg::-webkit-scrollbar {
  display: none;
}

.article-sidebar {
  display: none;
  width: 420px;
  flex-shrink: 0;
  max-height: calc(100vh - 48px);
  overflow: visible;
  padding: 0;
  flex-direction: column;
  justify-content: flex-start;
}

.article-sidebar-title {
  font-family: 'STKaiti', 'KaiTi', 'SimSun', serif;
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--primary-dark);
  margin-bottom: 16px;
  text-align: center;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.article-card {
  background: rgba(250, 247, 242, 0.92);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(60, 40, 20, 0.12);
}

.article-card-image {
  width: 100%;
  flex: 1 1 auto;
  min-height: 100px;
  object-fit: cover;
  display: block;
}

.article-card-body {
  padding: 8px;
  flex-shrink: 0;
}

.article-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-ink);
  line-height: 1.35;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card-excerpt {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 1200px) {
  .article-sidebar {
    display: flex;
    width: 360px;
  }
}

@media (min-width: 1400px) {
  .article-sidebar {
    width: 420px;
  }
}

@media (min-width: 1600px) {
  .article-sidebar {
    width: 480px;
  }
  .app-wrapper {
    gap: 32px;
  }
}

@media (max-width: 1199px) {
  .app-wrapper {
    padding: 16px;
  }
  .phone-frame {
    max-height: none;
    border-radius: 36px;
    min-height: auto;
  }
  .phone-frame::before {
    border-radius: 0 0 16px 16px;
    height: 24px;
    width: 120px;
  }
}

@media (max-width: 430px) {
  .app-wrapper {
    padding: 0;
  }
  .phone-frame {
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
  }
  .phone-frame::before,
  .phone-frame::after {
    display: none;
  }
}

.page-ink-bg-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  opacity: 0.25;
}

.page-ink-bg-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to top, rgba(240, 235, 227, 0.95), rgba(240, 235, 227, 0.6), transparent);
  pointer-events: none;
  z-index: 0;
}

.page-ink-bg-content {
  position: relative;
  z-index: 1;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.card {
  background: rgba(250, 247, 242, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--card-border);
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.5;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-ink);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  letter-spacing: 2px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
  margin-right: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #2d5a4a, #3d7a5e);
  color: #fff;
  border-radius: 6px;
  height: 46px;
  line-height: 46px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 3px;
  box-shadow: 0 4px 12px rgba(45, 90, 74, 0.28);
  cursor: pointer;
  border: none;
  display: block;
  width: 100%;
}

.btn-primary:active {
  opacity: 0.92;
  transform: translateY(1px);
}

.btn-secondary {
  background: #faf7f2;
  color: #2d5a4a;
  border: 1px solid #2d5a4a;
  border-radius: 6px;
  height: 42px;
  line-height: 42px;
  font-size: 15px;
  text-align: center;
  letter-spacing: 2px;
  cursor: pointer;
}

.btn-secondary:active {
  background: rgba(45, 90, 74, 0.06);
}

.btn-seal {
  background: linear-gradient(135deg, #b83a2a, #d4583e);
  color: #fff;
  border-radius: 5px;
  height: 44px;
  line-height: 44px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 3px;
  box-shadow: 0 4px 11px rgba(184, 58, 42, 0.25);
  cursor: pointer;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 11px;
  margin-right: 5px;
  margin-bottom: 5px;
  letter-spacing: 1px;
  border: 1px solid transparent;
}

.tag-primary {
  background: rgba(45, 90, 74, 0.1);
  color: #2d5a4a;
  border-color: rgba(45, 90, 74, 0.25);
}

.tag-accent {
  background: rgba(196, 162, 101, 0.15);
  color: #8f6b3a;
  border-color: rgba(196, 162, 101, 0.3);
}

.tag-secondary {
  background: rgba(184, 58, 42, 0.1);
  color: #b83a2a;
  border-color: rgba(184, 58, 42, 0.25);
}

.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-ink { color: var(--text-ink); }

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.element-mu { color: #4a8c4a; font-weight: 600; }
.element-huo { color: #c23a2a; font-weight: 600; }
.element-tu { color: #8b7355; font-weight: 600; }
.element-jin { color: #b8972e; font-weight: 700; }
.element-shui { color: #2a7a9c; font-weight: 600; }

/* Header / Language switch */
.top-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 16px;
  gap: 8px;
}

.lang-switch {
  display: inline-flex;
  background: rgba(250, 247, 242, 0.9);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  overflow: hidden;
}

.lang-btn {
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: rgba(250, 247, 242, 0.96);
  border-top: 1px solid var(--card-border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
}

.bottom-nav a.active {
  color: var(--secondary);
}

.nav-icon {
  display: block;
  font-size: 20px;
  margin-bottom: 2px;
}

/* Brand */
.brand-header {
  text-align: center;
  padding: 20px 0 12px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  line-height: 56px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(45, 90, 74, 0.25);
}

.brand-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-ink);
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

/* Loading */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
}

.loading-icon {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 12px;
  color: var(--text-secondary);
}

/* Modal / Mask */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.modal-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(30, 20, 10, 0.55);
}

.modal-content {
  position: relative;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  max-height: 80vh;
  overflow-y: auto;
  padding: 16px;
  animation: slideUp 0.2s ease-out;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  font-size: 22px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
}

/* Footer */
.page-footer {
  text-align: center;
  padding: 24px 16px 80px;
  color: var(--text-secondary);
  font-size: 12px;
}

.page-footer a {
  color: var(--primary);
  text-decoration: none;
}

.hidden { display: none !important; }

/* Responsive */
@media (min-width: 768px) {
  .container {
    padding: 24px;
  }
}
