/* home.css — Flowboard Home (hybrid command center).
   Scoped under .home-* so it can never bleed into other surfaces. */

.home-root {
  flex: 1; min-height: 0; overflow: auto;
  background: var(--bg-app);
  padding: 24px 28px 60px;
  display: flex; flex-direction: column; gap: 18px;
}

/* ── Hero ───────────────────────────────────────────────── */
.home-hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  padding: 22px 24px;
  background: linear-gradient(135deg, rgba(0,115,234,.06), rgba(162,93,220,.04) 80%), white;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.home-greet {
  font-size: 26px; font-weight: 800; color: var(--ink-strong);
  letter-spacing: -0.02em; line-height: 1.1;
}
.home-sub {
  font-size: 13.5px; color: var(--ink-muted);
  margin-top: 6px;
}
.home-stats {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.home-stat {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 10px 16px; min-width: 96px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: white; cursor: pointer;
  transition: transform .1s ease, box-shadow .12s ease, border-color .1s ease;
}
.home-stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.home-stat-num   { font-size: 22px; font-weight: 800; color: var(--ink-strong); line-height: 1; }
.home-stat-label { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; font-weight: 500; }
.home-stat-danger .home-stat-num { color: #b41f37; }
.home-stat-warn   .home-stat-num { color: #b66f00; }
.home-stat-brand  .home-stat-num { color: var(--brand-dark); }

/* ── Quick actions ──────────────────────────────────────── */
.home-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ── Body two-column ───────────────────────────────────── */
.home-body {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 18px; align-items: start;
}
@media (max-width: 1100px) { .home-body { grid-template-columns: 1fr; } }
.home-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.home-card {
  background: white;
  border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 0;
  overflow: hidden;
}
.home-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-row);
  background: #fafbfc;
}
.home-card-head h3 {
  margin: 0; font-size: 13px; font-weight: 700; color: var(--ink-strong);
  letter-spacing: -0.01em;
}
.home-link {
  border: none; background: transparent;
  font-size: 12px; font-weight: 600; color: var(--brand);
  cursor: pointer; padding: 4px 6px; border-radius: 4px;
}
.home-link:hover { background: var(--brand-soft); }

.home-empty {
  padding: 24px 16px; text-align: center;
  color: var(--ink-muted); font-size: 12.5px;
  font-style: italic;
}

/* ── Today's queue ─────────────────────────────────────── */
.home-tasklist { list-style: none; margin: 0; padding: 0; }
.home-taskrow {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-row);
  cursor: pointer;
  transition: background .08s;
  font-size: 13px;
}
.home-taskrow:last-child { border-bottom: none; }
.home-taskrow:hover { background: #fbfcfe; }
.home-taskrow.is-overdue { background: rgba(226,68,92,.04); }
.home-taskrow.is-overdue:hover { background: rgba(226,68,92,.08); }
.home-taskrow-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; box-shadow: 0 0 0 2px white;
}
.home-taskrow-name {
  flex: 1; min-width: 0;
  color: var(--ink-strong); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-taskrow-project {
  flex-shrink: 0;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--proj-color, #a3a8b6) 14%, white);
  color: color-mix(in srgb, var(--proj-color, #a3a8b6) 75%, var(--ink-strong));
  border: 1px solid color-mix(in srgb, var(--proj-color, #a3a8b6) 28%, transparent);
  max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-taskrow-due {
  flex-shrink: 0;
  font-size: 11.5px; color: var(--ink-muted); font-weight: 500;
  min-width: 64px; text-align: right;
}
.home-taskrow-due.is-overdue { color: #b41f37; font-weight: 700; }

/* ── Personal task chip on Home queue ─────────────────────────
   Shown instead of the project pill for rows that came from the
   Personal page's private todo table. Warm gradient (peach →
   coral → soft purple) marks them as "yours only" — no other row
   on Home uses this colour combo. The ✦ glyph echoes the Personal
   hero header for visual continuity. */
.home-taskrow-personal {
  background: linear-gradient(135deg, rgba(255,126,95,.16), rgba(255,94,156,.18) 60%, rgba(196,93,249,.14)) !important;
  color: #b8385f !important;
  border: 1px solid rgba(214, 130, 168, .35) !important;
  font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px;
}
.home-taskrow-personal-glyph {
  font-size: 10px; line-height: 1;
  color: #ff5e9c;
}
.home-taskrow.is-personal:hover {
  background: linear-gradient(180deg, #fff7f3, #fff);
}

/* ── Activity list ─────────────────────────────────────── */
.home-activitylist { list-style: none; margin: 0; padding: 0; }
.home-activity {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-row);
  cursor: pointer;
  transition: background .08s;
}
.home-activity:last-child { border-bottom: none; }
.home-activity:hover { background: #fbfcfe; }
.home-activity.is-unread { background: rgba(0,115,234,.04); }
.home-activity-dot {
  width: 9px; height: 9px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
  box-shadow: 0 0 0 2px white, 0 0 0 3px var(--border-row);
}
.home-activity-body { flex: 1; min-width: 0; }
.home-activity-title {
  font-size: 13px; color: var(--ink-strong); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-activity-meta {
  font-size: 11px; color: var(--ink-muted); margin-top: 2px;
}

/* ── Sprint summary ────────────────────────────────────── */
.home-sprintlist { list-style: none; margin: 0; padding: 0; }
.home-sprint {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-row);
  cursor: pointer;
  transition: background .08s;
}
.home-sprint:last-child { border-bottom: none; }
.home-sprint:hover { background: #fbfcfe; }
.home-sprint-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.home-sprint-label {
  font-size: 13px; font-weight: 700; color: var(--ink-strong);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-sprint-project {
  font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--proj-color, #a3a8b6) 14%, white);
  color: color-mix(in srgb, var(--proj-color, #a3a8b6) 75%, var(--ink-strong));
  border: 1px solid color-mix(in srgb, var(--proj-color, #a3a8b6) 28%, transparent);
}
.home-sprint-bar {
  height: 6px; border-radius: 3px;
  background: var(--bg-subtle); overflow: hidden;
  margin-bottom: 4px;
}
.home-sprint-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent-purple));
  border-radius: 3px;
  transition: width .3s ease;
}
.home-sprint-meta {
  font-size: 11.5px; color: var(--ink-muted);
}

/* ── Bugs / tickets list ───────────────────────────────── */
.home-buglist { list-style: none; margin: 0; padding: 0; }
.home-bug {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-row);
  cursor: pointer;
  transition: background .08s;
}
.home-bug:last-child { border-bottom: none; }
.home-bug:hover { background: #fbfcfe; }
.home-bug-sev {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  flex-shrink: 0;
}
.home-bug-title {
  flex: 1; min-width: 0;
  font-size: 13px; color: var(--ink-strong); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-bug-meta {
  flex-shrink: 0;
  font-size: 11px; color: var(--ink-muted);
}

/* ── Lead funnel ───────────────────────────────────────── */
.home-funnel {
  list-style: none; margin: 0; padding: 12px 16px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.home-funnel-stage {
  flex: 1; min-width: 70px;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-subtle);
  display: flex; flex-direction: column; align-items: center;
}
.home-funnel-label {
  font-size: 10.5px; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
}
.home-funnel-count {
  font-size: 18px; font-weight: 800; color: var(--ink-strong);
  margin-top: 2px;
}

/* ── Recent projects grid ─────────────────────────────── */
.home-projects {
  display: flex; flex-direction: column; gap: 10px;
}
.home-projects-head h3 {
  margin: 0; font-size: 13px; font-weight: 700; color: var(--ink-strong);
  letter-spacing: -0.01em; padding: 4px 2px;
}
.home-projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.home-project-tile {
  display: flex; align-items: stretch; gap: 0;
  background: white;
  border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; padding: 0;
  text-align: left;
  transition: transform .1s, box-shadow .12s, border-color .1s;
  overflow: hidden;
}
.home-project-tile:hover {
  transform: translateY(-1px); box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.home-project-stripe { width: 4px; flex-shrink: 0; }
.home-project-body { padding: 10px 14px; flex: 1; min-width: 0; }
.home-project-name {
  font-size: 13.5px; font-weight: 700; color: var(--ink-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-project-meta {
  font-size: 11.5px; color: var(--ink-muted); margin-top: 3px;
}

/* ── Mobile (≤760px) ────────────────────────────────────────
 * The desktop layout assumes lots of horizontal space — wide hero,
 * 5-column stat strip, two-column body, project tiles in a grid.
 * On phones we collapse all of that to single-column flow with
 * tighter padding, smaller type, and stat cards that wrap two-up.
 * Touch targets bumped to 44px where they're tappable rows. */
@media (max-width: 760px) {
  .home-root {
    /* Respect iOS safe area so the bottom of the page isn't hidden
       behind the home-indicator on iPhone. */
    padding: 14px 12px calc(60px + env(safe-area-inset-bottom, 0px));
    gap: 12px;
  }

  /* Hero — stack title block + stats; smaller greeting, full-width */
  .home-hero {
    padding: 16px 14px;
    gap: 12px;
    flex-direction: column;
    align-items: stretch;
  }
  .home-greet {
    font-size: 22px;
    word-break: break-word;       /* long names don't push the layout */
  }
  .home-sub   { font-size: 12.5px; }
  .home-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
  }
  .home-stat {
    padding: 10px 12px;
    min-width: 0;        /* override desktop min-width so the grid wins */
    min-height: 44px;     /* tappable */
  }
  .home-stat-num   { font-size: 18px; }
  .home-stat-label { font-size: 11px; }

  /* Quick action buttons — make them more tappable */
  .home-actions {
    gap: 6px;
  }
  .home-actions .btn {
    flex: 1 1 calc(50% - 3px);
    min-height: 38px;
    justify-content: center;
  }

  /* Body — already collapses at 1100px; tighten the stack gap */
  .home-body { gap: 12px; }
  .home-col  { gap: 10px; }

  /* Card heads — smaller padding so list rows get more room.
     Wrap when "Open My Work →" + title gets crowded. */
  .home-card-head {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .home-card-head h3 { font-size: 12.5px; }

  /* Task / activity / sprint / bug rows — fatter touch targets */
  .home-taskrow,
  .home-activity,
  .home-bug {
    padding: 12px 14px;
    min-height: 44px;
  }
  .home-sprint { padding: 12px 14px; }
  /* Hide the project pill on tiny screens — name + due is enough */
  .home-taskrow-project { max-width: 90px; font-size: 10px; }
  .home-taskrow-due { min-width: 56px; font-size: 11px; }

  /* Funnel — stack stages two-up at most */
  .home-funnel { gap: 6px; padding: 10px 14px; }
  .home-funnel-stage { min-width: calc(50% - 3px); padding: 6px 8px; }
  .home-funnel-count { font-size: 16px; }

  /* Projects grid → single column */
  .home-projects-grid { grid-template-columns: 1fr; gap: 8px; }
  .home-project-tile  { min-height: 52px; }
  .home-project-name  { font-size: 13px; }

  /* AvatarPromptCard — inline styles set flex row + side-by-side
     buttons. Override here so on phones the avatar sits on top of
     stacked text + full-width buttons. !important is needed because
     the React component uses inline `style` attributes for layout. */
  .home-avatar-prompt {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 14px !important;
    text-align: center;
  }
  .home-avatar-prompt > span:first-child {
    align-self: center;
  }
  .home-avatar-prompt > div:nth-child(2) {
    text-align: center;
  }
  .home-avatar-prompt > div:last-child {
    flex-direction: row !important;
    gap: 8px !important;
  }
  .home-avatar-prompt > div:last-child .btn {
    flex: 1 1 50% !important;
    min-height: 38px;
    justify-content: center;
  }
}

/* ── Tiny phones (≤380px) — extra tightening ─────────────── */
@media (max-width: 380px) {
  .home-root { padding-left: 10px; padding-right: 10px; }
  .home-greet { font-size: 20px; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
  .home-actions .btn { flex: 1 1 100%; }   /* full-width buttons */
  .home-funnel-stage { min-width: 100%; }
  /* Avatar prompt — stack buttons vertically on the smallest screens */
  .home-avatar-prompt > div:last-child {
    flex-direction: column !important;
  }
}
