/* cr-youtube — shadcn/ui dark slate theme.
   Server-rendered, no React, no Tailwind. */

:root {
  /* Surfaces */
  --bg:           hsl(240 10% 3.9%);    /* zinc-950 background */
  --surface:      hsl(240 10% 5%);      /* card bg */
  --surface-2:    hsl(240 5% 10%);      /* nested input bg */

  /* Borders */
  --border:       hsl(240 4% 16%);      /* zinc-800 border */
  --border-2:     hsl(240 5% 22%);      /* hover border */

  /* Foreground */
  --fg:           hsl(0 0% 98%);        /* zinc-50 */
  --fg-muted:     hsl(240 5% 65%);      /* zinc-400 */
  --fg-subtle:    hsl(240 4% 46%);      /* zinc-500 */

  /* Primary CTA = white-on-zinc */
  --accent:       hsl(0 0% 98%);
  --accent-fg:    hsl(240 6% 10%);
  --ring:         hsl(240 5% 64%);

  /* Semantic */
  --destructive:  hsl(0 62% 50%);
  --success:      hsl(142 70% 45%);
  --warn:         hsl(38 92% 50%);
  --info:         hsl(217 91% 60%);
  --star:         hsl(45 93% 58%);

  /* Aliases — subtle white/translucent for legacy refs */
  --accent-soft:  hsla(0 0% 98% / 0.06);
  --accent-glow:  hsla(0 0% 98% / 0.10);

  /* Geometry */
  --radius:       0.5rem;
  --radius-md:    0.375rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }

button { font: inherit; cursor: pointer; }

::selection { background: var(--surface-2); color: var(--fg); }

/* ---------- Layout ---------- */

header.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 52px;
  background: hsla(240 10% 3.9% / 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

header .brand {
  font-weight: 600; font-size: 14px; letter-spacing: -0.01em;
  color: var(--fg);
  display: flex; align-items: center; gap: 8px;
}
header .brand .dot {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg);
}

header nav { display: flex; gap: 2px; margin-left: 12px; }
header nav a {
  position: relative;
  color: var(--fg-muted); padding: 6px 8px; font-size: 14px;
  border-radius: var(--radius-md);
  transition: color 150ms ease;
}
header nav a:hover { color: var(--fg); text-decoration: none; }
header nav a.active { color: var(--fg); }
header nav a.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -16px;
  height: 1px; background: var(--fg);
}

header .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
header .channel-pick {
  background: var(--surface-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem; font-size: 14px; height: 36px;
}

main {
  max-width: 1500px; margin: 0 auto;
  padding: 24px 20px 80px;
}
@media (min-width: 800px) {
  main { padding: 32px 24px 80px; }
}

h1 {
  font-size: 20px; margin: 0 0 4px; font-weight: 600;
  letter-spacing: -0.015em; line-height: 1.2;
  color: var(--fg);
}
h2 {
  font-size: 15px; margin: 32px 0 16px;
  color: var(--fg); font-weight: 500;
  letter-spacing: -0.005em;
}

.muted { color: var(--fg-muted); }
.lede { color: var(--fg-muted); margin: 0 0 24px; font-size: 14px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0.5rem 0.875rem; font-size: 14px; font-weight: 500;
  height: 36px;
  transition: all 150ms ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ring);
}
.btn.primary {
  background: var(--accent); color: var(--accent-fg);
  border-color: transparent; font-weight: 500;
}
.btn.primary:hover { opacity: 0.9; background: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.destructive {
  background: var(--destructive); color: hsl(0 0% 98%);
  border-color: transparent;
}
.btn.destructive:hover { opacity: 0.9; }
.btn.danger { /* legacy alias */
  background: var(--destructive); color: hsl(0 0% 98%);
  border-color: transparent;
}
.btn.danger:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}
.card.tight { padding: 1rem; }

.grid { display: grid; gap: 16px; }
.grid.cards-4 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.cards-2 { grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); }

/* ---------- Badges / bucket pills ---------- */

.bucket, .badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.125rem 0.5rem;
  font-size: 11px; font-weight: 500; letter-spacing: 0;
  color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2);
  text-transform: none;
  line-height: 1.4;
}
.bucket::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; border-radius: 999px;
  background: currentColor; flex-shrink: 0;
}
.bucket {
  /* Reset color so ::before dot inherits bucket color, but text is muted */
  color: var(--fg-muted);
}
/* When inline style sets bucket color, dot picks it up via a child span pattern.
   Since pages may set `color:` on .bucket directly, we keep the dot using currentColor.
   Text color stays muted via explicit override on a wrapped span if needed. */

.badge.success { color: var(--success); border-color: hsla(142 70% 45% / 0.3); }
.badge.muted   { color: var(--fg-muted); }
.badge.destructive { color: var(--destructive); border-color: hsla(0 62% 50% / 0.3); }

/* ---------- Idea cards ---------- */

.idea-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
  transition: border-color 150ms ease;
}
.idea-card:hover { border-color: var(--border-2); }
.idea-card.entering { animation: idea-card-fade-in 200ms ease-out both; }
.idea-card.flash-yes,
.idea-card.flash-no { animation: idea-card-fade-in 200ms ease-out both; }

.idea-card .thumb {
  position: relative; width: 100%; aspect-ratio: 16/9;
  background: hsl(240 10% 2%); overflow: hidden;
}
.idea-card .thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.idea-card .thumb .empty {
  display:flex; align-items:center; justify-content:center; height:100%;
  color: var(--fg-subtle); font-size: 12px;
}

.idea-card .star-btn {
  position: absolute; top: 8px; right: 8px;
  background: hsla(240 10% 3.9% / 0.7);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  width: 28px; height: 28px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.idea-card .star-btn:hover { background: var(--surface-2); color: var(--fg); }
.idea-card .star-btn.on { color: var(--star); border-color: var(--border-2); }
.idea-card .star-btn.pulse-on,
.idea-card .star-btn.pulse-off { animation: idea-card-fade-in 200ms ease-out both; }

.idea-card .body {
  padding: 16px 16px 8px; flex: 1;
  display: flex; flex-direction: column; gap: 8px;
}
.idea-card .title {
  font-size: 14px; font-weight: 600; line-height: 1.4;
  color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.idea-card .concept {
  font-size: 13px; color: var(--fg-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.idea-card .meta {
  display: flex; gap: 8px; align-items: center;
  font-size: 12px; color: var(--fg-muted);
}

.idea-card .tally {
  display: flex; gap: 12px; padding: 0 16px 12px;
  font-size: 11px; align-items: center;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
}
.idea-card .tally .yes { color: var(--success); }
.idea-card .tally .no  { color: var(--fg-muted); }
.idea-card .tally .star { color: var(--star); margin-left: auto; }
.idea-card .tally .bump { animation: idea-card-fade-in 200ms ease-out both; }

.idea-card .vote-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.idea-card .vote-row button {
  background: transparent; color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem; font-size: 13px; font-weight: 500;
  height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 150ms ease;
}
.idea-card .vote-row button:hover { background: var(--surface-2); }
.idea-card .vote-row button.on-yes,
.idea-card .vote-row button.on-no {
  background: var(--surface-2); border-color: var(--ring);
}
.idea-card .vote-row button.flash-yes,
.idea-card .vote-row button.flash-no { animation: idea-card-fade-in 200ms ease-out both; }

.idea-card.closed-yes { border-left: 2px solid var(--success); }
.idea-card.closed-no  { border-left: 2px solid var(--border-2); opacity: 0.7; }

@keyframes idea-card-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .idea-card,
  .idea-card .star-btn,
  .idea-card .vote-row button { transition: none !important; animation: none !important; }
}

/* ---------- Filter bar ---------- */

.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 12px 0; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.filter-bar select, .filter-bar input {
  background: var(--surface-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem; font-size: 14px; height: 36px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.filter-bar select:focus, .filter-bar input:focus {
  outline: 0; border-color: var(--ring);
  box-shadow: 0 0 0 3px hsla(240 5% 64% / 0.15);
}
.filter-bar input { min-width: 220px; }
.filter-bar input::placeholder { color: var(--fg-subtle); }
.filter-bar .spacer { margin-left: auto; }

/* ---------- Pipeline (Kanban) ---------- */

.kanban {
  display: grid; gap: 16px;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  overflow-x: auto;
}
.kanban-col {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); min-height: 200px;
  display: flex; flex-direction: column;
  transition: border-color 150ms ease;
}
.kanban-col.drop-active { border-color: var(--ring); }
.kanban-col h3 {
  font-size: 13px; font-weight: 500;
  color: var(--fg); margin: 0; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-col h3 .count {
  color: var(--fg-muted); font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.kanban-col .col-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }

.prod-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
  transition: border-color 150ms ease, opacity 150ms ease;
  animation: idea-card-fade-in 200ms ease-out both;
}
.prod-card:hover { border-color: var(--border-2); }
.prod-card.dragging {
  opacity: 0.85;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  cursor: grabbing;
}
.prod-card.just-dropped { border-color: var(--border-2); }
.prod-card .thumb {
  width: 100%; aspect-ratio: 16/9;
  background: hsl(240 10% 2%); border-radius: var(--radius-md);
  margin-bottom: 10px; overflow: hidden;
}
.prod-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-card .title {
  font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.prod-card .meta {
  font-size: 12px; color: var(--fg-muted); margin-top: 8px;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}

.days-pill {
  display: inline-flex; align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 11px; font-weight: 500;
  border-radius: var(--radius-md);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.days-pill.warn { color: var(--warn); border-color: hsla(38 92% 50% / 0.3); }
.days-pill.danger { color: var(--destructive); border-color: hsla(0 62% 50% / 0.3); }
.blocker {
  display: inline-flex; align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 11px; font-weight: 500;
  border-radius: var(--radius-md);
  color: var(--destructive);
  border: 1px solid hsla(0 62% 50% / 0.3);
  background: hsla(0 62% 50% / 0.08);
}

@media (prefers-reduced-motion: reduce) {
  .prod-card, .kanban-col, .days-pill, .blocker { animation: none; transition: none; }
}

/* ---------- Tables ---------- */

table.list {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
table.list th {
  text-align: left; color: var(--fg-muted); font-weight: 500; font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
table.list td {
  padding: 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--fg);
}
table.list tr:hover td { background: var(--surface-2); }
table.list .thumb-cell img {
  width: 80px; aspect-ratio: 16/9; object-fit: cover;
  border-radius: var(--radius-md); background: hsl(240 10% 2%);
}

/* ---------- Stats strip ---------- */

.stat-strip {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 24px;
}
.stat-strip .stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.stat-strip .label {
  font-size: 13px; color: var(--fg-muted); margin-bottom: 8px;
  font-weight: 500;
}
.stat-strip .value {
  font-size: 24px; font-weight: 600; color: var(--fg);
  letter-spacing: -0.015em; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-strip .sub {
  font-size: 12px; color: var(--fg-muted); margin-top: 4px;
}

/* ---------- Channel cards (home) ---------- */

.channel-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
  transition: border-color 150ms ease;
  display: flex; flex-direction: column;
}
.channel-card:hover { border-color: var(--border-2); }
.channel-card .cover {
  width: 100%; aspect-ratio: 16/9; background: hsl(240 10% 2%);
  background-size: cover; background-position: center;
}
.channel-card .body { padding: 16px; }
.channel-card .name { font-size: 15px; font-weight: 600; color: var(--fg); }
.channel-card .stats { color: var(--fg-muted); font-size: 13px; margin-top: 4px; }
.channel-card .stats .pending { color: var(--fg); font-weight: 500; }

/* ---------- Forms ---------- */

label.field { display: block; margin-bottom: 16px; }
label.field span {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--fg); margin-bottom: 6px;
}
label.field input, label.field textarea, label.field select {
  width: 100%;
  background: var(--surface-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem; font-size: 14px; font-family: inherit;
  height: 36px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
label.field textarea { min-height: 80px; height: auto; resize: vertical; padding: 0.5rem 0.75rem; }
label.field input::placeholder, label.field textarea::placeholder {
  color: var(--fg-subtle);
}
label.field input:focus, label.field textarea:focus, label.field select:focus {
  outline: 0; border-color: var(--ring);
  box-shadow: 0 0 0 3px hsla(240 5% 64% / 0.15);
}
label.field input.invalid, label.field textarea.invalid, label.field select.invalid {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px hsla(0 62% 50% / 0.15);
}

@media (prefers-reduced-motion: reduce) {
  label.field input, label.field textarea, label.field select {
    transition: none !important;
  }
}

/* ---------- Empty states ---------- */

.empty-state {
  background: var(--surface); border: 1px dashed var(--border-2);
  border-radius: var(--radius); padding: 48px 24px;
  text-align: center; color: var(--fg-muted);
  animation: idea-card-fade-in 200ms ease-out both;
}
.empty-state h3 { color: var(--fg); margin: 0 0 8px; font-size: 15px; font-weight: 500; }

/* ---------- Toasts ---------- */

.toast {
  position: fixed; bottom: 24px; left: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.75rem 1rem; border-radius: var(--radius);
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: toast-in 150ms ease-out both;
}
.toast.error { border-color: hsla(0 62% 50% / 0.4); }
.toast.ok    { border-color: hsla(142 70% 45% / 0.4); }
.toast.removing { animation: toast-out 150ms ease-in both; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ---------- Spinner ---------- */

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--fg); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.ok, .toast.error, .toast.removing,
  .empty-state, .btn, .btn.primary {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 800px) {
  .kanban { grid-template-columns: 1fr; }
  header nav { gap: 0; }
  header nav a { padding: 6px; }
}

/* ---------- Lucide icon sizing utilities ---------- */

.icon {
  display: inline-block;
  width: 16px; height: 16px;
  vertical-align: -3px;
  flex-shrink: 0;
  stroke-width: 2;
}
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 20px; height: 20px; vertical-align: -4px; }

/* ---------- Comment body wrapping ---------- */
/* Long URLs / unbroken strings in comments must wrap, not blow out the row. */
.comment-row .body, .comment-row .comment-body, .comments-list .body {
  overflow-wrap: anywhere;
  word-break: break-word;
}
