/* ═══════════════════════════════════════════════════════════════════════
   CompanyDrawer — shared side-drawer for company profiles across the portal
   Lifted from matching-auckland-v2.html (the "Auckland-v2 gold standard")
   and generalised. Consumers: /companies directory, japan-gx, matching-*.
   Depends on light-theme.css CSS vars (--brand, --ink, --line, --muted,
   --surface-soft, --brand-soft, --brand-ink, --brand-2, --line-2, --ink-2,
   --shadow-sm).
   ═════════════════════════════════════════════════════════════════════ */

/* Backdrop + shell */
.cd-backdrop{
  position:fixed; inset:0; background:rgba(16,32,23,.44);
  opacity:0; pointer-events:none; transition:opacity .18s ease;
  z-index:1499;
}
.cd-backdrop.open{opacity:1; pointer-events:auto}

.cd-drawer{
  position:fixed; top:0; right:0; bottom:0; width:min(600px, 94vw);
  background:#fff; box-shadow:-24px 0 60px -20px rgba(16,32,23,.35);
  transform:translateX(100%); transition:transform .15s cubic-bezier(.22,1,.36,1);
  z-index:1500; display:flex; flex-direction:column;
}
.cd-drawer.open{transform:translateX(0)}
/* When interest drawer opens, shift the profile drawer left so both are visible. */
.cd-drawer.open.pushed{transform:translateX(-100%)}
/* When DrawerStack opens on top (investor drill), hide us completely — no shadow
   or edge peeks through behind the fresh drawer. */
.cd-drawer.open.ds-hidden{transform:translateX(100%)}

.cd-close{
  position:absolute; top:16px; right:18px; z-index:5;
  width:34px; height:34px; border-radius:50%; border:1px solid var(--line);
  background:#fff; cursor:pointer; font-size:16px; color:var(--ink-2);
  display:flex; align-items:center; justify-content:center;
  transition:background .1s, color .1s;
}
.cd-close:hover{background:var(--surface-soft); color:var(--ink)}

.cd-scroll{flex:1; overflow-y:auto}

/* Hero */
.cd-hero{padding:32px 32px 24px; border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, var(--brand-soft) 0%, #fff 100%)}
.cd-hero .cd-chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 10px; border-radius:999px; font-size:10.5px; font-weight:700;
  letter-spacing:.14em; text-transform:uppercase; margin-bottom:14px;
  background:var(--brand-soft); color:var(--brand); border:1px solid var(--brand-edge, rgba(11,154,74,.22));
}
.cd-hero .cd-chip .swatch{width:6px; height:6px; border-radius:50%; background:currentColor}
.cd-hero .cd-top{display:flex; align-items:flex-start; gap:16px; margin-bottom:14px}
.cd-hero .cd-logo{
  width:64px; height:64px; border-radius:14px; background:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:22px; color:var(--brand-ink);
  border:1px solid var(--line); flex-shrink:0;
  box-shadow:var(--shadow-sm); letter-spacing:-.03em;
  overflow:hidden;
}
.cd-hero .cd-logo img{width:100%; height:100%; object-fit:contain}
.cd-hero .cd-name{font-size:26px; font-weight:800; margin:0 0 4px; letter-spacing:-.02em; line-height:1.15}
.cd-hero .cd-meta{font-size:13px; color:var(--muted); margin:0}
.cd-hero .cd-meta a{color:var(--brand); font-weight:600}
.cd-hero .cd-summary{font-size:14.5px; color:var(--ink-2); margin:14px 0 0; line-height:1.6}
.cd-hero .cd-summary a{color:var(--brand); text-decoration:none; border-bottom:1px dotted var(--brand)}

/* Sections */
.cd-section{padding:22px 32px; border-bottom:1px solid var(--line)}
.cd-section:last-child{border-bottom:none}
.cd-section h3{
  font-size:11px; font-weight:800; letter-spacing:.16em; text-transform:uppercase;
  color:var(--muted); margin:0 0 12px;
}

/* "Why this fits <partner>" callout */
.cd-why{
  background:var(--brand-soft); border:1px solid rgba(11,154,74,.22);
  border-radius:14px; padding:18px 20px;
}
.cd-why h3{color:var(--brand); margin-bottom:10px}
.cd-why p{font-size:14px; color:var(--ink); line-height:1.65; margin:0 0 10px}
.cd-why p:last-child{margin-bottom:0}
.cd-why p strong{color:var(--brand-ink); font-weight:700}

/* Snapshot KV grid */
.cd-kv{display:grid; grid-template-columns:132px 1fr; gap:9px 18px; font-size:13px}
.cd-kv dt{color:var(--muted); font-weight:500}
.cd-kv dd{margin:0; color:var(--ink); font-weight:500}
.cd-kv dd a{color:var(--brand); text-decoration:none; border-bottom:1px dotted var(--brand)}

/* Chips */
.cd-tags{display:flex; flex-wrap:wrap; gap:6px}
.cd-hero-tags{display:flex; flex-wrap:wrap; gap:6px; margin:14px 0 6px}
.cd-tag{
  padding:4px 10px; border-radius:999px; font-size:11.5px; font-weight:600;
  background:var(--surface-soft); color:var(--ink-2); border:1px solid var(--line);
}

/* Industry / secondary-sector tag variants */
.cd-tag--industry{
  background:#f0f7ff; color:#1a5fab; border-color:#c8ddf4;
}
.cd-tag--sector{
  background:#f3f0ff; color:#5a3dbf; border-color:#d4cdf4;
}
/* Looking-for tag variants */
.cd-tag--help{
  background:#fff7ed; color:#b45309; border-color:#fde68a;
}
.cd-tag--capital{
  background:#ecfdf5; color:#047857; border-color:#a7f3d0;
}

/* Project cards */
.cd-project{
  padding:12px 14px; border:1px solid var(--line); border-radius:10px;
  background:var(--surface-soft); margin-bottom:8px;
}
.cd-project:last-child{margin-bottom:0}
.cd-proj-name{font-size:13px; font-weight:700; color:var(--ink); margin:0 0 4px; line-height:1.35}
.cd-proj-meta{font-size:11.5px; color:var(--muted); font-weight:600; margin:0 0 6px; letter-spacing:.02em}
.cd-proj-desc{font-size:12.5px; color:var(--ink-2); line-height:1.55; margin:0 0 6px}
.cd-proj-partners{font-size:12px; color:var(--ink-2); margin:0; line-height:1.45}
.cd-proj-label{font-weight:700; color:var(--ink)}

/* Proof/traction list */
.cd-proof{list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:10px}
.cd-proof-disclaimer{
  font-size:11px; color:var(--ink-3,#999); font-style:italic; margin:0 0 6px;
}
.cd-proof li{
  font-size:13px; color:var(--ink-2); line-height:1.55;
  padding:10px 12px 10px 30px; background:var(--surface-soft);
  border-radius:10px; position:relative;
}
.cd-proof li::before{
  content:"✓"; position:absolute; left:11px; top:9px;
  color:var(--brand); font-weight:800; font-size:13px;
}
.cd-proof li a{color:var(--brand); text-decoration:none; border-bottom:1px dotted var(--brand); font-size:11px; margin-left:6px}
.cd-proof li.k-traction::before{content:"→"}

/* Cap table */
.cd-cap{display:flex; flex-direction:column; gap:8px}
.cd-cap-row{
  display:grid; grid-template-columns:1fr 82px 60px; gap:12px; align-items:center;
  padding:9px 12px; border:1px solid var(--line); border-radius:9px; background:#fff; font-size:12.5px;
}
.cd-cap-row .cap-name{font-weight:600; color:var(--ink); display:flex; align-items:center; gap:8px}
.cd-cap-row .cap-lead{
  display:inline-block; font-size:9px; font-weight:800; letter-spacing:.1em;
  padding:2px 6px; border-radius:4px; background:var(--brand); color:#fff;
}
.cd-cap-row .cap-bar{
  height:6px; background:var(--surface-soft); border-radius:3px; overflow:hidden; position:relative;
}
.cd-cap-row .cap-bar::after{
  content:""; position:absolute; top:0; left:0; bottom:0; background:var(--brand);
  width:var(--pct); border-radius:3px;
}
.cd-cap-row .cap-pct{text-align:right; font-weight:700; color:var(--ink); font-variant-numeric:tabular-nums}
.cd-cap-row .cap-role{
  display:inline-block; font-size:9.5px; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
  padding:1.5px 6px; border-radius:4px; background:var(--surface-soft); color:var(--muted);
}
.cd-cap-row.clickable{cursor:pointer; transition:border-color .12s, box-shadow .12s, background .12s}
.cd-cap-row.clickable:hover{border-color:var(--brand); background:var(--brand-soft)}
.cd-cap-row.clickable .cap-name::after{content:" ›"; color:var(--brand); font-weight:800; opacity:.7}
.cd-cap-note{font-size:11.5px; color:var(--muted); margin-top:6px; font-style:italic}
.cd-cap-src{font-size:11px; color:var(--muted); margin-top:8px; display:flex; justify-content:space-between; gap:8px; align-items:baseline}
.cd-cap-src a{color:var(--brand); text-decoration:none; border-bottom:1px dotted var(--brand)}

/* When DrawerStack (investor drill) is layered above us, bump it — otherwise
   the investor drawer sits behind our backdrop. */
#ds-backdrop{z-index:2400 !important}
#ds-root{z-index:2401 !important}

/* DrawerStack chrome now lives inside drawer-stack.js itself (rewritten
   2026-08-09 to inherit --brand + match this drawer 1:1). No overrides
   needed here beyond the z-index bump above. */

/* Funding + milestones list */
.cd-flist{list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; font-size:13px}
.cd-flist li{
  padding:9px 12px; background:var(--surface-soft); border-radius:8px;
  display:flex; justify-content:space-between; gap:12px; align-items:baseline;
}
.cd-flist li .fdate{font-size:11px; color:var(--muted); font-weight:600; letter-spacing:.03em; white-space:nowrap}
.cd-flist li .fbody{color:var(--ink); font-weight:500; line-height:1.4}
.cd-flist li .fbody b{color:var(--ink); font-weight:700}
.cd-flist li .fbody a{color:var(--brand); text-decoration:none; border-bottom:1px dotted var(--brand); font-size:11px; margin-left:6px}

/* Team roster */
.cd-team{display:flex; flex-direction:column; gap:8px}
.cd-team-row{
  display:flex; align-items:center; gap:12px; padding:9px 12px;
  background:var(--surface-soft); border-radius:8px;
}
.cd-team-avatar{
  width:32px; height:32px; border-radius:50%; background:var(--brand-soft);
  display:flex; align-items:center; justify-content:center;
  color:var(--brand-ink); font-weight:700; font-size:12px; flex-shrink:0;
}
.cd-team-body{flex:1; min-width:0}
.cd-team-name{font-size:13px; font-weight:700; color:var(--ink); margin:0 0 1px}
.cd-team-role{font-size:11.5px; color:var(--muted); margin:0}
.cd-team-body a{color:var(--brand); text-decoration:none; border-bottom:1px dotted var(--brand); font-size:11px}

/* Loading & empty states */
.cd-loading{padding:60px 40px; text-align:center; color:var(--muted); font-size:13px}
.cd-empty{padding:12px; color:var(--muted); font-size:12.5px; font-style:italic}

/* Sticky footer + primary CTA */
.cd-foot{
  padding:16px 24px; border-top:1px solid var(--line); background:#fff;
  box-shadow:0 -6px 20px -12px rgba(16,32,23,.15);
}
.cd-btn-primary{
  display:flex; align-items:center; justify-content:center; gap:8px;
  width:100%; padding:14px 20px; border-radius:12px;
  background:var(--brand); color:#fff; border:none;
  font-weight:800; font-size:14.5px; cursor:pointer; letter-spacing:.01em;
  transition:background .12s, transform .1s;
}
.cd-btn-primary:hover{background:var(--brand-2); transform:translateY(-1px)}

/* Interest panel — sibling drawer that slides in from the right,
   pushing the profile drawer left (dual-pane cascade). */
.cd-interest{
  position:fixed; top:0; right:0; bottom:0; width:min(600px, 94vw);
  background:#fff; box-shadow:-24px 0 60px -20px rgba(16,32,23,.35);
  transform:translateX(100%); transition:transform .15s cubic-bezier(.22,1,.36,1);
  z-index:1501; display:flex; flex-direction:column; overflow:hidden;
}
.cd-interest.open{transform:translateX(0)}
.cd-i-head{
  padding:22px 32px 18px; border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:12px;
}
.cd-i-back{
  width:34px; height:34px; border-radius:8px; border:1px solid var(--line);
  background:#fff; cursor:pointer; font-size:15px; color:var(--ink-2);
  display:flex; align-items:center; justify-content:center;
  transition:background .1s;
}
.cd-i-back:hover{background:var(--surface-soft)}
.cd-i-head-body h2{font-size:19px; font-weight:800; margin:0 0 2px; letter-spacing:-.01em}
.cd-i-head-body p{margin:0; font-size:12.5px; color:var(--muted)}
.cd-i-scroll{flex:1; overflow-y:auto; padding:22px 32px 12px}
.cd-i-label{
  font-size:11px; font-weight:800; letter-spacing:.14em; text-transform:uppercase;
  color:var(--muted); margin:0 0 12px;
}
.cd-i-fieldrow{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:12px}
.cd-i-field{display:flex; flex-direction:column; gap:5px}
.cd-i-field.full{grid-column:1 / -1}
.cd-i-field label{font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--muted)}
.cd-i-input, .cd-i-textarea{
  width:100%; padding:10px 12px; border:1px solid var(--line-2); border-radius:9px;
  font-family:inherit; font-size:13.5px; color:var(--ink); background:#fff;
  transition:border-color .1s, box-shadow .1s;
}
.cd-i-input:focus, .cd-i-textarea:focus{
  outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(11,154,74,.14);
}
.cd-i-textarea{min-height:110px; resize:vertical; line-height:1.5}
.cd-i-foot{
  padding:16px 24px; border-top:1px solid var(--line); background:#fff;
  display:flex; gap:10px;
}
.cd-i-cancel{
  flex:0 0 auto; padding:12px 18px; border-radius:11px; border:1px solid var(--line);
  background:#fff; color:var(--ink-2); font-weight:600; font-size:13.5px; cursor:pointer;
}
.cd-i-cancel:hover{background:var(--surface-soft)}
.cd-i-submit{
  flex:1; padding:12px 18px; border-radius:11px; border:none;
  background:var(--brand); color:#fff; font-weight:800; font-size:13.5px; cursor:pointer;
  transition:background .12s, transform .1s;
}
.cd-i-submit:hover:not(:disabled){background:var(--brand-2); transform:translateY(-1px)}
.cd-i-submit:disabled{opacity:.5; cursor:not-allowed}
.cd-i-success{
  text-align:center; padding:60px 40px; display:flex; flex-direction:column;
  align-items:center; gap:14px;
}
.cd-i-success-icon{
  width:64px; height:64px; border-radius:50%; background:var(--brand-soft);
  display:flex; align-items:center; justify-content:center;
  color:var(--brand); font-size:28px; font-weight:800;
}
.cd-i-success h2{font-size:22px; font-weight:800; margin:0; letter-spacing:-.01em}
.cd-i-success p{font-size:13.5px; color:var(--muted); max-width:340px; margin:0; line-height:1.55}

/* Mobile */
@media(max-width:640px){
  .cd-i-fieldrow{grid-template-columns:1fr}
  .cd-hero{padding:24px 22px 20px}
  .cd-section{padding:18px 22px}
}

/* Owner-only visibility chip — appears next to section titles when the
   caller owns (or admins) the row. Shows the founder what they've locked
   away from whom. Non-owners never see this because the server strips
   _visibility metadata for them. Added Phase 2 (2026-08-11). */
.cd-vis-chip{
  display:inline-block;
  margin-left:8px;
  padding:2px 8px;
  font-size:11px;
  font-weight:500;
  line-height:1.5;
  color:#5b4520;
  background:#fff4d6;
  border:1px solid #ecd487;
  border-radius:999px;
  vertical-align:middle;
  letter-spacing:.01em;
  cursor:help;
}
.cd-vis-chip:hover{background:#ffedb8;border-color:#e4c56b}
