/* Adaptive layout foundation
   Goal: replace one-off zoom guidance with reusable, screen-aware layout primitives.
   Keep this file conservative: it should tune density and available space without
   changing page responsibilities or component behavior. */

:root {
  --adaptive-page-gutter: clamp(16px, 2vw, 40px);
  --adaptive-shell-gap: clamp(14px, 1.35vw, 22px);
  --adaptive-card-padding: clamp(20px, 1.45vw, 28px);
  --adaptive-content-max: 1680px;
  --adaptive-readable-max: 78ch;
  --adaptive-dense-scale: 1;
}

.shell-header,
main.app-main {
  width: min(calc(100% - (var(--adaptive-page-gutter) * 2)), var(--adaptive-content-max));
}

main.app-main {
  gap: var(--adaptive-shell-gap);
}

.stack {
  gap: var(--adaptive-shell-gap);
  container-type: inline-size;
}

.card {
  padding: var(--adaptive-card-padding);
}

.section-header,
.inline-actions,
.filter-chip-row,
.button-row {
  row-gap: clamp(8px, 1vw, 14px);
}

/* Wide and shallow screens need density, not a user-visible zoom warning. */
@media (min-width: 1180px) and (max-height: 820px) {
  :root {
    --adaptive-page-gutter: clamp(12px, 1.45vw, 26px);
    --adaptive-shell-gap: clamp(12px, 1vw, 16px);
    --adaptive-card-padding: clamp(18px, 1.1vw, 22px);
    --adaptive-content-max: 1880px;
    --sticky-shell-offset: 104px;
  }

  html {
    font-size: 14px;
  }

  .shell-header {
    margin-top: 10px;
    padding-block: 14px;
  }

  main.app-main {
    margin-top: 12px;
  }

  .page-section {
    min-height: calc(100vh - 162px);
  }

  .auth-viewport-tip {
    display: none;
  }
}

/* Very wide screens should use width for structure instead of only enlarging whitespace. */
@media (min-width: 1720px) and (min-height: 860px) {
  :root {
    --adaptive-content-max: 1840px;
    --adaptive-page-gutter: clamp(28px, 2.4vw, 54px);
  }
}

/* Narrow app containers collapse reusable columns based on available space. */
@container (max-width: 760px) {
  .two-col,
  .three-col {
    grid-template-columns: 1fr;
  }

  .section-header {
    align-items: stretch;
  }
}

@container (min-width: 980px) {
  .three-col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Component authors can opt into adaptive grids without new JS. */
.adaptive-grid {
  display: grid;
  gap: var(--adaptive-shell-gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.adaptive-readable {
  max-width: var(--adaptive-readable-max);
}

/* Student page shell and sidebar baseline. */
:root {
  --student-content-max: var(--adaptive-content-max);
  --student-sidebar-compact-width: 240px;
}

body[data-role="student"] .shell-header,
body[data-role="student"] main.app-main {
  max-width: var(--student-content-max);
}

body[data-role="student"] main.app-main {
  grid-template-columns: minmax(232px, var(--sidebar-width)) minmax(0, 1fr);
}

@media (min-width: 981px) and (max-width: 1320px) {
  body[data-role="student"] main.app-main {
    grid-template-columns: minmax(216px, var(--student-sidebar-compact-width)) minmax(0, 1fr);
  }

  body[data-role="student"] .sidebar {
    padding-inline: 16px;
  }
}

@media (min-width: 981px) {
  body[data-role="student"] .mobile-sidebar-scrim {
    display: none !important;
  }
}
