:root {
  --font-body: 'Amaranth', Arial, sans-serif;
  --font-heading: 'Inter', Helvetica, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --color-primary: #667eea;
  --color-primary-2: #764ba2;
  --color-accent-pink: #f093fb;
  --color-accent-blue: #4facfe;

  --color-text: #2d3748;
  --color-text-muted: #718096;
  --color-bg: #f7fafc;
  --color-bg-card: #ffffff;
  --color-border: #e2e8f0;

  /* chart ink adapts to theme so original charts stay legible in both modes */
  --chart-ink: #475569;
  --chart-grid: #e8edf4;
}
[data-theme="dark"] {
  --color-text: #e2e8f0;
  --color-text-muted: #a0aec0;
  --color-bg: #141a26;
  --color-bg-card: #1f2735;
  --color-border: #33415a;
  --chart-ink: #aab6cc;
  --chart-grid: #2c374a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-body); color: var(--color-text);
  background: var(--color-bg); line-height: 1.6; padding-top: 44px; -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; } }

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 800; line-height: 1.2; }
a { color: var(--color-primary); }

.skip-link { position: absolute; left: -999px; top: 0; z-index: 10000; background: var(--color-primary); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }

/* ---------- Top bar ---------- */
.im-topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; background: rgba(16, 21, 34, 0.95); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid rgba(255,255,255,0.08); padding: 0.5rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.im-topbar-home { display: flex; align-items: center; gap: 0.5rem; color: #fff; text-decoration: none; font-family: var(--font-heading); font-weight: 700; }
.im-topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.im-premium-btn { display: inline-flex; align-items: center; gap: 0.35rem; background: linear-gradient(135deg, #667eea, #764ba2); color: #ffffff; -webkit-text-fill-color: #ffffff; text-decoration: none; font-weight: 700; font-size: 0.85rem; padding: 0.4rem 0.8rem; border-radius: 8px; font-family: var(--font-heading); }
.im-premium-btn svg { width: 15px; height: 15px; }
.im-theme-selector { display: flex; gap: 2px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; padding: 2px; }
.im-theme-btn { background: transparent; border: none; color: #9aa6c8; padding: 6px; border-radius: 5px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; }
.im-theme-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.im-theme-btn.active { background: var(--color-primary); color: #fff; }
.im-theme-btn svg { width: 16px; height: 16px; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; background: radial-gradient(1100px 540px at 78% -10%, rgba(118,75,162,0.5), transparent 60%), radial-gradient(820px 480px at 8% 115%, rgba(79,172,254,0.38), transparent 55%), linear-gradient(135deg, #101522 0%, #1a1838 55%, #241a44 100%); color: #fff; padding: 6rem 1.5rem 5rem; text-align: center; }
.hero-inner { max-width: 880px; margin: 0 auto; position: relative; z-index: 2; }
.hero .eyebrow { display: inline-block; font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 3px; text-transform: uppercase; color: #c9b8ff; border: 1px solid rgba(255,255,255,0.2); padding: 0.35rem 0.9rem; border-radius: 999px; margin-bottom: 1.5rem; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); margin: 0; letter-spacing: -1.5px; }
.hero h1 .accent { background: linear-gradient(90deg, #f093fb, #4facfe); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero .lede { font-size: 1.25rem; color: #eef1ff; font-weight: 700; font-family: var(--font-heading); margin: 1rem auto 0; max-width: 660px; }
.hero .sub { font-size: 1.02rem; color: #cdd5f2; max-width: 640px; margin: 1.1rem auto 0; }
.hero-cta { margin-top: 2.2rem; display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--font-heading); font-weight: 700; text-decoration: none; padding: 0.75rem 1.4rem; border-radius: 10px; font-size: 0.95rem; cursor: pointer; border: none; }
.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; -webkit-text-fill-color: #fff; }
.btn-ghost { background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.22); }
.btn:hover { transform: translateY(-2px); transition: transform 0.2s; }
.hero-dots { position: absolute; inset: 0; z-index: 1; opacity: 0.5; }
.hero-dots span { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.5); animation: drift 9s ease-in-out infinite; }

/* ---------- Layout ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.section { padding: 4.5rem 0; }
.section-head { max-width: 760px; margin: 0 auto 3rem; text-align: center; }
.section-head .kicker { font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 2.5px; text-transform: uppercase; color: var(--color-primary); }
.section-head h2 { font-size: clamp(1.9rem, 4vw, 2.7rem); margin: 0.6rem 0 0.8rem; color: var(--color-text); }
.section-head p { color: var(--color-text-muted); font-size: 1.05rem; margin: 0; }

/* ---------- Cards grid ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 1.8rem; }
@media (min-width: 860px) { .grid { grid-template-columns: 1fr 1fr; } }

.card { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 18px; padding: 1.6rem 1.7rem 1.5rem; box-shadow: 0 10px 30px rgba(15,23,42,0.06); display: flex; flex-direction: column; opacity: 0; transform: translateY(22px); }
.card.in { opacity: 1; transform: none; transition: opacity 0.7s ease, transform 0.7s ease; }
.card .tag { align-self: flex-start; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 1.4px; text-transform: uppercase; color: var(--color-primary); background: rgba(102,126,234,0.12); padding: 0.22rem 0.6rem; border-radius: 6px; margin-bottom: 0.7rem; }
.card h3 { font-size: 1.3rem; margin: 0 0 0.5rem; color: var(--color-text); }
.chart-holder { width: 100%; margin: 0.4rem 0 0.9rem; }
.chart-holder svg { width: 100%; height: auto; display: block; }
.card .insight { color: var(--color-text); font-size: 0.98rem; margin: 0.2rem 0 0.9rem; }
.card .insight strong { color: var(--color-primary); }
.card .source { font-family: var(--font-mono); font-size: 0.72rem; color: var(--color-text-muted); border-top: 1px solid var(--color-border); padding-top: 0.8rem; margin-top: auto; }

/* Frameworks have a taller, simpler canvas */
.frame-canvas { width: 100%; margin: 0.4rem 0 0.9rem; }
.frame-canvas svg { width: 100%; height: auto; display: block; }
.card .caption { color: var(--color-text-muted); font-size: 0.92rem; margin: 0.2rem 0 0; }

.frameworks-bg { background: var(--color-bg-card); border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.frameworks-bg .card { background: var(--color-bg); }

/* ---------- Methods / closing ---------- */
.methods { background: linear-gradient(135deg, #101522, #251447); color: #fff; }
.methods .wrap { padding-top: 4.5rem; padding-bottom: 4.5rem; }
.methods h2 { color: #fff; font-size: clamp(1.7rem, 4vw, 2.3rem); }
.methods p.intro { color: #cdd5f2; max-width: 700px; font-size: 1.03rem; }
.source-list { list-style: none; padding: 0; margin: 1.8rem 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.7rem; }
.source-list li { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 0.8rem 1rem; font-size: 0.85rem; color: #c4cce6; }
.source-list li b { color: #fff; font-family: var(--font-heading); display: block; font-size: 0.82rem; margin-bottom: 0.15rem; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; margin-top: 2.5rem; }
.tool-link { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; padding: 1.3rem; text-decoration: none; color: #fff; transition: background 0.2s, transform 0.2s; }
.tool-link:hover { background: rgba(255,255,255,0.1); transform: translateY(-3px); }
.tool-link h4 { margin: 0 0 0.3rem; font-size: 1.02rem; color: #fff; }
.tool-link span { color: #aeb8df; font-size: 0.86rem; }
.credit-note { margin-top: 2.4rem; font-size: 0.9rem; color: #aeb8df; }
.credit-note a { color: #fff; font-weight: 700; }

/* ---------- Footer ---------- */
.site-footer { background: #101522; color: #cdd5f2; padding: 3.5rem 1.5rem 1.5rem; }
.footer-grid { max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2rem; }
.footer-col h4 { color: #fff; font-size: 1rem; margin: 0 0 1rem; }
.footer-col a { display: block; color: #9aa6c8; text-decoration: none; font-size: 0.9rem; padding: 0.25rem 0; }
.footer-col a:hover { color: #fff; }
.footer-bottom { max-width: 1200px; margin: 2.5rem auto 0; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); text-align: center; color: #7c87aa; font-size: 0.85rem; }

/* ---------- Masters' wing (recreated classics) ---------- */
.masters { display: grid; grid-template-columns: 1fr; gap: 1.8rem; }
@media (min-width: 860px) { .masters { grid-template-columns: 1fr 1fr; } }
.plate { background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 18px; overflow: hidden; box-shadow: 0 10px 30px rgba(15,23,42,0.06); display: flex; flex-direction: column; opacity: 0; transform: translateY(22px); }
[data-theme="dark"] .plate { background: linear-gradient(160deg, #131a2e, #1a2238); border-color: rgba(255,255,255,0.08); box-shadow: 0 16px 40px rgba(8,12,30,0.3); }
.plate.in { opacity: 1; transform: none; transition: opacity 0.7s ease, transform 0.7s ease; }
.plate-canvas { position: relative; aspect-ratio: 4 / 3; padding: 1.1rem; display: flex; align-items: center; justify-content: center; background: #f4f1ea; }
[data-theme="dark"] .plate-canvas { background: radial-gradient(560px 280px at 50% 0%, rgba(118,75,162,0.18), transparent 70%); }
.plate-canvas svg { width: 100%; height: 100%; display: block; }
.plate-caption { padding: 1.3rem 1.5rem 1.6rem; border-top: 1px solid var(--color-border); }
[data-theme="dark"] .plate-caption { border-top-color: rgba(255,255,255,0.08); }
.plate-caption .tag { display: inline-block; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 1.4px; text-transform: uppercase; color: #6b4ea0; background: rgba(118,75,162,0.12); padding: 0.22rem 0.6rem; border-radius: 6px; margin-bottom: 0.6rem; }
[data-theme="dark"] .plate-caption .tag { color: #c9b8ff; background: rgba(118,75,162,0.25); }
.plate-caption h3 { color: var(--color-text); font-size: 1.25rem; margin: 0 0 0.15rem; }
.plate-caption .meta { font-family: var(--font-mono); font-size: 0.78rem; color: var(--color-text-muted); margin-bottom: 0.7rem; }
.plate-caption p { color: var(--color-text); font-size: 0.93rem; margin: 0 0 0.8rem; }
.plate-caption .why { color: var(--color-text-muted); font-size: 0.88rem; border-left: 2px solid var(--color-accent-blue); padding-left: 0.8rem; }
.plate-caption a.source { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.9rem; font-family: var(--font-heading); font-weight: 700; font-size: 0.84rem; color: var(--color-primary); text-decoration: none; }
.plate-caption a.source:hover { text-decoration: underline; }
.plate-canvas { background: #f4f1ea; }
.plate--dubois .plate-canvas { background: #e8d9b8 !important; }

/* ---------- Greats gallery (curated, links out) ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-bottom: 2.4rem; }
.filter-chip { font-family: var(--font-heading); font-weight: 600; font-size: 0.82rem; background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); padding: 0.45rem 0.95rem; border-radius: 999px; cursor: pointer; transition: all 0.18s; }
.filter-chip:hover { color: var(--color-text); border-color: var(--color-primary); }
.filter-chip.active { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border-color: transparent; }
.cards-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.6rem; }
.viz-card { display: flex; flex-direction: column; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 16px; overflow: hidden; text-decoration: none; color: inherit; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
.viz-card:hover { transform: translateY(-5px); box-shadow: 0 16px 36px rgba(0,0,0,0.13); border-color: var(--color-primary); }
.viz-card .swatch { height: 96px; position: relative; }
.viz-card .swatch::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(0,0,0,0.18)); }
.viz-card .vbody { padding: 1.2rem 1.3rem 1.4rem; display: flex; flex-direction: column; flex: 1; }
.viz-card .theme-tag { align-self: flex-start; font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 1px; text-transform: uppercase; color: var(--color-primary); background: rgba(102,126,234,0.12); padding: 0.2rem 0.55rem; border-radius: 5px; margin-bottom: 0.7rem; }
.viz-card h3 { font-size: 1.08rem; margin: 0 0 0.25rem; color: var(--color-text); }
.viz-card .meta { font-family: var(--font-mono); font-size: 0.74rem; color: var(--color-text-muted); margin-bottom: 0.7rem; }
.viz-card p { font-size: 0.88rem; color: var(--color-text-muted); margin: 0 0 1rem; flex: 1; }
.viz-card .view { font-family: var(--font-heading); font-weight: 700; font-size: 0.82rem; color: var(--color-primary); display: inline-flex; align-items: center; gap: 0.3rem; }
.viz-card.hidden { display: none; }

/* ---------- Paper plane ---------- */
.paper-plane { position: fixed; bottom: 2rem; right: 2rem; opacity: 0.05; pointer-events: none; z-index: 0; animation: float 6s ease-in-out infinite; }
@media (max-width: 900px) { .paper-plane { display: none; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-15px) rotate(3deg); } }
@keyframes drift { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-18px); } }
@media (prefers-reduced-motion: reduce) { .paper-plane, .hero-dots span { animation: none; } }

/* ---------- clickable tiles + gallery link (Stage 2) ---------- */
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link .card.tile { cursor: pointer; height: 100%; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
.card-link:hover .card.tile { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(0,0,0,0.12); border-color: var(--color-primary); }
.card .explore { padding-top: 0.7rem; font-family: var(--font-heading); font-weight: 700; font-size: 0.82rem; color: var(--color-primary); display: inline-flex; align-items: center; gap: 0.3rem; }
.gallery-cta { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; background: var(--color-bg-card); border: 1px solid var(--color-border); border-radius: 18px; padding: 1.6rem 1.8rem; text-decoration: none; box-shadow: 0 10px 30px rgba(15,23,42,0.06); transition: transform 0.2s, border-color 0.2s; }
.gallery-cta:hover { transform: translateY(-3px); border-color: var(--color-primary); }
.gallery-arrow { font-size: 1.8rem; color: var(--color-primary); font-weight: 800; }
