/* Jam Creative Hub — shadcn-flavored tokens
 * --------------------------------------------------------------
 * Adapted from claude.ai/design "Creative Hub | shadcn" handoff bundle.
 * - OKLCH neutral scale (zinc-leaning)
 * - Inter / JetBrains Mono / EB Garamond (italic editorial accent)
 * - 10px base radius
 * - Light theme default + .dark override
 * - Brand hue tuned to Jam dark-berry (#5c286a → hue 320)
 */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&family=Instrument+Serif:ital@0;1&display=swap");

:root {
  /* Radii */
  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) * 0.6);   /* 6px */
  --radius-md: calc(var(--radius) * 0.8);   /* 8px */
  --radius-lg: var(--radius);                /* 10px */
  --radius-xl: calc(var(--radius) * 1.4);    /* 14px */
  --radius-2xl: calc(var(--radius) * 1.8);   /* 18px */
  --radius-3xl: calc(var(--radius) * 2.2);   /* 22px */

  /* Neutral scale (zinc / OKLCH) */
  --neutral-50:  oklch(0.985 0 0);
  --neutral-100: oklch(0.97  0 0);
  --neutral-200: oklch(0.922 0 0);
  --neutral-300: oklch(0.87  0 0);
  --neutral-400: oklch(0.708 0 0);
  --neutral-500: oklch(0.556 0 0);
  --neutral-600: oklch(0.439 0 0);
  --neutral-700: oklch(0.371 0 0);
  --neutral-800: oklch(0.269 0 0);
  --neutral-900: oklch(0.205 0 0);
  --neutral-950: oklch(0.145 0 0);

  /* Semantic — LIGHT */
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.97 0.01 17);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);

  /* Brand — tuned to Jam dark-berry */
  --accent-hue: 320;
  --accent-chroma: 0.16;
  --brand: oklch(0.40 var(--accent-chroma) var(--accent-hue));
  --brand-fg: oklch(0.985 0 0);
  --brand-soft: oklch(0.96 0.04 var(--accent-hue));
  --brand-soft-fg: oklch(0.35 0.14 var(--accent-hue));
  --brand-border: oklch(0.88 0.06 var(--accent-hue));
  --brand-ring: oklch(0.40 var(--accent-chroma) var(--accent-hue) / 0.35);

  /* Backgrounds — keep Jam textures available */
  --jam-cream: #f7f1e8;
  --jam-light: #faf7f1;
  --topo-stroke: rgba(19, 19, 19, 0.10);
  --dot: rgba(19, 19, 19, 0.09);

  /* Typography */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-serif: "Instrument Serif", "EB Garamond", "Cormorant Garamond", Georgia, serif;
  --font-heading: var(--font-serif);

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  --shadow-2xs: 0 1px rgb(0 0 0 / 0.05);
  --shadow-xs:  0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm:  0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md:  0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl:  0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem;   --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem;   --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem;
}

.dark, [data-theme="dark"] {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.371 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.58 0.22 27);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);

  --brand: oklch(0.70 var(--accent-chroma) var(--accent-hue));
  --brand-fg: oklch(0.18 0 0);
  --brand-soft: oklch(0.27 0.06 var(--accent-hue));
  --brand-soft-fg: oklch(0.92 0.06 var(--accent-hue));
  --brand-border: oklch(0.35 0.08 var(--accent-hue));
  --brand-ring: oklch(0.7 var(--accent-chroma) var(--accent-hue) / 0.4);

  --jam-cream: #1a1a1a;
  --jam-light: #141414;
  --topo-stroke: rgba(255, 255, 255, 0.08);
  --dot: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}

/* All titles use Instrument Serif (regular + italic) — body stays Inter. */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.01em;
}
/* The .serif-accent and .accent helpers keep working — both already point to --font-serif. */
.accent, .serif-accent { font-family: var(--font-serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; color: var(--brand); }

/* Backgrounds (the textured + dot grid are KEPT) */
.bg-topographic {
  background-color: var(--jam-cream);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1600' height='1200' viewBox='0 0 1600 1200'><defs><filter id='r'><feTurbulence type='fractalNoise' baseFrequency='0.0015 0.002' numOctaves='3' seed='4'/><feDisplacementMap in='SourceGraphic' scale='180'/></filter></defs><g fill='none' stroke='rgba(19,19,19,0.10)' stroke-width='1.2' filter='url(%23r)'><circle cx='800' cy='600' r='80'/><circle cx='800' cy='600' r='140'/><circle cx='800' cy='600' r='200'/><circle cx='800' cy='600' r='260'/><circle cx='800' cy='600' r='320'/><circle cx='800' cy='600' r='380'/><circle cx='800' cy='600' r='440'/><circle cx='800' cy='600' r='500'/><circle cx='800' cy='600' r='560'/><circle cx='800' cy='600' r='620'/><circle cx='800' cy='600' r='680'/><circle cx='800' cy='600' r='740'/><circle cx='800' cy='600' r='800'/><circle cx='800' cy='600' r='860'/><circle cx='800' cy='600' r='920'/><circle cx='800' cy='600' r='980'/></g></svg>");
  background-size: 100% auto;
  background-repeat: no-repeat;
  background-position: center top;
  background-attachment: fixed;
}
.bg-dotgrid {
  background-color: var(--jam-light);
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* ============== Top Nav ============== */
.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex; align-items: center; gap: var(--space-6);
  padding: 0 var(--space-6);
  height: 56px;
  background: color-mix(in oklch, var(--background) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-logo { display: flex; align-items: center; gap: var(--space-2); color: var(--foreground); text-decoration: none; }
/* Background-aware logo: SVG is filled white; mix-blend-mode: difference
   subtracts that white from whatever's behind it, so it reads as dark on
   cream/white surfaces and light on dark surfaces — automatically, with no
   theme-based filter hacks. */
.nav-logo img { height: 24px; width: auto; display: block; mix-blend-mode: difference; transition: opacity .15s; }
.nav-logo:hover img { opacity: 0.78; }
/* Legacy .glyph rule kept for back-compat — no longer used after logo SVG replaced it. */
.nav-logo .glyph { width: 22px; height: 22px; border-radius: var(--radius-sm); background: var(--foreground); color: var(--background); display: grid; place-items: center; font-weight: 800; font-size: 13px; font-family: var(--font-mono); }
.nav-links { display: flex; gap: var(--space-1); }
.nav-link { font-size: var(--text-sm); color: var(--muted-foreground); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); text-decoration: none; font-weight: 500; background: transparent; border: none; cursor: pointer; font-family: inherit; transition: color .15s, background .15s; }
.nav-link:hover { color: var(--foreground); background: var(--accent); }
.nav-link[data-active="true"] { color: var(--foreground); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.avatar { width: 28px; height: 28px; border-radius: 9999px; background: linear-gradient(135deg, var(--brand) 0%, oklch(0.7 0.14 calc(var(--accent-hue) + 40)) 100%); color: var(--brand-fg); display: grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: -0.02em; overflow: hidden; background-size: cover; background-position: center; }

/* ============== Buttons ============== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: 36px; padding: 0 var(--space-4); font-size: var(--text-sm); font-weight: 500; font-family: inherit; border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; transition: all .15s; white-space: nowrap; text-decoration: none; color: inherit; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn-primary { background: var(--foreground); color: var(--background); }
.btn-primary:hover { opacity: 0.9; }
.btn-brand { background: var(--brand); color: var(--brand-fg); }
.btn-brand:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); border-color: var(--border); }
.btn-secondary:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--accent); }
.btn-outline { background: var(--background); border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { background: var(--accent); }
.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: var(--text-base); }
.btn-icon { width: 36px; padding: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============= Badges ============= */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 var(--space-2); border-radius: 9999px; font-size: 11px; font-weight: 500; background: var(--secondary); color: var(--secondary-foreground); border: 1px solid var(--border); white-space: nowrap; }
.badge-brand { background: var(--brand-soft); color: var(--brand-soft-fg); border-color: var(--brand-border); }
.badge-outline { background: transparent; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; }
.badge-cat-image  { background: oklch(0.96 0.04 256); color: oklch(0.35 0.16 256); border-color: oklch(0.88 0.06 256); }
.badge-cat-video  { background: oklch(0.96 0.04 340); color: oklch(0.4 0.16 340); border-color: oklch(0.88 0.06 340); }
.badge-cat-motion { background: oklch(0.96 0.04 145); color: oklch(0.4 0.14 145); border-color: oklch(0.88 0.06 145); }
.badge-cat-social { background: oklch(0.96 0.04 50);  color: oklch(0.45 0.15 50); border-color: oklch(0.88 0.06 50); }
.badge-cat-pitch  { background: oklch(0.96 0.04 290); color: oklch(0.4 0.16 290); border-color: oklch(0.88 0.06 290); }
.dark .badge-cat-image  { background: oklch(0.27 0.06 256); color: oklch(0.85 0.1 256); border-color: oklch(0.4 0.1 256); }
.dark .badge-cat-video  { background: oklch(0.27 0.06 340); color: oklch(0.85 0.1 340); border-color: oklch(0.4 0.1 340); }
.dark .badge-cat-motion { background: oklch(0.27 0.06 145); color: oklch(0.85 0.1 145); border-color: oklch(0.4 0.1 145); }
.dark .badge-cat-social { background: oklch(0.27 0.06 50);  color: oklch(0.85 0.1 50);  border-color: oklch(0.4 0.1 50); }
.dark .badge-cat-pitch  { background: oklch(0.27 0.06 290); color: oklch(0.85 0.1 290); border-color: oklch(0.4 0.1 290); }

/* ============ Tabs ============ */
.tabs { display: inline-flex; align-items: center; gap: var(--space-1); padding: 4px; background: var(--muted); border-radius: var(--radius-md); border: 1px solid var(--border); }
.tab { font-family: inherit; font-size: var(--text-sm); font-weight: 500; padding: 6px 12px; border-radius: var(--radius-sm); border: none; background: transparent; color: var(--muted-foreground); cursor: pointer; transition: all .15s; display: flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--foreground); }
.tab[data-active="true"] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); }

/* ============ Cards ============ */
.card-shell {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--card-foreground);
}

/* ============ Editorial accent ============ */
.serif-accent {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--brand);
}
.section-num {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: var(--space-2);
}
.section-num::before { content: ""; width: 18px; height: 1px; background: var(--border); }

/* ============ Inputs ============ */
.input-field {
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  font-family: inherit; font-size: var(--text-sm);
  color: var(--foreground);
  width: 100%; resize: none;
  transition: border-color .15s, box-shadow .15s;
}
.input-field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.input-field::placeholder { color: var(--muted-foreground); }

/* ============ Hub SDK classes (preserved names — restyled with shadcn tokens) ============ */
/* These are what the agent-generated Visu code references. */
.vfield { margin-bottom: var(--space-3); }
.vlabel { display: block; font-size: var(--text-xs); color: var(--muted-foreground); margin-bottom: 6px; font-weight: 500; letter-spacing: -0.005em; }
.vinput, .vtextarea, select.vinput {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--input); border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--text-sm);
  background: var(--background); color: var(--foreground);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.vinput:focus, .vtextarea:focus, select.vinput:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.vtextarea { resize: vertical; min-height: 72px; line-height: 1.5; font-family: var(--font-sans); }
.vupload, input.vupload {
  display: block; width: 100%; padding: var(--space-3);
  border: 1px dashed var(--input); border-radius: var(--radius-md);
  background: var(--muted); font-size: var(--text-xs); color: var(--muted-foreground);
  cursor: pointer; transition: all .15s; text-align: center;
}
.vupload:hover, input.vupload:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-soft-fg); }
input.vupload::file-selector-button { display: none; }
.vupload-zone {
  position: relative; width: 100%;
  border: 1px dashed var(--input); border-radius: var(--radius-md);
  padding: var(--space-3); text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: var(--text-xs); color: var(--muted-foreground);
  min-height: 92px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: var(--muted);
}
.vupload-zone:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-soft-fg); }
.vupload-zone.has-file { padding: 4px; border-style: solid; min-height: 120px; }
.vupload-zone img { width: 100%; max-height: 160px; border-radius: var(--radius-sm); object-fit: cover; display: block; }
.vupload-zone input[type=file] { display: none; }
.vbtn {
  width: 100%;
  background: var(--brand); color: var(--brand-fg);
  border-radius: var(--radius-md); padding: 0 var(--space-4); height: 36px;
  font-size: var(--text-sm); font-weight: 500; margin-top: var(--space-2);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  transition: filter .15s; border: 1px solid transparent; cursor: pointer; font-family: inherit;
}
.vbtn:hover:not(:disabled) { filter: brightness(1.05); }
.vbtn:disabled { opacity: 0.5; cursor: not-allowed; }
.vbtn.secondary { background: var(--secondary); color: var(--secondary-foreground); border-color: var(--border); }
.vbtn.secondary:hover:not(:disabled) { background: var(--accent); }
.vrow { display: flex; align-items: center; }
.vgap-sm { gap: var(--space-2); } .vgap-md { gap: var(--space-3); } .vgap-lg { gap: var(--space-4); }

/* ============ Aspect-ratio picker (.vratio) ============
   Drop a <div class="vratio" data-default="free"></div> anywhere in a Potion's
   toolbox HTML — the Hub SDK auto-renders the pill grid and tracks the value
   on `data-value`. Default selection is "Free" (no constraint / fullscreen). */
.vratio { display: block; }
.vratio-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-3); }
.vratio-head .vratio-title { font-family: var(--font-sans); font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; color: var(--foreground); }
.vratio-head .vratio-current { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-sm); color: var(--muted-foreground); }
.vratio-head .vratio-current svg { opacity: 0.6; }
.vratio-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.vratio-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 14px; height: 36px;
  background: var(--muted); color: var(--foreground);
  border: 1px solid transparent; border-radius: 9999px;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .12s, color .12s, transform .08s;
  white-space: nowrap;
}
.vratio-pill:hover { background: var(--accent); }
.vratio-pill:active { transform: scale(0.98); }
.vratio-pill .vratio-icon { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.vratio-pill .vratio-icon svg { display: block; }
.vratio-pill .vratio-icon rect, .vratio-pill .vratio-icon path, .vratio-pill .vratio-icon line {
  stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.vratio-pill[aria-pressed="true"] {
  background: var(--foreground); color: var(--background);
}
.vratio-pill[aria-pressed="true"]:hover { background: var(--foreground); filter: brightness(1.08); }

/* ============ Toast + modal ============ */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--foreground); color: var(--background); padding: 10px 18px; border-radius: var(--radius-md); font-size: var(--text-sm); box-shadow: var(--shadow-lg); z-index: 200; animation: toastIn 180ms ease-out; }
.toast.error { background: var(--destructive); color: var(--destructive-foreground); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
