:root {
  --bg: #0b0d12;
  --panel: #0f1218;
  --border: #1e2430;
  --text: #e5e7eb;
  --muted: #9aa3b2;
  --brand: #7c5cff;
  --accent: #22d3ee;
  --danger: #ef4444;
  --glow: rgba(124,92,255,0.4);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

/* Light theme overrides */
[data-theme="light"] {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #0b0f19;
  --muted: #6b7280;
  --brand: #6452ff;
  --accent: #06b6d4;
  --glow: rgba(100,82,255,0.35);
  --shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* Accent variants */
[data-accent="violet"] { --brand:#7c5cff; --accent:#8b5cf6; }
[data-accent="cyan"] { --brand:#22d3ee; --accent:#06b6d4; }
[data-accent="emerald"] { --brand:#10b981; --accent:#34d399; }
[data-accent="rose"] { --brand:#f43f5e; --accent:#fb7185; }
[data-accent="amber"] { --brand:#f59e0b; --accent:#fbbf24; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1000px 600px at 10% -10%, rgba(124,92,255,0.12), transparent), radial-gradient(800px 500px at 90% 0%, rgba(34,211,238,0.08), transparent), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

.sidebar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; text-decoration: none; color: var(--text); line-height: 1; }
.brand .logo {
  width: 48px; height: 48px; display: inline-block; vertical-align: middle;
  background: var(--brand);
  /* Fill box with glyph (crop internal whitespace) */
  -webkit-mask-image: url('../img/logo.svg');
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: cover;
          mask-image: url('../img/logo.svg');
          mask-repeat: no-repeat;
          mask-position: center;
          mask-size: cover;
}
.logo-fallback { display: none; }
@supports not (mask: url("")) {
  .brand .logo { display: none; }
  .logo-fallback { display: inline-block; }
}
.brand-name { font-weight: 700; letter-spacing: 0.2px; font-family: 'Space Grotesk', Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }

/* Hero title uses bold geometric sans */
.graffiti-title {
  font-family: 'Space Grotesk', Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-link { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 8px; display: inline-block; border: 1px solid transparent; }
.nav-link:hover { background: rgba(124,92,255,0.08); border-color: var(--border); }
.nav-link.active { background: rgba(124,92,255,0.16); border-color: var(--brand); }
button#themeToggle { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 10px; cursor: pointer; }

.main { display: flex; flex-direction: column; }
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 8px 20px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--panel); backdrop-filter: saturate(120%) blur(6px); position: sticky; top: 0; z-index: 40; }
.topbar-actions { display: flex; gap: 8px; }
.topbar-actions select#planSelect { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }

.topnav { display: flex; gap: 8px; align-items: center; }
.dropdown { position: relative; }
.dropbtn { background: transparent; color: var(--text); border: 1px solid var(--border); padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); left: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; min-width: 220px; padding: 8px; display: none; box-shadow: var(--shadow); z-index: 50; transform-origin: top; transform: scale(0.98) translateY(-6px); opacity: 0; transition: transform .18s ease, opacity .18s ease; }
.dropdown:hover .dropdown-menu, .dropdown.open .dropdown-menu { display: block; transform: scale(1) translateY(0); opacity: 1; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 8px 10px; border-radius: 6px; }
.dropdown-menu a:hover { background: rgba(124,92,255,0.08); }

.titlebar { padding: 8px 20px; border-bottom: 1px solid var(--border); }

button { cursor: pointer; }
button, input, select, textarea {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .2s ease;
}
button.primary { background: var(--brand); border-color: var(--brand); color: white; box-shadow: 0 0 0 rgba(0,0,0,0); }
button.primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px var(--glow); }
button.secondary { background: transparent; }
button.ghost { background: transparent; border-color: transparent; }

.nav-link, .dropbtn { transition: background .15s ease, transform .15s ease, border-color .15s ease; }
.nav-link:hover, .dropbtn:hover { transform: translateY(-1px); }

.view { padding: 20px; display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
.panel { background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.panel:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(0,0,0,0.4); border-color: rgba(124,92,255,0.3); }
.logo-hero {
  width: 160px; height: 160px; display: inline-block; background: var(--brand); margin-bottom: 10px; vertical-align: middle; margin-left: 16px;
  -webkit-mask-image: url('../img/logo.svg');
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 100% 100%;
          mask-image: url('../img/logo.svg');
          mask-repeat: no-repeat;
          mask-position: center;
          mask-size: 100% 100%;
}
/* Fallback for browsers without mask support */
@supports not (mask: url("")) {
  .logo-hero { display: none; }
  .logo-hero-fallback { display: inline-block !important; margin-left: 12px; }
}
.panel h2 { margin: 0 0 10px 0; font-size: 16px; }
.panel h3 { margin: 16px 0 8px 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.field { display: grid; gap: 6px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.diagram-wrap { position: relative; min-height: 480px; overflow: auto; }
.k8s-visuals .diagram-wrap { min-height: 720px; }
.diagram { position: relative; overflow: auto; }
.diagram-stage { transform-origin: 0 0; will-change: transform; }
.diagram-controls { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; z-index: 10; }
.diagram-controls button { padding: 6px 8px; font-size: 12px; }
.aws-grid { display: grid; gap: 16px; grid-template-columns: minmax(360px, 480px) 1fr; align-items: start; }
.aws-right.panel:hover { transform: none; box-shadow: var(--shadow); }
.aws-right { position: relative; }
.aws-right .diagram-wrap { min-height: 640px; padding-bottom: 220px; }
.aws-cost { position: absolute; right: 12px; bottom: 12px; width: 320px; }

/* Generic two-column visualizer layout (applies across views) */
.viz-grid { display: grid; gap: 16px; grid-template-columns: minmax(360px, 480px) 1fr; align-items: start; }
.viz-right { position: relative; padding-bottom: 220px; }
.viz-right.panel:hover { transform: none; box-shadow: var(--shadow); }
.viz-right .diagram-wrap { min-height: 640px; }
.viz-cost { position: absolute; right: 12px; bottom: 12px; width: 320px; max-height: 50vh; overflow: auto; }
.diagram-wrap .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; }
.diagram { overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.k8s-visuals { display: grid; gap: 16px; }
@media (min-width: 1200px) {
  .k8s-visuals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.mermaid-error { color: var(--danger); font-size: 12px; margin-top: 8px; }

.footer-note { font-size: 12px; color: var(--muted); }

/* Home footer */
.home-footer { 
  grid-column: 1 / -1; 
  border: 1px solid var(--border); 
  border-radius: 14px; 
  padding: 28px 20px; 
  background: radial-gradient(1200px 800px at 10% -10%, rgba(139,92,246,0.25), transparent 55%),
              radial-gradient(1000px 600px at 90% 20%, rgba(6,182,212,0.18), transparent 55%),
              linear-gradient(180deg, rgba(255,255,255,0.03), transparent),
              var(--panel);
  position: relative;
  overflow: hidden;
}
.home-footer .footer-wrap { 
  display: grid; 
  grid-template-columns: repeat(5, minmax(160px, 1fr)); 
  gap: 20px; 
}
.home-footer .footer-title { margin: 0 0 10px 0; font-size: 14px; font-weight: 700; }
.home-footer .footer-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.home-footer .footer-link { color: var(--text); text-decoration: none; opacity: .9; }
.home-footer .footer-link:hover { text-decoration: underline; opacity: 1; }
.home-footer .social-bubbles { display: grid; grid-template-columns: repeat(2, 48px); gap: 12px; align-content: start; }
.home-footer .bubble { width: 48px; height: 48px; border-radius: 999px; background: white; color: #111827; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 700; box-shadow: 0 6px 16px rgba(0,0,0,.25); }
[data-theme="light"] .home-footer .bubble { background: #f8fafc; color: #0b0f19; }
.home-footer-bottom { border-top: 1px dashed rgba(255,255,255,0.18); margin-top: 18px; padding-top: 10px; font-size: 12px; color: var(--muted); }
[data-theme="light"] .home-footer-bottom { border-top-color: rgba(0,0,0,0.12); }

@media (max-width: 900px) {
  .home-footer .footer-wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .home-footer .footer-wrap { grid-template-columns: 1fr; }
}

.slo-visuals { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.slo-visuals .viz-card { background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); }
[data-theme="light"] .slo-visuals .viz-card { background: rgba(255,255,255,0.92); }
.viz-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.slo-donut, .slo-burn { width: 100%; height: 220px; }
.slo-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 12px; }
.slo-legend span { display: inline-flex; align-items: center; gap: 6px; }
.slo-legend span::before { content: ''; width: 10px; height: 10px; border-radius: 999px; background: currentColor; opacity: 0.75; }
.slo-out { display: grid; gap: 6px; font-size: 13px; }

/* Upsell overlay */
.upsell {
  border: 1px dashed var(--brand);
  padding: 16px; border-radius: 12px; background: rgba(124,92,255,0.06);
}

/* Help icon + popover */
.help { display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; border:1px solid var(--border); border-radius:50%; font-size:11px; margin-left:6px; color: var(--muted); cursor:pointer; background: transparent; vertical-align: middle; }
.help::after { content:'i'; line-height:1; }
.help:hover { color: var(--text); border-color: var(--brand); }
.help-popover { position:absolute; max-width: 360px; background: var(--panel); color: var(--text); border:1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); padding: 10px 12px; z-index: 100; }
.help-popover-body { font-size: 12px; line-height: 1.4; }

/* Responsive */
@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; grid-auto-rows: auto; }
  .topnav { flex-wrap: wrap; }
  .view { grid-template-columns: 1fr; }
  .aws-grid { grid-template-columns: 1fr; }
  .aws-right .diagram-wrap { padding-bottom: 0; min-height: 360px; }
  .aws-cost { position: static; width: auto; margin-top: 12px; }
  .viz-grid { grid-template-columns: 1fr; }
  .viz-right { padding-bottom: 0; }
  .viz-right .diagram-wrap { min-height: 360px; }
  .viz-cost { position: static; width: auto; margin-top: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .diagram-controls { top: 6px; right: 6px; gap: 4px; }
  .diagram-controls button { padding: 6px 8px; font-size: 12px; }
  .k8s-visuals .diagram-wrap { min-height: 420px; }
}

/* Mobile drawer */
.mobile-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 80; }
.mobile-menu { position: fixed; top: 0; bottom: 0; left: 0; width: 86vw; max-width: 380px; background: var(--panel); border-right: 1px solid var(--border); transform: translateX(-105%); transition: transform .24s ease; z-index: 100; display: flex; flex-direction: column; }
.mobile-menu-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.mobile-menu .brand-mini { display: inline-flex; align-items: center; gap: 8px; }
.mobile-nav-links { padding: 10px; display: grid; gap: 6px; overflow: auto; }
.mobile-nav-links a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); border: 1px solid var(--border); }
.mobile-nav-links a:hover { background: rgba(124,92,255,0.08); border-color: var(--brand); }

/* Open state */
.drawer-open .mobile-backdrop { opacity: 1; pointer-events: auto; }
.drawer-open .mobile-menu { transform: translateX(0); }

/* Breakpoints: Phone, iPad, Desktop */
@media (max-width: 1024px) {
  #menuToggle { display: inline-block !important; }
  .topnav { display: none !important; }
}
@media (min-width: 1025px) {
  #menuToggle { display: none !important; }
}
@media (max-width: 600px) {
  .mobile-menu { width: 100vw; max-width: none; }
  .mobile-nav-links a { padding: 12px 14px; }
}

/* Motion safety */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Utilities */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg);} to { transform: rotate(360deg);} }

.skeleton { position: relative; overflow: hidden; background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.12), rgba(255,255,255,0.06)); background-size: 400% 100%; animation: shimmer 1.2s ease-in-out infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
