/* ==========================================================================
   Hamida Academy — Floating support hub

   Built by pixel-support.js. One restrained control in the corner furthest
   from the reading edge; a tap opens a compact sheet with the two support
   channels (technical / scientific). No badge, no pulse, no label that grows
   on hover. It is a way out for a stuck student, not a promotion.

   Colour comes from the shared --pa-* tokens, so the sheet follows the light
   and dark themes on the pages that have them and falls back to the light
   values everywhere else.
   ========================================================================== */

:root {
  /* Height of any fixed bottom bar on this page, measured and published by
     pixel-support.js. Zero when there is none. */
  --px-support-bar: 0px;
  /* A page with its own bottom-fixed CTA can raise the control further. */
  --px-support-lift: 0px;
  --px-support-gap: 16px;

  --px-support-fill: #0f7c68;
  --px-support-fill-2: #0b6754;
  --px-support-sheet: #ffffff;
  --px-support-sheet-border: rgba(8, 82, 68, 0.16);
  --px-support-ink: #0f2a26;
  --px-support-ink-2: #3a5a54;
  --px-support-ink-3: #5e7f78;
  --px-support-row: #f4faf7;
  --px-support-row-border: rgba(8, 82, 68, 0.12);
  --px-support-row-hover: #e9f7f2;
  --px-support-shadow: 0 18px 44px rgba(6, 48, 42, 0.22), 0 2px 8px rgba(6, 48, 42, 0.12);
  --px-support-scrim: rgba(6, 29, 25, 0.28);
  --px-support-tech: #0f7c68;
  --px-support-tech-bg: #e9f7f2;
  --px-support-science: #b8732a;
  --px-support-science-bg: #fdf3e6;
  --px-support-wa: #25d366;
}

html[data-theme="dark"] {
  --px-support-fill: #1a9b82;
  --px-support-fill-2: #0f7c68;
  --px-support-sheet: #0f3029;
  --px-support-sheet-border: rgba(255, 255, 255, 0.14);
  --px-support-ink: #ffffff;
  --px-support-ink-2: rgba(255, 255, 255, 0.8);
  --px-support-ink-3: rgba(255, 255, 255, 0.6);
  --px-support-row: #133a32;
  --px-support-row-border: rgba(255, 255, 255, 0.1);
  --px-support-row-hover: #184a40;
  --px-support-shadow: 0 22px 54px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  --px-support-scrim: rgba(2, 12, 10, 0.55);
  --px-support-tech: #9fe3d1;
  --px-support-tech-bg: rgba(26, 155, 130, 0.18);
  --px-support-science: #f0bf7c;
  --px-support-science-bg: rgba(217, 145, 63, 0.18);
}

/* --------------------------------------------------------------------------
   1. Anchor — the fixed corner the whole hub hangs from
   -------------------------------------------------------------------------- */
.px-support {
  position: fixed;
  z-index: 95;
  /* Lower-left. In this RTL layout that is the side away from where the eye
     starts, so it interrupts nothing. */
  left: var(--px-support-gap);
  right: auto;
  bottom: calc(
    var(--px-support-gap) + var(--px-support-bar) + var(--px-support-lift) +
      env(safe-area-inset-bottom, 0px)
  );
  direction: rtl;
  font-family: "Cairo", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* --------------------------------------------------------------------------
   2. The control
   -------------------------------------------------------------------------- */
.px-support__btn {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* Comfortably past the 44px minimum target. */
  min-width: 56px;
  height: 56px;
  padding: 0 18px 0 16px;
  margin: 0;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, var(--px-support-fill) 0%, var(--px-support-fill-2) 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(6, 48, 42, 0.3), 0 2px 6px rgba(6, 48, 42, 0.2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 200ms cubic-bezier(0.22, 0.61, 0.24, 1),
    box-shadow 200ms cubic-bezier(0.22, 0.61, 0.24, 1);
}

.px-support__btn:hover,
.px-support__btn:focus-visible {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(6, 48, 42, 0.36), 0 3px 8px rgba(6, 48, 42, 0.24);
}

.px-support__btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.px-support__btn:active {
  transform: translateY(0);
}

.px-support__glyphs {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-size: 1.45rem;
  line-height: 1;
}

.px-support__glyphs i {
  position: absolute;
  transition: opacity 200ms cubic-bezier(0.22, 0.61, 0.24, 1),
    transform 240ms cubic-bezier(0.22, 0.61, 0.24, 1);
}

.px-support__glyph--close {
  font-size: 1.15rem;
  opacity: 0;
  transform: rotate(-60deg) scale(0.6);
}

.px-support.is-open .px-support__glyph--open {
  opacity: 0;
  transform: rotate(60deg) scale(0.6);
}

.px-support.is-open .px-support__glyph--close {
  opacity: 1;
  transform: none;
}

.px-support__label {
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   3. The sheet — anchored above the control, never wider than the phone
   -------------------------------------------------------------------------- */
.px-support__scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--px-support-scrim);
  opacity: 0;
  transition: opacity 220ms cubic-bezier(0.22, 0.61, 0.24, 1);
}

.px-support__scrim[hidden],
.px-support__sheet[hidden] {
  display: none;
}

.px-support.is-open .px-support__scrim {
  opacity: 1;
}

.px-support__sheet {
  position: absolute;
  z-index: 2;
  left: 0;
  bottom: calc(100% + 12px);
  width: min(340px, calc(100vw - (2 * var(--px-support-gap))));
  padding: 16px;
  color: var(--px-support-ink);
  background: var(--px-support-sheet);
  border: 1px solid var(--px-support-sheet-border);
  border-radius: 20px;
  box-shadow: var(--px-support-shadow);
  transform-origin: 12% 100%;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 220ms cubic-bezier(0.22, 0.61, 0.24, 1),
    transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.px-support.is-open .px-support__sheet {
  opacity: 1;
  transform: none;
}

.px-support__head {
  position: relative;
  padding-inline-end: 44px;
  margin-bottom: 12px;
}

.px-support__title {
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--px-support-ink);
}

.px-support__sub {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--px-support-ink-3);
}

.px-support__close {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1rem;
  color: var(--px-support-ink-3);
  background: var(--px-support-row);
  border: 1px solid var(--px-support-row-border);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.px-support__close:hover,
.px-support__close:focus-visible {
  color: var(--px-support-ink);
  background: var(--px-support-row-hover);
}

.px-support__list {
  display: grid;
  gap: 8px;
}

.px-support__opt {
  display: flex;
  align-items: center;
  gap: 12px;
  /* Thumb-sized rows. */
  min-height: 64px;
  padding: 10px 12px;
  color: var(--px-support-ink);
  text-decoration: none;
  background: var(--px-support-row);
  border: 1px solid var(--px-support-row-border);
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms cubic-bezier(0.22, 0.61, 0.24, 1),
    border-color 160ms cubic-bezier(0.22, 0.61, 0.24, 1),
    transform 160ms cubic-bezier(0.22, 0.61, 0.24, 1);
}

.px-support__opt:hover,
.px-support__opt:focus-visible {
  color: var(--px-support-ink);
  background: var(--px-support-row-hover);
  border-color: var(--px-support-sheet-border);
  transform: translateY(-1px);
}

.px-support__opt:focus-visible {
  outline: 3px solid var(--px-support-fill);
  outline-offset: 2px;
}

.px-support__ico {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  border-radius: 13px;
}

.px-support__opt--tech .px-support__ico {
  color: var(--px-support-tech);
  background: var(--px-support-tech-bg);
}

.px-support__opt--science .px-support__ico {
  color: var(--px-support-science);
  background: var(--px-support-science-bg);
}

.px-support__text {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.px-support__name {
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.35;
}

.px-support__hint {
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--px-support-ink-3);
}

.px-support__num {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--px-support-ink-2);
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.px-support__wa {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  font-size: 1.2rem;
  color: #fff;
  background: var(--px-support-wa);
  border-radius: 999px;
}

/* Pages whose own fixed bottom bar the control has to clear. These bars are
   page-specific, so rather than teaching the module about each one, each page
   declares its bar with data-px-bottombar (measured at runtime) and this block
   covers the ones that were already built without it. */
.pxe-bottombar ~ .px-support,
.lp-actions ~ .px-support {
  --px-support-lift: 8px;
}

/* Slightly smaller on the narrowest phones, where the corner is scarcer:
   the label folds away and the control becomes a plain circle. */
@media (max-width: 380px) {
  .px-support {
    --px-support-gap: 12px;
  }

  .px-support__btn {
    min-width: 52px;
    height: 52px;
    padding: 0;
  }

  .px-support__label {
    display: none;
  }

  .px-support__sheet {
    padding: 14px;
  }
}

/* Printing a page should not print a chat control. */
@media print {
  .px-support {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .px-support__btn,
  .px-support__sheet,
  .px-support__scrim,
  .px-support__opt,
  .px-support__glyphs i {
    transition: none;
  }

  .px-support__btn:hover,
  .px-support__btn:focus-visible,
  .px-support__opt:hover {
    transform: none;
  }
}
