/*
 * Cedarras shared element styles.
 *
 * Plain class names (no CSS modules) so the same markup patterns work in
 * both HAML views and React components -- see shared-styles/README.md.
 * Depends on tokens.css being loaded first.
 */

/* ---- Reset & base ---- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  background: var(--color-page-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-body);
  /* Sticky footer (Spec0056): the footer's auto top margin pins it to the
   * viewport bottom on short pages. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* React mounts into #root; let its children be the body's flex items. */
#root {
  display: contents;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  line-height: var(--line-height-heading);
  color: var(--color-primary-hover);
  margin: 0 0 var(--space-4);
}

h1 {
  font-size: var(--font-size-3xl);
}
h2 {
  font-size: var(--font-size-2xl);
}
h3 {
  font-size: var(--font-size-xl);
}
h4 {
  font-size: var(--font-size-lg);
}

a {
  color: var(--color-primary);
}

a:hover {
  color: var(--color-primary-hover);
}

:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

/* ---- Layout ---- */

.page {
  /* width: 100% because auto margins in the body's flex column would
   * otherwise shrink the box to its content. */
  width: 100%;
  box-sizing: border-box;
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

/* ---- Site footer (Spec0056) ----
 * One line, centered, muted. Shared by shared/_footer.html.haml and
 * ui/SiteFooter.jsx; pinned to the bottom by the body's flex column. */
.site-footer {
  margin-top: auto;
  padding: var(--space-4);
  text-align: center;
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-text-muted);
}

/* ---- Nav menu ----
 * One shared pattern for all three top nav bars (main admin, sysadmin,
 * student -- Spec0034). Plain class names only, no CSS modules, so the
 * same rules serve React (NavMenu.jsx/AppLayout.jsx) and HAML
 * (_sysadmin_nav.html.haml, _learn_nav.html.haml) alike. A bar that
 * genuinely needs to differ gets a modifier (.nav-menu--sysadmin,
 * .nav-menu--learn) with the reason recorded here, never a parallel
 * block. */

.nav-menu {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

/* The brand block (logo + wordmark, and the student bar's account name)
 * is one link with no visible link rendering -- no underline, no link
 * color change on hover. The only hover feedback is the pointer cursor;
 * :focus-visible still applies so it's reachable by keyboard. */
.nav-menu__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-primary-hover);
  text-decoration: none;
  cursor: pointer;
}

.nav-menu__brand:hover {
  color: var(--color-primary-hover);
}

.nav-menu__brand img {
  height: 1.75rem;
  width: auto;
}

.nav-menu__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-menu__links a {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-default);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}

.nav-menu__links a:hover,
.nav-menu__links a.is-active {
  background: var(--color-primary-tint);
  color: var(--color-primary-hover);
}

/* Groups items within a dense bar (sysadmin today). Not every bar needs
 * one -- the main admin and student bars have too few items to group. */
.nav-menu__divider {
  width: 1px;
  align-self: stretch;
  background: var(--color-border);
}

.nav-menu__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

.nav-menu__email {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* A plain secondary text link in the right-hand cluster -- a "back to X"
 * link, or any other right-side link that isn't the primary email/Log
 * out/account items. Gives every such link a real rule instead of
 * rendering as a default underlined body link. */
.nav-menu__back {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--font-size-sm);
}

.nav-menu__back:hover {
  color: var(--color-primary);
}

/* Sysadmin: a dozen items vs. the other bars' three, so it keeps a
 * tighter link gap and wraps -- a documented variant, not an accident. */
.nav-menu--sysadmin {
  flex-wrap: wrap;
}

.nav-menu--sysadmin .nav-menu__links {
  gap: var(--space-3);
}

/* Student: wraps like sysadmin (Spec0029); no other variance yet -- it
 * has no items of its own in this bar today. */
.nav-menu--learn {
  flex-wrap: wrap;
}

/* ---- Sidebar nav (e.g. Settings) ---- */

.sidebar-nav {
  display: flex;
  align-items: flex-start;
  gap: var(--space-6);
}

.sidebar-nav__sidebar {
  flex: 0 0 12rem;
  display: flex;
  flex-direction: column;
}

.sidebar-nav__group {
  margin-bottom: var(--space-4);
}

.sidebar-nav__group-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sidebar-nav__links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav__links a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-default);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}

.sidebar-nav__links a:hover,
.sidebar-nav__links a.is-active {
  background: var(--color-primary-tint);
  color: var(--color-primary);
}

.sidebar-nav__version {
  margin: var(--space-4) var(--space-3) 0;
}

.sidebar-nav__content {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 48rem) {
  .sidebar-nav {
    flex-direction: column;
  }

  .sidebar-nav__sidebar {
    flex-basis: auto;
    width: 100%;
  }

  .sidebar-nav__links {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-nav__group {
    margin-bottom: var(--space-3);
  }

  .sidebar-nav__version {
    margin: var(--space-3) 0 0;
  }
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-default);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--font-size-base);
  line-height: 1;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn--sm {
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-3);
}

.btn--lg {
  font-size: var(--font-size-lg);
  padding: var(--space-4) var(--space-5);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
}
.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn--secondary {
  background: var(--color-surface);
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--color-secondary-tint);
}

.btn--tertiary {
  background: transparent;
  color: var(--color-primary);
}
.btn--tertiary:hover:not(:disabled) {
  background: var(--color-primary-tint);
}

.btn--destructive {
  background: var(--color-error);
  color: var(--color-text-on-primary);
}
.btn--destructive:hover:not(:disabled) {
  background: #8f1c13;
}

/* ---- Form inputs ---- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.field__label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.field__hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.field__error {
  font-size: var(--font-size-sm);
  color: var(--color-error);
}

.text-input,
.select-input {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-default);
  background: var(--color-surface);
  color: var(--color-text);
}

.text-input:focus,
.select-input:focus {
  border-color: var(--color-primary);
}

.field--error .text-input,
.field--error .select-input {
  border-color: var(--color-error);
}

.checkbox-input,
.radio-input {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-base);
}

/* ---- Tables ---- */

.table-wrap {
  /* Tables are the one thing allowed to scroll instead of shrink -- wrap
     any .table in this at narrow widths so the page itself never gains
     horizontal overflow. */
  overflow-x: auto;
}

.table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
}

.table th,
.table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.table th {
  background: var(--color-surface-sunken);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr.is-selected {
  background: var(--color-primary-tint);
}

/* ---- Badges ---- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.badge--neutral {
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
}
.badge--success {
  background: var(--color-success-tint);
  color: var(--color-success);
}
.badge--warning {
  background: var(--color-warning-tint);
  color: var(--color-warning);
}
.badge--error {
  background: var(--color-error-tint);
  color: var(--color-error);
}
.badge--info {
  background: var(--color-info-tint);
  color: var(--color-info);
}
.badge--accent {
  background: var(--color-accent-tint);
  color: var(--color-accent);
}

/* ---- Banners ---- */

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
}

.banner--info {
  background: var(--color-info-tint);
  color: var(--color-info);
}

.banner--warning {
  background: var(--color-warning-tint);
  color: var(--color-warning);
}

.banner--error {
  background: var(--color-error-tint);
  color: var(--color-error);
}

.banner--warning .btn,
.banner--info .btn,
.banner--error .btn {
  flex-shrink: 0;
}

/* ---- Cards / surfaces ---- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

/* ---- Course grid ---- */

.course-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 64rem) {
  .course-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 40rem) {
  .course-grid {
    grid-template-columns: 1fr;
  }
}

.course-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* A card that is a link (an <a> or router Link) lifts on hover; a static
   card (e.g. a course the student can no longer open) does not. */
a.course-card:hover,
a.course-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.course-card__image-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--color-surface-sunken);
}

.course-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.course-card__badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
}

/* Second corner pill (e.g. an access problem), opposite the first. */
.course-card__badge--right {
  left: auto;
  right: var(--space-3);
}

/* Every card in a grid is the same height (Spec0043 item 2): the body grows
   to fill the card, the description reserves three lines, and the footer is
   pinned to the bottom by margin-top: auto. */
.course-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: var(--space-4);
}

.course-card__title {
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  line-height: 1.3;
  color: var(--color-primary-hover);
  margin: 0 0 var(--space-1);
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Quiet secondary line under the title: the slug (admin card, monospace)
   or the owning account (student card). */
.course-card__slug,
.course-card__account {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin: 0 0 var(--space-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-card__slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.course-card__description {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  min-height: 4.5em;
  margin: 0 0 var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card__meta {
  margin: auto 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
}

/* Student card footer: a percentage with a thin bar, or a grade. */
.course-card__progress {
  margin: auto 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.course-card__progress-bar {
  height: 0.375rem;
  margin-top: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--color-surface-sunken);
  overflow: hidden;
}

.course-card__progress-fill {
  height: 100%;
  background: var(--color-primary);
}

.course-index__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.course-index__header p {
  color: var(--color-text-muted);
  margin: var(--space-1) 0 0;
}

/* Second, smaller line under the sentence naming whose courses these are. */
.course-index__header .course-index__note {
  font-size: var(--font-size-sm);
}

.course-index__empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.course-index__empty p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.course-form__image-preview {
  width: 100%;
  height: auto;
  max-width: 24rem;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-default);
  border: 1px solid var(--color-border);
  display: block;
  margin-bottom: var(--space-3);
}

.course-form__image-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.textarea-input {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-default);
  background: var(--color-surface);
  color: var(--color-text);
  resize: vertical;
}

.textarea-input:focus {
  border-color: var(--color-primary);
}

.field--error .textarea-input {
  border-color: var(--color-error);
}

/* ---- Kit tags (Spec0014) ---- */

.tag-select {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.tag-chip:has(input:checked) {
  background: var(--color-primary-tint);
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

.tag-chip--static {
  cursor: default;
  background: var(--color-primary-tint);
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

.tag-select__new {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tag-select__new .text-input {
  flex: 1;
  max-width: 20rem;
}

/* ---- Kit tags connected list (Spec0015) ---- */

.kit-tag-note {
  margin-top: calc(-1 * var(--space-1));
}

.kit-tag-list {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
  max-width: 28rem;
  overflow: hidden;
}

.kit-tag-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
}

.kit-tag-list__row + .kit-tag-list__row {
  border-top: 1px solid var(--color-border);
}

.kit-tag-list__name {
  font-size: var(--font-size-sm);
}

.kit-tag-list__empty {
  padding: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.kit-tag-list__confirm-text {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.kit-tag-list__confirm-actions {
  display: flex;
  gap: var(--space-2);
}

.kit-tag-add {
  max-width: 28rem;
  margin-top: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-default);
  background: var(--color-surface);
}

.kit-tag-add .text-input {
  width: 100%;
}

.kit-tag-add__results {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  max-height: 12rem;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
}

.kit-tag-add__results:empty {
  display: none;
}

.kit-tag-add__result {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  cursor: pointer;
}

.kit-tag-add__result:hover {
  background: var(--color-primary-tint);
}

.kit-tag-add li:last-child .kit-tag-add__result {
  border-bottom: none;
}

.kit-tag-add__result--create {
  color: var(--color-primary-hover);
  font-weight: 600;
}

.kit-tag-add__empty {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.kit-tag-add__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-2);
}

/* Account custom domains (Spec0025 §8/step 10) -- a plain list of rows,
   same shape as .kit-tag-list, but each row also needs a status badge and
   DNS instructions, so it gets its own block rather than overloading the
   Kit-tag-specific class names. */
.domain-list {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
  overflow: hidden;
}

.domain-list__row {
  padding: var(--space-3);
}

.domain-list__row + .domain-list__row {
  border-top: 1px solid var(--color-border);
}

.domain-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.domain-list__hostname {
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.domain-list__empty {
  padding: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.domain-list__instructions {
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
}

.domain-list__instructions code {
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
  padding: 0 var(--space-1);
}

/* Course content authoring (Spec0041) */
.outline { list-style: none; margin: 0; padding: 0; }
.outline--nested { margin-left: var(--space-5); }
.outline-row { padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border); }
.outline-row__head { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: space-between; align-items: center; }
.outline-row--lesson { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: space-between; align-items: center; }
.outline-row__title { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }
.outline-row__actions { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }
.outline-add { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; margin: var(--space-2) 0 var(--space-5); }
.outline-add .field { margin-bottom: 0; position: relative; }
/* Errors hang below the input so the buttons stay aligned with it. */
.outline-add .field__error { position: absolute; top: 100%; left: 0; white-space: nowrap; }
.outline-add__target { flex-basis: 100%; margin: 0; font-weight: 600; }
.outline-footer { margin-top: var(--space-4); }
.outline-footer__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* Explains why a row reads Hidden when its own flag is on. */
.outline-row__note { color: var(--color-text-muted); font-size: var(--font-size-sm); }

/* Icons (Spec0043 item 12): hand-maintained inline SVGs, no icon library, so
   shared-styles serves Rails and Vite alike. Colour follows the text. */
.icon {
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Lesson type: an icon that reveals its name on hover or focus (and always
   below 48rem, where hover doesn't exist). The name stays in the DOM for
   screen readers either way. */
.outline-type {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.outline-type:not(:hover):not(:focus-within) .outline-type__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 48rem) {
  .outline-type:not(:hover):not(:focus-within) .outline-type__label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }
}

/* Visibility pill: the state indicator IS the control (Spec0043 item 10).
   Lighter than .badge, which stays untouched for its ~40 other users. */
.outline-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-1);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: none;
  font: inherit;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

button.outline-pill {
  cursor: pointer;
  border-color: var(--color-border);
}

button.outline-pill:hover:not(:disabled) {
  background: var(--color-surface-sunken);
}

button.outline-pill:disabled {
  cursor: default;
  opacity: 0.6;
}

button.outline-pill[aria-busy="true"] {
  cursor: progress;
  opacity: 0.6;
}

.outline-icon-btn {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.outline-icon-btn:hover { color: var(--color-text); }

.outline-pill--visible {
  color: var(--color-success);
}

.lesson-editor__fields { border: 0; padding: 0; margin: 0; }
/* Rendered Markdown (Spec0049): lesson bodies on student pages and the
   editor preview. Markdown output carries no classes, so everything is
   scoped by element under .markdown. */
.markdown { padding: var(--space-2) 0; line-height: var(--line-height-body); }
.markdown > :first-child { margin-top: 0; }
.markdown p { margin: 0 0 var(--space-4); }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 {
  font-family: var(--font-heading);
  line-height: 1.25;
  margin: var(--space-6) 0 var(--space-3);
}
.markdown h1 { font-size: var(--font-size-xl); }
.markdown h2 { font-size: var(--font-size-lg); }
.markdown h3 { font-size: var(--font-size-base); }
.markdown h4, .markdown h5, .markdown h6 { font-size: var(--font-size-base); font-weight: 600; }
.markdown strong { font-weight: 600; }
.markdown em { font-style: italic; }
.markdown del { text-decoration: line-through; color: var(--color-text-muted); }
.markdown a { text-decoration: underline; }
.markdown code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface-sunken);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-default);
}
.markdown pre {
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-default);
  padding: var(--space-4);
  margin: 0 0 var(--space-4);
  overflow-x: auto;
}
.markdown pre code { background: none; padding: 0; font-size: var(--font-size-sm); white-space: pre; }
.markdown blockquote {
  margin: 0 0 var(--space-4);
  padding: var(--space-1) var(--space-4);
  border-left: 3px solid var(--color-primary);
  color: var(--color-text-muted);
}
.markdown blockquote > :last-child { margin-bottom: 0; }
.markdown ul, .markdown ol { margin: 0 0 var(--space-4); padding-left: var(--space-6); }
.markdown li { margin-bottom: var(--space-1); }
.markdown li > ul, .markdown li > ol { margin: var(--space-1) 0 0; }
.markdown hr { border: 0; border-top: 1px solid var(--color-border); margin: var(--space-6) 0; }
.markdown img { display: block; max-width: 100%; height: auto; margin: var(--space-4) 0; }
.markdown .table-wrap { margin: 0 0 var(--space-4); }
.markdown table {
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.markdown th, .markdown td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.markdown th[align="center"], .markdown td[align="center"] { text-align: center; }
.markdown th[align="right"], .markdown td[align="right"] { text-align: right; }
.markdown th {
  background: var(--color-surface-sunken);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}
.markdown tr:last-child td { border-bottom: none; }
.resource-items__list { list-style: none; margin: 0; padding: 0; }
.resource-item { padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border); }

/* Lesson resource editor (Spec0052): placement groups of compact rows that
   expand in place. */
.resource-group { margin-top: var(--space-4); }
.resource-group__title { font-size: var(--font-size-base); margin: 0 0 var(--space-2); }
.resource-items__empty {
  margin: 0 0 var(--space-2);
  padding: var(--space-3);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-default);
  color: var(--color-text-muted);
}
.resource-items__list { margin-bottom: var(--space-2); }
.resource-row { border: 1px solid var(--color-border); border-radius: var(--radius-default); background: var(--color-surface); }
.resource-row + .resource-row { margin-top: var(--space-1); }
.resource-row--open { border-color: var(--color-primary); }
.resource-row--error { border-color: var(--color-error); }
.resource-row__line { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-3); }
.resource-row__toggle {
  flex: 1 1 12rem;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  align-items: baseline;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.resource-row__title { font-weight: 600; }
.resource-row__target { color: var(--color-text-muted); font-size: var(--font-size-sm); overflow-wrap: anywhere; }
.resource-row__form { padding: var(--space-3); border-top: 1px solid var(--color-border); background: var(--color-surface-sunken); }

/* Authoring flow design pass (Spec0044): one header and one section pattern
   shared by the course edit, course content and lesson editor pages. Designed
   for wide screens; narrow just stacks. */
.course-header {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.course-header__main { flex: 1; min-width: 0; }
.course-header__course {
  margin: 0;
  min-height: 1.5em;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
}
.course-header__title-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.course-header__title-row h1 { margin: 0; }
.course-header__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.course-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.course-tabs__tab {
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-decoration: none;
}
.course-tabs__tab:hover { background: var(--color-surface-alt, rgba(12, 107, 46, 0.1)); color: var(--color-primary); }
.course-tabs__tab.is-selected,
.course-tabs__tab.is-selected:hover { background: var(--color-primary); color: #fff; }
.course-header__image-slot { display: none; }
.course-header__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-default);
  border: 1px solid var(--color-border);
  opacity: 0;
  transition: opacity 0.2s;
}
.course-header__image.is-loaded { opacity: 1; }
@media (min-width: 64rem) {
  .course-header__image-slot {
    display: block;
    position: relative;
    flex: none;
    width: 12rem;
    aspect-ratio: 16 / 9;
  }
}

.form-sections { display: flex; flex-direction: column; gap: var(--space-5); }
.form-section { padding-bottom: var(--space-4); border-bottom: 1px solid var(--color-border); }
.form-section__title { margin: 0 0 var(--space-3); font-size: var(--font-size-lg); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

/* Markdown editor: a real tab pair. Both panes stay mounted (the inactive one
   hidden) so cursor, selection and scroll survive a switch. */
.md-editor__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-2); }
.md-editor__tabs { display: flex; gap: var(--space-1); }
.md-editor__tab {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-bottom: 0;
  border-radius: var(--radius-default) var(--radius-default) 0 0;
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  font: inherit;
  cursor: pointer;
}
.md-editor__tab[aria-selected="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
}
.md-editor__help { font-size: var(--font-size-sm); }
.md-editor__pane { min-height: 22rem; }
.md-editor__pane[hidden] { display: none; }
.md-editor__preview {
  min-height: 22rem;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: 0 var(--radius-default) var(--radius-default) var(--radius-default);
  background: var(--color-surface);
}
.md-editor__empty { color: var(--color-text-muted); font-style: italic; }

/* Danger zone (Spec0043 item 6): an irreversible action, set apart from the
   form it belongs to and preceded by a plain statement of what it destroys. */
.danger-zone {
  margin-top: var(--space-6);
  padding: var(--space-4);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-default);
  background: var(--color-error-tint);
}

.danger-zone__title {
  margin: 0 0 var(--space-2);
  color: var(--color-error);
  font-size: var(--font-size-lg);
}

.danger-zone p {
  margin: 0 0 var(--space-3);
}

/* Stat tiles (Spec0035): a wrapping row of one number over a caption. */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-3, 0.75rem);
  margin: 1rem 0;
}

.stat-tile {
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 0.5rem;
}

.stat-tile__value {
  font-family: var(--font-heading, inherit);
  font-size: 1.75rem;
  line-height: 1.2;
}

.stat-tile__label {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Quiz question editor (Spec0040) */
.quiz-editor__question { margin-bottom: var(--space-4, 1rem); }
.quiz-editor__head { display: flex; justify-content: space-between; align-items: center; }
.quiz-editor__choices { margin: 0.75rem 0; }
.quiz-editor__choice { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.35rem; }
.quiz-editor__choice .field { flex: 1; margin: 0; }
