/* ==========================================================================
   Phantom — application layout
   ==========================================================================
   Two levels, as the brief asked for:

     1. Launchpad  — no chrome. Pick a project, or create one.
     2. Project    — persistent header with tabs. Everything is scoped here.

   There is no global "overview" competing with the project. When a tool is
   scoped to a project, a cross-project dashboard is just a hop between the
   user and the thing they came to do.
   ========================================================================== */

/* ── Launchpad ───────────────────────────────────────────────────────── */

.launch {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* One column that can't be wider than the screen. The implicit column grew to
     the header's unwrapped width, and on a phone the whole page scrolled sideways. */
  grid-template-columns: minmax(0, 1fr);
}

.launch__bar {
  display: flex; align-items: center; justify-content: space-between;
  /* 76px, matching the R5 header. */
  min-height: 76px;
  padding: var(--sp-4) var(--sp-8);
}

.launch__main {
  width: 100%;
  max-width: 920px;
  margin-inline: auto;
  padding: var(--sp-8) var(--sp-6) var(--sp-12);
}

.launch__foot {
  padding: var(--sp-5) var(--sp-6);
  color: var(--text-4);
  font-size: var(--t-xs);
  text-align: center;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: var(--sp-3);
}

.project-card {
  --r: var(--r-lg);
  --p: 1px;
  display: block;
  padding: var(--sp-5);
  border-radius: var(--r);
  background: var(--surface-1);
  box-shadow: var(--elev-2);
  corner-shape: squircle;
  transition:
    background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    transform  var(--dur-fast) var(--ease-out);
}
.project-card:hover {
  background: var(--surface-1);
  box-shadow: var(--ring), var(--shadow-lift);
  /* 2px, not scale(1.05) — a card that grows on hover is a generated-UI tell
     and it nudges everything around it. */
  transform: translateY(-2px);
}

.project-card__mark {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--t-md);
  font-weight: 800;
  corner-shape: squircle;
}

.project-card--new {
  display: grid;
  place-items: center;
  min-height: 132px;
  background: none;
  box-shadow: none;
  border: 1px dashed var(--line-strong);
  color: var(--text-3);
  text-align: center;
}
.project-card--new:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: none;
}

/* ── Project shell ───────────────────────────────────────────────────── */

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
}

.topbar__row {
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--topbar-h);
  padding: 0 var(--sp-8);
}

.backlink {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px 0 10px;
  margin-left: -10px;
  border-radius: var(--r-full);
  color: var(--text-3);
  font-size: var(--t-sm);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.backlink:hover { background: var(--surface-2); color: var(--text-1); }

.topbar__sep { width: 1px; height: 17px; background: var(--line); flex-shrink: 0; }

.topbar__name { font-size: var(--t-sm); font-weight: 560; letter-spacing: -0.008em; }

/* Tabs sit on the bottom edge of the header so the active one reads as
   connected to the content below it. */
.tabs {
  display: flex; align-items: center; gap: 2px;
  padding: 0 var(--sp-8);
}
.tab {
  position: relative;
  padding: 0 10px 9px;
  color: var(--text-3);
  font-size: var(--t-sm);
  transition: color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text-1); }
.tab[aria-current="page"] { color: var(--text-1); font-weight: 520; }
.tab[aria-current="page"]::after {
  content: "";
  position: absolute; inset-inline: 8px; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.page {
  flex: 1;
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding: var(--sp-8) var(--sp-6) var(--sp-16);
}
.page--narrow { max-width: 780px; }

.page__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

/* ── Pipeline strip ──────────────────────────────────────────────────── */

.pipeline {
  display: flex;
  /* Contains its .sr-only labels: absolutely positioned against the page, they
     sat past the scroll clip and made the whole page scroll sideways. */
  position: relative;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--elev-2);
  overflow-x: auto;
  corner-shape: squircle;
}
.pipeline__cell {
  flex: 1 0 auto;
  min-width: 96px;
  padding: 10px var(--sp-3) 12px;
}
.pipeline__cell + .pipeline__cell { border-left: 1px solid var(--line); }
.pipeline__cell--idle { opacity: 0.42; }
.pipeline__n {
  font-family: var(--font-display);
  font-size: var(--t-xl);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ── Task row ────────────────────────────────────────────────────────── */

.task {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--sp-4);
  padding: 11px var(--sp-4);
  transition: background var(--dur-fast) var(--ease);
}
.task:hover { background: var(--surface-2); }
.task__meta { display: flex; align-items: center; gap: var(--sp-3); margin-top: 3px; }

/* ── Confidence ──────────────────────────────────────────────────────── */

.conf { display: inline-flex; align-items: center; gap: var(--sp-2); }
.conf__bars { display: inline-flex; gap: 2px; }
.conf__bar {
  width: 3px; height: 13px;
  border-radius: 1px;
  background: var(--line-strong);
}
.conf__bar--on { background: var(--tone, var(--neutral)); }
.conf__n { font-size: var(--t-xs); font-weight: 550; font-variant-numeric: tabular-nums; color: var(--tone, var(--text-2)); }

/* ── Setup checklist ─────────────────────────────────────────────────── */

.setup { border-radius: var(--r-lg); overflow: hidden; box-shadow: 0 0 0 1px var(--warning-soft); corner-shape: squircle; }
.setup__head { padding: 12px var(--sp-4); background: var(--warning-soft); }
.setup__list { background: var(--surface-1); }
.setup__item { display: flex; align-items: flex-start; gap: 10px; padding: 11px var(--sp-4); }
.setup__item + .setup__item { border-top: 1px solid var(--line); }
.setup__tick {
  display: grid; place-items: center;
  width: 17px; height: 17px; margin-top: 1px; flex-shrink: 0;
  border-radius: var(--r-full);
  font-size: 10px;
}
.setup__tick--done { background: var(--success); color: var(--canvas); }
.setup__tick--todo { box-shadow: inset 0 0 0 1px var(--warning); color: var(--warning); }
.setup__tick--opt  { box-shadow: inset 0 0 0 1px var(--line-strong); }

/* ── Activity feed (live agent output) ───────────────────────────────── */

.feed { display: flex; flex-direction: column; gap: 7px; }
.feed__line { display: flex; align-items: flex-start; gap: 10px; font-size: var(--t-sm); color: var(--text-3); }
.feed__line:last-child { color: var(--text-1); }
.feed__dot { width: 5px; height: 5px; margin-top: 7px; border-radius: var(--r-full); background: var(--line-strong); flex-shrink: 0; }
.feed__line:last-child .feed__dot { background: var(--accent); animation: pulse-soft 2s var(--ease) infinite; }

/* ── Auth ────────────────────────────────────────────────────────────── */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-6); }

/* Every other surface in the app is a white card on the off-white page. A form
   floating bare on the canvas read fine on the old dark theme and looks
   unfinished on this one — and this is the first screen anyone sees. */
.auth__card {
  width: 100%;
  max-width: 404px;
  padding: var(--sp-8);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--elev-2);
}

@media (max-width: 420px) {
  .auth { padding: var(--sp-3); }
  .auth__card { padding: var(--sp-5); }
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .topbar__row { padding: 0 var(--sp-4); }
  .tabs { padding: 0 var(--sp-4); overflow-x: auto; }
  .page { padding: var(--sp-6) var(--sp-4) var(--sp-10); }
  .task { grid-template-columns: 1fr; gap: var(--sp-2); }
  /* The repo path truncates to nothing at this width and drags the project
     name — the identifier that actually matters — down with it. */
  .topbar__row .mono { display: none; }
  .launch__bar { padding: var(--sp-3) var(--sp-4); min-height: 64px; }
  .launch__main { padding: var(--sp-6) var(--sp-4) var(--sp-10); }
  /* Guide, Phantom ID, avatar and sign-out don't fit beside the name on a
     phone. The email goes (the avatar stays), and what's left may wrap. */
  .launch__bar { flex-wrap: wrap; row-gap: var(--sp-2); }
  .launch__bar > .row { flex-wrap: wrap; min-width: 0; }
  .launch__bar .truncate { display: none; }
  /* Settings: the sub-menu beside the content left the content ~150px wide
     and cut its buttons off. On a phone it becomes a scrolling row on top.
     (!important because the layout sets these inline.) */
  .settings { flex-direction: column; align-items: stretch !important; gap: var(--sp-4) !important; }
  .settings__nav { flex-direction: row; width: auto !important; overflow-x: auto; }
  .settings__nav > a { flex-shrink: 0; }
}
