/* ============================================================
   layout.css — app shell, sidebar, stage, slides, footer nav
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 296px 1fr;
  height: 100vh;
  height: 100dvh;
}

/* Overlay for the mobile drawer. Must be out of grid flow at every width,
   otherwise it takes a grid cell and pushes .stage onto a second row. */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

.scrim.is-on {
  opacity: 1;
  pointer-events: auto;
}

/* ---------------- Sidebar ---------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-4);
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  overflow-y: auto;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-2);
}

.brand__mark {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(123, 92, 255, 0.4);
}

.brand__name {
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand__sub {
  font-size: var(--t-xs);
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

/* Progress ring block */
.progress-card {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.ring {
  width: 52px;
  height: 52px;
  flex: none;
}

.ring circle {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
}

.ring__track {
  stroke: var(--line-strong);
}

.ring__bar {
  stroke: url(#ringGrad);
  transition: stroke-dashoffset var(--dur) var(--ease);
}

.progress-card__label {
  font-size: var(--t-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.progress-card__value {
  font-size: var(--t-sm);
  color: var(--ink);
  font-weight: 600;
}

/* Outline nav */
.outline {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.outline__title {
  font-size: var(--t-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  padding: var(--s-3) var(--s-3) var(--s-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 10px var(--s-3);
  border-radius: var(--r-md);
  text-align: left;
  color: var(--ink-2);
  font-size: var(--t-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item[aria-current="true"] {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 640;
  box-shadow: inset 2px 0 0 var(--accent-2);
}

.nav-item__num {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  font-family: var(--mono);
}

.nav-item[aria-current="true"] .nav-item__num {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
}

.nav-item.is-done .nav-item__num {
  background: rgba(52, 199, 89, 0.16);
  border-color: rgba(52, 199, 89, 0.4);
  color: var(--ok);
}

.sidebar__foot {
  display: flex;
  gap: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
}

/* ---------------- Stage ---------------- */

.stage {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  /* Grid items default to min-width:auto, which lets wide children (tables,
     the step nav) push the whole column past the viewport. */
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-6);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar__title {
  font-size: var(--t-sm);
  color: var(--ink-3);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* Specificity has to beat .icon-btn{display:grid} from components.css */
.topbar .menu-btn {
  display: none;
}

/* Slides */

.slides {
  flex: 1;
  min-width: 0;
  padding: var(--s-7) var(--s-6) var(--s-8);
}

.slide {
  display: none;
  max-width: 1080px;
  min-width: 0;
  margin: 0 auto;
  animation: slideIn 380ms var(--ease);
}

.slide.is-active {
  display: block;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.slide__head {
  margin-bottom: var(--s-6);
}

.section-gap {
  margin-top: var(--s-7);
}

/* Generic responsive columns */
.cols {
  display: grid;
  gap: var(--s-4);
}
.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
}

/* ---------------- Footer step nav ---------------- */

.stepnav {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-6);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.dots {
  display: flex;
  gap: 7px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  transition: all var(--dur) var(--ease);
}

.dot[aria-current="true"] {
  width: 26px;
  background: var(--accent-grad);
}

/* ---------------- Responsive ---------------- */

@media (max-width: 1080px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 288px;
    transform: translateX(-101%);
    transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    transform: none;
  }

  .topbar .menu-btn {
    display: grid;
  }

  .slides {
    padding: var(--s-5) var(--s-4) var(--s-7);
  }

  .topbar,
  .stepnav {
    padding-inline: var(--s-4);
  }

  .split,
  .cols-3,
  .cols-4 {
    grid-template-columns: 1fr;
  }

  .cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  :root {
    --t-3xl: 2.1rem;
    --t-2xl: 1.6rem;
    --t-xl: 1.3rem;
  }

  .cols-2,
  .cols-4 {
    grid-template-columns: 1fr;
  }

  .topbar__title {
    display: none;
  }

  /* Ten dots plus two labelled buttons cannot share a phone-width row. */
  .dots {
    display: none;
  }

  .stepnav {
    padding: 10px var(--s-3);
    gap: var(--s-2);
  }

  .stepnav .btn {
    flex: 1;
    padding-inline: var(--s-3);
  }
}

@media print {
  .sidebar,
  .topbar,
  .stepnav,
  .scrim {
    display: none !important;
  }
  .app {
    grid-template-columns: 1fr;
    height: auto;
  }
  body {
    overflow: visible;
    background: #fff;
  }
  .slide {
    display: block !important;
    page-break-after: always;
  }
}
