/**
 * style.css — 人生关键窗口期观测系统
 * 温暖 · 清晰 · 克制的视觉语言
 */

/* ── Variables ────────────────────────────────────────────────── */
:root {
  /* Palette */
  --clr-bg: #f7f5f0;
  --clr-surface: #ffffff;
  --clr-border: #e4e0d8;

  --clr-green: #3d6b47;
  --clr-green-light: #d6e8da;
  --clr-amber: #b45309;
  --clr-amber-light: #fef0d9;
  --clr-terra: #9a3412;
  --clr-terra-light: #fddba8;
  --clr-crimson: #b91c1c;
  --clr-crimson-light: #fee2e2;
  --clr-grey: #6b7280;
  --clr-grey-light: #f3f4f6;

  --clr-text: #1a1814;
  --clr-text-md: #5c5650;
  --clr-text-sm: #9c9590;

  /* Lock-force fixed color tiers */
  --clr-lf-high: #b91c1c; /* ≥90 */
  --clr-lf-mid: #9a3412; /* 70-89 */
  --clr-lf-low: #b45309; /* 50-69 */
  --clr-lf-gentle: #3d6b47; /* <50 */

  /* Cost colors */
  --clr-low: #3d6b47;
  --clr-medium: #b45309;
  --clr-high: #9a3412;
  --clr-extreme: #b91c1c;

  /* Typography */
  --font-d: 'Georgia', 'Songti SC', 'SimSun', serif;
  --font-b:
    'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', system-ui, sans-serif;

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;

  /* Shadows */
  --sh-card: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.06);
  --sh-hover: 0 8px 28px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  --sh-modal: 0 32px 80px rgba(0, 0, 0, 0.22), 0 8px 24px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --t-f: 120ms ease-out;
  --t-n: 200ms ease-out;
  --t-s: 300ms ease-out;
}

/* ── Reset ────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--clr-bg);
  color: var(--clr-text);
  font-family: var(--font-b);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Scrollbar & Selection ───────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--clr-border);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--clr-text-sm);
}
::selection {
  background: var(--clr-green-light);
  color: var(--clr-text);
}

/* ── HEADER ───────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--clr-bg);
  border-bottom: 1px solid var(--clr-border);
  padding: 0;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 14px clamp(20px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* Left block */
.header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.site-title {
  font-family: var(--font-d);
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 700;
  color: var(--clr-text);
  letter-spacing: -0.025em;
  line-height: 1.2;
  white-space: nowrap;
}

.site-subtitle {
  font-size: 12px;
  color: var(--clr-text-sm);
  line-height: 1.4;
}

.site-subtitle em {
  color: var(--clr-amber);
  font-style: normal;
  font-weight: 400;
}

/* Right controls */
.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* Stage toggle */
.stage-toggle {
  display: flex;
  background: var(--clr-border);
  border-radius: 99px;
  padding: 3px;
  gap: 2px;
  user-select: none;
}

.stage-btn {
  font-family: var(--font-b);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 16px;
  border: none;
  border-radius: 99px;
  cursor: pointer;
  background: transparent;
  color: var(--clr-text-sm);
  transition:
    background var(--t-n),
    color var(--t-n),
    box-shadow var(--t-n);
}

.stage-btn.active {
  background: var(--clr-surface);
  color: var(--clr-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.stage-btn:hover:not(.active) {
  color: var(--clr-text-md);
}

/* Slider */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

.slider-label {
  font-size: 12px;
  color: var(--clr-text-sm);
  font-weight: 500;
  white-space: nowrap;
}

.slider-track {
  display: flex;
  align-items: center;
  gap: 12px;
}

.age-slider {
  width: 202px;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--clr-border);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.age-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--clr-green);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(61, 107, 71, 0.4);
  transition:
    transform var(--t-f),
    box-shadow var(--t-f);
}

.age-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(61, 107, 71, 0.45);
}

.age-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--clr-green);
  cursor: pointer;
}

.age-slider:focus-visible {
  outline: 2px solid var(--clr-green);
  outline-offset: 3px;
}

.slider-num {
  font-family: var(--font-d);
  font-size: 22px;
  font-weight: 700;
  color: var(--clr-text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
}

.slider-unit {
  font-size: 12px;
  color: var(--clr-text-sm);
}

/* ── MAIN ─────────────────────────────────────────────────────── */
.site-main {
  padding: clamp(24px, 4vw, 44px) 0;
}

.main-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px);
}

/* ── CARDS GRID ──────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

@media (max-width: 1400px) {
  .cards-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 1050px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 720px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

/* ── CARD ─────────────────────────────────────────────────────── */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-lg);
  padding: 15px 16px 14px;
  cursor: pointer;
  box-shadow: var(--sh-card);
  display: flex;
  flex-direction: column;
  gap: 9px;
  outline: none;
  transition:
    transform var(--t-n),
    box-shadow var(--t-n);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-hover);
}

.card:focus-visible {
  outline: 2px solid var(--clr-green);
  outline-offset: 2px;
}

.card--locked {
  opacity: 0.5;
  pointer-events: none;
}

/* ── BADGE — text color only, no background ─────────────────── */
.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  width: fit-content;
  line-height: 1;
  letter-spacing: 0.01em;
}

.badge-icon {
  font-size: 11px;
}
.badge-text {
  line-height: 1;
}

/* State colors via text/icon color only */
.badge--open {
  color: var(--clr-green);
}
.badge--countdown {
  color: var(--clr-amber);
}
.badge--rescue {
  color: var(--clr-terra);
}
.badge--penalty {
  color: var(--clr-crimson);
}
.badge--locked {
  color: var(--clr-grey);
}

/* ── CARD TYPOGRAPHY ─────────────────────────────────────────── */
.card-title {
  font-family: var(--font-b);
  font-size: 14px;
  font-weight: 600;
  color: var(--clr-text);
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.meta-label {
  color: var(--clr-text-sm);
  font-weight: 500;
}

.meta-range {
  color: var(--clr-text-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── PROGRESS BAR ──────────────────────────────────────────────── */
.card-progress-track {
  width: 100%;
  height: 5px;
  background: var(--clr-border);
  border-radius: 99px;
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition:
    width var(--t-s),
    background var(--t-s);
}

.progress--open {
  background: var(--clr-green);
}
.progress--countdown {
  background: var(--clr-amber);
}
.progress--rescue {
  background: var(--clr-terra);
}
.progress--penalty {
  background: var(--clr-crimson);
}
.progress--locked {
  background: var(--clr-grey);
}

/* ── CARD DESCRIPTION ───────────────────────────────────────────── */
.card-desc {
  font-size: 12.5px;
  color: var(--clr-text-sm);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: calc(12.5px * 1.65 * 3);
  flex: none;
}

/* ── CARD METRICS — clean inline row, no cross ─────────────── */
.card-metrics {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--clr-border);
  gap: 8px;
}

.lf-inline {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cost-inline {
  font-size: 11px;
  font-weight: 600;
}

/* Lock-force: fixed color by threshold */
.lf--gentle {
  color: var(--clr-lf-gentle);
}
.lf--low {
  color: var(--clr-lf-low);
}
.lf--mid {
  color: var(--clr-lf-mid);
}
.lf--high {
  color: var(--clr-lf-high);
}

/* Rescue cost: fixed color by level */
.cost--low {
  color: var(--clr-low);
}
.cost--medium {
  color: var(--clr-medium);
}
.cost--high {
  color: var(--clr-high);
}
.cost--extreme {
  color: var(--clr-extreme);
  font-weight: 800;
}
.cost--hidden {
  color: var(--clr-text-sm);
}

/* ── CARD TAG ──────────────────────────────────────────────────── */
.card-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  color: var(--clr-text-sm);
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  padding: 2px 8px;
  border-radius: 99px;
  width: fit-content;
  letter-spacing: 0.02em;
  margin-top: auto;
}

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--clr-text-sm);
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.empty-text {
  font-size: 15px;
}

/* ── MODAL ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 20, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ov-in var(--t-n) ease-out;
}

@keyframes ov-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-panel {
  background: var(--clr-surface);
  border-radius: var(--r-lg);
  padding: clamp(28px, 5vw, 44px);
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--sh-modal);
  animation: pan-in var(--t-s) cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pan-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Modal tinted background per state */
.panel--open {
  background: linear-gradient(148deg, #f0fdf4 0%, var(--clr-surface) 55%);
}
.panel--countdown {
  background: linear-gradient(148deg, #fffbeb 0%, var(--clr-surface) 55%);
}
.panel--rescue {
  background: linear-gradient(148deg, #fff7ed 0%, var(--clr-surface) 55%);
}
.panel--penalty {
  background: linear-gradient(148deg, #fef2f2 0%, var(--clr-surface) 55%);
}
.panel--locked {
  background: linear-gradient(148deg, #f9fafb 0%, var(--clr-surface) 55%);
}

/* Close button */
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--clr-text-sm);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition:
    background var(--t-f),
    color var(--t-f);
}

.modal-close:hover {
  background: var(--clr-bg);
  color: var(--clr-text);
}
.modal-close:focus-visible {
  outline: 2px solid var(--clr-green);
  outline-offset: 2px;
}

/* Modal badge */
.modal-badge-row {
  margin-bottom: 12px;
}

.modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.modal-badge .badge-icon {
  font-size: 13px;
}

/* Modal title */
.modal-title {
  font-family: var(--font-d);
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 700;
  color: var(--clr-text);
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 14px;
}

/* Modal meta */
.modal-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 10px;
}

/* Modal progress */
.modal-progress-track {
  width: 100%;
  height: 8px;
  background: var(--clr-border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 20px;
}

.modal-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition:
    width var(--t-s),
    background var(--t-s);
}

/* Modal body */
.modal-desc {
  font-size: 14px;
  color: var(--clr-text-md);
  line-height: 1.8;
  margin-bottom: 12px;
  min-height: calc(14px * 1.8 * 3);
}

.modal-impact {
  font-size: 13px;
  color: var(--clr-text-md);
  line-height: 1.7;
  background: var(--clr-bg);
  border-radius: var(--r-md);
  padding: 13px 15px;
  margin-bottom: 22px;
}

.modal-impact strong {
  color: var(--clr-text);
  font-weight: 600;
}

/* Modal metrics */
.modal-metrics {
  display: flex;
  gap: 36px;
  margin-bottom: 18px;
}

.modal-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-metric-num {
  font-family: var(--font-d);
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.modal-metric-lbl {
  font-size: 11px;
  color: var(--clr-text-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Modal tag */
.modal-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--clr-text-sm);
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  padding: 4px 12px;
  border-radius: 99px;
}

/* Modal nav arrows — horizontal left/right layout */
.modal-nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-text-md);
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sh-card);
  transition:
    background var(--t-f),
    color var(--t-f),
    opacity var(--t-f);
}

.modal-nav:hover:not(:disabled) {
  background: var(--clr-bg);
  color: var(--clr-text);
}
.modal-nav:disabled {
  opacity: 0.28;
  cursor: default;
}
.modal-nav:focus-visible {
  outline: 2px solid var(--clr-green);
  outline-offset: 2px;
}

.modal-nav-wrap {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .header-right {
    align-items: flex-start;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }
  .stage-toggle {
    flex-shrink: 0;
  }
  .slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
  }
  .slider-label {
    flex-shrink: 0;
  }
  .slider-track {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
  .age-slider {
    flex: 1;
    min-width: 0;
    width: 100%;
  }
  .slider-num {
    font-size: 20px;
  }
  .modal-nav--prev {
    bottom: 46px;
  }
  .modal-nav--next {
    bottom: 4px;
  }
}

/* ── REDUCED MOTION ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
