/* =====================================================================
   SAFES homepage motion: gentle, professional, light on slow phones.
   Everything here is switched off when the device asks for reduced motion.
   ===================================================================== */

/* ---------- Entrance: cards rise in one after another ---------- */
@keyframes safesRise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.safes-enter > .hero-banner-card,
.safes-enter > .card,
.safes-enter > .grid-4 > .card,
.safes-enter > div > .card {
  animation: safesRise 0.55s cubic-bezier(.22, .8, .3, 1) both;
}
.safes-enter > .hero-banner-card { animation-delay: 0s; }
.safes-enter > .ann-card { animation-delay: 0.08s; }
.safes-enter > .grid-4 > .card:nth-child(1) { animation-delay: 0.16s; }
.safes-enter > .grid-4 > .card:nth-child(2) { animation-delay: 0.23s; }
.safes-enter > .grid-4 > .card:nth-child(3) { animation-delay: 0.30s; }
.safes-enter > .grid-4 > .card:nth-child(4) { animation-delay: 0.37s; }
.safes-enter > .safes-timeline { animation-delay: 0.44s; }
.safes-enter > #safes-stats-card { animation-delay: 0.51s; }

/* ---------- Login cards: lift on hover, glow while typing ---------- */
.login-card {
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  will-change: transform;
}
@media (hover: hover) {
  .login-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px -10px rgba(15, 23, 42, 0.28);
  }
}
.login-card:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16), 0 10px 24px -12px rgba(15, 23, 42, 0.3);
}
.login-card .btn { transition: filter 0.2s ease, transform 0.15s ease; }
.login-card .btn:active { transform: scale(0.98); }

/* ---------- Living banner: slow drift of the photo + a soft passing light ---------- */
@keyframes safesHeroDrift {
  0%   { transform: scale(1.02) translateY(0); }
  100% { transform: scale(1.09) translateY(-2%); }
}
@keyframes safesHeroSheen {
  0%   { transform: translateX(-120%) skewX(-18deg); }
  60%, 100% { transform: translateX(260%) skewX(-18deg); }
}
.hero-banner-card { isolation: isolate; }
/* A copy of the banner photo behind the text slowly zooms (the card itself keeps its fixed background) */
.hero-banner-card::before {
  content: '';
  position: absolute; inset: 0;
  background: inherit;
  transform-origin: center 40%;
  animation: safesHeroDrift 26s ease-in-out infinite alternate;
  z-index: 0;
  pointer-events: none;
}
.hero-banner-card::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 35%;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0) 100%);
  animation: safesHeroSheen 9s ease-in-out infinite;
  animation-delay: 2s;
  pointer-events: none;
  z-index: 1;
}
.bana-kaih-slogan { transition: opacity 0.45s ease, transform 0.45s ease; }
.bana-kaih-slogan.swap-out { opacity: 0; transform: translateY(6px); }

/* ---------- Assessment timeline strip ---------- */
.safes-timeline {
  margin-bottom: 1.2rem;
  padding: 0.85rem 1.1rem !important;
  border-left: 4px solid #0ea5e9;
  background: linear-gradient(90deg, #f0f9ff 0%, #ffffff 60%);
}
.safes-timeline .tl-head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap;
  margin-bottom: 0.65rem;
}
.safes-timeline .tl-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 0.95rem; color: #0f172a; }
.safes-timeline .tl-live {
  width: 9px; height: 9px; border-radius: 50%; background: #10b981; flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  animation: safesPulse 2s ease-out infinite;
}
@keyframes safesPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.safes-timeline .tl-countdown { font-size: 0.82rem; color: #334155; }
.safes-timeline .tl-countdown strong { color: #0369a1; }
.safes-timeline .tl-steps { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.65rem; }
.safes-timeline .tl-step { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; color: #94a3b8; font-size: 0.78rem; font-weight: 600; }
.safes-timeline .tl-dot {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; background: #f1f5f9; color: #94a3b8; border: 2px solid #e2e8f0;
}
.safes-timeline .tl-step.done { color: #047857; }
.safes-timeline .tl-step.done .tl-dot { background: #10b981; color: #fff; border-color: #10b981; }
.safes-timeline .tl-step.current { color: #0369a1; }
.safes-timeline .tl-step.current .tl-dot {
  background: #0ea5e9; color: #fff; border-color: #0ea5e9;
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
}
.safes-timeline .tl-line { flex: 1; height: 2px; min-width: 12px; background: linear-gradient(90deg, #cbd5e1, #e2e8f0); border-radius: 2px; }
.safes-timeline .tl-progress { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; font-size: 0.78rem; color: #475569; }
.safes-timeline .tl-bar { flex: 1; min-width: 140px; height: 6px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.safes-timeline .tl-bar > div { height: 100%; background: linear-gradient(90deg, #0ea5e9, #10b981); border-radius: 6px; transition: width 1.2s cubic-bezier(.22,.8,.3,1); }

/* Phones: steps become a compact vertical list */
@media (max-width: 640px) {
  .safes-timeline { padding: 0.8rem 0.9rem !important; }
  .safes-timeline .tl-steps { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
  .safes-timeline .tl-line { display: none; }
  .safes-timeline .tl-step:not(.current):not(.done) { opacity: 0.8; }
}

/* ---------- Respect "reduce motion" ---------- */
@media (prefers-reduced-motion: reduce) {
  .safes-enter > *, .safes-enter > .grid-4 > .card, .safes-enter > div > .card,
  .hero-banner-card::before, .hero-banner-card::after, .safes-timeline .tl-live {
    animation: none !important;
  }
  .login-card, .login-card:hover, .login-card:focus-within { transform: none !important; transition: none !important; }
  .hero-banner-card::after { display: none; }
}

/* =====================================================================
   Homepage banner on phones: photo strip on top, text on a deep-blue panel
   ===================================================================== */
.hero-actions { display: none; }
@media (max-width: 640px) {
  .hero-banner-card {
    background: linear-gradient(180deg, #0f1f3d 0px, #0f1f3d 185px, #1b2a5c 70%, #35206a 100%) !important;
    padding: 172px 1.1rem 1.15rem !important;
    min-height: 0 !important;
    border-radius: 18px !important;
    box-shadow: 0 10px 30px -14px rgba(15, 23, 42, 0.55) !important;
  }
  /* The building photo: a clean strip across the top that fades into the blue panel */
  .hero-banner-card::before {
    inset: 0 0 auto 0 !important;
    height: 190px;
    background:
      linear-gradient(180deg, rgba(15, 31, 61, 0.05) 0%, rgba(15, 31, 61, 0.25) 55%, #0f1f3d 100%),
      var(--hero-img, url('../assets/scert_building_bg.jpg')) center 40% / cover no-repeat !important;
    transform-origin: center 30%;
  }
  .hero-banner-card::after { bottom: auto; height: 190px; }

  /* Bana Kaih badge sits on the photo, top-left; slogan just under it */
  .hero-bana-kaih-box {
    position: absolute !important;
    top: 12px !important; left: 12px !important; right: 12px !important;
    margin: 0 !important;
    align-items: flex-start !important;
    gap: 0.4rem !important;
  }
  .bana-kaih-badge { background: transparent !important; padding: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
  .bana-kaih-logo { height: 32px !important; max-width: 130px !important; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5)) !important; }
  .bana-kaih-slogan {
    font-size: 0.82rem !important;
    color: #ffffff !important;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.75) !important;
    max-width: 85%;
  }

  .hero-subtitle { font-size: 0.64rem !important; letter-spacing: 0.06em; color: #93c5fd !important; line-height: 1.35 !important; margin-bottom: 0.3rem; }
  .hero-title { font-size: 1.3rem !important; line-height: 1.22 !important; margin: 0 0 0.45rem !important; }
  .hero-description {
    font-size: 0.8rem !important; line-height: 1.5 !important; opacity: 0.9;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 0 !important;
  }

  /* Quick actions */
  .hero-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
  .hero-chip {
    display: inline-flex; align-items: center; min-height: 36px; padding: 0 0.95rem;
    border-radius: 999px; font-size: 0.8rem; font-weight: 700; text-decoration: none;
    color: #e0e7ff; background: rgba(255, 255, 255, 0.10); border: 1px solid rgba(255, 255, 255, 0.22);
  }
  .hero-chip-primary { background: #ffffff; color: #1e3a8a; border-color: #ffffff; }
  .hero-chip:active { transform: scale(0.97); }
}

/* =====================================================================
   Announcements: scrolling news ticker
   ===================================================================== */
.ann-card {
  /* whole-pixel gap below (1.2rem = 19.2px put the next card's blue top line between two pixel rows,
     where it shimmered while the ticker moved); the moving text is drawn on its own layer, kept inside
     this card, so nothing around it is repainted */
  margin-bottom: 20px; padding: 0 !important; overflow: hidden; border-left: 4px solid var(--primary-600, #2563eb);
  isolation: isolate; contain: paint; transform: translateZ(0); backface-visibility: hidden;
}
.ann-bar { display: flex; align-items: stretch; min-height: 48px; min-width: 0; overflow: hidden; }
.ann-label {
  display: flex; align-items: center; gap: 0.45rem; flex-shrink: 0; position: relative; z-index: 1;
  padding: 0 1rem; background: linear-gradient(90deg, #1e3a8a, #2563eb); color: #fff;
  font-size: 0.82rem; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap;
}
.ann-live { width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.6); animation: annPulse 1.8s ease-out infinite; }
@keyframes annPulse { 0% { box-shadow: 0 0 0 0 rgba(251,191,36,.6); } 70% { box-shadow: 0 0 0 7px rgba(251,191,36,0); } 100% { box-shadow: 0 0 0 0 rgba(251,191,36,0); } }
.ann-empty { flex: 1; display: flex; align-items: center; padding: 0 1rem; font-size: 0.82rem; color: #64748b; font-style: italic; }
.ann-viewport {
  flex: 1 1 0; min-width: 0; overflow: hidden; display: flex; align-items: center; position: relative; contain: paint;
}
/* Soft edges: two white fades laid over the ends (a CSS mask did this before, but the browser had to
   recompute it on every frame of the scroll, which caused flicker) */
.ann-viewport::before, .ann-viewport::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 24px; z-index: 2; pointer-events: none;
}
.ann-viewport::before { left: 0; background: linear-gradient(90deg, #fff, rgba(255,255,255,0)); }
.ann-viewport::after { right: 0; background: linear-gradient(270deg, #fff, rgba(255,255,255,0)); }
.ann-track {
  display: inline-flex; align-items: center; white-space: nowrap; flex-shrink: 0;
  animation: annScroll var(--ann-dur, 30s) linear infinite;
  will-change: transform; backface-visibility: hidden;
}
.ann-viewport:hover .ann-track, .ann-viewport:focus-within .ann-track, .ann-viewport:active .ann-track { animation-play-state: paused; }
@keyframes annScroll { from { transform: translateX(0); } to { transform: translateX(var(--ann-shift, -50%)); } }
.ann-tick {
  display: inline-flex; align-items: center; gap: 0.5rem; flex-shrink: 0;
  background: none; border: 0; padding: 0.35rem 0.2rem; min-height: 0 !important; cursor: pointer;
  font: inherit; font-size: 0.86rem; color: #0f172a;
}
.ann-tick:hover strong { text-decoration: underline; color: #1d4ed8; }
.ann-tick strong { font-weight: 700; }
.ann-msg { color: #475569; font-size: 0.82rem; }
.ann-date { color: #94a3b8; font-size: 0.74rem; }
.ann-sep { color: #cbd5e1; flex-shrink: 0; }
.ann-pri { font-size: 0.62rem; font-weight: 800; padding: 2px 6px; border-radius: 4px; letter-spacing: 0.03em; background: #e0f2fe; color: #0369a1; }
.ann-pri.pri-HIGH { background: #fee2e2; color: #b91c1c; }
.ann-pri.pri-MEDIUM { background: #fef3c7; color: #b45309; }
.ann-actions { display: flex; align-items: center; gap: 0.4rem; padding: 0 0.75rem; flex-shrink: 0; border-left: 1px solid #eef2f6; position: relative; z-index: 1; background: #fff; }
.ann-btn {
  display: inline-flex; align-items: center; gap: 0.3rem; min-height: 30px !important; padding: 0 0.7rem;
  border-radius: 8px; border: 1px solid #dbe3ee; background: #fff; color: #334155;
  font-size: 0.76rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.ann-btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.ann-copy { display: inline-flex; align-items: center; gap: 0.9rem; padding: 0 0.9rem 0 1rem; flex-shrink: 0; }
.ann-tick, .ann-tick * { white-space: nowrap; line-height: 1.3; }


@media (max-width: 640px) {
  .ann-bar { flex-wrap: wrap; }
  .ann-label { padding: 0.55rem 0.85rem; border-radius: 0 0 10px 0; font-size: 0.78rem; }
  .ann-label { order: 1; }
  .ann-actions { order: 2; margin-left: auto; border-left: 0; padding: 0.35rem 0.6rem; }
  .ann-viewport, .ann-empty { order: 3; flex: 0 0 100%; min-height: 46px; border-top: 1px solid #eef2f6; }
  .ann-tick { font-size: 0.85rem; }
}
/* While a box (notifications, details...) is open, the moving parts behind it stand still */
body.safes-modal-open .ann-track,
body.safes-modal-open .ann-live { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .ann-track { animation: none !important; }
  .ann-dup { display: none !important; }
  .ann-viewport { overflow-x: auto; -webkit-mask-image: none; mask-image: none; }
  .ann-live { animation: none; }
}

/* Offline / sync status pill */
#safes-sync-pill {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3000;
  max-width: min(92vw, 560px); padding: 0.55rem 1rem; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; line-height: 1.35; text-align: center;
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.5); color: #fff; background: #334155;
  animation: safesRise 0.3s ease both;
}
#safes-sync-pill.offline { background: #b45309; }
#safes-sync-pill.sending { background: #1d4ed8; }
#safes-sync-pill.ok { background: #047857; }
@media (max-width: 640px) { #safes-sync-pill { bottom: 10px; font-size: 0.76rem; border-radius: 14px; } }

/* A section the user must finish first glows briefly (School Information) */
@keyframes safesNeedsAttention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
  25%, 75% { box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.35); }
}
.safes-needs-attention {
  border-color: #d97706 !important;
  animation: safesNeedsAttention 1.2s ease-in-out 2;
}
@media (prefers-reduced-motion: reduce) {
  .safes-needs-attention { animation: none; box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.35); }
}
/* Notification cards sit below the phone header and span the screen width */
@media (max-width: 600px) {
  #safes-toast-container { top: calc(12px + env(safe-area-inset-top, 0px)) !important; right: 12px !important; left: 12px !important; width: auto !important; max-width: none !important; }
}

/* ---------- Whole-pixel positions for the top of each page ----------
   The top bar (66.36px) and the gap under it (0.35rem = 5.6px) were fractions of a pixel, so every card
   below started between two pixel rows. Their coloured top lines then looked blurred and shimmered
   whenever something next to them moved (the news ticker). */
@media (min-width: 993px) {
  html body #safes-navbar { height: 66px; box-sizing: border-box; }
}
html body #view-container { padding-top: 6px !important; }
@media (max-width: 640px) {
  .ann-label { height: 40px; padding-top: 0; padding-bottom: 0; box-sizing: border-box; }
  .ann-actions { height: 40px; padding-top: 0; padding-bottom: 0; box-sizing: border-box; }
  .ann-viewport, .ann-empty { height: 46px; box-sizing: border-box; }
}
