/* Rushd theme: the masterclass popup that rushd-site's Live countdown banner opens
   (src/frontend/live-popup.js). Everything between this note and the "WordPress only" section is
   website/css/live-masterclass-popup.css, unchanged. Change the two together. Loaded on every page
   with the banner block (functions.php). */
/* The Free Live Masterclass popup (js/live-masterclass-popup.js).

   The script loads this file only when the popup is about to open. Classes are prefixed lmp- so
   nothing here can restyle a page. The values are the final design's (masterclass-popup.html):
   the photo on the left with the name on it, and the copy, the countdown and the button on the
   right. Fonts and colours are the site's tokens (css/typography.css, css/colors.css): Plus
   Jakarta Sans, where the design names Movatif, which the site does not have, and the navy and
   gold of the /live/ campaign. The light gold #f3d88e, the red dot #e5484d and the greys #b9c2d0
   and #d5dbe5 have no token, so they are written as css/live-campaign.css writes them. Sizes
   inside the popup are rem, so a larger default font size scales it; breakpoints are px like the
   site's other stylesheets.

   Layouts:
   - Phones: the photo on top with the name on it, then the copy, centred. That part scrolls when
     it is too tall.
   - 640px and up, and any landscape screen under 500px tall: the photo on the left, the copy on
     the right. The copy scrolls on its own when it is too tall.
   In every layout the button, the date and "Maybe later" sit in the card's foot, outside what
   scrolls, so the button is always on screen. */

/* The <dialog> is the whole screen and the card is centred in it, so a tap anywhere outside the
   card lands on the dialog itself: that is the backdrop tap. The padding is the gap to the screen
   edge, and the safe areas keep the card clear of notches and the home indicator. */
.lmp {
  --lmp-edge: 1rem;
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding:
    max(var(--lmp-edge), env(safe-area-inset-top))
    max(var(--lmp-edge), env(safe-area-inset-right))
    max(var(--lmp-edge), env(safe-area-inset-bottom))
    max(var(--lmp-edge), env(safe-area-inset-left));
  border: 0;
  background: transparent;
  color: var(--cream-hi);
  overflow: hidden;
  color-scheme: dark;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.5;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Only an open dialog is laid out: the browser's own rule hides a closed one. */
.lmp[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The script focuses the dialog itself when it opens; Tab then reaches the close button. */
.lmp:focus {
  outline: none;
}

.lmp::backdrop {
  background: rgba(6, 14, 26, 0.62);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.lmp *,
.lmp *::before,
.lmp *::after {
  box-sizing: border-box;
}

.lmp-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 25rem);
  max-height: 100%;
  max-height: min(100%, calc(100dvh - 2rem));
  overflow: hidden;
  border: 1px solid rgba(231, 192, 99, 0.35);
  border-radius: 1.375rem;
  background: var(--navy-3);
  box-shadow: 0 2.5rem 5.625rem -1.875rem rgba(0, 0, 0, 0.85);
}

/* Phones: the photo and the copy. This is what scrolls. */
.lmp-scroll {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "photo"
    "body";
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lmp-close {
  position: absolute;
  z-index: 3;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.375rem;
  height: 2.375rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(10, 22, 38, 0.6);
  color: var(--cream-hi);
  cursor: pointer;
  transition: background 0.2s;
}

/* Drawn at 38px, as designed; a finger gets 46px. */
.lmp-close::after {
  content: "";
  position: absolute;
  inset: -0.25rem;
  border-radius: 50%;
}

.lmp-close:hover {
  background: rgba(231, 192, 99, 0.25);
}

.lmp-close:focus-visible {
  outline: 3px solid #f3d88e;
  outline-offset: 2px;
}

.lmp-close svg {
  width: 1rem;
  height: 1rem;
}

/* ---- The photo, and the name on it ---- */

.lmp-media {
  grid-area: photo;
  position: relative;
  z-index: 0;
  height: 13.75rem;
  height: min(13.75rem, 32dvh);
  min-height: 6.25rem;
  overflow: hidden;
}

/* Phones: the photo fades into the card's navy at the bottom, under the name. */
.lmp-photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 14%;
  filter: contrast(1.03) brightness(1.05);
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
}

.lmp-speaker {
  grid-area: photo;
  align-self: end;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
  padding: 2.5rem 1.125rem 1rem;
  background: linear-gradient(180deg, rgba(10, 22, 38, 0), rgba(10, 22, 38, 0.85));
}

.lmp-name {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #ffffff;
  overflow-wrap: break-word;
}

.lmp-role {
  margin: 0;
  font-size: 0.71875rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.4;
  color: #f3d88e;
}

/* ---- The copy: phones centre it ---- */

.lmp-body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.125rem;
  min-width: 0;
  padding: 0.75rem 1.375rem 0.25rem;
  text-align: center;
}

.lmp-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  max-width: 100%;
  margin: 0;
  padding: 0.4375rem 0.875rem 0.4375rem 0.6875rem;
  border: 1.5px solid var(--gold-hero);
  border-radius: 999px;
  background: rgba(231, 192, 99, 0.14);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.3;
  color: #f3d88e;
}

.lmp-dot {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #e5484d;
}

.lmp-title {
  align-self: stretch;
  margin: 0;
  font-family: inherit;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.03em;
  color: var(--cream-hi);
  text-wrap: balance;
  overflow-wrap: break-word;
}

/* The gold sentence, a gradient as on the /live/ page's headline (.rl-accent). */
.lmp-accent {
  background: linear-gradient(100deg, var(--gold), #f3d88e 45%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* The time left, in the header countdown's units. Gone once the masterclass starts. */
.lmp-countdown {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  max-width: 100%;
}

.lmp-countdown[hidden] {
  display: none;
}

.lmp-unit {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  width: 3.875rem;
  min-width: 0;
  padding: 0.5rem 0 0.4375rem;
  border: 1px solid rgba(231, 192, 99, 0.28);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
}

.lmp-unit-value {
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #f3d88e;
}

.lmp-unit-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.2;
  color: #b9c2d0;
}

/* ---- The foot: the button, the date and "Maybe later" ---- */

.lmp-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.375rem 1.25rem;
  background: var(--navy-3);
}

/* On phones the copy scrolls under the foot: fade it out instead of cutting it off. */
.lmp-actions::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  height: 1rem;
  background: linear-gradient(180deg, rgba(10, 22, 38, 0), var(--navy-3));
  pointer-events: none;
}

.lmp-cta {
  display: flex;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  min-height: 3.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #f3d88e, var(--gold));
  box-shadow: 0 1rem 2.5rem -0.875rem rgba(216, 180, 99, 0.6);
  color: var(--navy-3);
  font-size: 0.96875rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.2s;
}

.lmp-cta:hover {
  color: var(--navy-3);
  box-shadow: 0 0 0 4px rgba(243, 216, 142, 0.22), 0 1.125rem 2.75rem -0.75rem rgba(231, 192, 99, 0.9);
}

.lmp-cta:focus-visible {
  outline: 3px solid #f3d88e;
  outline-offset: 3px;
}

/* Written "Saturday, 21 November · 1 PM KSA" and set in capitals here, so a screen reader reads
   words, not letters. */
.lmp-when {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-align: center;
  text-transform: uppercase;
  color: #d5dbe5;
}

.lmp-later {
  position: relative;
  margin: 0.375rem 0 0;
  padding: 0.125rem 0.375rem;
  border: 0;
  background: none;
  color: var(--fg-6);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Small words, a finger-sized target. */
.lmp-later::after {
  content: "";
  position: absolute;
  inset: -0.75rem -0.5rem;
}

.lmp-later:hover {
  color: var(--cream-hi);
}

.lmp-later:focus-visible {
  outline: 2px solid #f3d88e;
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* Under 300px wide only happens with browser zoom, such as a phone at 200%. The name moves below
   the photo, the countdown goes to two rows, and the button's words get tighter. */
@media (max-width: 299px) {
  .lmp-scroll {
    grid-template-areas:
      "photo"
      "speaker"
      "body";
  }
  .lmp-speaker {
    grid-area: speaker;
    padding: 0.5rem 0.75rem 0;
    background: none;
    text-align: center;
  }
  .lmp-name {
    font-size: 1.125rem;
  }
  .lmp-body,
  .lmp-actions {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }
  .lmp-title {
    font-size: 1.375rem;
  }
  .lmp-countdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .lmp-unit {
    width: auto;
  }
  .lmp-cta {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
  }
}

/* Narrow phones: the date stays on one line. */
@media (max-width: 359px) {
  .lmp-when {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-wrap: balance;
  }
}

/* Short phones, such as 320 by 568: a shorter photo and tighter copy, so the countdown is not
   under the foot. Portrait only: a phone turned on its side has the two-column layout. */
@media (max-width: 639px) and (max-height: 640px) and (orientation: portrait) {
  .lmp-media {
    height: min(13.75rem, 26dvh);
  }
  .lmp-body {
    gap: 0.875rem;
  }
}

/* ---- Two columns: tablets and up, and short landscape screens ---- */

@media (min-width: 640px), (orientation: landscape) and (max-height: 499px) {
  /* The photo fills the left column; the copy and the foot share the right one. */
  .lmp-card {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "photo body"
      "photo actions";
  }
  .lmp-scroll {
    display: contents;
  }
  .lmp-media {
    height: auto;
    min-height: 0;
  }
  .lmp-photo {
    object-position: 50% 18%;
    -webkit-mask-image: none;
    mask-image: none;
  }
  /* The photo fades into the copy's navy on its right edge. */
  .lmp-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(10, 22, 38, 0) 55%, var(--navy-3) 100%);
    pointer-events: none;
  }
  .lmp-body {
    position: relative;
    z-index: 1;
    align-items: flex-start;
    text-align: left;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  /* Spare height goes above the copy, so it sits on the button. An auto margin, unlike
     justify-content, keeps the top reachable when the copy has to scroll. */
  .lmp-body > :first-child {
    margin-top: auto;
  }
  .lmp-countdown {
    justify-content: flex-start;
  }
  .lmp-actions {
    grid-area: actions;
    background: none;
  }
  .lmp-actions::before {
    display: none;
  }
}

/* ---- Tablets and desktops: 640px and up, 780px wide at most ---- */

@media (min-width: 640px) {
  .lmp {
    --lmp-edge: 1.5rem;
  }
  .lmp-card {
    width: min(92vw, 48.75rem, 100%);
    min-height: min(27.5rem, 100%);
    max-height: min(100%, calc(100dvh - 3rem));
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }
  .lmp-body {
    padding: 2.375rem 2.125rem 0 1.625rem;
  }
  /* 34px from about 880px; smaller below, so "accountability!" fits the narrower column. */
  .lmp-title {
    font-size: clamp(1.75rem, 0.75rem + 2.5vw, 2.125rem);
  }
  .lmp-actions {
    padding: 1.375rem 2.125rem 2rem 1.625rem;
  }
}

/* ---- Landscape phones, and any screen under 500px tall: smaller everything ---- */

@media (orientation: landscape) and (max-height: 499px) {
  .lmp {
    --lmp-edge: 0.75rem;
  }
  .lmp-card {
    width: min(100%, 46rem);
    min-height: 0;
    max-height: min(100%, calc(100dvh - 1.5rem));
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    border-radius: 1.125rem;
  }
  .lmp-close {
    top: 0.5rem;
    right: 0.5rem;
  }
  .lmp-body {
    gap: 0.625rem;
    padding: 1rem 1.25rem 0;
  }
  .lmp-eyebrow {
    padding: 0.3125rem 0.75rem 0.3125rem 0.625rem;
    font-size: 0.6875rem;
  }
  .lmp-title {
    font-size: clamp(1.25rem, 0.5rem + 2vw, 1.625rem);
  }
  .lmp-unit {
    width: 3.25rem;
    padding: 0.375rem 0 0.3125rem;
    border-radius: 0.625rem;
  }
  .lmp-unit-value {
    font-size: 1.125rem;
  }
  .lmp-unit-label {
    font-size: 0.5625rem;
  }
  .lmp-actions {
    gap: 0.375rem;
    padding: 0.75rem 1.25rem;
  }
  .lmp-cta {
    min-height: 3rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  .lmp-when {
    font-size: 0.75rem;
  }
  .lmp-later {
    margin-top: 0;
  }
  .lmp-speaker {
    padding: 2rem 0.875rem 0.75rem;
  }
  .lmp-name {
    font-size: 1.125rem;
  }
  .lmp-role {
    font-size: 0.625rem;
  }
}

/* ---- Motion: only when the visitor allows it ---- */

@media (prefers-reduced-motion: no-preference) {
  .lmp[open] .lmp-card {
    animation: lmp-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
  .lmp[open]::backdrop {
    animation: lmp-fade-in 0.3s ease both;
  }
  .lmp.lmp-closing .lmp-card {
    animation: lmp-out 0.18s ease-in both;
  }
  .lmp.lmp-closing::backdrop {
    animation: lmp-fade-out 0.18s ease-in both;
  }
  .lmp-dot {
    animation: lmp-dot 1.6s infinite;
  }
  .lmp-cta:hover {
    transform: translateY(-2px);
  }
}

@keyframes lmp-in {
  from {
    opacity: 0;
    transform: translateY(1rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes lmp-out {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(0.5rem) scale(0.98);
  }
}

@keyframes lmp-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes lmp-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* The dot's ring, as in the design. */
@keyframes lmp-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(229, 72, 77, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(229, 72, 77, 0);
  }
}

/* ---- WordPress only (not in website/css/live-masterclass-popup.css) ---- */

/* The static site's tokens (css/colors.css, css/typography.css) that the rules above use. The
   theme has its own (theme.json), so the popup carries these. */
.lmp {
  --navy-3: #0A1626;
  --cream-hi: #FCFAF4;
  --gold: #C99A3F;
  --gold-hero: #E7C063;
  --fg-6: #8A94A6;
  --font-display: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
