/* ══════════════════════════════════════════════════════════════════════
   Shared CSS: design tokens, reset, nav, footer, utilities, responsive
   ══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Serif:ital@0;1&display=swap');

/* ── Design tokens ─────────────────────────────────────────────────── */
:root {
  --bg: #fafaf9;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --border: #e8e8e5;
  --card-bg: #fff;
  --tag-bg: #f3f3f0;
  --green: #22c55e;
  --green-dim: #16a34a;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 14px;
  --max-width: 1100px;
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
}

/* ── Reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Animations ────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.85); }
}

.fade-up {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.fade-up.visible {
  opacity: 1;
  transform: none;
}

/* ── Layout ────────────────────────────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Nav ───────────────────────────────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 249, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.nav-logo span {
  color: var(--text-secondary);
  font-weight: 400;
}

.nav-logo:hover { text-decoration: none; }

.nav-links {
  display: flex;
  gap: 28px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.nav-links a { color: var(--text-secondary); }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ── Nav auth (homepage only) ──────────────────────────────────────── */
.nav-auth {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
}

.nav-auth-email {
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-sign-in, .btn-sign-out {
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 16px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.btn-sign-in:hover, .btn-sign-out:hover {
  background: var(--tag-bg);
  border-color: #b0b0ab;
}

/* ── Footer ────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 48px;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-logo {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.footer-logo span {
  color: var(--text-secondary);
  font-weight: 400;
}

.footer-tagline {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 260px;
}

.footer-col h4 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 4px;
}

.footer-col a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-col a:hover {
  color: var(--text);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.footer-bottom a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-bottom a:hover {
  color: var(--text);
}

/* ── Letter Banner ─────────────────────────────────────────────────── */
.letter-bar {
  background: #1a1a1a;
  color: #fff;
  text-align: center;
  padding: 10px 24px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
  transition: background 0.2s;
  user-select: none;
}

.letter-bar:hover { background: #2a2a2a; }

.letter-bar-inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.letter-bar .bar-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

.letter-bar .bar-chevron {
  display: inline-block;
  transition: transform 0.3s ease;
  font-size: 0.75rem;
}

.letter-bar.open .bar-chevron {
  transform: rotate(180deg);
}

/* ── Letter overlay ─────────────────────────────────────────────── */
.letter-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  pointer-events: none;
  opacity: 0;
  transition: background 0.4s ease, backdrop-filter 0.4s ease, -webkit-backdrop-filter 0.4s ease, opacity 0.3s ease;
}

.letter-overlay.visible {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  opacity: 1;
}

.letter-card {
  background: #fffef8;
  max-width: 620px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 4px;
  padding: 48px 44px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
  position: relative;
  transform: scale(0.9) translateY(30px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  font-family: var(--font-serif);
  border: 1px solid #e8e4d8;
  /* subtle paper texture */
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(255,252,240,0.6) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(245,240,220,0.4) 0%, transparent 60%);
}

.letter-overlay.visible .letter-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.letter-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
  font-family: var(--font-sans);
}

.letter-close:hover { color: #333; }

.letter-date {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 28px;
}

.letter-to {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  color: #555;
  margin-bottom: 24px;
}

.letter-body p {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.75;
  color: #333;
  margin-bottom: 16px;
}

.letter-body p:last-child {
  margin-bottom: 0;
}

.letter-body strong {
  font-weight: 600;
  color: #1a1a1a;
}

.letter-body .letter-stat {
  font-family: var(--font-sans);
  display: block;
  background: #f8f7f2;
  border-left: 3px solid #1a1a1a;
  padding: 12px 16px;
  margin: 20px 0;
  font-size: 0.85rem;
  color: #444;
  line-height: 1.7;
  border-radius: 0 6px 6px 0;
}

.letter-body .letter-stat span {
  font-weight: 700;
  color: #1a1a1a;
}

.letter-body .letter-highlight {
  background: linear-gradient(to bottom, transparent 60%, rgba(34,197,94,0.18) 60%);
  padding: 0 2px;
}

/* ── Letter section headers ───────────────────────────────────────── */
.letter-section-head {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 400;
  color: #1a1a1a;
  margin: 32px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e8e4d8;
  letter-spacing: -0.01em;
}

/* ── Letter quote grid ────────────────────────────────────────────── */
.letter-quote-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.letter-quote {
  background: #f8f7f2;
  border-radius: 8px;
  padding: 14px 16px;
  border: 1px solid #ece9de;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.letter-quote p {
  font-family: var(--font-sans) !important;
  font-size: 0.82rem !important;
  line-height: 1.6 !important;
  color: #444 !important;
  margin-bottom: 8px !important;
  font-style: italic;
}

.letter-quote cite {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 600;
  color: #999;
  display: block;
}

@media (max-width: 600px) {
  .letter-quote-grid { grid-template-columns: 1fr; }
}

/* ── Letter chart containers ──────────────────────────────────────── */
.letter-chart {
  margin: 16px -12px;
  min-height: 80px;
  border-radius: 8px;
  overflow: hidden;
}

.letter-sign {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #e8e4d8;
}

.letter-sign-off {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 4px;
}

.letter-sign-name {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1a1a;
}

.letter-sign-title {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: #999;
}

.letter-ps {
  margin-top: 24px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: #888;
  font-style: italic;
  line-height: 1.6;
}

.letter-cta {
  display: inline-block;
  margin-top: 24px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: 12px 32px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}

.letter-cta:hover { background: #333; color: #fff; }
.letter-cta:active { transform: scale(0.97); }

.letter-help {
  margin-top: 24px;
  padding: 16px 20px;
  background: #f8f7f2;
  border: 1px solid #ece9de;
  border-radius: 8px;
}

.letter-help p {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.65;
  color: #555;
  margin-bottom: 6px;
}

.letter-help p:last-child { margin-bottom: 0; }

.letter-help a {
  color: #1a1a1a;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.letter-help a:hover { color: #555; }

@media (max-width: 768px) {
  .letter-card {
    padding: 32px 24px;
    max-height: 90vh;
  }
  .letter-body p { font-size: 0.88rem; }
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }
}
