/* =========================================================
   matrix-core.css - V4.3 Matrix core layout
   Shell, back link, 3-region grid, progress rail, step shell,
   field primitives (label, input, range, chip group), nav bar.
   ========================================================= */

.matrix-shell {
  background: var(--ink, #0a1213);
  color: var(--ivory, #ece4d2);
  min-height: 100vh;
  padding: 24px 24px 96px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.matrix-shell .matrix-back-home {
  display: inline-block;
  font-family: "JetBrains Mono", sans-serif;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--stone, #b6a98c);
  text-decoration: none;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(166, 124, 82, 0.30);
  padding-bottom: 4px;
}

.matrix-back-home:hover {
  color: var(--ivory, #ece4d2);
  border-bottom-color: var(--brass-bright, #c79c70);
}

/* ---- File workspace title bar (V4.4 polish) ----
   Editorial header above the grid: kind label + serif title +
   short truth-line subhead. Replaces the old "this is a wizard"
   feel with a "this is a private file" feel. */
.matrix-shell-head {
  max-width: 1240px;
  margin: 0 auto 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(166, 124, 82, 0.25);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.matrix-shell-head-text {
  min-width: 0;
}

.matrix-shell-eyebrow {
  font-family: "JetBrains Mono", sans-serif;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brass, #a67c52);
  margin: 0 0 6px;
}

.matrix-shell-title {
  font-family: "Newsreader", Georgia, serif;
  font-weight: 500;
  font-size: clamp(30px, 4.2vw, 48px);
  line-height: 1.0;
  letter-spacing: -0.018em;
  color: var(--ivory, #ece4d2);
  margin: 0 0 10px;
}

.matrix-shell-sub {
  font-family: "Newsreader", Georgia, serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--stone, #b6a98c);
  margin: 0;
  max-width: 60ch;
}

@media (max-width: 640px) {
  .matrix-shell-head { margin-bottom: 18px; padding-bottom: 14px; }
}

/* ---- File workspace 3-region layout ----
   Mobile / tablet (default): single column, stacked. Section
   index collapses to a compact "Section X of Y · Title" row.
   Desktop (>=1080px): index | active section | working draft
   preview, side by side, like a real file workspace. */
.matrix-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "index"
    "step"
    "preview";
  gap: 18px;
  max-width: 1240px;
  margin: 0 auto;
}

/* V4.4 polish — Claude Web v442 layout: section-index left,
   working draft preview CENTER (the file is the object), editor
   on the right. The user looks at the file and edits beside it. */
@media (min-width: 1080px) {
  .matrix-grid.has-preview {
    grid-template-columns: 200px minmax(0, 1fr) 360px;
    grid-template-areas: "index preview step";
    gap: 24px;
  }
}

@media (min-width: 1240px) {
  .matrix-grid.has-preview {
    grid-template-columns: 220px minmax(0, 1fr) 380px;
    gap: 28px;
  }
}

.matrix-progress {
  grid-area: index;
  min-width: 0;
}

@media (min-width: 1080px) {
  .matrix-progress {
    position: sticky;
    top: 24px;
    align-self: start;
  }
}

.matrix-step-region {
  grid-area: step;
  min-width: 0;
  max-width: 720px;
}

.matrix-preview-region {
  grid-area: preview;
  min-width: 0;
}

@media (min-width: 1080px) {
  .matrix-preview-region {
    position: sticky;
    top: 24px;
    align-self: start;
  }
}

/* ---- Section index (replaces the old horizontal progress rail) ---- */
.matrix-section-index {
  border: 1px solid rgba(166, 124, 82, 0.30);
  background: rgba(16, 37, 30, 0.20);
  padding: 12px 12px 10px;
}

.matrix-section-index-file {
  font-family: "JetBrains Mono", sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass, #a67c52);
  margin: 0 0 6px;
}

.matrix-section-index-status {
  font-family: "Newsreader", Georgia, serif;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ivory, #ece4d2);
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(166, 124, 82, 0.25);
}

.matrix-section-index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.matrix-section-index-row {
  margin: 0;
  padding: 0;
}

.matrix-section-index-item {
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  padding: 8px 10px 8px 12px;
  text-align: left;
  font-family: "Newsreader", Georgia, serif;
  font-size: 14px;
  color: var(--stone, #b6a98c);
  cursor: pointer;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.matrix-section-index-item:hover {
  color: var(--ivory, #ece4d2);
  background: rgba(16, 37, 30, 0.45);
}

.matrix-section-index-num {
  font-family: "JetBrains Mono", sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--stone-dim, #7a7264);
}

.matrix-section-index-label {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.is-done .matrix-section-index-item { color: var(--ivory, #ece4d2); }
.is-done .matrix-section-index-num { color: var(--brass, #a67c52); }

.is-current .matrix-section-index-item {
  border-left-color: var(--brass-bright, #c79c70);
  color: var(--ivory, #ece4d2);
  background: rgba(16, 37, 30, 0.45);
  font-weight: 500;
}

.is-current .matrix-section-index-num {
  color: var(--brass-bright, #c79c70);
}

/* Mobile / tablet collapse: hide the full list, keep status line. */
@media (max-width: 1079px) {
  .matrix-section-index {
    padding: 10px 14px;
  }
  .matrix-section-index-status {
    margin: 0;
    padding-bottom: 0;
    border-bottom: 0;
  }
  .matrix-section-index-list {
    display: none;
  }
}

/* ---- Step shell ---- */
.matrix-step {
  background: rgba(16, 37, 30, 0.20);
  border: 1px solid rgba(166, 124, 82, 0.35);
  padding: 32px 28px 28px;
  position: relative;
}

.matrix-step::before,
.matrix-step::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--brass-bright, #c79c70);
  pointer-events: none;
}

.matrix-step::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}

.matrix-step::after {
  bottom: -1px;
  right: -1px;
  border-left: 0;
  border-top: 0;
}

.matrix-step-title {
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.15;
  letter-spacing: -0.012em;
  margin: 0 0 24px;
  color: var(--ivory, #ece4d2);
}

.matrix-helper {
  color: var(--stone, #b6a98c);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.matrix-sublabel {
  font-family: "JetBrains Mono", sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass, #a67c52);
  margin: 24px 0 10px;
}

/* ---- Field primitives ---- */
.matrix-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.matrix-label {
  font-family: "JetBrains Mono", sans-serif;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brass, #a67c52);
  margin-bottom: 6px;
}

.matrix-input,
.matrix-range {
  background: rgba(10, 18, 19, 0.60);
  border: 1px solid rgba(166, 124, 82, 0.40);
  color: var(--ivory, #ece4d2);
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 0;
}

.matrix-input:focus,
.matrix-range:focus {
  outline: 2px solid var(--brass-bright, #c79c70);
  outline-offset: 2px;
}

.matrix-range-display {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--brass-bright, #c79c70);
  font-family: "JetBrains Mono", sans-serif;
}

.matrix-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

/* ---- Nav bar ---- */
.matrix-nav {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(166, 124, 82, 0.20);
}

.matrix-nav .matrix-back,
.matrix-nav .matrix-next {
  min-width: 120px;
}

.matrix-nav .matrix-back:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---- Mobile core tweaks ---- */
@media (max-width: 640px) {
  .matrix-shell { padding: 16px 16px 80px; }
  .matrix-step { padding: 24px 18px 22px; }
  .matrix-rail-node { min-width: 80px; padding: 10px 10px; }
  .matrix-rail-label { font-size: 12px; }
}
