/* layout.css - structure + spacing ONLY. No color hex, no font-family strings.
   v4 LAYERED EXPLORER: a calm, scrollable, macro-first explorer (NOT a single-viewport
   wall of widgets). A breadcrumb bar + one visible "layer" at a time; generous space.
   The INTERACTIVE layer is the one place the sim + controls live, as a two-column grid.
   Uses var(--token) for every color/font/spacing that has a token. */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image: var(--page-wash);
  overflow-x: hidden;
}

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

/* the explorer shell */
.explorer {
  min-height: 100vh;
  padding: var(--sp-5) 0 var(--sp-8);
}

/* breadcrumb bar (hidden on home, shown on drill) */
.crumb-bar {
  display: none;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--rule);
  /* sticky so the Back button stays visible even after a deep-link scrolls the page down */
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper, #fbfaf8);
}
.crumb-bar.is-visible { display: flex; }
.crumb-back { font-weight: 600; }

/* one layer host; only the active layer is shown (the rest are [hidden]) */
.layer-host { position: relative; }
.layer[hidden] { display: none; }
.layer { animation: layer-in var(--dur) var(--ease-out); }
@keyframes layer-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===================== L0 MACRO HOME ===================== */
.macro { padding: var(--sp-5) 0 var(--sp-6); }
.macro-ideas {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-top: var(--sp-7);
}

/* ===================== L1/L2 PARTS ===================== */
.parts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}
.part-points {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}
.part-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--rule);
}

/* ===================== L3 NUMBERS ===================== */
.numbers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
  margin: var(--sp-5) 0 var(--sp-6);
}
.firmness {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

/* ===================== INTERACTIVE LAYER ===================== */
.layer-interactive { max-width: 1180px; }
.interactive-head { margin-bottom: var(--sp-5); }
.interactive-grid {
  display: grid;
  /* v7 (founder): the LEVERS lead -- controls take a prominent LEFT column (wide enough
     that the knowledge graph no longer overlaps), the stage/sim follows on the right. */
  grid-template-columns: clamp(340px, 40vw, 560px) minmax(0, 1fr);
  gap: var(--sp-5);
  align-items: start;
}
.interactive-stage { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.sim-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 11 / 6;
}
.sim-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.interactive-cb { margin-top: var(--sp-2); }
.cb-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: var(--sp-3);
}

/* the interactive layer pushes #app wider so the two-column grid has room */
.layer-interactive { width: 100%; }

@media (min-width: 1100px) {
  /* let the interactive layer breathe wider than the calm reading column */
  #app:has(.layer-interactive:not([hidden])) { max-width: 1240px; }
}

/* ===================== responsive: stack ===================== */
@media (max-width: 920px) {
  .interactive-grid {
    grid-template-columns: 1fr;
  }
  .cb-strip { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  #app { padding: 0 var(--sp-4); }
}
