/* ═══════════════════════════════════════════
   LearnLattice — Main Stylesheet
   ═══════════════════════════════════════════ */

:root {
  --ink: #134E4A;
  --ink-deep: #0f3d38;
  --ink-light: #2d6a5e;
  --ink-muted: #5f8a82;
  --surface: #f8faf9;
  --surface-warm: #f0f5f3;
  --surface-card: #ffffff;
  --teal: #0D9488;
  --teal-deep: #0a7c72;
  --teal-bright: #14b8a6;
  --teal-light: #ccfbf1;
  --teal-wash: #e6faf6;
  --sky: #0284C7;
  --sky-light: #e0f2fe;
  --amber: #d97706;
  --amber-warm: #F59E0B;
  --amber-light: #fef3c7;
  --rose: #e11d48;
  --rose-light: #ffe4e6;
  --border: #d5e5e0;
  --border-hover: #b0cec6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(13,78,74,0.05);
  --shadow-md: 0 4px 16px rgba(13,78,74,0.07);
  --shadow-lg: 0 8px 32px rgba(13,78,74,0.09);
  --shadow-hover: 0 12px 40px rgba(13,78,74,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--surface);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

img { max-width: 100%; height: auto; }

/* ─── LATTICE BACKGROUND ─── */
.lattice-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.25;
  background-image: radial-gradient(circle at 1px 1px, #a8d5cf 1px, transparent 0);
  background-size: 40px 40px;
}

/* ─── NAV ─── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248,250,249,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.nav-logo-svg { width: 38px; height: 38px; }

.nav-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -0.5px;
}

.nav-title-accent {
  color: var(--teal);
  font-weight: 400;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  transition: color 0.2s;
  position: relative;
}

.nav-links a:hover { color: var(--ink); }

.nav-links a.active {
  color: var(--teal);
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -22px;
  left: 0; right: 0;
  height: 2px;
  background: var(--teal);
  border-radius: 1px;
}

.nav-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-search:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.nav-search svg { color: var(--ink-muted); }

.nav-search span {
  font-size: 13px;
  color: var(--ink-muted);
}

.nav-search kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink-muted);
  margin-left: 12px;
}

/* ─── HERO ─── */
.hero {
  position: relative;
  z-index: 1;
  padding: 100px 48px 80px;
  max-width: 1200px;
  margin: 0 auto;
}

.hero-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeUp 0.6s ease both;
}

.hero-eyebrow::before {
  content: '';
  width: 32px;
  height: 2px;
  background: var(--teal);
  border-radius: 1px;
}

.hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(42px, 5.5vw, 72px);
  line-height: 1.08;
  letter-spacing: -1.5px;
  color: var(--ink);
  max-width: 700px;
  margin-bottom: 24px;
  animation: fadeUp 0.6s ease 0.1s both;
}

.hero h1 em {
  font-style: italic;
  color: var(--teal);
}

.hero p {
  font-size: 18px;
  line-height: 1.7;
  color: var(--ink-muted);
  max-width: 520px;
  margin-bottom: 40px;
  font-weight: 300;
  animation: fadeUp 0.6s ease 0.2s both;
}

.hero-actions {
  display: flex;
  gap: 16px;
  animation: fadeUp 0.6s ease 0.3s both;
}

/* ─── BUTTONS ─── */
.btn-primary {
  padding: 14px 28px;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 100px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--teal-deep);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  padding: 14px 28px;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-secondary:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-wash);
}

.btn-amber {
  padding: 14px 32px;
  background: var(--amber-warm);
  color: #451a03;
  border: none;
  border-radius: 100px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}

.btn-amber:hover {
  background: #fbbf24;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

/* ─── STATS ─── */
.stats {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 48px 80px;
  display: flex;
  gap: 48px;
  animation: fadeUp 0.6s ease 0.4s both;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.stat-num {
  font-family: 'DM Serif Display', serif;
  font-size: 36px;
  color: var(--ink);
  letter-spacing: -1px;
}

.stat-label {
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 400;
  line-height: 1.4;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  align-self: center;
}

/* ─── SECTIONS ─── */
.section {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 48px 72px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 36px;
}

.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 32px;
  letter-spacing: -0.5px;
  color: var(--ink);
}

.section-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--teal);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: gap 0.2s;
}

.section-link:hover { gap: 10px; }

/* ─── SUBJECT CARDS ─── */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.subject-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0, 0, 1);
  position: relative;
  overflow: hidden;
}

.subject-card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

.subject-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.subject-card:hover::before { opacity: 1; }

.subject-card[data-color="teal"]::before { background: var(--teal); }
.subject-card[data-color="sky"]::before { background: var(--sky); }
.subject-card[data-color="amber"]::before { background: var(--amber); }
.subject-card[data-color="rose"]::before { background: var(--rose); }

.subject-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 20px;
}

.subject-card[data-color="teal"] .subject-icon { background: var(--teal-light); }
.subject-card[data-color="sky"] .subject-icon { background: var(--sky-light); }
.subject-card[data-color="amber"] .subject-icon { background: var(--amber-light); }
.subject-card[data-color="rose"] .subject-icon { background: var(--rose-light); }

.subject-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.subject-card p {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.5;
  font-weight: 300;
}

.subject-count {
  margin-top: 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
}

/* ─── RESOURCE CARDS ─── */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.resource-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0, 0, 1);
}

.resource-card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

.resource-thumb {
  height: 180px;
  position: relative;
  overflow: hidden;
}

.resource-thumb.teal-bg {
  background: linear-gradient(135deg, #042f2e 0%, #0D9488 50%, #5eead4 100%);
}

.resource-thumb.sky-bg {
  background: linear-gradient(135deg, #0c4a6e 0%, #0284C7 50%, #7dd3fc 100%);
}

.resource-thumb.amber-bg {
  background: linear-gradient(135deg, #78350f 0%, #d97706 50%, #fcd34d 100%);
}

.resource-thumb.rose-bg {
  background: linear-gradient(135deg, #881337 0%, #e11d48 50%, #fda4af 100%);
}

.resource-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.resource-thumb .formula {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'DM Serif Display', serif;
  font-size: 42px;
  font-style: italic;
  color: rgba(255,255,255,0.2);
  white-space: nowrap;
  letter-spacing: 2px;
  z-index: 1;
}

.resource-thumb-label {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 4px 12px;
  background: rgba(255,255,255,0.95);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  z-index: 2;
}

.resource-thumb-type {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  color: white;
  border-radius: 100px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 2;
}

.resource-body {
  padding: 22px 24px;
}

.resource-body h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  line-height: 1.35;
}

.resource-body p {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.6;
  font-weight: 300;
  margin-bottom: 16px;
}

.resource-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.resource-tag {
  padding: 3px 10px;
  background: var(--surface-warm);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-light);
}

/* ─── SINGLE RESOURCE PAGE ─── */
.resource-single {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: 60px 24px 80px;
}

.resource-single-header {
  margin-bottom: 40px;
}

.resource-single-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--teal);
  margin-bottom: 24px;
  transition: gap 0.2s;
}

.resource-single-back:hover { gap: 10px; }

.resource-single-header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -1px;
  color: var(--ink);
  margin-bottom: 16px;
}

.resource-single-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.resource-single-date {
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 300;
}

.resource-content {
  font-size: 17px;
  line-height: 1.8;
  color: var(--ink-light);
}

.resource-content h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  color: var(--ink);
  margin: 48px 0 16px;
  letter-spacing: -0.5px;
}

.resource-content h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  margin: 32px 0 12px;
}

.resource-content p { margin-bottom: 20px; }

.resource-content ul, .resource-content ol {
  margin-bottom: 20px;
  padding-left: 24px;
}

.resource-content li { margin-bottom: 8px; }

.resource-content a {
  color: var(--teal);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.resource-content img {
  border-radius: var(--radius);
  margin: 24px 0;
}

.resource-content blockquote {
  border-left: 3px solid var(--teal);
  padding: 16px 24px;
  margin: 24px 0;
  background: var(--teal-wash);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--ink-light);
}

/* Download box */
.download-box {
  background: var(--surface-card);
  border: 2px solid var(--teal-light);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin: 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.download-box-info h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.download-box-info p {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 0;
}

/* ─── TOPIC PILLS ─── */
.topics-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.topic-pill {
  padding: 10px 20px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-light);
  cursor: pointer;
  transition: all 0.2s;
}

.topic-pill:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-wash);
}

.topic-pill .count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-muted);
  margin-left: 6px;
}

/* ─── FEATURED BANNER ─── */
.featured-banner {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto 72px;
  padding: 0 48px;
}

.featured-inner {
  background: linear-gradient(135deg, #042f2e 0%, #134E4A 40%, #0D9488 100%);
  border-radius: 20px;
  padding: 56px 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
  position: relative;
  overflow: hidden;
}

.featured-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.featured-inner::after {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,158,11,0.15) 0%, transparent 70%);
}

.featured-text {
  position: relative;
  z-index: 1;
}

.featured-text h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 32px;
  color: white;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  line-height: 1.2;
}

.featured-text p {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  font-weight: 300;
  line-height: 1.6;
  max-width: 420px;
}

/* ─── PAGE HEADER (for list/taxonomy pages) ─── */
.page-header {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 48px 48px;
}

.page-header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 48px;
  letter-spacing: -1px;
  color: var(--ink);
  margin-bottom: 12px;
}

.page-header p {
  font-size: 18px;
  color: var(--ink-muted);
  font-weight: 300;
  max-width: 560px;
  line-height: 1.6;
}

/* ─── FOOTER ─── */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 48px;
  margin-top: 40px;
  background: var(--surface-warm);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.footer-brand-text {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--ink);
}

.footer-tagline {
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 300;
  max-width: 280px;
  line-height: 1.6;
}

.footer-links {
  display: flex;
  gap: 64px;
}

.footer-col h4 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 16px;
}

.footer-col a {
  display: block;
  font-size: 14px;
  color: var(--ink-light);
  margin-bottom: 10px;
  font-weight: 400;
  transition: color 0.2s;
}

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

.footer-bottom {
  max-width: 1200px;
  margin: 32px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 300;
}

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

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1024px) {
  .subjects-grid { grid-template-columns: repeat(2, 1fr); }
  .resources-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  nav { padding: 0 24px; }
  .nav-links { display: none; }
  .nav-search { display: none; }
  .hero { padding: 60px 24px 48px; }
  .stats { padding: 0 24px 48px; flex-wrap: wrap; gap: 24px; }
  .section { padding: 0 24px 48px; }
  .subjects-grid { grid-template-columns: 1fr; }
  .resources-grid { grid-template-columns: 1fr; }
  .featured-banner { padding: 0 24px; }
  .featured-inner { flex-direction: column; padding: 40px 32px; text-align: center; }
  .featured-text p { max-width: 100%; }
  .page-header { padding: 48px 24px 32px; }
  .page-header h1 { font-size: 36px; }
  footer { padding: 32px 24px; }
  .footer-inner { flex-direction: column; gap: 32px; }
  .footer-links { gap: 32px; }
  .resource-single { padding: 40px 20px 60px; }
  .resource-single-header h1 { font-size: 30px; }
  .download-box { flex-direction: column; text-align: center; }
}
