/* APOSA TTU portal — mobile-first PWA styles. Theme --brand is set per-app
   (crimson for members, navy for alumni) by app.js at boot. */
:root {
  --brand: #C1272D;
  --brand-ink: #8E1B22;
  --accent: #0E2340;
  --bg: #F5F6F8;
  --card: #ffffff;
  --ink: #14181F;
  --muted: #6B7480;
  --line: #E7EAEF;
  --ok: #1E9E5A;
  --warn: #C87A12;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(16,26,45,.06), 0 8px 30px rgba(16,26,45,.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tab-h: 62px;
  /* APOSA logo palette (sampled from the crest): red "a", indigo globe, flame */
  --c-red: #C1272D;
  --c-indigo: #3A2DB0;
  --c-blue: #2765D9;
  --c-flame: #EE7B2B;
  --c-gold: #F4B23E;
  --c-green: #1E9E5A;
}
html { font-size: 16px; }   /* text-size setting scales this (rem-based) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C1017; --card: #151B24; --ink: #EDF0F4; --muted: #97A1AE;
    --line: #232C38; --shadow: 0 2px 12px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 0.94rem; line-height: 1.45; overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.ico { width: 22px; height: 22px; display: inline-block; vertical-align: middle; }

/* ---------- Splash / centered screens ---------- */
.splash, .screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 28px;
  padding-top: calc(28px + var(--safe-t)); text-align: center; z-index: 20;
  background: var(--bg);
}
.screen { overflow-y: auto; justify-content: flex-start; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brandmark {
  width: 82px; height: 82px; border-radius: 22px; background: #fff;
  display: grid; place-items: center; box-shadow: var(--shadow); overflow: hidden;
}
.brandmark img { width: 74%; height: 74%; object-fit: contain; }

/* ---------- Auth ---------- */
.auth-wrap { width: 100%; max-width: 380px; margin: auto; }
.auth-wrap h1 { font-size: 1.5rem; margin: 18px 0 4px; }
.auth-wrap .sub { color: var(--muted); margin: 0 0 26px; }
.field { text-align: left; margin-bottom: 14px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--muted);
  display: block; margin-bottom: 6px; }
.input {
  width: 100%; padding: 14px 16px; border: 1.5px solid var(--line);
  border-radius: 12px; background: var(--card); color: var(--ink);
  font-size: 1rem; outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--brand); }
.btn {
  width: 100%; padding: 15px; border: none; border-radius: 12px;
  background: var(--brand); color: #fff; font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:disabled { opacity: .55; }
.btn.ghost { background: transparent; color: var(--brand);
  border: 1.5px solid var(--line); }
.btn.subtle { background: color-mix(in srgb, var(--brand) 10%, transparent);
  color: var(--brand); }
.btn.sm { width: auto; padding: 9px 14px; font-size: .85rem; border-radius: 10px; }
.err { color: var(--brand-ink); font-size: .85rem; margin: 4px 2px; min-height: 1em; }
.linkbtn { background: none; border: none; color: var(--brand); font-weight: 600;
  padding: 8px; font-size: .9rem; }

/* OTP boxes */
.otp { display: flex; gap: 8px; justify-content: center; margin: 8px 0 4px; }
.otp input {
  width: 46px; height: 56px; text-align: center; font-size: 1.5rem;
  font-weight: 700; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink); outline: none;
}
.otp input:focus { border-color: var(--brand); }

/* ---------- App shell ---------- */
.app { min-height: 100%; padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
#topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
  gap: 12px; padding: calc(12px + var(--safe-t)) 16px 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-ink));
  color: #fff;
}
#topbar .who { flex: 1; min-width: 0; }
#topbar .who .hi { font-size: .78rem; opacity: .85; }
#topbar .who .nm { font-weight: 700; font-size: 1.05rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
#topbar .av {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,.6); background: #fff;
}
#topbar .iconbtn { color: #fff; }
.iconbtn { background: rgba(255,255,255,.15); border: none; color: inherit;
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  position: relative; }
.badge-dot { position: absolute; top: 7px; right: 8px; width: 9px; height: 9px;
  background: #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--brand); }

#view { padding: 16px; max-width: 640px; margin: 0 auto; }
.view-title { font-size: 1.3rem; font-weight: 800; margin: 2px 0 14px; }
.section-h { font-size: .82rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin: 22px 2px 10px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px; }
.card.tap { cursor: pointer; }
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.card .meta { color: var(--muted); font-size: .82rem; }
.rowline { display: flex; align-items: center; gap: 12px; }
.rowline .grow { flex: 1; min-width: 0; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); }
.stat .n { font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.stat .l { color: var(--muted); font-size: .8rem; }

/* Quick actions */
.qa { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin: 14px 0; }
.qa button { background: var(--card); border: none; border-radius: 14px;
  padding: 12px 6px; box-shadow: var(--shadow); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 600; }
.qa button .ico { color: var(--brand); }

/* Hero (home) */
.hero { background: linear-gradient(150deg, var(--brand), var(--brand-ink));
  color: #fff; border-radius: 20px; padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 6px; }
.hero .code { font-family: ui-monospace, monospace; letter-spacing: .06em;
  background: rgba(255,255,255,.16); padding: 3px 10px; border-radius: 8px;
  font-size: .8rem; display: inline-block; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand); }
.chip.g { background: rgba(30,158,90,.14); color: var(--ok); }
.chip.n { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
/* chips sitting on the coloured hero need light-on-dark contrast */
.hero .chip { background: rgba(255,255,255,.20); color: #fff; }

/* Digital card */
.dcard { border-radius: 20px; padding: 20px; color: #fff;
  background: linear-gradient(140deg, var(--brand), var(--brand-ink));
  box-shadow: var(--shadow); position: relative; overflow: hidden; }
.dcard .av { width: 66px; height: 66px; border-radius: 16px; object-fit: cover;
  border: 2px solid rgba(255,255,255,.5); }
.dcard .nm { font-weight: 800; font-size: 1.15rem; }
.dcard .sub { opacity: .9; font-size: .85rem; }
.dcard .qr { background: #fff; padding: 8px; border-radius: 12px; width: 116px; }
.dcard .qr img { width: 100%; display: block; }
.kv { display: flex; justify-content: space-between; padding: 9px 0;
  border-bottom: 1px solid var(--line); font-size: .92rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; }

/* Directory */
.dir-item { display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line); }
.dir-item .av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.dir-item .nm { font-weight: 600; }
.dir-item .rl { color: var(--muted); font-size: .8rem; }
.searchbar { position: relative; margin-bottom: 12px; }
.searchbar .input { padding-left: 14px; }

/* Chat */
.msg { max-width: 78%; padding: 10px 13px; border-radius: 14px; margin: 6px 0;
  font-size: .92rem; }
.msg.them { background: var(--card); box-shadow: var(--shadow);
  border-bottom-left-radius: 4px; }
.msg.mine { background: var(--brand); color: #fff; margin-left: auto;
  border-bottom-right-radius: 4px; }
.msg .t { font-size: .66rem; opacity: .7; margin-top: 3px; }
.composer { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 0;
  background: var(--bg); }

/* Bottom tab bar */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b); background: var(--card);
  border-top: 1px solid var(--line); display: flex; z-index: 15;
}
#tabbar button { flex: 1; background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: .66rem; font-weight: 600; padding-top: 8px; position: relative; }
#tabbar button.active { color: var(--brand); }
#tabbar button .ico { width: 24px; height: 24px; }
#tabbar .nb { position: absolute; top: 6px; right: 50%; transform: translateX(16px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px;
  background: var(--brand); color: #fff; font-size: .6rem; display: grid;
  place-items: center; }

/* misc */
.list-empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.list-empty .ico { width: 40px; height: 40px; opacity: .4; margin-bottom: 8px; }
.pill-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
.pill { white-space: nowrap; padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font-size: .82rem; font-weight: 600; }
.pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.content-html { font-size: .95rem; line-height: 1.55; }
.content-html img { max-width: 100%; border-radius: 10px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px + var(--safe-b));
  transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: 12px; font-size: .88rem; font-weight: 600;
  z-index: 40; box-shadow: var(--shadow); max-width: 88%; text-align: center; }
.fab-note { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 8px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* developer credit */
.credits { text-align: center; color: var(--muted); font-size: .72rem;
  line-height: 1.6; margin-top: 24px; }
.credits a { color: var(--muted); text-decoration: underline; }

/* auto-shown install banner (floats above the tab bar) */
.installbar { position: fixed; left: 10px; right: 10px;
  bottom: calc(var(--tab-h) + var(--safe-b) + 10px); z-index: 60;
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 6px 24px rgba(16,26,45,.18); animation: slideup .3s ease; }
@keyframes slideup { from { transform: translateY(20px); opacity: 0; } }
.installbar img { width: 38px; height: 38px; border-radius: 10px; }
.installbar .grow { flex: 1; min-width: 0; }
.installbar .grow strong { font-size: .9rem; }
.installbar .mini { font-size: .74rem; color: var(--muted); }
.installbar .x { background: none; border: none; color: var(--muted);
  font-size: 1.5rem; line-height: 1; padding: 2px 6px; }

/* ===== Colourful accents drawn from the APOSA logo palette ===== */
/* Home hero gets a rainbow top ribbon */
.hero { position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: linear-gradient(90deg, var(--c-red), var(--c-flame), var(--c-gold),
    var(--c-green), var(--c-blue), var(--c-indigo)); }
/* Quick-action tiles — each a different logo colour */
.qa button:nth-child(4n+1) { background: color-mix(in srgb, var(--c-red) 12%, var(--card)); }
.qa button:nth-child(4n+1) .ico { color: var(--c-red); }
.qa button:nth-child(4n+2) { background: color-mix(in srgb, var(--c-indigo) 12%, var(--card)); }
.qa button:nth-child(4n+2) .ico { color: var(--c-indigo); }
.qa button:nth-child(4n+3) { background: color-mix(in srgb, var(--c-flame) 14%, var(--card)); }
.qa button:nth-child(4n+3) .ico { color: var(--c-flame); }
.qa button:nth-child(4n+4) { background: color-mix(in srgb, var(--c-blue) 12%, var(--card)); }
.qa button:nth-child(4n+4) .ico { color: var(--c-blue); }
/* Stat numbers alternate colour */
.stats .stat:nth-child(odd) .n { color: var(--c-red); }
.stats .stat:nth-child(even) .n { color: var(--c-indigo); }
.stat .n { color: var(--c-red); }
/* Media filter pills cycle through the palette when active */
.pill-row .pill:nth-child(4n+1).active { background: var(--c-red); border-color: var(--c-red); }
.pill-row .pill:nth-child(4n+2).active { background: var(--c-indigo); border-color: var(--c-indigo); }
.pill-row .pill:nth-child(4n+3).active { background: var(--c-flame); border-color: var(--c-flame); }
.pill-row .pill:nth-child(4n+4).active { background: var(--c-green); border-color: var(--c-green); }
/* Alumnus chip in indigo, section headers get a colour tick */
.chip.n { background: color-mix(in srgb, var(--c-indigo) 14%, transparent); color: var(--c-indigo); }
.section-h { display: flex; align-items: center; gap: 8px; }
.section-h::before { content: ""; width: 14px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--c-red), var(--c-flame)); }

/* ===== Text-size segmented control (More menu) ===== */
.seg { display: flex; gap: 6px; background: color-mix(in srgb, var(--muted) 12%, transparent);
  padding: 4px; border-radius: 12px; margin-top: 6px; }
.seg button { flex: 1; border: none; background: transparent; color: var(--ink);
  padding: 9px 6px; border-radius: 9px; font-weight: 600; font-size: .85rem; }
.seg button.active { background: var(--brand); color: #fff; }
.back-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.back-h button { background: none; border: none; color: var(--ink);
  display: grid; place-items: center; padding: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label.tgl { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
