/**
 * Venture Card Styles
 * Shared card, drag, and grid styles for all dashboard pages.
 */

/* ============================================================================
   CARD GRID
   ============================================================================ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
}

/* ============================================================================
   VENTURE CARD - BASE
   ============================================================================ */

.venture-card {
  background: linear-gradient(135deg, rgba(var(--card-tint),0.08), rgba(var(--card-tint),0.02) 60%, var(--card));
  border: 1px solid var(--border);
  border-left: 3px solid rgba(var(--card-tint),0.5);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 2.25rem 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, opacity .2s, transform .2s ease, border-radius .3s ease;
  position: relative;
  cursor: grab;
  --card-tint: 128,128,128;
  grid-column: span 6;
  overflow: visible;
  margin-bottom: .25rem;
  container-type: inline-size;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.venture-card:active { cursor: grabbing; }
.venture-card button, .venture-card a { cursor: pointer; }
.venture-card.sample-card { border-style: dashed; opacity: 0.88; }

/* Card textures */
.venture-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: .07;
  z-index: 0;
}

.venture-card[data-texture="dots"]::before {
  background-image: radial-gradient(rgba(var(--card-tint),0.8) 1px, transparent 1px);
  background-size: 8px 8px;
}

.venture-card[data-texture="grid"]::before {
  background-image: linear-gradient(rgba(var(--card-tint),0.6) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(var(--card-tint),0.6) 1px, transparent 1px);
  background-size: 12px 12px;
}

.venture-card[data-texture="diagonal"]::before {
  background-image: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(var(--card-tint),0.7) 4px, rgba(var(--card-tint),0.7) 5px);
}

.venture-card[data-texture="noise"]::before {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .12;
}

.venture-card[data-texture="topography"]::before {
  background-image: repeating-linear-gradient(0deg, transparent, transparent 6px, rgba(var(--card-tint),0.5) 6px, rgba(var(--card-tint),0.5) 7px),
                    repeating-linear-gradient(90deg, transparent, transparent 16px, rgba(var(--card-tint),0.2) 16px, rgba(var(--card-tint),0.2) 17px);
}

.venture-card[data-texture="wave"]::before {
  background-image: repeating-linear-gradient(135deg, transparent, transparent 3px, rgba(var(--card-tint),0.5) 3px, rgba(var(--card-tint),0.5) 4px, transparent 4px, transparent 10px);
}

.venture-card > * { position: relative; z-index: 1; }
.venture-card:hover { box-shadow: var(--shadow-lg); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

/* Card states */
.venture-card.dimmed { opacity: .35; }
.venture-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-lg); }

/* ============================================================================
   CARD INNER LAYOUT
   ============================================================================ */

.card-inner { display: flex; flex-direction: column; gap: 1rem; overflow: hidden; }
.card-row-1 { display: flex; flex-direction: row; gap: 1rem; overflow: hidden; }
.card-row-1 > div:first-child { flex: 1 1 0%; min-width: 0; }
.card-row-1 > .card-children-row1 { flex: 0 0 40%; min-width: 0; overflow: hidden; }
.card-children-row1:empty, .card-children-row2:empty { display: none; }
.card-children-row2 { overflow: hidden; }

/* ============================================================================
   CARD HEADER
   ============================================================================ */

.card-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; }

.card-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--card-chip-bg, var(--bg));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--card-accent, var(--muted));
  overflow: hidden;
  border: 1px solid var(--card-chip-border, transparent);
}

.card-logo img { width: 100%; height: 100%; object-fit: cover; }

.card-name { font-size: 1rem; font-weight: 600; color: var(--card-accent, var(--text)); }
.card-name a, .card-sub-name a { color: inherit; text-decoration: none; }
.card-name a:hover, .card-sub-name a:hover { color: var(--accent); text-decoration: underline; }

.card-edit-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .75rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-edit-btn:hover { background: var(--bg); color: var(--accent); }

/* ============================================================================
   BADGES
   ============================================================================ */

.badge { font-size: .65rem; padding: 2px 8px; border-radius: 20px; font-weight: 600; }

.type-badge {
  font-size: .6rem;
  padding: 3px 9px 3px 6px;
  border-radius: 20px;
  background: rgba(124,110,240,0.12);
  color: var(--accent);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: .02em;
  line-height: 1;
  border: 1px solid rgba(124,110,240,0.25);
}

.type-badge svg { flex-shrink: 0; }

.sample-badge {
  display: inline-block;
  font-size: .5rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(124,110,240,0.07);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-left: .4rem;
  vertical-align: middle;
  opacity: .5;
}

.card-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .5rem; }
.card-top-badges { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; gap: 4px; align-items: center; }
.card-bottom-badges { display: flex; gap: 4px; align-items: center; margin-top: .5rem; }

/* Status badges */
.badge-status { background: #0d2818; color: #34d399; }
.badge-status[data-v="Dormant"] { background: #1f1f2a; color: #8888a0; }
.badge-status[data-v="Seasonal"] { background: #2a2210; color: #d4a843; }
.badge-status[data-v="Backlog"] { background: #1f1f2a; color: #8888a0; }
.badge-status[data-v="Pitch"] { background: #111830; color: #60a5fa; }
.badge-status[data-v="Growth"] { background: #0d2818; color: #4ade80; }
.badge-status[data-v="Maintenance"] { background: #2a2210; color: #d4a843; }

/* Priority badges */
.badge-priority { color: #fff; }
.badge-priority[data-v="Critical"] { background: var(--critical); }
.badge-priority[data-v="High"] { background: var(--high); }
.badge-priority[data-v="Medium"] { background: var(--medium); }
.badge-priority[data-v="Low"] { background: var(--low); }

.badge-risk { background: #2a1515; color: var(--critical); }
.badge-attention { font-size: .68rem; color: var(--muted); font-style: italic; }

/* ============================================================================
   KEY DRIVERS / CHIPS
   ============================================================================ */

.kd-chips { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .4rem; }

.kd-chip {
  font-size: .75rem;
  padding: 2px 7px;
  background: var(--card-chip-bg, rgba(255,255,255,.06));
  border: 1px solid var(--card-chip-border, rgba(255,255,255,.1));
  border-radius: 4px;
  color: var(--card-accent, var(--text));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.kd-chip.kd-event { border-color: rgba(var(--accent-rgb,99,102,241),.3); }

.card-note {
  font-size: .72rem;
  color: var(--card-accent-muted, var(--muted));
  font-style: italic;
  margin-bottom: .4rem;
  padding: 4px 6px;
  background: rgba(255,255,255,.03);
  border-left: 2px solid var(--card-accent, var(--accent));
  border-radius: 2px;
}

/* ============================================================================
   RESIZE HANDLE
   ============================================================================ */

.resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 10px;
  cursor: col-resize;
  z-index: 3;
}

.resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 3px;
  width: 4px;
  height: 28px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--border);
  opacity: 0;
  transition: opacity .15s;
}

.venture-card:hover .resize-handle::after { opacity: .6; }
.resize-handle:hover::after { opacity: 1; background: var(--accent); }

.resize-indicator {
  position: absolute;
  top: 8px;
  right: 20px;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  z-index: 5;
  pointer-events: none;
}

/* ============================================================================
   DRAG & DROP
   ============================================================================ */

/* Drag ghost - follows cursor */
.venture-card.dragging {
  opacity: .8;
  z-index: 1000;
  position: fixed;
  pointer-events: none;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  transform: rotate(1.5deg) scale(1.03);
  grid-column: auto !important;
  will-change: transform, left, top;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* FLIP animation for live card movement */
.venture-card.flip-animate {
  transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.venture-card.flip-immediate {
  transition: none !important;
}

/* Card being dragged (removed from grid flow - ghost follows cursor) */
.venture-card.drag-source {
  position: absolute !important;
  opacity: 0;
  pointer-events: none;
}

/* Drop placeholder */
.drop-placeholder {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(124,110,240,.06);
  min-height: 80px;
  transition: all .15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Action label inside drop placeholder */
.drop-action-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(124,110,240,.12);
  padding: 5px 12px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  pointer-events: none;
}

.drop-action-label svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Drop zone highlighting during drag */
.card-grid.dragging-active .venture-card:not(.dragging):not(.drag-source) {
  border-color: rgba(124,110,240, 0.25);
  transition: border-color .15s, box-shadow .15s;
}

/* Same-row swap: reduce ghost opacity for clarity */
.venture-card.dragging.same-row-swap {
  opacity: 0.55;
}

/* Direction indicator on ghost */
.ghost-direction-indicator {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}

.venture-card.dragging .ghost-direction-indicator.visible {
  opacity: 1;
}

/* ============================================================================
   CHILD CARDS (SUB-VENTURES)
   ============================================================================ */

.card-sub-venture {
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  position: relative;
  cursor: grab;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.card-sub-venture:active { cursor: grabbing; }
.card-sub-venture button, .card-sub-venture a { cursor: pointer; }

.card-sub-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; position: relative; }
.card-sub-name { font-weight: 600; font-size: .95rem; }
.card-sub-edit { position: static; opacity: 0; transition: opacity .15s; }
.card-sub-venture:hover .card-sub-edit { opacity: 1; }

/* Child card container */
.card-children { display: flex; flex-direction: row; gap: 0; position: relative; }
.card-children > .card-sub-venture { min-width: 0; box-sizing: border-box; }
.card-children.single-child > .card-sub-venture { flex: 0 0 50%; }

/* Child drag states */
.card-inner.child-dragging .card-children-row1,
.card-inner.child-dragging .card-children-row2 { min-height: 50px; }

.card-inner.child-dragging .card-children-row1:empty,
.card-inner.child-dragging .card-children-row2:empty {
  display: flex;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  opacity: .5;
}

.card-inner.child-dragging .card-children-row1:empty::after,
.card-inner.child-dragging .card-children-row2:empty::after {
  content: 'Drop here';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: var(--muted);
  font-size: .75rem;
}

/* Child drag ghost */
.child-drag-ghost {
  position: fixed;
  opacity: .85;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  transform: rotate(1deg) scale(1.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: .75rem;
  will-change: transform, left, top;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Child drop placeholder */
.child-drop-placeholder {
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(124,110,240,.06);
  min-height: 50px;
  flex: 0 0 auto;
}

/* Child resize handles */
.child-edge-resize {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: col-resize;
  z-index: 3;
}

.child-edge-resize.edge-right { right: -5px; }
.child-edge-resize.edge-left { left: -5px; }

.child-edge-resize::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 4px;
  height: 24px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--border);
  opacity: 0;
  transition: opacity .15s;
}

.child-edge-resize.edge-right::after { right: 3px; }
.child-edge-resize.edge-left::after { left: 3px; }
.card-sub-venture:hover .child-edge-resize::after { opacity: .6; }
.child-edge-resize:hover::after { opacity: 1; background: var(--accent); }

.card-children > .child-resize-handle {
  width: 8px;
  flex-shrink: 0;
  cursor: col-resize;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-children > .child-resize-handle::after {
  content: '';
  width: 3px;
  height: 24px;
  border-radius: 2px;
  background: var(--border);
  opacity: 0;
  transition: opacity .15s;
}

.card-children:hover > .child-resize-handle::after { opacity: .6; }
.card-children > .child-resize-handle:hover::after { opacity: 1; background: var(--accent); }

/* ============================================================================
   KD (KEY DRIVER) DRAG
   ============================================================================ */

.kd-drop-placeholder {
  border: 2px dashed var(--accent);
  border-radius: 20px;
  background: rgba(124,110,240,.06);
  min-height: 28px;
  transition: all .15s ease;
}

.kd-drag-ghost {
  position: fixed;
  opacity: .8;
  z-index: 1000;
  transform: rotate(1.5deg) scale(1.03);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  pointer-events: none;
  will-change: transform, left, top;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

/* Small Tablet (max-width: 900px) */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .venture-card { grid-column: span 1 !important; }
}

/* Mobile (max-width: 700px) */
@media (max-width: 700px) {
  .card-children { flex-direction: column; }
  .card-children > .child-resize-handle { display: none; }
  .child-edge-resize { display: none; }
  .card-children.single-child > .card-sub-venture { flex: 1 1 100%; }
}

/* Mobile (max-width: 600px) */
@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
}
