/* ==========================================================================
   MMBC Attendance - Reset, element defaults and utilities
   ========================================================================== */

/* --- Reset ---------------------------------------------------------------- */

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

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

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, ul, ol {
  margin: 0;
}

ul[class],
ol[class] {
  list-style: none;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* --- Motion preference ----------------------------------------------------
   A single global override. Individual components never need to re-check.   */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Typography ------------------------------------------------------------ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }
h5, h6 { font-size: var(--text-md); }

a {
  color: var(--text-link);
  text-decoration: none;
  border-radius: var(--radius-xs);
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--mmbc-800);
  text-decoration: underline;
  text-underline-offset: 2px;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.1em 0.4em;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.5;
  text-align: center;
  color: var(--text-secondary);
  background: var(--gray-50);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
}

/* --- Focus -----------------------------------------------------------------
   Visible focus is never removed. :focus-visible keeps it off mouse clicks
   while guaranteeing it for keyboard users.                                  */

:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-sm);
}

/* --- Selection ------------------------------------------------------------- */

::selection {
  background: var(--mmbc-200);
  color: var(--mmbc-950);
}

/* --- Scrollbars ------------------------------------------------------------ */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: var(--gray-300);
  border: 3px solid transparent;
  border-radius: var(--radius-full);
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--gray-400);
}

/* --- Icons -----------------------------------------------------------------
   All icons come from an inline SVG sprite. They inherit currentColor so a
   component's text colour drives its icon colour automatically.              */

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

.icon--sm { width: 1em; height: 1em; }
.icon--lg { width: 1.5em; height: 1.5em; }
.icon--xl { width: 2rem; height: 2rem; }

/* --- Accessibility utilities ----------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link: hidden until focused, then anchored top-left. */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  font-weight: var(--weight-medium);
  color: var(--text-inverse);
  background: var(--mmbc-700);
  border-radius: var(--radius-md);
  transform: translateY(-200%);
  transition: transform var(--duration-fast) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  text-decoration: none;
}

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

.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }

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

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

/*
  Responsive card row.

  `auto-fit` rather than `auto-fill`: auto-fill keeps the empty tracks it
  created, so a panel of two cards on a wide screen sat in the first two of
  four 240px columns and left half the row blank while the forms inside them
  were squeezed. auto-fit collapses the tracks nothing occupies, so the cards
  that exist share the width. With enough cards to fill the row the two behave
  identically.
*/
.grid-auto {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger-700); }
.text-warning { color: var(--warning-700); }
.text-success { color: var(--success-700); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-mono { font-family: var(--font-mono); }
.text-nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.full-width { width: 100%; }
.is-hidden { display: none !important; }

/* Horizontal overflow container: wide tables and diagrams scroll inside
   themselves so the page body never scrolls sideways. */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Print ------------------------------------------------------------------ */

@media print {
  .app-sidebar,
  .app-topbar,
  .toast-region,
  .impersonation-banner,
  .no-print {
    display: none !important;
  }
  .app-main { padding: 0; }
  body { background: #fff; }
}
