
/*
 * SimpleAIHub - Layout Polish / Small UI Fixes
 * Loaded after accessibility typography so readability and layout rules are consistent.
 *
 * Goals:
 *  - Keep code toolbar controls from overlapping.
 *  - Keep practice-card action/hint content from colliding with the description.
 *  - Give recap items clear spacing.
 *  - Keep lesson previous/next navigation as separate, readable controls.
 *  - Prevent horizontal overflow without shrinking text.
 */

/* ---------- Code blocks ---------- */
.sah-page-shell .sah-code-header,
.sah-page-shell .sah-codebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.sah-page-shell .sah-code-actions,
.sah-page-shell .sah-codebar > div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
  flex: 0 0 auto;
}

.sah-page-shell .sah-code-header > .sah-code-language,
.sah-page-shell .sah-codebar .sah-codebar__language {
  flex: 0 1 auto;
  min-width: 0;
}

.sah-page-shell .sah-code-actions button,
.sah-page-shell .sah-code-actions a,
.sah-page-shell .sah-codebar button,
.sah-page-shell .sah-codebar a {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: max-content;
  max-width: none !important;
}

.sah-page-shell .sah-code-block pre {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Practice cards ---------- */
.sah-page-shell .sah-practice-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.sah-page-shell .sah-practice-card > * {
  min-width: 0;
}

.sah-page-shell .sah-practice-card__hint {
  white-space: nowrap;
  align-self: center;
  justify-self: end;
}

.sah-page-shell .sah-practice-card > a {
  justify-self: end;
  white-space: nowrap;
  max-width: none !important;
}

/* ---------- Recap grids ---------- */
.sah-page-shell [class*="recap-grid"] {
  display: grid;
  gap: 10px;
}

.sah-page-shell [class*="recap-grid"] > div {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.sah-page-shell [class*="recap-grid"] > div b,
.sah-page-shell [class*="recap-grid"] > div span {
  display: block;
}

.sah-page-shell [class*="recap-grid"] > div b {
  margin-bottom: 6px;
}

/* Lesson 30 currently has six recap items. */
.sah-page-shell .lesson30-recap-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ---------- Lesson navigation ---------- */
.sah-page-shell [class*="bottom-nav"],
.sah-page-shell [class*="lesson-navigation"] {
  min-width: 0;
  gap: 12px;
}

.sah-page-shell [class*="bottom-nav"] a,
.sah-page-shell [class*="lesson-navigation"] a {
  min-width: 0;
  max-width: 100% !important;
  overflow-wrap: anywhere;
  word-break: normal;
  text-align: center;
  line-height: 1.5;
}

.sah-page-shell .lesson30-navigation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid #e7eaf0;
}

.sah-page-shell .lesson30-navigation a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 14px;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  background: #fff;
  color: #344054;
  text-decoration: none;
  font-size: 15px;
}

.sah-page-shell .lesson30-navigation a:hover {
  border-color: #7c3aed;
  color: #5b21b6;
}

/* ---------- Never let utility text cause layout overflow ---------- */
.sah-page-shell :where(
  .sah-practice-card,
  .sah-code-header,
  .sah-codebar,
  .lesson30-navigation
) {
  max-width: 100%;
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .sah-page-shell .sah-code-header,
  .sah-page-shell .sah-codebar {
    align-items: flex-start;
  }

  .sah-page-shell .sah-code-actions,
  .sah-page-shell .sah-codebar > div {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .sah-page-shell .sah-practice-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .sah-page-shell .sah-practice-card__hint,
  .sah-page-shell .sah-practice-card > a {
    justify-self: stretch;
    white-space: normal;
    width: 100%;
    text-align: center;
  }

  .sah-page-shell .lesson30-recap-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sah-page-shell .lesson30-navigation {
    grid-template-columns: minmax(0, 1fr);
  }

  .sah-page-shell .lesson30-navigation a {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .sah-page-shell .lesson30-recap-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .sah-page-shell .sah-code-actions,
  .sah-page-shell .sah-codebar > div {
    gap: 7px;
  }
}
