/* ==========================================================================
   Mathe mit Bilal – base styles
   Design tokens, reset, typography, layout, buttons, forms,
   header, footer and credit bar. Mobile-first.
   ========================================================================== */

/* --- Font (self-hosted, no external requests) --------------------------- */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* --- Design tokens ------------------------------------------------------- */
:root {
  /* Colors: the only colors used on the site.
     Brand blue was measured from the logo ("BILAL" lettering). */
  --blue: #002cba;
  --navy: #0f1b3d;
  --light-blue: #eaf1ff;
  --tint: #f6f9ff;
  --border: #d5e0f5;
  --gray: #5c6b8a;
  --white: #ffffff;
  --credit-label: #c7d6f5;

  /* Typography */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-small: 14px;
  --fs-xsmall: 13px;
  --fs-body: 16px;
  --lh-body: 26px;

  /* 8px spacing grid */
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 32px;
  --s5: 40px;
  --s6: 48px;
  --s8: 64px;

  /* Shape */
  --radius: 8px;
  --radius-video: 12px;
  --radius-pill: 999px;

  /* Layout */
  --content-max: 1032px;
  --gutter: 16px;
}

@media (min-width: 768px) {
  :root { --gutter: 32px; }
}
@media (min-width: 1024px) {
  :root { --gutter: 48px; }
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--navy);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  /* Sticky footer: on short pages, main grows so footer and credit bar sit at the bottom */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
body > main { flex: 1 0 auto; }

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

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: var(--blue); }
a:hover { color: var(--navy); }

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

/* Visible focus state for keyboard users */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

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

.skip-link {
  position: absolute;
  left: var(--s2);
  top: -100px;
  z-index: 100;
  padding: var(--s1) var(--s2);
  background: var(--blue);
  color: var(--white);
  border-radius: var(--radius);
  font-weight: 600;
}
.skip-link:focus { top: var(--s2); color: var(--white); }

/* --- Typography ---------------------------------------------------------- */
h1 { font-size: 30px; line-height: 38px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 22px; line-height: 30px; font-weight: 700; }
h3 { font-size: 18px; line-height: 26px; font-weight: 700; }

@media (min-width: 768px) {
  h1 { font-size: 36px; line-height: 44px; }
  h2 { font-size: 26px; line-height: 34px; }
}

.text-gray { color: var(--gray); }
.text-small { font-size: var(--fs-small); line-height: 22px; }

/* --- Layout -------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: calc(var(--content-max) + 2 * var(--gutter));
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.section { padding: var(--s5) 0; }
.section--band { background: var(--light-blue); }

@media (min-width: 768px) {
  .section { padding: var(--s6) 0; }
}

.section__title { margin-bottom: var(--s3); }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  padding: 13px 22px;
  border-radius: var(--radius);
  border: 1.5px solid var(--blue);
  font-size: 16px;
  line-height: 20px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}

.btn--primary { background: var(--blue); color: var(--white); }
.btn--primary:hover { background: var(--navy); border-color: var(--navy); color: var(--white); }

.btn--secondary { background: var(--white); color: var(--blue); }
.btn--secondary:hover { background: var(--light-blue); color: var(--blue); }

.btn--block { display: flex; width: 100%; }

/* --- Form fields --------------------------------------------------------- */
.field {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 22px;
}
.field::placeholder { color: var(--gray); }
.field:focus-visible { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }

/* Search field with a magnifier icon on the left */
.search-field { position: relative; }
.search-field .field { padding-left: 40px; }
.search-field__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--gray);
  pointer-events: none;
}

/* Live-search dropdown (filled by main.js) */
.live-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.live-results[hidden] { display: none; }
.live-results a {
  display: block;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--navy);
  text-decoration: none;
  font-size: var(--fs-small);
  line-height: 20px;
}
.live-results li:first-child a { border-top: 0; }
.live-results a:hover,
.live-results a[aria-selected="true"] { background: var(--light-blue); }
.live-results__title { display: block; font-weight: 600; }
.live-results__meta { display: block; color: var(--gray); font-size: var(--fs-xsmall); }
.live-results__all { color: var(--blue) !important; font-weight: 600; }
.live-results__empty { padding: 10px 14px; color: var(--gray); font-size: var(--fs-small); }

/* --- Header -------------------------------------------------------------- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "logo . toggle"
    "search search search";
  align-items: center;
  row-gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.site-header__logo { grid-area: logo; display: block; }
.site-header__logo img { height: 52px; width: auto; }

.nav-toggle {
  grid-area: toggle;
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--navy);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; }

.site-header__search { grid-area: search; }

/* Mobile menu: full-width list with large tap targets */
.site-nav { grid-area: nav; }
.site-nav[hidden] { display: none; }
.site-nav ul { border-top: 1px solid var(--border); }
.site-nav a {
  display: block;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--navy);
  font-size: 17px;
  font-weight: 500;
  text-decoration: none;
}
.site-nav a:hover { color: var(--blue); }
.site-nav a[aria-current="page"] { color: var(--blue); font-weight: 600; }

.site-header__inner.is-open {
  grid-template-areas:
    "logo . toggle"
    "search search search"
    "nav nav nav";
}

@media (min-width: 1024px) {
  .site-header__inner,
  .site-header__inner.is-open {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "logo nav search";
    column-gap: var(--s3);
    padding-top: 14px;
    padding-bottom: 14px;
  }
  .site-header__logo img { height: 60px; }
  .nav-toggle { display: none; }
  .site-nav,
  .site-nav[hidden] { display: block; justify-self: end; }
  .site-nav ul { display: flex; gap: var(--s3); border: 0; }
  .site-nav a { padding: 6px 0; border: 0; font-size: 15px; }
  .site-header__search { width: 200px; }
  .site-header__search .field { padding-top: 8px; padding-bottom: 8px; font-size: 15px; }
  .site-header__search .live-results { width: 320px; left: auto; }
}

/* --- Footer -------------------------------------------------------------- */
.site-footer {
  background: var(--light-blue);
  border-top: 1px solid var(--border);
  font-size: var(--fs-small);
}
.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding-top: var(--s3);
  padding-bottom: var(--s3);
}
.site-footer__links { display: flex; flex-direction: column; gap: 4px; }
.site-footer a { color: var(--navy); text-decoration: none; }
.site-footer a:hover { color: var(--blue); text-decoration: underline; }

@media (min-width: 768px) {
  .site-footer__inner { flex-direction: row; justify-content: space-between; align-items: center; }
  .site-footer__links { flex-direction: row; gap: var(--s3); }
}

/* --- Credit bar (every public page, never in admin) ----------------------- */
.credit-bar {
  padding: 14px 20px;
  background: var(--navy);
  color: var(--credit-label);
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}
.credit-bar strong { color: var(--white); font-weight: 600; }
.credit-bar a { color: var(--white); text-decoration: underline; }
.credit-bar a:hover { color: var(--credit-label); }
.credit-bar a:focus-visible { outline-color: var(--white); }

/* --- Cards, forms, alerts (shared by public pages and admin) -------------- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s3);
}
@media (max-width: 599px) {
  .card { padding: var(--s2); }
}

.form-row { margin: 0 0 var(--s2); padding: 0; border: 0; min-width: 0; }
.form-row > label,
.form-row > legend,
.form-row > .label {
  display: block;
  margin-bottom: 6px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
}
.form-row > label .text-gray,
.form-row > legend .text-gray,
.form-row > .label .text-gray { font-weight: 400; }
textarea.field { resize: vertical; min-height: 120px; }
select.field { appearance: auto; }
.field[aria-invalid="true"] { border: 2px solid var(--navy); }

.form-help { margin-top: 6px; color: var(--gray); font-size: var(--fs-small); line-height: 20px; }
.field-error,
.form-error {
  margin-top: 6px;
  color: var(--navy);
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 20px;
}
.form-error { margin: 0 0 var(--s2); padding: 12px var(--s2); border: 2px solid var(--navy); border-radius: var(--radius); }

.alert {
  margin-bottom: var(--s3);
  padding: 12px var(--s2);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 22px;
}
.alert ul { margin-top: 4px; padding-left: 20px; list-style: disc; }
.alert--success { background: var(--light-blue); border: 1px solid var(--border); color: var(--navy); }
.alert--error { background: var(--white); border: 2px solid var(--navy); color: var(--navy); font-weight: 500; }

.btn--small { padding: 8px 14px; font-size: 14px; line-height: 18px; }

/* Chips (tags, filters) – fully rounded */
.chip {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--navy);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
}
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip--active,
.chip--active:hover { background: var(--blue); border-color: var(--blue); color: var(--white); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  margin-top: var(--s3);
  font-size: var(--fs-small);
}
