/* ==========================================================================
   EdSy public site — mobile-first.
   Base styles target small screens; @media (min-width:…) layers on tablet and
   desktop. Nothing should scroll horizontally at 360px.
   ========================================================================== */

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

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

body {
  margin: 0;
  font-family: var(--edsy-font);
  /* Fluid body copy: 15px on a phone, up to 17px on a wide screen. */
  font-size: clamp(0.9375rem, 0.9rem + 0.2vw, 1.0625rem);
  line-height: 1.6;
  color: var(--edsy-text);
  background: var(--edsy-bg);
  overflow-x: hidden;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a { color: var(--edsy-primary); text-decoration: none; }
a:hover, a:focus-visible { color: var(--edsy-primary-light); text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 1.3rem + 2.2vw, 3rem); }
h2 { font-size: clamp(1.375rem, 1.1rem + 1.4vw, 2.125rem); }
h3 { font-size: clamp(1.125rem, 1rem + 0.7vw, 1.5rem); }
p  { margin: 0 0 1rem; }

:focus-visible {
  outline: 2px solid var(--edsy-primary-light);
  outline-offset: 2px;
}

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

.container {
  width: 100%;
  max-width: var(--edsy-container);
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 768px) {
  .container { padding-inline: 2rem; }
}

.section { padding-block: clamp(2.5rem, 1.5rem + 4vw, 5rem); }

/* Auto-fitting grid: 1 column on a phone, as many as fit thereafter.
   No breakpoint needed — minmax() does the work. */
.grid {
  display: grid;
  gap: var(--edsy-gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

/* ---------- Header / navigation ------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--edsy-surface);
  border-bottom: 1px solid var(--edsy-border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--edsy-text);
}
.nav__brand:hover { text-decoration: none; }
.nav__brand img {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.nav__brand-text {
  font-family: var(--edsy-heading-font);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--edsy-primary);
  line-height: 1;
}

/* Hamburger — visible only on small screens. */
.nav__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--edsy-tap);
  height: var(--edsy-tap);
  padding: 0;
  background: transparent;
  border: 1px solid var(--edsy-border);
  border-radius: var(--edsy-radius-sm);
  color: var(--edsy-primary);
  cursor: pointer;
}
.nav__toggle:hover { background: var(--edsy-elevated); }
.nav__toggle-bar,
.nav__toggle-bar::before,
.nav__toggle-bar::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  content: '';
  position: relative;
}
.nav__toggle-bar::before { position: absolute; top: -6px; }
.nav__toggle-bar::after  { position: absolute; top: 6px; }

/* Menu: stacked drawer under the header on mobile. */
.nav__menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem 1rem;
  background: var(--edsy-surface);
  border-bottom: 1px solid var(--edsy-border);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}
.nav__menu.is-open { display: flex; }

.nav__link {
  display: flex;
  align-items: center;
  min-height: var(--edsy-tap);
  padding: 0.5rem 0.75rem;
  border-radius: var(--edsy-radius-sm);
  color: var(--edsy-text-secondary);
  font-weight: 600;
}
.nav__link:hover,
.nav__link:focus-visible {
  background: var(--edsy-elevated);
  color: var(--edsy-primary);
  text-decoration: none;
}
.nav__link.is-active { color: var(--edsy-primary); }

@media (min-width: 900px) {
  .nav__toggle { display: none; }
  .nav__menu {
    display: flex;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .nav__menu .btn { margin-left: 0.5rem; }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--edsy-control-h);
  padding: 0.5rem 1.25rem;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  border: 1px solid transparent;
  border-radius: var(--edsy-radius);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover, .btn:focus-visible { text-decoration: none; }

.btn--primary {
  background: var(--edsy-primary);
  color: var(--edsy-on-primary);
}
.btn--primary:hover, .btn--primary:focus-visible {
  background: var(--edsy-primary-light);
  color: var(--edsy-on-primary);
}

.btn--ghost {
  background: var(--edsy-surface);
  color: var(--edsy-primary);
  border-color: var(--edsy-primary);
}
.btn--ghost:hover, .btn--ghost:focus-visible {
  background: var(--edsy-elevated);
  color: var(--edsy-primary-light);
}

.btn--lg { min-height: var(--edsy-control-h-lg); padding-inline: 1.75rem; }

/* Full-width buttons on the narrowest screens read better than centred pills. */
@media (max-width: 479px) {
  .btn--block-xs { width: 100%; }
}

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

.card {
  background: var(--edsy-surface);
  border: 1px solid var(--edsy-border);
  border-radius: var(--edsy-radius-lg);
  padding: clamp(1rem, 0.8rem + 0.8vw, 1.75rem);
}
.card__title { color: var(--edsy-primary); margin-bottom: 0.35rem; }
.card__meta { color: var(--edsy-text-muted); font-size: 0.875rem; }

/* ---------- Hero --------------------------------------------------------- */

.hero {
  background:
    radial-gradient(1000px 400px at 80% -10%, rgba(165, 201, 60, 0.16), transparent 60%),
    var(--edsy-bg);
  border-bottom: 1px solid var(--edsy-border-light);
}
.hero__inner { padding-block: clamp(2.5rem, 1.5rem + 6vw, 6rem); max-width: 46rem; }
.hero__eyebrow {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--edsy-accent);
  background: rgba(241, 229, 160, 0.1);
  border: 1px solid rgba(241, 229, 160, 0.25);
  border-radius: 999px;
}
.hero__lead { color: var(--edsy-text-secondary); font-size: 1.0625rem; }
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ---------- Forms -------------------------------------------------------- */

.field { margin-bottom: 1.125rem; }
.field > label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 600;
  color: var(--edsy-text-secondary);
}

.input,
input[type='text'], input[type='email'], input[type='tel'], input[type='password'],
input[type='number'], input[type='date'], input[type='url'], select, textarea {
  width: 100%;
  min-height: var(--edsy-control-h);
  padding: 0.5rem 0.75rem;
  /* 16px prevents iOS Safari zooming the page when a field is focused. */
  font-family: inherit;
  font-size: 16px;
  color: var(--edsy-text);
  background: var(--edsy-bg);
  border: 1px solid var(--edsy-primary);
  border-radius: var(--edsy-radius);
}
textarea { min-height: 7rem; resize: vertical; }
::placeholder { color: var(--edsy-text-muted); }

/* Checkboxes and radios must not inherit the full-width text-input sizing. */
input[type='checkbox'], input[type='radio'] {
  width: auto;
  min-height: 0;
  margin-right: 0.4rem;
  accent-color: var(--edsy-primary);
}
input[type='file'] {
  width: 100%;
  padding: 0.5rem;
  color: var(--edsy-text-secondary);
  background: var(--edsy-bg);
  border: 1px dashed var(--edsy-primary);
  border-radius: var(--edsy-radius);
}
input[type='file']::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-weight: 700;
  color: var(--edsy-on-primary);
  background: var(--edsy-primary);
  border: 0;
  border-radius: var(--edsy-radius-sm);
  cursor: pointer;
}

/* Auth / form pages share this narrow centred card. */
.form-card {
  width: 100%;
  max-width: 34rem;
  margin-inline: auto;
  background: var(--edsy-surface);
  border: 1px solid var(--edsy-border);
  border-radius: var(--edsy-radius-lg);
  padding: clamp(1.25rem, 1rem + 1.5vw, 2rem);
}
.form-card--wide { max-width: 60rem; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
@media (max-width: 479px) {
  .form-actions .btn { width: 100%; }
}

.status-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-pill--draft { background: rgba(154,163,158,.18); color: var(--edsy-text-muted); }
.status-pill--submitted { background: rgba(245,158,11,.18); color: var(--edsy-warning); }
.status-pill--correction { background: rgba(94,200,242,.18); color: var(--edsy-info); }
.status-pill--approved { background: rgba(16,185,129,.18); color: var(--edsy-success); }
.status-pill--rejected { background: rgba(220,38,38,.2); color: var(--edsy-error); }

/* Formset rows stack on mobile and become a grid on wider screens. */
.formset-row {
  display: grid;
  gap: 0.5rem 1rem;
  grid-template-columns: 1fr;
  padding: 1rem 0;
  border-bottom: 1px solid var(--edsy-border-light);
}
@media (min-width: 760px) {
  .formset-row { grid-template-columns: repeat(5, 1fr); align-items: end; }
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--edsy-primary-light);
  box-shadow: 0 0 0 3px rgba(165, 201, 60, 0.2);
}

.help { font-size: 0.8125rem; color: var(--edsy-text-muted); margin-top: 0.25rem; }
.errorlist {
  margin: 0.375rem 0 0;
  padding-left: 1.1rem;
  color: var(--edsy-error);
  font-size: 0.875rem;
}

/* Two-up form rows on tablet and wider, single column on phones. */
.form-grid {
  display: grid;
  gap: 0 var(--edsy-gap);
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .field--wide { grid-column: 1 / -1; }
}

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

/* Wide tables scroll inside their own box rather than pushing the page out. */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--edsy-border);
  border-radius: var(--edsy-radius);
}
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--edsy-border-light); }
th { background: var(--edsy-bg); color: var(--edsy-primary); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: rgba(165, 201, 60, 0.06); }

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

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  background: var(--edsy-primary);
  color: var(--edsy-on-primary);
}
.badge--muted { background: var(--edsy-elevated); color: var(--edsy-text-secondary); }

/* ---------- Messages ----------------------------------------------------- */

.messages { list-style: none; margin: 1rem 0 0; padding: 0; }
.messages li {
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: var(--edsy-radius);
  border-left: 4px solid var(--edsy-info);
  background: var(--edsy-surface);
}
.messages .success { border-left-color: var(--edsy-success); }
.messages .warning { border-left-color: var(--edsy-warning); }
.messages .error   { border-left-color: var(--edsy-error); }

/* ---------- Footer ------------------------------------------------------- */

.site-footer {
  margin-top: auto;
  padding: 3rem 0 1.5rem;
  background: #1A3B2F;
  border-top: 1px solid var(--edsy-border);
  color: var(--edsy-text-muted);
  font-size: 0.875rem;
}
.site-footer a { color: var(--edsy-text-muted); }
.site-footer a:hover { color: var(--edsy-primary); text-decoration: none; }

.site-footer__cols {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .site-footer__cols { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1000px) {
  .site-footer__cols { grid-template-columns: 1.5fr 1fr 1fr 1.2fr; }
}

.site-footer h4 {
  color: var(--edsy-text-secondary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 0.6rem; }

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.footer-brand img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  padding: 2px;
}
.footer-brand span {
  font-family: var(--edsy-heading-font);
  font-size: 1.375rem;
  font-weight: 900;
  color: var(--edsy-primary);
}

.footer-badge {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--edsy-text-secondary);
  background: rgba(165, 201, 60, 0.1);
  border: 1px solid var(--edsy-border);
  border-radius: var(--edsy-radius-sm);
}

.footer-contact li { display: flex; align-items: flex-start; gap: 0.6rem; }
.footer-contact svg { width: 16px; height: 16px; color: var(--edsy-primary); flex: none; margin-top: 3px; }
.footer-contact strong { display: block; color: var(--edsy-text-secondary); font-weight: 600; }
.footer-contact small { color: var(--edsy-text-subtle); font-size: 0.6875rem; }

.site-footer__bottom {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--edsy-border-light);
  font-size: 0.8125rem;
  text-align: center;
}
.site-footer__bottom nav { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }
.version-tag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--edsy-primary);
  background: rgba(165, 201, 60, 0.12);
  border: 1px solid var(--edsy-border);
  border-radius: 999px;
}
@media (min-width: 700px) {
  .site-footer__bottom { flex-direction: row; text-align: left; }
}

/* ---------- Page scaffold ------------------------------------------------ */

.page { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
main { flex: 1 0 auto; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.75rem 1rem;
  background: var(--edsy-primary);
  color: var(--edsy-on-primary);
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
