/* ==========================================================================
   LLA Design System — Base / Reset
   ========================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-body);
  background: var(--surface-page);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 4px;
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.25;
}

h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

p { margin: 0 0 8px; }

button { font-family: inherit; }

ul { margin: 0; padding: 0; list-style: none; }

.u-flex { display: flex; }
.u-flex-col { flex-direction: column; }
.u-flex-wrap { flex-wrap: wrap; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-xs { gap: 6px; }
.u-gap-sm { gap: 10px; }
.u-gap-md { gap: 16px; }
.u-gap-lg { gap: 24px; }
.u-mt-0 { margin-top: 0; }
.u-mb-0 { margin-bottom: 0; }
.u-text-muted { color: var(--text-muted); }
.u-text-sm { font-size: 12.5px; }
.u-w-full { width: 100%; }

/* A utility must beat the element's own display rule, otherwise anything with
   `display: flex` of its own (the session switcher, icon buttons) stays
   visible on phones and pushes the topbar off screen. Above the breakpoint
   the element keeps whatever display it declared for itself. */
@media (max-width: 767px) {
  .u-hide-mobile { display: none !important; }
}

/* Simple responsive grid for dashboard widgets */
.grid { display: grid; gap: 20px; }
.grid-cols-1 { grid-template-columns: 1fr; }

/* auto-fit so however many stat cards a page has, they always spread to fill the row
   rather than leaving a gap when the count doesn't divide evenly into a fixed column count */
@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* The fixed 280px sidebar appears at 1024px, leaving only ~744px of content,
   which is too narrow for these side-by-side layouts. They split at 1200px
   instead, once there is real room for two columns. */
@media (min-width: 1200px) {
  .widget-grid-3 { grid-template-columns: 2fr 1.3fr 1.3fr; align-items: start; }
  .widget-grid-2 { grid-template-columns: 1fr 1fr; align-items: start; }
  .widget-grid-2-wide { grid-template-columns: 2fr 1fr; align-items: start; }
}

/* These three carry their own display and gap. They only ever set
   grid-template-columns inside media queries, so used on their own they were
   a plain block — and below 640px they were a plain block everywhere. Every
   existing use pairs them with .grid, which set the same two properties, so
   nothing that already worked changes. */
.grid-fields-2,
.grid-fields-3,
.grid-fields-4 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 18px;
}

/* Responsive form-field row: 1 col mobile, 2 col tablet, 4 col desktop.
   Use instead of an inline grid-template-columns, which would ignore breakpoints entirely. */
@media (min-width: 640px) {
  .grid-fields-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .grid-fields-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Two-field row: stacks on phones, side by side from tablet up. */
@media (min-width: 640px) {
  .grid-fields-2 { grid-template-columns: repeat(2, 1fr); }
}

/* Three-field row: one column on phones, two from tablet, three on a laptop.
   Long forms — an admission application, a pupil record — read as a grid of
   short fields rather than a column of full-width boxes. */
@media (min-width: 640px) {
  .grid-fields-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid-fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Two-up tile grid (quick actions, small icon buttons): stacks on very small phones only. */
@media (min-width: 420px) {
  .grid-2up { grid-template-columns: repeat(2, 1fr); }
}

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
}

/* The browser's own [hidden] rule is only `display: none` at user-agent
   weight, so any component that sets its own display (.btn is inline-flex)
   silently ignores it. This makes the attribute mean what it says. */
[hidden] { display: none !important; }
