/* boot-frame.css — the first-paint frame in index.html (#boot-frame).
 *
 * Linked first in <head>, same-origin (the CSP allows 'self' stylesheets), and
 * self-contained: the frame must never paint unstyled, so it does not depend
 * on the app stylesheet, Tailwind, or anything that arrives with the bundle.
 *
 * It must look like what React renders in its place — the shared nav
 * (@trackit/nav, themed by NAV_THEME in src/App.jsx; geometry from the
 * package's nav.css), components/VaultControl.jsx in the nav's slot, App's
 * <main> padding and components/PageSkeleton.jsx — so the hand-over is not a
 * visible jump. Every value below is copied from those, or from the tokens in
 * src/index.css (@theme) they resolve to. Change them together. Since the Oct
 * 2026 redesign that is the TrackIt light family: cream page and sidebar,
 * borderless white cards, Finance's accent #4c44b3.
 *
 * No dark variant: the React frame has none. Reduced motion is handled the
 * same way as the app's `skeleton-block` (src/index.css): no sweep, a breathe.
 */

#boot-frame {
  /* Page and text: bg-page / text-ink on App's root (src/index.css @theme). */
  --boot-page-bg: #faf9f5;
  --boot-text: #1a1916;
  /* Nav (NAV_THEME in src/App.jsx — the @trackit/nav variables). */
  --boot-sidebar-bg: #faf9f5;
  --boot-sidebar-border: #ece9e1;
  --boot-sidebar-text: #1a1916;
  --boot-sidebar-muted: #6b675f;
  --boot-sidebar-accent: #4c44b3;
  --boot-sidebar-accent-light: #eceaf9;
  --boot-danger: #b3233b;
  /* Cards: bg-card + shadow-card, radius 20. */
  --boot-card-bg: #ffffff;
  --boot-card-shadow: 0 1px 2px rgba(26, 25, 22, 0.04);
  /* Placeholder blocks: the subtle fill (skeleton-block). */
  --boot-block: #f1eee6;
  /* @trackit/nav defaults: --nav-width 240px, --nav-tabbar-height 56px. */
  --boot-sidebar-width: 240px;
  --boot-mobile-nav-height: 56px;
}

/* ── Base (what Tailwind's preflight + src/index.css give the React frame) ─ */

body { margin: 0; background: #faf9f5; }

#boot-frame,
#boot-frame * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#boot-frame {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--boot-page-bg);
  color: var(--boot-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#boot-frame a { color: inherit; text-decoration: none; }
#boot-frame ul { list-style: none; }

/* ── Placeholder blocks (= skeleton-block) ────────────────────────────────── */

@keyframes boot-shimmer {
  from { transform: translateX(-100%) skewX(-20deg); }
  to   { transform: translateX(220%) skewX(-20deg); }
}

@keyframes boot-breathe {
  50% { opacity: 0.55; }
}

.boot-block {
  position: relative;
  overflow: hidden;
  background: var(--boot-block);
  border-radius: 0.375rem;
}

.boot-block::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  background-image: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.7), transparent);
  animation: boot-shimmer 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .boot-block { animation: boot-breathe 2s ease-in-out infinite; }
  .boot-block::before { display: none; }
}

/* ── Desktop sidebar (@trackit/nav .tnav-sidebar …) ───────────────────────── */

.boot-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: var(--boot-sidebar-width);
  padding: 16px 12px;
  background: var(--boot-sidebar-bg);
  border-right: 1px solid var(--boot-sidebar-border);
  z-index: 40;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .boot-sidebar { display: flex; }
}

/* .tnav-header: avatar + app name. */
.boot-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* = .tnav-avatar (32px, radius 10, the accent). */
.boot-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--boot-sidebar-accent);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.boot-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--boot-sidebar-text);
}

/* "Hey {name}" (.tnav-hey) and "← All apps" (.tnav-back), as placeholders. */
.boot-greeting { margin: 6px 2px 0; height: 18px; display: flex; align-items: center; }
.boot-greeting .boot-block { height: 10px; width: 72px; }
.boot-backlink { margin: 10px 2px 14px; height: 18px; display: flex; align-items: center; }
.boot-backlink .boot-block { height: 10px; width: 64px; }

/* .tnav-list / .tnav-item */
.boot-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.boot-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--boot-sidebar-muted);
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.boot-nav-label {
  white-space: nowrap;
}

.boot-nav-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--boot-sidebar-accent-light);
  flex-shrink: 0;
}

/* VaultControl in the nav's slot: one white card, status row + auto-lock row. */
.boot-vault {
  margin-top: auto;
  padding: 0.75rem;
  background: var(--boot-card-bg);
  box-shadow: var(--boot-card-shadow);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.boot-vault-row { display: flex; align-items: center; justify-content: space-between; height: 32px; }
.boot-vault-row .boot-block:first-child { height: 12px; width: 72px; }
.boot-vault-row .boot-block:last-child { height: 32px; width: 72px; border-radius: 9999px; }
.boot-vault-row + .boot-vault-row .boot-block:last-child { width: 96px; border-radius: 8px; }

/* .tnav-bottom: divider, Settings, Logout, the footer line. Both it and the
   vault card carry margin-top: auto, as .tnav-bottom and VaultControl's
   mt-auto do, so the free space splits the same way. */
.boot-sidebar-footer {
  margin-top: auto;
  padding-top: 8px;
  flex-shrink: 0;
}

.boot-settings {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--boot-sidebar-muted);
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.boot-footer-line { margin: 10px 10px 0; height: 16px; display: flex; align-items: center; }
.boot-footer-line .boot-block { height: 8px; width: 140px; }

.boot-divider {
  border-top: 1px solid var(--boot-sidebar-border);
  margin: 10px 0;
}

.boot-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--boot-danger);
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.boot-logout-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: #f8e7ea;
  flex-shrink: 0;
}

/* ── Mobile top bar (@trackit/nav .tnav-topbar) ───────────────────────────── */

.boot-mobile-topbar {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  align-items: center;
  gap: 10px;
  height: calc(var(--boot-mobile-nav-height) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: var(--boot-sidebar-bg);
  border-bottom: 1px solid var(--boot-sidebar-border);
}

@media (min-width: 768px) {
  .boot-mobile-topbar { display: none; }
}

/* = .tnav-avatar (32px, radius 10) and .tnav-appname. */
.boot-topbar-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--boot-sidebar-accent);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.boot-topbar-title {
  font-weight: 600;
  line-height: 1.2;
  font-size: 0.875rem;
  color: var(--boot-sidebar-text);
}

/* ── Mobile bottom bar (@trackit/nav .tnav-tabbar) ────────────────────────── */

.boot-mobile-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--boot-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  background: var(--boot-sidebar-bg);
  border-top: 1px solid var(--boot-sidebar-border);
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 768px) {
  .boot-mobile-nav { display: none; }
}

.boot-mobile-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.6875rem;
  letter-spacing: -0.04em; /* @trackit/nav .tnav-tab .tnav-label */
  color: var(--boot-sidebar-muted);
}

.boot-mobile-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--boot-block);
}

/* ── Content column (App <main> + PageSkeleton) ───────────────────────────── */

/* Clears BOTH fixed mobile bars, exactly as @trackit/nav's .tnav-content does
   (56px + the safe-area inset each way), so the boot-frame → React handoff on
   a phone is zero-shift. */
.boot-main {
  flex: 1;
  min-height: 100vh;
  padding-top: calc(var(--boot-mobile-nav-height) + env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--boot-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .boot-main { margin-left: var(--boot-sidebar-width); padding-top: 0; padding-bottom: 0; }
}

/* main's px-4 pt-2 pb-6 md:px-10 md:pt-8 md:pb-14 */
.boot-main-inner { padding: 0.5rem 1rem 1.5rem; }
@media (min-width: 768px) { .boot-main-inner { padding: 2rem 2.5rem 3.5rem; } }

/* PageSkeleton: mx-auto w-full max-w-6xl flex flex-col gap-4 md:gap-5 */
.boot-page { max-width: 72rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 768px) { .boot-page { gap: 1.25rem; } }

.boot-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}
.boot-page-header .boot-block:first-child { height: 36px; width: 192px; border-radius: 0.5rem; }
.boot-page-header .boot-block:last-child { height: 40px; width: 160px; border-radius: 9999px; }

/* h-12 w-full md:max-w-[720px] rounded-[14px] */
.boot-tabs { height: 48px; width: 100%; border-radius: 14px; }
@media (min-width: 768px) { .boot-tabs { max-width: 720px; } }

.boot-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .boot-grid { gap: 1.25rem; } }
@media (min-width: 1024px) { .boot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Card frame: rounded-card bg-card shadow-card p-4 md:px-6 md:py-[22px] —
   borderless since the redesign. */
.boot-card {
  border-radius: 20px;
  background: var(--boot-card-bg);
  box-shadow: var(--boot-card-shadow);
  padding: 1rem;
}
@media (min-width: 768px) { .boot-card { padding: 22px 1.5rem; } }

.boot-card-title { height: 20px; width: 160px; margin-bottom: 1rem; }

/* CardSkeleton variant="chart": donut beside six legend rows */
.boot-chart { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
@media (min-width: 1024px) { .boot-chart { flex-direction: row; } }
.boot-chart-plot { width: 100%; height: 180px; display: flex; align-items: center; justify-content: center; }
@media (min-width: 1024px) { .boot-chart-plot, .boot-legend { width: 50%; } }
.boot-donut { width: 150px; height: 150px; border-radius: 9999px; }
.boot-legend { width: 100%; display: flex; flex-direction: column; gap: 0.5rem; }

/* CardSkeleton variant="list": five rows, min-h-[160px] */
.boot-list { min-height: 160px; padding-top: 0.25rem; display: flex; flex-direction: column; gap: 1rem; }

.boot-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.boot-legend .boot-row { height: 20px; }
.boot-row .boot-block { height: 12px; }
.boot-row .boot-block:last-child { width: 56px; }
.boot-list .boot-row .boot-block:last-child { width: 64px; }
.boot-w-2-5 { width: 40%; }
.boot-w-1-2 { width: 50%; }
.boot-w-1-3 { width: 33.333%; }
.boot-w-1-4 { width: 25%; }

/* ── Routes where the frame is wrong (public/boot-frame.js marks them) ─────── */

/* Embedded in another app's tile or popup: paint nothing until React decides. */
html[data-boot="embedded"] #boot-frame { display: none; }

/* Onboarding: no sidebar, no bars. */
html[data-boot="bare"] #boot-frame .boot-sidebar,
html[data-boot="bare"] #boot-frame .boot-mobile-topbar,
html[data-boot="bare"] #boot-frame .boot-mobile-nav { display: none; }
html[data-boot="bare"] #boot-frame .boot-main { margin-left: 0; padding-top: 0; padding-bottom: 0; }

/* "/" is a hop (public/boot-frame.js): neither the dashboard frame nor the
 * onboarding one, only the brand and one centred shimmer line — the static
 * copy of <PageSkeleton variant="hop" />. Everything else in the frame goes. */
.boot-hop { display: none; }
html[data-boot="hop"] #boot-frame .boot-sidebar,
html[data-boot="hop"] #boot-frame .boot-mobile-topbar,
html[data-boot="hop"] #boot-frame .boot-mobile-nav,
html[data-boot="hop"] #boot-frame .boot-onboarding-bar,
html[data-boot="hop"] #boot-frame .boot-main { display: none; }
html[data-boot="hop"] #boot-frame .boot-hop {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
/* h-3 w-40 */
.boot-hop-line { height: 12px; width: 160px; }

/* Onboarding's own bar (= components/OnboardingTopBar.jsx): the TrackIt mark,
 * the page title and "← All apps". Hidden on every other route; on the two
 * onboarding routes boot-frame.js also says which title to show. */
.boot-onboarding-bar { display: none; }
html[data-boot="bare"] #boot-frame .boot-onboarding-bar {
  display: block;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--boot-sidebar-border);
  background: var(--boot-page-bg);
  padding-top: env(safe-area-inset-top, 0px);
}
.boot-onboarding-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 768px) { .boot-onboarding-inner { padding: 0 40px; } }
.boot-onboarding-mark { width: 24px; height: 24px; flex-shrink: 0; }
.boot-onboarding-name { font-size: 15px; font-weight: 800; }
.boot-onboarding-title { display: none; font-size: 14px; font-weight: 600; color: var(--boot-sidebar-muted); }
html[data-boot-page="setup-profile"] .boot-onboarding-title-profile,
html[data-boot-page="lifestyle"] .boot-onboarding-title-lifestyle,
html[data-boot-page="plan-import"] .boot-onboarding-title-lifestyle { display: inline; }
/* The spreadsheet import opened from the plan: "← Back to plan" in place of
 * "← All apps". */
#boot-frame a.boot-onboarding-back-plan,
html[data-boot-page="plan-import"] #boot-frame a.boot-onboarding-back { display: none; }
html[data-boot-page="plan-import"] #boot-frame a.boot-onboarding-back-plan,
#boot-frame a.boot-onboarding-back {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--boot-sidebar-accent);
}
@media (min-width: 768px) { #boot-frame a.boot-onboarding-back, #boot-frame a.boot-onboarding-back-plan { min-height: 32px; } }
