/* ==========================================================================
   Component workshop: the sidebar + iframe layout used by the _components
   pages. Uses the site's design tokens (defined in base.css) so it matches
   the rest of the site and follows the visitor's color scheme.
   ========================================================================== */

/* The workshop owns the whole viewport: no site header, footer, or margins. */
.components-body {
  height: 100vh;
  overflow: hidden;
}

.components {
  display: flex;
  height: 100%;
}

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

.components__sidebar {
  flex: 0 0 18rem;
  width: 18rem;
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
}

.components__heading {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}

.components__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.components__link {
  display: block;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-header);
  font-size: 0.9375rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.components__link:hover {
  background-color: var(--color-bg);
  text-decoration: none;
}

.components__link--active {
  background-color: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* --- Canvas (iframe) --------------------------------------------------- */

.components__canvas {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1rem;
}

.components__frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: var(--color-surface);
}

/* The index page shows prose instead of an iframe; let it scroll. */
.components__canvas .components__intro {
  max-width: 46rem;
}

/* --- Frame page (inside the iframe) ----------------------------------- */

/* The frame page renders a bare partial. Give it a little breathing room and
   let it scroll if the partial is tall. */
.components-frame-body {
  margin: 0;
}

.components-frame {
  padding: 1.5rem;
}

.components-frame__fallback {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* On small screens the sidebar stacks above the canvas. */
@media (max-width: 40rem) {
  .components {
    flex-direction: column;
  }

  .components__sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-height: 40vh;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .components__canvas {
    flex: 1 1 auto;
  }
}
