/* Maple Telecom logo: colours, placement, and the "Signal Leaf" animations.
   The SVG comes from brand-logo.js. Shapes: .leaf-body, .leaf-wave-1/2,
   .logo-line-1/2 > .logo-letter. */

:root {
  --maple-red: #d0021b;
  --maple-red-bright: #ee1c33;
  --maple-ink: #16181f;
  --brand-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --brand-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.maple-logo,
.maple-logo-mark {
  display: block;
  overflow: visible;
  --logo-leaf: var(--maple-red);
  --logo-word: var(--maple-ink);
}
.maple-logo .logo-leaf path,
.maple-logo-mark .logo-leaf path {
  fill: var(--logo-leaf);
}
.maple-logo .logo-letter {
  fill: var(--logo-word);
}
.maple-logo.on-dark,
.maple-logo-mark.on-dark {
  --logo-leaf: var(--maple-red-bright);
  --logo-word: #fff;
}
.maple-logo-mark.white {
  --logo-leaf: #fff;
}
.maple-logo path,
.maple-logo-mark path {
  transform-box: fill-box;
}

/* ---------- Sidebar placement (customer workspace and admin) ---------- */
.sidebar .brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  min-height: 0;
  margin: 0 0 14px;
  padding: 2px 8px 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  border-radius: 10px;
}
.sidebar .brand .maple-logo {
  width: 148px;
  height: auto;
}
.sidebar .brand .maple-logo .logo-leaf {
  filter: drop-shadow(0 4px 14px #ee1c3333);
}
.sidebar .brand > small {
  margin: 2px 0 0;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #9ea4c4;
}
/* Hover: the waves broadcast, like a signal leaving the leaf */
.sidebar .brand:hover .leaf-wave,
.sidebar .brand:focus-visible .leaf-wave {
  animation: wave-broadcast 900ms var(--brand-ease) both;
}
.sidebar .brand:hover .leaf-wave-2,
.sidebar .brand:focus-visible .leaf-wave-2 {
  animation-delay: 110ms;
}
.sidebar .brand:hover .leaf-body {
  animation: leaf-nod 900ms var(--brand-spring) both;
}

/* Mobile header and sign-in card (light surfaces) */
.mobile-brand .maple-logo {
  width: 132px;
  height: auto;
}
.auth-card > .maple-logo,
.access-error > .maple-logo {
  width: 190px;
  height: auto;
  margin: 0 0 6px;
}

/* Letter stagger index (no inline styles: CSP style-src 'self') */
.logo-line-1 .logo-letter:nth-child(1) { --i: 0; }
.logo-line-1 .logo-letter:nth-child(2) { --i: 1; }
.logo-line-1 .logo-letter:nth-child(3) { --i: 2; }
.logo-line-1 .logo-letter:nth-child(4) { --i: 3; }
.logo-line-1 .logo-letter:nth-child(5) { --i: 4; }
.logo-line-2 .logo-letter:nth-child(1) { --i: 5; }
.logo-line-2 .logo-letter:nth-child(2) { --i: 6; }
.logo-line-2 .logo-letter:nth-child(3) { --i: 7; }
.logo-line-2 .logo-letter:nth-child(4) { --i: 8; }
.logo-line-2 .logo-letter:nth-child(5) { --i: 9; }
.logo-line-2 .logo-letter:nth-child(6) { --i: 10; }
.logo-line-2 .logo-letter:nth-child(7) { --i: 11; }

/* ---------- Boot loader: "Signal Leaf" ----------
   Timeline (first visit): outline draws 0-0.85s, fill crossfades in,
   waves sweep 0.75-1.45s, letters rise 0.95-1.75s, sheen 1.7s, then the
   whole screen dissolves into the app (boot.js). */
#boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
}
.boot-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(70% 60% at 50% 45%, #1d2148 0%, #121733 55%, #0a0d1f 100%);
  transition: opacity 620ms cubic-bezier(0.4, 0, 0.2, 1);
}
.boot-backdrop::before,
.boot-backdrop::after {
  content: "";
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}
.boot-backdrop::before {
  left: 8%;
  top: 6%;
  background: radial-gradient(circle, #e0213a 0%, transparent 62%);
  opacity: 0.28;
  animation: aurora-a 9s ease-in-out infinite alternate;
}
.boot-backdrop::after {
  right: 0;
  bottom: -10%;
  background: radial-gradient(circle, #5b45d6 0%, transparent 62%);
  opacity: 0.45;
  animation: aurora-b 11s ease-in-out infinite alternate;
}
#boot.leaving .boot-backdrop {
  opacity: 0;
}
#boot.leaving .boot-rings,
#boot.leaving .boot-progress,
#boot.leaving .boot-caption {
  transition: opacity 220ms ease;
  opacity: 0 !important;
  animation-play-state: paused;
}
#boot.leaving {
  pointer-events: none;
}
#boot.leaving .boot-stage {
  transition: opacity 560ms cubic-bezier(0.4, 0, 0.2, 1), transform 680ms cubic-bezier(0.16, 1, 0.3, 1), filter 560ms;
  opacity: 0;
  transform: translateY(-10px) scale(1.04);
  filter: blur(3px);
}
.boot-stage {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 34px;
  width: min(440px, 78vw);
}
.boot-logo {
  position: relative;
  width: 100%;
}
.boot-stage .maple-logo {
  width: 100%;
  height: auto;
  transform-origin: 0 0;
}
.boot-stage .leaf-body {
  animation:
    leaf-fill 640ms cubic-bezier(0.4, 0, 0.2, 1) 480ms both,
    leaf-settle 1150ms cubic-bezier(0.16, 1, 0.3, 1) 60ms both;
}
.boot-stage .leaf-trace {
  fill: none !important;
  stroke: var(--maple-red-bright);
  stroke-width: 16;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation:
    trace-draw 900ms cubic-bezier(0.65, 0, 0.35, 1) 40ms forwards,
    trace-fade 520ms ease 640ms forwards;
}
.boot-stage .leaf-wave {
  animation:
    wave-sweep 720ms cubic-bezier(0.16, 1, 0.3, 1) 760ms both,
    wave-pulse 2400ms ease-in-out 2600ms infinite;
}
.boot-stage .leaf-wave-2 {
  animation-delay: 880ms, 2800ms;
}
.boot-stage .logo-leaf {
  animation: leaf-glow 3200ms ease-in-out 1800ms infinite;
}
.boot-stage .logo-line-1 .logo-letter {
  animation: letter-rise 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(960ms + var(--i, 0) * 55ms);
}
.boot-stage .logo-line-2 .logo-letter {
  animation: letter-fade 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(1000ms + var(--i, 0) * 40ms);
}
/* Light sheen across the finished logo (masked to the logo shapes) */
.boot-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-mask: url("/brand/logo.svg") center / 100% 100% no-repeat;
  mask: url("/brand/logo.svg") center / 100% 100% no-repeat;
  background: linear-gradient(105deg, transparent 35%, #ffffffb3 50%, transparent 65%) no-repeat;
  background-size: 250% 100%;
  background-position: 130% 0;
  opacity: 0;
  animation: sheen 1100ms cubic-bezier(0.65, 0, 0.35, 1) 1700ms both;
}
#boot.leaving .boot-sheen {
  display: none;
}
/* Signal rings radiating from the leaf */
.boot-rings {
  position: absolute;
  left: 21%;
  top: 44%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.boot-rings span {
  position: absolute;
  left: -120px;
  top: -120px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 1.5px solid #ee1c3366;
  opacity: 0;
  animation: ring-out 3000ms cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
.boot-rings span:nth-child(1) { animation-delay: 1800ms; }
.boot-rings span:nth-child(2) { animation-delay: 2800ms; }
.boot-rings span:nth-child(3) { animation-delay: 3800ms; }
/* Indeterminate progress line */
.boot-progress {
  position: relative;
  width: 132px;
  height: 3px;
  border-radius: 3px;
  overflow: hidden;
  background: #ffffff14;
  opacity: 0;
  animation: fade-up 500ms cubic-bezier(0.16, 1, 0.3, 1) 1700ms forwards;
}
.boot-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, #ee1c33, #ff8a95, transparent);
  animation: progress-slide 1500ms cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.boot-caption {
  margin: -18px 0 0;
  font: 500 12px/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.4px;
  color: #a9aed0;
  opacity: 0;
  animation: fade-up 500ms cubic-bezier(0.16, 1, 0.3, 1) 1850ms forwards;
}

/* ---------- Keyframes ---------- */
@keyframes trace-draw {
  to { stroke-dashoffset: 0; }
}
@keyframes trace-fade {
  to { stroke-opacity: 0; }
}
@keyframes leaf-fill {
  from { fill-opacity: 0; }
  to { fill-opacity: 1; }
}
@keyframes leaf-settle {
  from { transform: scale(0.9) rotate(-5deg); transform-origin: 50% 60%; }
  to { transform: none; transform-origin: 50% 60%; }
}
@keyframes leaf-nod {
  0%, 100% { transform: none; transform-origin: 50% 80%; }
  40% { transform: rotate(-4deg) scale(1.03); transform-origin: 50% 80%; }
}
@keyframes wave-sweep {
  from { clip-path: inset(0 100% 0 0); transform: translateX(-5%); }
  to { clip-path: inset(0 0 0 0); transform: none; }
}
@keyframes wave-broadcast {
  0% { transform: none; opacity: 1; }
  35% { transform: translate(5%, -4%); opacity: 0.55; }
  100% { transform: none; opacity: 1; }
}
@keyframes wave-pulse {
  0%, 100% { opacity: 1; transform: none; }
  50% { opacity: 0.8; transform: translate(1.2%, -1.2%); }
}
@keyframes leaf-glow {
  0%, 100% { filter: drop-shadow(0 0 0 #ee1c3300); }
  50% { filter: drop-shadow(0 0 20px #ee1c3359); }
}
@keyframes letter-rise {
  from { opacity: 0; transform: translateY(42%); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes letter-fade {
  from { opacity: 0; transform: translateY(18%); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes sheen {
  0% { opacity: 0; background-position: 130% 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; background-position: -30% 0; }
}
@keyframes ring-out {
  0% { transform: scale(0.35); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: scale(2.1); opacity: 0; }
}
@keyframes progress-slide {
  from { transform: translateX(-110%); }
  to { transform: translateX(260%); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes aurora-a {
  from { transform: translate(-6%, -4%) scale(1); }
  to { transform: translate(10%, 8%) scale(1.15); }
}
@keyframes aurora-b {
  from { transform: translate(6%, 4%) scale(1.1); }
  to { transform: translate(-12%, -6%) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .maple-logo *,
  .maple-logo-mark *,
  #boot,
  #boot * {
    animation: none !important;
  }
  .boot-stage .leaf-trace,
  .boot-rings,
  .boot-sheen,
  .boot-backdrop::before,
  .boot-backdrop::after {
    display: none;
  }
  .boot-progress,
  .boot-caption {
    opacity: 1;
  }
}

