/* The sales home's page styles.
 *
 * Built on the brand tokens from https://cdn.makepop.ai/theme.css, and the card
 * shapes are the launcher index's (makepop-web-app-router site/index.html): the
 * `.grid` / `.tile` pair, the `.ibox`, the `.group-label` rule, the page-role
 * remap at the top and the dark flair below it are all that page's, copied rather
 * than reinvented so a tool card here reads as the same object as the Sales card
 * there. Two pages one click apart should not look like two products.
 *
 * What is NOT copied: the launcher's `.feature` cards (this page has one group, not
 * two tiers) and its reveal/hide animation (nothing here is hidden behind a
 * marker). What is new: the empty state and the boot overlay.
 *
 * No build step, so the two-scope pattern below - every rule written once under
 * [data-theme="dark"] and again under the prefers-color-scheme fallback - is the
 * only way to share a rule body between the explicit choice and the OS default.
 * theme.css itself is written the same way. Keep the two blocks identical. */

/* ---------- Page roles ----------
   Every brand token named on the right is mode-variant in theme.css, which
   redefines it under [data-theme=dark] and under the prefers-color-scheme
   fallback, so these page roles need no dark remap of their own and the page does
   not set color-scheme (theme.css sets it per scope). */
:root {
  --bg: var(--bg-alt);
  --panel: var(--bg-raised);
  --raise: var(--bg-raised);
  --line: var(--border-card);
  --line-soft: var(--border-divider);
  --text: var(--text-body);
  --head: var(--text-heading);
  --dim: var(--text-muted);
  --icon: var(--c-primary);
  --icon-bg: color-mix(in srgb, var(--c-primary) 10%, transparent);
  --accent: var(--c-cta);
  --accent-soft: color-mix(in srgb, var(--c-cta) 10%, transparent);
  --ring: var(--c-cta);
  --card-shadow: var(--shadow-sm);
  --card-shadow-hover: var(--shadow-md);
}

/* ---------- Dark flair ----------
   Not brand roles: the purple/pink accent hues, the resting shadow off and the
   logo swap are the launcher's approved look (POP-3057), carried here so the two
   pages match in dark mode as well as light. */
[data-theme="dark"] {
  --icon: var(--c-purple-300);
  --icon-bg: color-mix(in srgb, var(--c-purple-300) 14%, transparent);
  --accent: var(--c-pink-300);
  --accent-soft: color-mix(in srgb, var(--c-pink-300) 14%, transparent);
  --ring: var(--c-pink-300);
  --card-shadow: none;
  --card-shadow-hover: var(--shadow-lg);
}
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --icon: var(--c-purple-300);
    --icon-bg: color-mix(in srgb, var(--c-purple-300) 14%, transparent);
    --accent: var(--c-pink-300);
    --accent-soft: color-mix(in srgb, var(--c-pink-300) 14%, transparent);
    --ring: var(--c-pink-300);
    --card-shadow: none;
    --card-shadow-hover: var(--shadow-lg);
  }
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-3);
  line-height: var(--lh-normal, 1.5);
  -webkit-font-smoothing: antialiased;
  transition: background-color 200ms ease, color 200ms ease;
}
a { color: inherit; text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

/* ---------- Layout ---------- */
.shell {
  position: relative;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: var(--space-8) var(--space-3) var(--space-6);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
@media (min-width: 720px) {
  .shell { padding: calc(var(--space-8) + var(--space-5)) var(--space-5) var(--space-6); }
}

/* The masthead is centred, so the theme toggle sits in the corner rather than in
   the flow: pinned to the content column's own top right, which keeps it aligned
   with the cards at every width. */
.shell > mp-theme-toggle {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
}
@media (min-width: 720px) {
  .shell > mp-theme-toggle { top: var(--space-5); right: var(--space-5); }
}

/* ---------- Header ---------- */
.masthead {
  text-align: center;
  margin-bottom: var(--space-6);
}
.masthead .logo {
  height: 2rem;
  width: auto;
  margin: 0 auto;
}
.logo-dark { display: none; }
.logo-light { display: block; }
.masthead .title {
  margin: var(--space-4) 0 0;
  font-family: var(--font-heading);
  font-weight: var(--fw-700);
  font-size: var(--fs-7);
  color: var(--head);
  letter-spacing: var(--track-tight, -0.01em);
  line-height: var(--lh-tight, 1.2);
}
.masthead .tagline {
  margin: var(--space-2) 0 0;
  font-size: var(--fs-3);
  color: var(--dim);
}

/* ---------- Group ---------- */
.group { margin-top: var(--space-4); }
.group-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  font-family: var(--font-heading);
  font-weight: var(--fw-600);
  font-size: var(--fs-1);
  text-transform: uppercase;
  letter-spacing: var(--track-wide, 0.12em);
  color: var(--dim);
}
/* The launcher's label rules draw a line on both sides. Here the count sits on the
   right, so only the left side gets one and the line after the text flexes. */
.group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
  order: 1;
}
.group-label .count {
  order: 2;
  font-size: var(--fs-1);
  font-weight: var(--fw-500);
  letter-spacing: normal;
  text-transform: none;
  color: var(--dim);
}
.group-label .count:empty { display: none; }

/* ---------- Tool grid: the launcher index's a.tile, unchanged ---------- */
/* `hidden` is only a user-agent display:none, so any rule here that sets a
   display (the grid's display:grid, the empty state's display:flex) beats it.
   Without this the "Tools land here" box showed under a populated grid. */
[hidden] {
  display: none !important;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
@media (min-width: 720px) {
  .grid { gap: var(--space-3); }
}
.grid li { display: flex; }
.tile {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.tile:focus-visible { border-color: var(--accent); }
.tile .ibox {
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--icon-bg);
  color: var(--icon);
  font-size: var(--fs-3);
  transition: color 160ms ease, background-color 160ms ease;
}
.tile:hover .ibox,
.tile:focus-visible .ibox { color: var(--accent); background: var(--accent-soft); }
.tile .name {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: var(--fw-600);
  font-size: var(--fs-3);
  color: var(--head);
  line-height: var(--lh-tight, 1.25);
}
.tile .desc {
  margin: 0;
  font-size: var(--fs-2);
  color: var(--text);
  line-height: var(--lh-snug, 1.4);
}
.tile .path {
  margin-top: auto;
  padding-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  color: var(--dim);
}

/* Tiles rise in as they are rendered. Same keyframe and the same --i stagger the
   launcher uses, because app.js sets --i per <li> exactly as that page's markup
   does. */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.grid li {
  animation: rise-in 360ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(80ms + var(--i, 0) * 70ms);
}

/* ---------- Empty state ----------
   The shipped state on launch day, so it is a designed card rather than a shrug.
   Dashed border and no shadow: it reads as a placeholder for something, which is
   exactly what it is. */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.empty-ibox {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--icon-bg);
  color: var(--icon);
  font-size: var(--fs-5);
}
.empty-title {
  margin: var(--space-2) 0 0;
  font-family: var(--font-heading);
  font-weight: var(--fw-600);
  font-size: var(--fs-4);
  color: var(--head);
}
.empty-msg {
  margin: 0;
  max-width: 28rem;
  font-size: var(--fs-2);
  color: var(--dim);
  line-height: var(--lh-snug, 1.45);
}

/* ---------- Footer ---------- */
.foot {
  margin-top: auto;
  padding-top: var(--space-7);
  display: flex;
  justify-content: center;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-weight: var(--fw-500);
  font-size: var(--fs-2);
  color: var(--dim);
  transition: color 160ms ease;
}
.back:hover, .back:focus-visible { color: var(--accent); }

/* ---------- Boot overlay (auth.js) ----------
   The shell paints first and this sits on top of it, so a Cloud Run cold start
   reads as "working on it" rather than "broken". Every failure card shares this
   box; auth.js swaps the title, the message and the one action.

   The scrim is a brand token rather than a hardcoded rgba, so it is right in both
   modes without a second rule. */
.boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(3px);
}
.boot .boot-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
  text-align: center;
  max-width: 26rem;
  padding: var(--space-6) var(--space-5);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.boot h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: var(--fw-600);
  font-size: var(--fs-4);
  color: var(--head);
  line-height: var(--lh-tight, 1.25);
}
.boot .boot-msg {
  margin: 0;
  font-size: var(--fs-2);
  color: var(--dim);
  line-height: var(--lh-snug, 1.45);
}
.boot .boot-msg:empty { display: none; }
.boot .boot-act:empty { display: none; }
.boot .boot-spin {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: boot-spin 0.8s linear infinite;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }

/* ---------- Reduced motion ----------
   One block for the whole page, at the end so it wins. The ring stays and stops
   rotating; the tiles stay and stop rising. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .grid li { animation: none !important; }
  .boot .boot-spin { animation: none; }
  .tile:hover { transform: none; }
}
