/* Grant Parish Schools — prototype styles
   Accessible by construction: real text, 4.5:1 contrast, visible focus,
   keyboard operable, honours reduced-motion and dark mode.
   No frameworks, no build step. */

/* Brand tokens (palette, type, surfaces) live in brand.css. */

* { box-sizing: border-box; }

/* Author display rules otherwise beat the UA rule for [hidden]. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* District site uses DM Sans for headings, Source Sans 3 for body. */
h1, h2, h3, h4,
.brand-name, .card-h, .item-title, .view-h, .greeting, .section-h,
.btn, .tab, .pill, .alert-title {
  font-family: var(--font-head);
}

@media (min-width: 560px) {
  body { background: var(--surface-2); }
  .app {
    max-width: 520px;
    margin: 0 auto;
    background: var(--bg);
    min-height: 100dvh;
    box-shadow: 0 0 0 1px var(--line);
  }
}

h1, h2, h3, p { margin: 0; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

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

.skip-link {
  position: absolute;
  left: 8px; top: -60px;
  z-index: 100;
  background: var(--brand);
  color: var(--on-brand);
  padding: 10px 16px;
  border-radius: 0 0 10px 10px;
  text-decoration: none;
  font-weight: 600;
  transition: top .15s;
}
.skip-link:focus { top: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Top bar ─────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--brand);
  color: var(--on-brand);
  padding-top: max(10px, env(safe-area-inset-top));
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.brand-logo {
  height: 24px;
  width: auto;
  max-width: 100%;
  display: block;
}

.brand-sub { font-size: .72rem; color: #c5d5e4; letter-spacing: .01em; }

.pill {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 999px;
  background: rgb(255 255 255 / 10%);
  color: var(--on-brand);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.pill:hover { background: rgb(255 255 255 / 18%); }
.pill .chev { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* ── Banner ──────────────────────────────────────────── */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
}
.alert-body { min-width: 0; }
.alert-title { font-weight: 700; font-size: .92rem; color: var(--accent); }
.alert-text { font-size: .88rem; color: var(--ink); }
.alert-time { font-size: .76rem; color: var(--ink-3); margin-top: 2px; }

/* ── Views ───────────────────────────────────────────── */

main {
  padding: 0 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom));
  outline: none;
}

.view-h {
  font-size: 1.55rem;
  font-weight: 750;
  letter-spacing: -.02em;
  margin: 20px 0 2px;
}

/* Headings take focus on navigation for screen readers; no visual ring needed. */
main h1:focus { outline: none; }

.view-sub { color: var(--ink-2); font-size: .88rem; margin-bottom: 14px; }

.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.greeting {
  font-size: 1.5rem;
  font-weight: 750;
  letter-spacing: -.02em;
  margin: 18px 0 16px;
}

.section-h {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 26px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }

.spacer { height: 28px; }

/* ── Cards ───────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stack > .card, .stack-sm > .card { margin: 0; }

.card-h { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.card-p { font-size: .9rem; color: var(--ink-2); }
.fine { font-size: .78rem; color: var(--ink-3); margin-top: 8px; }

/* ── List items ──────────────────────────────────────── */

.item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .12s, transform .12s;
}
a.item { text-decoration: none; }
.item:hover { border-color: #c3ccd4; }
.item:active { transform: scale(.995); }

.item-main { min-width: 0; flex: 1; display: block; }
.item-title { display: block; font-weight: 650; font-size: .95rem; line-height: 1.35; }
.item-sub { display: block; font-size: .82rem; color: var(--ink-2); margin-top: 3px; }
.item-meta { font-size: .75rem; color: var(--ink-3); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }

.date-chip {
  flex: none;
  width: 48px;
  text-align: center;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 5px 0;
}
.date-chip .m { display: block; font-size: .66rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--danger); }
.date-chip .d { display: block; font-size: 1.12rem; font-weight: 750; line-height: 1.1; }

.avatar {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .8rem;
  font-weight: 700;
  background: var(--brand);
  color: var(--on-brand);
}

.unread-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--focus);
  flex: none;
  margin-top: 6px;
}

.source-badge {
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 28%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
}
.source-badge.offline { color: var(--ink-3); background: var(--surface-2); border-color: var(--line); }

.muted { color: var(--ink-3); font-size: .9rem; }

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
}
.btn:hover { border-color: #c3ccd4; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-2); }
.btn-quiet {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: .84rem;
  font-weight: 650;
  padding: 8px 6px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn[disabled] { opacity: .55; cursor: default; }

/* ── Messages ────────────────────────────────────────── */

.thread-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
}
.back {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--ink);
  flex: none;
}
.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  max-width: 92%;
}
.bubble.from-me {
  margin-left: auto;
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  border-radius: 14px 4px 14px 14px;
}
.bubble .who { font-size: .76rem; font-weight: 700; opacity: .75; margin-bottom: 4px; }
.bubble .when { font-size: .72rem; opacity: .7; margin-top: 6px; }

.compose textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 8px;
}
.compose label { font-size: .82rem; font-weight: 650; color: var(--ink-2); }
.compose select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-top: 6px;
}
.form-row { margin-top: 12px; }

/* ── Tab bar ─────────────────────────────────────────── */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 520px;
  margin: 0 auto;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}

@media (min-width: 560px) {
  .tabbar { box-shadow: 0 0 0 1px var(--line); }
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--ink-3);
  font: inherit;
  font-size: .68rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
}
.tab svg {
  width: 23px; height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab[aria-current="page"] { color: var(--brand); }
@media (prefers-color-scheme: dark) {
  .tab[aria-current="page"] { color: #8ab8e8; }
}

.dot {
  position: absolute;
  top: 7px;
  right: calc(50% - 15px);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* ── Toast ───────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  z-index: 60;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 16px;
  background: #101820;
  color: #fff;
  border-radius: 12px;
  font-size: .88rem;
  box-shadow: 0 10px 30px rgb(0 0 0 / 30%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast[data-show="true"] { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Dialog ──────────────────────────────────────────── */

.sheet {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgb(0 0 0 / 30%);
}
.sheet::backdrop { background: rgb(8 14 20 / 55%); }
.sheet .btn { width: 100%; margin-top: 16px; }

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.choice[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.choice-name { font-weight: 650; }
.choice-sub { font-size: .8rem; color: var(--ink-2); }

/* ── Motion ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
