/* ==========================================================================
   MySchoolOS Entry PWA — shared design tokens
   Brand colors are pulled straight from the tenant login screen
   (tenant_Ci4/app/Views/backend/login.php: --brand-950 #161950,
   --brand-500 #465fff) so the app, the landing page and the tenant portal
   read as one product. Pink is this app's own accent, layered on top for
   the "flow" landing treatment — the offline page deliberately stays
   pink-free and closer to the tenant screen's own navy/blue look.
   No external fonts/CDNs anywhere in this file — every page here (this
   one especially, once cached) has to render correctly with zero network.
   ========================================================================== */

:root {
  --navy-950: #0c0e30;
  --navy-900: #161950;
  --navy-800: #1c2166;
  --blue-500: #465fff;
  --blue-400: #7c93ff;
  --pink-500: #ec4899;
  --pink-400: #f472b6;
  --white-a06: rgba(255, 255, 255, 0.06);
  --white-a10: rgba(255, 255, 255, 0.1);
  --white-a12: rgba(255, 255, 255, 0.12);
  --white-a60: rgba(255, 255, 255, 0.6);
  --text: #f5f6fb;
  --text-muted: #a6acd4;
  --danger: #ff8a80;
  --danger-bg: rgba(255, 90, 90, 0.14);
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow-lg: 0 24px 60px rgba(3, 5, 22, 0.55);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Segoe UI Variable", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  background: var(--navy-950);
  overflow-x: hidden;
}

a { color: inherit; }
button { font-family: inherit; }

/* Decorative dot-grid panel background, inline SVG data-URI — replaces any
   external image asset so it survives fully offline. */
.grid-decor {
  background-image: radial-gradient(circle, rgba(255,255,255,0.14) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* ==========================================================================
   Landing / entry page ("flow" blue + pink theme)
   ========================================================================== */

body.page-entry {
  position: relative;
  display: flex;
  flex-direction: column;
  /* Deliberately NOT align-items:center — with a percentage-width child
     (.wrap, .hero, .topbar all use width:100%) that makes every child's
     cross-axis size shrink-to-fit its content instead of resolving
     against the real viewport, which is what was causing the card/help/
     footer text to compute a wider-than-viewport box and clip at the
     edge instead of wrapping. Default (stretch) gives every child the
     full, correct width; each child centers itself via margin:0 auto
     against its own max-width instead. */
  background: radial-gradient(1000px 700px at 50% -12%, var(--navy-800) 0%, var(--navy-950) 60%);
}

/* Flowing gradient blobs — slow, subtle, GPU-cheap (transform only). */
.flow-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
.flow-blob.b1 {
  width: 480px; height: 480px;
  top: -160px; left: -140px;
  background: radial-gradient(circle at 30% 30%, var(--blue-500), transparent 70%);
  animation: flowDrift1 16s ease-in-out infinite alternate;
}
.flow-blob.b2 {
  width: 420px; height: 420px;
  top: 120px; right: -160px;
  background: radial-gradient(circle at 60% 40%, var(--pink-500), transparent 70%);
  animation: flowDrift2 20s ease-in-out infinite alternate;
}
.flow-blob.b3 {
  width: 360px; height: 360px;
  bottom: -140px; left: 30%;
  background: radial-gradient(circle at 50% 50%, var(--pink-400), transparent 70%);
  opacity: 0.35;
  animation: flowDrift3 24s ease-in-out infinite alternate;
}
@keyframes flowDrift1 { from { transform: translate(0,0) scale(1); } to { transform: translate(40px,50px) scale(1.08); } }
@keyframes flowDrift2 { from { transform: translate(0,0) scale(1); } to { transform: translate(-50px,30px) scale(1.1); } }
@keyframes flowDrift3 { from { transform: translate(0,0) scale(1); } to { transform: translate(30px,-30px) scale(1.05); } }
@media (prefers-reduced-motion: reduce) {
  .flow-blob { animation: none !important; }
}

/* ==========================================================================
   Cold-start splash + first-launch feature intro
   app.js drives the timing/visibility; these rules only handle the look.
   Both overlays paint their own copy of the page background so the blobs
   underneath never need to show through — no flash of unstyled content.
   ========================================================================== */

.splash-screen,
.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: radial-gradient(1000px 700px at 50% -12%, var(--navy-800) 0%, var(--navy-950) 60%);
  transition: opacity 0.4s ease;
}
.intro-screen { z-index: 190; opacity: 0; pointer-events: none; }
.intro-screen.show { opacity: 1; pointer-events: auto; }
.splash-screen.fade-out,
.intro-screen.fade-out { opacity: 0; pointer-events: none; }

.splash-logo {
  height: 42px;
  width: auto;
  animation: splashPop 0.6s cubic-bezier(.175,.885,.32,1.275) both;
}
@keyframes splashPop {
  from { opacity: 0; transform: scale(0.6) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.intro-inner { width: 100%; max-width: 380px; text-align: center; }
.intro-inner h2 { font-size: 1.3rem; font-weight: 800; margin: 0 0 6px; }
.intro-inner .intro-sub { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 26px; }

.intro-features { list-style: none; margin: 0 0 24px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.intro-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.03));
  border: 1px solid var(--white-a12);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: left;
  opacity: 0;
}
.intro-screen.show .intro-feature.from-left  { animation: introLeft 0.55s cubic-bezier(.175,.885,.32,1.275) forwards; }
.intro-screen.show .intro-feature.from-right { animation: introRight 0.55s cubic-bezier(.175,.885,.32,1.275) forwards; }
.intro-feature:nth-child(1) { animation-delay: 0.05s; }
.intro-feature:nth-child(2) { animation-delay: 0.22s; }
.intro-feature:nth-child(3) { animation-delay: 0.39s; }
@keyframes introLeft  { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: translateX(0); } }
@keyframes introRight { from { opacity: 0; transform: translateX(36px);  } to { opacity: 1; transform: translateX(0); } }

.intro-feature .icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(70,95,255,0.22), rgba(236,72,153,0.22));
}
.intro-feature .icon svg { width: 18px; height: 18px; color: var(--blue-400); }
.intro-feature .txt { min-width: 0; }
.intro-feature .txt strong { display: block; font-size: 0.86rem; font-weight: 700; }
.intro-feature .txt span { display: block; font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; line-height: 1.35; }

.main-app {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.main-app.ready { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .splash-logo, .intro-feature { animation: none !important; opacity: 1 !important; transform: none !important; }
  .main-app { transition: opacity 0.15s ease; transform: none !important; }
}

.topbar {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
  padding: 20px 20px 0;
}
.topbar .brandmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  min-width: 0;
  white-space: nowrap;
}
.topbar .brandmark img { height: 24px; width: auto; display: block; }
.topbar .tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pink-400);
  background: rgba(236, 72, 153, 0.12);
  border: 1px solid rgba(236, 72, 153, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
}

.hero {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 20px 8px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.05rem, 5.6vw, 1.55rem);
  line-height: 1.25;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
/* Reusable gradient-text utility — hero heading, intro heading, footer
   brand link all share this, so it lives once, not re-scoped per parent. */
.grad {
  background: linear-gradient(90deg, var(--blue-400), var(--pink-400));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  margin: 0 auto;
  max-width: 34ch;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: center;
  margin: 16px auto 4px;
  padding: 2px 2px 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.badges::-webkit-scrollbar { display: none; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  white-space: nowrap;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--white-a06);
  border: 1px solid var(--white-a10);
  padding: 5px 9px;
  border-radius: 999px;
}
.badge svg { width: 11px; height: 11px; flex: none; }
.badge.blue svg { color: var(--blue-400); }
.badge.pink svg { color: var(--pink-400); }

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 18px 20px 12px;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.03));
  border: 1px solid var(--white-a12);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue-500), var(--pink-500));
}

/* Remembered-school state — shown instead of the blank form once a
   previous successful login has saved a school (see app.js). */
.remembered-school {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.remembered-icon {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(70,95,255,0.22), rgba(236,72,153,0.22));
  border: 1px solid var(--white-a12);
}
.remembered-icon svg { width: 20px; height: 20px; color: var(--blue-400); }
.remembered-text { min-width: 0; }
.remembered-text small {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.remembered-text strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
  text-align: center;
}
.link-btn:hover { color: var(--text); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-shell {
  position: relative;
  border-radius: var(--radius-md);
  padding: 1.5px;
  background: var(--white-a10);
  transition: background 0.2s ease;
}
.input-shell:focus-within {
  background: linear-gradient(90deg, var(--blue-500), var(--pink-500));
}
.field input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.03em;
  background: var(--navy-950);
  border: none;
  border-radius: calc(var(--radius-md) - 1.5px);
  color: var(--text);
  outline: none;
  display: block;
}
.field input::placeholder {
  color: #4c5486;
  letter-spacing: normal;
  font-family: var(--font);
}

.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

button.submit {
  width: 100%;
  padding: 15px 16px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, var(--blue-500), var(--pink-500));
  background-size: 160% 100%;
  background-position: 0% 0%;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 14px 30px rgba(70, 95, 255, 0.28);
  transition: background-position 0.4s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
button.submit:hover { background-position: 100% 0%; }
button.submit:active { transform: scale(0.98); }
button.submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: none;
}
button.submit[aria-busy="true"] .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.message {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  display: none;
}
.message.show { display: block; }
.message.error { background: var(--danger-bg); color: #ffb4ac; border: 1px solid rgba(255,120,110,0.35); }
.message.info { background: rgba(70, 95, 255, 0.14); color: #cdd6ff; border: 1px solid rgba(70,95,255,0.35); }
.message.offline { background: rgba(255,190,60,0.14); color: #ffd98a; border: 1px solid rgba(255,190,60,0.35); }

.steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--white-a10);
}
.step { flex: 1; text-align: center; position: relative; }
.step .dot {
  width: 26px; height: 26px;
  margin: 0 auto 6px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  background: var(--white-a10);
  color: var(--text-muted);
  border: 1px solid var(--white-a12);
}
.step.active .dot {
  background: linear-gradient(135deg, var(--blue-500), var(--pink-500));
  color: #fff;
  border-color: transparent;
}
.step small { display: block; font-size: 0.66rem; color: var(--text-muted); line-height: 1.3; }
.step-line {
  position: absolute;
  top: 13px; left: -50%; right: 50%;
  height: 1px;
  background: var(--white-a12);
  z-index: -1;
}
.step:first-child .step-line { display: none; }

.help {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  margin: 16px auto 0;
  padding: 0 20px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.help a { color: var(--blue-400); text-decoration: none; font-weight: 600; }
.help a:hover { text-decoration: underline; }

.install-hint {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--white-a06);
  border: 1px solid var(--white-a10);
  color: var(--text-muted);
  font-size: 0.76rem;
  text-align: center;
  display: none;
}
.install-hint.show { display: block; }

footer.legal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  margin: 26px auto 0;
  padding: 0 20px calc(32px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.74rem;
  color: #626ba0;
}
footer.legal .brand-line {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-bottom: 8px; font-weight: 700; color: var(--text-muted);
}
footer.legal .powered-by {
  margin-bottom: 14px;
  font-size: 0.72rem;
  color: #626ba0;
}
footer.legal .powered-by a { font-weight: 700; color: #8891c4; }
footer.legal .powered-by a:hover { color: var(--text-muted); }
footer.legal a:not(.grad) { color: #8891c4; text-decoration: none; }
footer.legal a:not(.grad):hover { color: var(--text-muted); }
footer.legal a.grad { text-decoration: none; }
footer.legal .sep { margin: 0 8px; opacity: 0.5; }

@media (max-width: 360px) {
  .card { padding: 22px 18px; }
  .hero h1 { font-size: 1.65rem; }
}

/* ==========================================================================
   Offline page — same flow blue/pink theme as the landing page (shares
   body.page-entry, .topbar, .hero, .wrap, .card, button.submit, footer.legal
   wholesale). Only the bits unique to the offline screen live here: the
   icon badge in the hero and the connection status row inside the card.
   ========================================================================== */

.icon-badge {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(70,95,255,0.18), rgba(236,72,153,0.18));
  border: 1px solid var(--white-a12);
  position: relative;
  overflow: hidden;
}
.icon-badge .grid-decor { position: absolute; inset: 0; opacity: 0.4; }
.icon-badge svg { width: 30px; height: 30px; color: var(--blue-400); position: relative; }

.status-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.78rem; color: var(--text-muted); margin-bottom: 16px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 138, 128, 0.18);
}
.status-dot.online { background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,0.18); }
