/* ==========================================================================
   bw-modal.css  —  Reusable CSS-only modal shell (no JavaScript required)

   Sequence on open:  page dims -> card fades in from the top -> "Loading"
   spinner -> card expands downward into the full modal.

   HOW TO REUSE (per modal):
     1. Put a hidden checkbox + overlay as SIBLINGS anywhere in the page:
          <input type="checkbox" id="bwm-YOURNAME" class="bwm-toggle">
          <div class="bwm-overlay"> ... (see sweepstakes markup) ... </div>
     2. Open it from ANY section with:  <label for="bwm-YOURNAME">Open</label>
     3. Every close control is also a label pointing at the same id.
   Each modal needs its own unique id. One CSS file serves all of them.

   Timing knobs (override on .bwm-overlay or :root):
     --bwm-intro   dim + drop-in duration
     --bwm-load    how long "Loading" is shown (a fixed minimum, not a real load check)
     --bwm-expand  expand duration
   ========================================================================== */

:root {
  --bwm-dim: rgba(16, 18, 20, 0.55);
  --bwm-width: 768px;
  --bwm-gap: 24px;
  --bwm-loader-h: 82px;
  --bwm-intro: 0.25s;
  --bwm-load: 0.3s;
  --bwm-expand: 0.4s;
}

/* Hidden but keyboard-focusable checkbox that holds open/closed state */
.bwm-toggle {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Lock page scroll while any modal is open */
html:has(.bwm-toggle:checked),
body:has(.bwm-toggle:checked) { overflow: hidden; }

/* ----- Overlay ----- */
.bwm-overlay {
  --bwm-max-h: calc(100vh - (var(--bwm-gap) * 2));
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: var(--bwm-gap);
  box-sizing: border-box;
}
.bwm-toggle:checked ~ .bwm-overlay { display: flex; }

/* Dimmed backdrop (also the click-outside-to-close target) */
.bwm-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  cursor: default;
  background: var(--bwm-dim);
  animation: bwm-fade var(--bwm-intro) ease-out both;
}

/* ----- Modal card ----- */
.bwm-modal {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: var(--bwm-width);
  max-width: 100%;
  max-height: var(--bwm-loader-h);          /* starts as the loading bar */
  overflow: hidden;
  background: #FFFFFF;
  border-radius: 2px;
  box-shadow: 0 0 1px rgba(9, 30, 66, 0.31), 0 8px 12px rgba(9, 30, 66, 0.15);
  color: #101214;
  font-family: 'Charlie Text', sans-serif;
  animation:
    bwm-drop var(--bwm-intro) cubic-bezier(0.2, 0.7, 0.2, 1) both,
    bwm-expand var(--bwm-expand) cubic-bezier(0.3, 0.1, 0.2, 1)
      calc(var(--bwm-intro) + var(--bwm-load)) both;
}
.bwm-modal *, .bwm-modal *::before, .bwm-modal *::after { box-sizing: border-box; }

/* ----- Loading bar ----- */
.bwm-loader {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--bwm-loader-h);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #FFFFFF;
  animation: bwm-loader-out 0.15s ease-in calc(var(--bwm-intro) + var(--bwm-load)) both;
}
/* Self-contained spinner (no dependency on Font Awesome being loaded on the page).
   Same motion as FA's fa-spin: one full turn every 2s, linear. */
.bwm-spinner { width: 22px; height: 22px; flex: none; animation: bwm-spin 2s linear infinite; }

/* Atlassian's actual spinner: Font Awesome Pro "spinner" (U+F110), loaded straight from the
   Font Awesome kit CDN. Uses its own font-family name so it can't clash with the site's FA.
   Only the spinner's character range is requested. */
@font-face {
  font-family: "BWM Spinner Icon";
  font-style: normal;
  font-weight: 900;
  font-display: block;
  src: url("https://ka-p.fontawesome.com/releases/v6.7.2/webfonts/pro-fa-solid-900-1.woff2") format("woff2");
  unicode-range: U+F10E-F112;
}
.bwm-spinner-icon {
  display: inline-block;
  flex: none;
  font-family: "BWM Spinner Icon";
  font-weight: 900;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  color: #101214;
  animation: bwm-spin 2s linear infinite;
}
.bwm-spinner-icon::before { content: "\f110"; }
.bwm-loader-text {
  font-family: 'Charlie Display', sans-serif;
  font-weight: 600;
  font-size: 22px;
  line-height: 26px;
  color: #101214;
}
.bwm-loader-close {
  position: absolute;
  top: 50%;
  right: 24px;
  width: 24px; height: 24px;
  margin-top: -12px;
  display: flex;
  cursor: pointer;
}
.bwm-loader-close svg { width: 24px; height: 24px; }

/* ----- Scrolling body (revealed after loading) ----- */
.bwm-scroll {
  position: relative;
  max-height: var(--bwm-max-h);
  overflow-y: auto;
  animation: bwm-content-in 0.3s ease-out
    calc(var(--bwm-intro) + var(--bwm-load) + 0.1s) both;
}

.bwm-hero {
  display: block;
  width: 100%;
  height: 297px;
  object-fit: cover;
  object-position: center;
  background: #DFE1E6;
}

/* Back + close controls (labels, so they work without JS) */
.bwm-back {
  position: absolute;
  top: 16px; left: 20px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 80px; height: 32px;
  padding: 8px 10px 8px 0;
  background: #FFFFFF;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Charlie Text', sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  color: #1868DB;
}
.bwm-back svg { width: 24px; height: 24px; flex: none; }
.bwm-close {
  position: absolute;
  top: 20px; right: 20px;
  z-index: 2;
  display: flex;
  width: 24px; height: 24px;
  padding: 2.4px;
  background: #FFFFFF;
  border-radius: 36px;
  cursor: pointer;
}
.bwm-close svg { width: 19.2px; height: 19.2px; }
.bwm-back:hover, .bwm-close:hover { background: #E9F2FF; }

.bwm-content {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 40px 68px 68px;
}

/* ----- Keyframes ----- */
@keyframes bwm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bwm-drop {
  from { opacity: 0; transform: translateY(-24px); }
  to   { opacity: 1; transform: none; }
}
@keyframes bwm-expand {
  from { max-height: var(--bwm-loader-h); }
  to   { max-height: var(--bwm-max-h); }
}
@keyframes bwm-spin { to { transform: rotate(360deg); } }
@keyframes bwm-loader-out {
  from { opacity: 1; visibility: visible; }
  to   { opacity: 0; visibility: hidden; }
}
@keyframes bwm-content-in {
  from { opacity: 0; visibility: hidden; }
  to   { opacity: 1; visibility: visible; }
}

/* ----- Mobile: full-screen ----- */
@media (max-width: 640px) {
  .bwm-overlay { --bwm-gap: 0px; }
  .bwm-modal { border-radius: 0; }
  .bwm-hero { height: 200px; }
  .bwm-content { padding: 32px 24px 48px; }
}

/* ----- Reduced motion: skip the loading sequence, show modal immediately ----- */
@media (prefers-reduced-motion: reduce) {
  .bwm-backdrop, .bwm-modal, .bwm-scroll { animation: none; }
  .bwm-modal { max-height: var(--bwm-max-h); }
  .bwm-loader { display: none; }
}
