/* One motion treatment for every loading surface, at every viewport width. */
:root {
  --skeleton-base: #e2e8ef;
  --skeleton-highlight: #f8fafc;
  --skeleton-duration: 1.6s;
}
.skeleton-pulse, .skeleton-line, .bus-skeleton-bar {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  max-width: 100%;
  background: var(--skeleton-base);
  border-radius: 4px;
  animation: none;
  opacity: 1;
}
.skeleton-pulse::after, .skeleton-line::after, .bus-skeleton-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--skeleton-highlight), transparent);
  transform: translateX(-100%);
  animation: qcu-shimmer var(--skeleton-duration) ease-in-out infinite;
}
@keyframes qcu-shimmer { to { transform: translateX(100%); } }
.loading-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.loading-bar { display: block; width: 85%; height: 12px; flex-shrink: 0; }
.loading-bar-title { width: 68%; height: 20px; }
.loading-bar-short { width: 44%; height: 10px; }
.loading-lines { display: flex; flex-direction: column; gap: 12px; min-width: 0; width: 100%; }
.loading-placeholder { display: block; padding: 0; min-height: 0; width: 100%; min-width: 0; }
.loading-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.loading-card { min-width: 0; padding: 20px; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; background: var(--card, #fff); }
.loading-card-top, .loading-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.loading-card-top { margin-bottom: 24px; }
.loading-card-footer { justify-content: flex-start; margin-top: 24px; }
.loading-chip { width: 72px; height: 16px; }
.loading-header .header-brand { flex: 1; min-width: 0; }
.loading-avatar { width: 38px; height: 38px; border-radius: 50%; }
.loading-brand-title { width: 168px; height: 14px; }
.loading-brand-sub { width: 112px; height: 10px; }
.loading-header .header-clock { width: 72px; }
.student-shell .bottom-nav .loading-nav-item { pointer-events: none; }
.student-shell .bottom-nav .loading-nav-item.active { gap: 6px; }
.student-shell .bottom-nav .loading-nav-add { pointer-events: none; }
.student-shell .bottom-nav .loading-nav-icon { --skeleton-base: #bcb2ff; --skeleton-highlight: #ddd7ff; }
.student-shell .bottom-nav .loading-nav-label { --skeleton-base: #b3a9eb; --skeleton-highlight: #d3cafc; }
.loading-nav-icon { width: 21px; height: 21px; border-radius: 6px; }
.loading-nav-label { width: 38px; height: 8px; }
.loading-auth { min-height: 100svh; }
.loading-auth-heading { padding: 24px 0; }
.loading-auth-heading .loading-bar-title { width: min(320px, 78%); height: 32px; }
.loading-auth-heading .loading-bar-short { width: min(240px, 60%); }
.loading-auth-summary { padding: 20px; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; background: var(--card, #fff); }
.loading-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.loading-week .loading-bar { width: 100%; height: 60px; }
.home-hero-skeleton { display: flex; gap: 24px; margin-top: 16px; }
.home-today-grid > .loading-placeholder, #building-grid > .loading-placeholder { grid-column: 1 / -1; }
.home-tracker-cell > .loading-lines { padding: 16px; }
.home-countdown > .loading-lines { width: min(200px, 100%); margin: 16px auto; align-items: center; }
.loading-settings { display: grid; gap: 12px; }
.loading-setting { display: flex; align-items: center; gap: 24px; padding: 20px; background: var(--card, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 8px; }
.loading-setting > .loading-bar { width: 40px; height: 24px; }
[data-loading-cover] { position: relative; }
[data-loading-cover] > :not(.loading-cover) { visibility: hidden; }
.loading-cover { position: absolute; inset: 0; overflow: hidden; }
.loading-cover > .loading-lines { padding: 20px; }
.loading-cover .loading-header { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.loading-cover > .loading-header { padding: 8px 20px; }
.loading-cover .header-brand, .loading-cover .header-right { display: flex; align-items: center; gap: 12px; }
.loading-cover .loading-lines { flex: 1; }
.loading-cover-nav { display: flex; align-items: center; justify-content: space-around; height: 100%; gap: 12px; }
.loading-cover-nav > .loading-lines { align-items: center; }
.loading-cover-nav .loading-lines { gap: 8px; }
.loading-cover-nav .loading-bar-title { width: 20px; height: 20px; border-radius: 50%; }
.loading-cover-nav .loading-bar:not(.loading-bar-title) { height: 8px; }
.loading-cover-nav .loading-bar-short { display: none; }
.onboarding-main > .loading-cover { inset: 20px; }
.admin-nav > .loading-cover .loading-lines { gap: 10px; }
.admin-nav > .loading-cover .loading-bar-title { height: 12px; }
.loading-admin { margin-top: 24px; }
.loading-admin .loading-cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.loading-admin .loading-card { min-height: 180px; }
.loading-weather { min-height: 160px; padding: 20px; }
.google-card-skeleton .google-card-band { background: var(--skeleton-base); }
/* Keep labels in the layout, so starting an action never changes button width. */
.btn-spinner {
  position: relative;
  pointer-events: none;
  cursor: progress;
  color: transparent !important;
  opacity: 1;
}
.btn-spinner > * { visibility: hidden; }
.btn-spinner::after {
  content: "";
  position: absolute;
  top: calc(50% - 9px);
  left: calc(50% - 9px);
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  border: 2px solid var(--blue-mid, #c8defa);
  border-top-color: var(--blue, #005bac);
  border-radius: 50%;
  animation: qcu-button-spin .75s linear infinite;
}
.btn-primary.btn-spinner::after, .action-button:not(.secondary).btn-spinner::after,
.primary.btn-spinner::after, .danger.btn-spinner::after, .btn-danger.btn-spinner::after, .google-primary-button.btn-spinner::after {
  border-color: #ffffff55;
  border-top-color: #fff;
}
@keyframes qcu-button-spin { to { transform: rotate(360deg); } }
@media (min-width: 720px) {
  .loading-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .loading-avatar { width: 34px; height: 34px; }
  .loading-header .header-clock { display: none; }
  .loading-card { padding: 16px; }
  .loading-brand-title { width: 136px; }
  .loading-auth-heading { padding: 16px 0; }
  .loading-week { gap: 6px; }
  .loading-week .loading-bar { height: 48px; }
}
@media (max-width: 400px) {
  .loading-brand-sub { display: none; }
  .loading-brand-title { width: 120px; }
}
/* Keep placeholder rows in the timetable's table layout at every width. */
.table-wrap:has(#schedule-rows[data-loading-region]) table { min-width: 0; width: 100%; table-layout: fixed; }
@media (max-width: 720px) {
  .table-wrap:has(#schedule-rows[data-loading-region]) thead th { padding-inline: 6px; font-size: 9px; }
  #schedule-rows[data-loading-region] td { padding: 12px 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-pulse::after, .skeleton-line::after, .bus-skeleton-bar::after { animation: none; display: none; }
  .btn-spinner::after { animation: none; }
}
@media print {
  .loading-placeholder, .loading-cover, .loading-auth { display: none; }
}

/* ============================================================
   SOFT-UI SKELETON OVERLAY — matches the redesigned theme.
   Same class names, new look: pill-shaped shimmer bars on
   soft #F4F7FC tones, floating 22-28px cards, pastel chips.
   Applies to every page's loading state (Home, Bus, Google,
   Settings, Workspace, Buildings, Schedule, Today).
   ============================================================ */

/* Softer, cooler shimmer tones + pill-shaped bars */
:root {
  --skeleton-base: #E8EBF5;
  --skeleton-highlight: #F7F9FE;
}
.skeleton-pulse, .skeleton-line, .bus-skeleton-bar {
  border-radius: 9999px;
}
.loading-bar, .loading-bar-title, .loading-bar-short {
  border-radius: 9999px;
  height: 11px;
}
.loading-bar-title { height: 18px; }
.loading-bar-short { height: 9px; }
.loading-avatar { border-radius: 9999px; }

/* Loading cards: floating white with soft shadow, big radius */
.loading-card {
  border: 1px solid rgba(0, 0, 0, 0.03);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}
.loading-cards { gap: 14px; }

/* Chips inside skeleton cards: pastel pill instead of flat gray */
.loading-chip {
  width: 76px; height: 22px;
  border-radius: 9999px;
  background: #EDEAFF;
}
/* Keep the shimmer only on the chip's overlay, not its pastel base:
   the ::after shimmer still runs, which reads nicely on pastel. */

/* Header skeleton: round avatar + pill brand bars */
.loading-avatar { width: 40px; height: 40px; }
.loading-brand-title { width: 168px; height: 13px; }
.loading-brand-sub { width: 110px; height: 9px; }

/* Nav skeleton items: round icon chips */
.loading-nav-icon { width: 22px; height: 22px; border-radius: 9999px; }
.loading-nav-label { border-radius: 9999px; }

/* Settings skeleton rows: pastel card shapes like the real rows */
.loading-setting {
  border: 0;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  padding: 18px;
}
.loading-setting > .loading-bar { border-radius: 9999px; }
.loading-setting:nth-child(3n + 1) { background: #E0F7F6; }
.loading-setting:nth-child(3n + 2) { background: #FFE8D6; }
.loading-setting:nth-child(3n)     { background: #EDEAFF; }
.loading-setting > .loading-lines { gap: 8px; }

/* Auth/summary skeleton: floating card */
.loading-auth-summary {
  border: 1px solid rgba(0, 0, 0, 0.03);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

/* Week skeleton cells: pill day slots like the week strip */
.loading-week { gap: 10px; }
.loading-week .loading-bar { height: 58px; border-radius: 20px; }

/* Weather module skeleton: soft card */
.loading-weather {
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

/* Google card skeleton: rounded band + body */
.google-card-skeleton { border-radius: 22px; overflow: hidden; }
.google-card-skeleton .google-card-band { border-radius: 18px 18px 0 0; background: #E8EBF5; }
.google-card-skeleton .google-card-body .skeleton-line { border-radius: 9999px; }

/* Bus skeleton bars: pills */
.bus-skeleton { gap: 10px; }
.bus-skeleton-bar { height: 14px; border-radius: 9999px; }

/* Button spinner: purple instead of legacy blue */
.btn-spinner::after {
  border-color: #ECEBFF;
  border-top-color: #4A3AFF;
}
.btn-primary.btn-spinner::after, .action-button:not(.secondary).btn-spinner::after,
.primary.btn-spinner::after, .danger.btn-spinner::after, .btn-danger.btn-spinner::after,
.google-primary-button.btn-spinner::after, .nav-fab-btn.btn-spinner::after {
  border-color: #ffffff55;
  border-top-color: #fff;
}

/* ── Soft-UI skeleton SHAPES (Home dashboard + all pages) ── */

/* Stacked full-width task-row skeletons (Home Today Task line-up) */
.loading-cards--stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px 2px;
}
.loading-cards--stack .loading-card {
  width: 100%;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 28px;
  padding: 18px 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}
.loading-cards--stack .loading-card-top { margin-bottom: 14px; }
.loading-cards--stack .loading-card-footer { margin-top: 14px; }

/* Pastel skeleton cards: the card itself is pastel, bars shimmer white-ish */
.loading-card--pastel { background: #E0F7F6; }
.loading-card--pastel:nth-child(3n + 2) { background: #FFE8D6; }
.loading-card--pastel:nth-child(3n) { background: #EDEAFF; }
.loading-card--pastel .skeleton-pulse,
.loading-card--pastel .skeleton-line {
  --skeleton-base: rgba(255, 255, 255, 0.75);
  --skeleton-highlight: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.75);
}

/* Calendar skeleton: header dots + 7x5 pill cells (matches .soft-cal-grid) */
.loading-cal-skel { width: 100%; }
.loading-cal-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 8px;
}
.loading-cal-head::before, .loading-cal-head::after,
.loading-cal-grid::before { content: none; }
/* seven small header bars via background gradient trick is fragile — use cells */
.loading-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.loading-cal-cell {
  aspect-ratio: 1;
  max-height: 40px;
  border-radius: 9999px;
  background: var(--skeleton-base, #E8EBF5);
}
.loading-cal-cell:nth-child(9n + 3) { background: #ECEBFF; }

/* Pastel row skeletons with icon chips (Classroom Updates + Tasks & Notes) */
.loading-rows-skel { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.loading-row-skel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-radius: 20px;
  padding: 14px 16px;
}
.loading-row-skel--peach    { background: #FFE8D6; }
.loading-row-skel--mint     { background: #E0F7F6; }
.loading-row-skel--lavender { background: #EDEAFF; }
.loading-row-skel .loading-icon-skel {
  width: 36px; height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
}
.loading-row-skel .loading-lines { gap: 8px; }
.loading-row-skel .skeleton-pulse {
  --skeleton-base: rgba(255, 255, 255, 0.75);
  --skeleton-highlight: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.75);
}

/* Calendar header skeleton: render 7 mini bars above the grid */
.loading-cal-skel .loading-cal-head {
  counter-reset: none;
}

/* Match the dashboard's stacked class blocks. */
#auth-dashboard #today-grid .loading-card { border-radius: 26px; padding: 20px; min-height: 210px; }
#auth-dashboard #today-grid .loading-card:first-child { background: #EAE6FF; }
#auth-dashboard #today-grid .loading-card:nth-child(2) { background: #DCF4F7; }
#auth-dashboard #today-grid .loading-card:nth-child(3) { background: #FFE8D6; }
#auth-dashboard .loading-row-skel--mint { background: #DCF4F7; }
#auth-dashboard .loading-row-skel--lavender { background: #EAE6FF; }
#auth-dashboard .loading-date-strip { display: flex; gap: 6px; min-width: 0; }
#auth-dashboard .loading-date-strip > span { flex: 1; min-width: 44px; height: 68px; border-radius: 16px; background: #F1EFFB; }
/* Current header, class timeline, profile, and map silhouettes. */
.loading-profile-ring {
  display: grid; place-items: center; padding: 3px; width: 48px; height: 48px;
  border-radius: 50%; flex: 0 0 48px;
  background: conic-gradient(#E83B46 0deg 120deg, #F6C942 120deg 240deg, #245ACB 240deg 360deg);
}
.loading-profile-face { display: block; width: 100%; height: 100%; border: 2px solid #fff; border-radius: 50%; }
.loading-cal-head .loading-bar { width: 50%; height: 8px; margin: auto; }
.loading-cal-grid { gap: 5px; }
.loading-cal-cell { width: 100%; max-height: none; border-radius: 12px; }
.loading-dashboard { max-width: 1440px; }
.loading-dashboard-grid { display: grid; gap: 28px; }
.loading-dashboard-grid > * { min-width: 0; display: grid; align-content: start; gap: 24px; }
.loading-dashboard .loading-card--pastel, #auth-dashboard #today-grid .loading-card:first-child { background: #4435EE; }
.loading-dashboard .loading-card--pastel:nth-child(2), #auth-dashboard #today-grid .loading-card:nth-child(2) { background: #D779C4; }
.loading-dashboard .loading-card--pastel:nth-child(3), #auth-dashboard #today-grid .loading-card:nth-child(3) { background: #F3F0FC; }
.loading-dashboard .loading-card--pastel:nth-child(-n+2) .skeleton-pulse,
#auth-dashboard #today-grid .loading-card:nth-child(-n+2) .skeleton-pulse { --skeleton-base: #FFFFFF40; --skeleton-highlight: #FFFFFF8F; background: var(--skeleton-base); }
.loading-profile-card { display: flex; align-items: center; gap: 20px; padding: 28px; border-radius: 28px; background: #E6F0FE; min-height: 164px; }
.loading-profile-portrait { width: 88px; height: 88px; border-radius: 50%; flex-shrink: 0; }
.loading-profile-card .loading-lines { gap: 10px; }
.loading-profile-group { background: #fff; border: 1px solid #E6EAF2; border-radius: 24px; overflow: hidden; }
.loading-profile-group .loading-setting { background: #fff; padding: 20px; gap: 13px; border-radius: 0; box-shadow: none; min-height: 78px; }
.loading-profile-group .loading-setting + .loading-setting { border-top: 1px solid #EEF1F6; }
.loading-profile-icon { width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0; background: #EEF3FC; }
.loading-profile-group .loading-setting > .loading-bar { width: 60%; height: 13px; }
.loading-profile-chevron { margin-left: auto; width: 9px; height: 16px; border-radius: 5px; flex-shrink: 0; }
.loading-profile-toolbar .header-brand { justify-content: center; }
.loading-profile-toolbar .loading-brand-sub { display: none; }
.loading-profile-toolbar .loading-profile-ring { background: #E8EBF5; border-radius: 14px; }
.loading-stat-value { width: 90%; height: 32px; }
.bus-trip-skeleton .bus-trip-endpoints { margin-block: 24px; gap: 24px; }
.bus-trip-skeleton .bus-trip-endpoints::before { display: none; }
.bus-map-loading { position: absolute; inset: 0; pointer-events: none; background: #EBEFF040; }
.bus-map-loading-pill { position: absolute; width: 130px; height: 36px; border: 1px solid #D7E0EB; border-radius: 999px; box-shadow: 0 3px 10px #19335A12; }
.bus-map-loading-pill:nth-of-type(2) { top: 30%; left: 40%; }
.bus-map-loading-pill:nth-of-type(3) { top: 42%; left: 25%; }
.bus-map-loading-pill:nth-of-type(4) { top: 52%; left: 50%; }
@media (min-width: 900px) { .loading-dashboard-grid { grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); } }
@media (max-width: 560px) {
  .loading-profile-card { padding: 22px; gap: 14px; }
  .loading-profile-portrait { width: 68px; height: 68px; }
  .loading-profile-group .loading-setting { padding: 18px; }
}
