/* ========================================
   XCEED WAITING ROOM STYLES
   Dark & Light Mode Support

   Colours, type and radii follow the XCEED design tokens shared by b2cweb, jukebox2, checkout
   and widget-b2c (src/styles/theme/variables.css there). The token each value comes from is
   noted next to it, so a brand change can be mapped across by name.
======================================== */

/* Silka, XCEED's typeface, served from this bucket (s3/fonts/, copied from
   b2cweb/src/styles/fonts/). Not from static.xceed.me: the copies there are b2cweb build output
   with content-hashed names and CORS limited to https://xceed.me. Needs `font-src 'self'` in
   the CloudFront CSP (terraform/modules/queue-system/cloudfront.tf). */
@font-face {
  font-family: 'Silka';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/silka-regular-webfont.woff2') format('woff2');
}

@font-face {
  font-family: 'Silka';
  font-weight: 500;
  font-display: swap;
  src: url('fonts/silka-medium-webfont.woff2') format('woff2');
}

@font-face {
  font-family: 'Silka';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/silka-semibold-webfont.woff2') format('woff2');
}

:root {
  /* Dark Mode (Default) */
  --bg-primary: #000000;          /* neutrals-100 */
  --bg-secondary: #000000;        /* neutrals-100: inner blocks are outlined, not filled */
  --bg-card: #000000;             /* neutrals-100 */
  --text-primary: #ffffff;        /* neutrals-0 */
  --text-secondary: #a8a8b2;      /* neutrals-30 */
  --text-muted: #8e8e99;          /* neutrals-40 */
  --border-color: #242426;        /* neutrals-85 */
  --accent-primary: #ff1e00;      /* fireRed-50, XCEED's one accent */
  --accent-hover: #ff7866;        /* fireRed-30 */
  --success: #00c537;             /* green-50 */
  --progress-bg: #242426;         /* neutrals-85 */

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Border Radius (radius-100 / -300 / -400; nothing above 12px) */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Variables */
body:not(.dark-mode) {
  --bg-primary: #ffffff;          /* neutrals-0 */
  --bg-secondary: #ffffff;        /* neutrals-0 */
  --bg-card: #ffffff;             /* neutrals-0 */
  --text-primary: #000000;        /* neutrals-100 */
  --text-secondary: #5f5f66;      /* neutrals-60 */
  --text-muted: #5f5f66;          /* neutrals-60: neutrals-50 is under 4.5:1 on white */
  --border-color: #e4e4eb;        /* neutrals-8 */
  --accent-primary: #ff1e00;      /* fireRed-50 */
  --accent-hover: #991200;        /* fireRed-70 */
  --success: #00c537;             /* green-50 */
  --progress-bg: #f4f4f7;         /* neutrals-3 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ========================================
   RESET & BASE STYLES
======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Silka', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  transition: var(--transition);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Form controls don't inherit the page font by default, so the language and theme buttons
   would otherwise render in the browser's system font. */
button {
  font-family: inherit;
}

/* ========================================
   CONTAINER & LAYOUT
======================================== */

.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   HEADER
======================================== */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xl);
}

/* The wordmark is an inline SVG whose paths fill with currentColor, so `color` sets its colour
   in both themes. Width AND height are explicit: older Safari sizes an inline SVG without a
   width at 300px. 120x22 keeps the 175:32 viewBox ratio. */
.logo {
  display: block;
  flex-shrink: 0;
  width: 120px;
  height: 22px;
  color: var(--text-primary);
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.sun-icon,
.moon-icon {
  position: absolute;
  transition: opacity 0.3s, transform 0.3s;
}

.dark-mode .sun-icon {
  opacity: 0;
  transform: rotate(180deg);
}

.dark-mode .moon-icon {
  opacity: 1;
  transform: rotate(0deg);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* Language Selector Dropdown */
.language-selector {
  position: relative;
}

.lang-current {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 70px;
}

.lang-current:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
}

.lang-current svg {
  transition: transform 0.3s;
}

.lang-current.open svg {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 1000;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s, transform 0.2s;
}

.lang-dropdown.hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.lang-option {
  width: 100%;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-color);
}

.lang-option:last-child {
  border-bottom: none;
}

.lang-option:hover {
  background: var(--bg-secondary);
  color: var(--accent-primary);
}

.lang-option.active {
  background: rgba(255, 30, 0, 0.1); /* fireRed-50 at 10% */
  color: var(--accent-primary);
}

.lang-option:active {
  transform: scale(0.98);
}

body:not(.dark-mode) .sun-icon {
  opacity: 1;
  transform: rotate(0deg);
}

body:not(.dark-mode) .moon-icon {
  opacity: 0;
  transform: rotate(-180deg);
}

/* ========================================
   MAIN CONTENT
======================================== */

.main-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.queue-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  text-align: center;
}

/* ========================================
   STATUS ICON
======================================== */

.status-icon {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* XCEED's "waiting" loader: the animation b2cweb, bouncer and checkout show while something is
   pending (jukebox2 WAITING_LOADER_*_ASSET), from images.xceed.me (already in the CSP img-src).
   A CSS background rather than <img>, because the browser only downloads the background of the
   rule that applies: one ~125 KB animation per visit, not both. image-set() serves the WebP;
   the plain url() before it is the GIF for browsers without image-set(). Light theme: black ink.
   Dark theme: white mark on a black square that blends into the page. */
.status-icon {
  background: center / contain no-repeat;
  background-image: url('https://images.xceed.me/static/brand/auth/waiting_white.gif');
  background-image: image-set(
    url('https://images.xceed.me/static/brand/auth/waiting_white.webp') type('image/webp'),
    url('https://images.xceed.me/static/brand/auth/waiting_white.gif') type('image/gif')
  );
}

.dark-mode .status-icon {
  background-image: url('https://images.xceed.me/static/brand/auth/waiting_black.gif');
  background-image: image-set(
    url('https://images.xceed.me/static/brand/auth/waiting_black.webp') type('image/webp'),
    url('https://images.xceed.me/static/brand/auth/waiting_black.gif') type('image/gif')
  );
}


/* ========================================
   TITLES & TEXT
======================================== */

.queue-title {
  font-size: 1.625rem; /* headlines-l */
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  color: var(--text-primary);
}

.queue-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
}

/* ========================================
   POSITION INFO
======================================== */

.position-container {
  display: grid;
  /* Columns follow the visible cards: #opens-card is hidden for most of a queue's life, and a
     fixed `1fr 1fr` left the position card alone in the left half on tablet and desktop. */
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--spacing-md);
  margin: var(--spacing-lg) 0;
}

.position-container.hidden {
  display: none;
}

.position-card,
.opens-card {
  padding: var(--spacing-sm) 0;
}

/* There is deliberately NO bare `.hidden { display: none }` rule in this file — `.hidden` is
   defined per component, because `.lang-dropdown.hidden` animates via opacity/transform and a
   global display:none would break it. So a new element that needs hiding needs its own rule,
   or `classList.add('hidden')` silently does nothing. */
.opens-card.hidden {
  display: none;
}

.position-label,
.opens-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.position-number {
  font-size: 3rem;
  font-weight: 600;
  color: var(--accent-primary);
  line-height: 1;
}

.opens-time {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: var(--spacing-xs);
}

/* ========================================
   PROGRESS BAR
======================================== */

.progress-wrapper {
  margin-bottom: var(--spacing-lg);
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--progress-bg);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  position: relative;
  overflow: hidden;
}


/* ========================================
   INFO MESSAGE
======================================== */

.info-message {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-md) 0 0;
  margin-bottom: var(--spacing-sm);
  text-align: left;
}

.info-message svg {
  color: var(--accent-primary);
  flex-shrink: 0;
  margin-top: 2px;
}

.info-message p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

.keep-open {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: left;
}

/* ========================================
   FOOTER
======================================== */

.footer {
  padding-top: var(--spacing-lg);
  text-align: center;
  border-top: 1px solid var(--border-color);
  margin-top: var(--spacing-lg);
}

.footer p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 600px) {
  .container {
    padding: var(--spacing-md);
  }

  .queue-card {
    padding: var(--spacing-lg);
  }

  .queue-title {
    font-size: 1.375rem; /* headlines-m */
  }

  .queue-subtitle {
    font-size: 1rem;
  }

  .position-container {
    grid-auto-flow: row;
  }

  .position-number {
    font-size: 2.5rem;
  }

  .opens-time {
    font-size: 1.25rem;
  }

  .status-icon {
    width: 56px;
    height: 56px;
  }
}

/* ========================================
   ANIMATIONS & TRANSITIONS
======================================== */

.queue-card {
  animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Smooth transitions for theme switching */
* {
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* Respect the OS "reduce motion" setting: the entrance animation stops. (The loader is an
   animated image, which CSS cannot pause.) */
@media (prefers-reduced-motion: reduce) {
  .queue-card {
    animation: none;
  }
}

/* ========================================
   EVENT CARD STYLES
======================================== */

.event-card {
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-xl);
  border-bottom: 1px solid var(--border-color);
  opacity: 1;
  max-height: 1000px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.event-card.hidden {
  opacity: 0;
  max-height: 0;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.event-image {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

/* There is deliberately no bare `.hidden { display: none }` in this stylesheet — the class
   is only ever defined per component, because .lang-dropdown.hidden animates via
   opacity/transform and a global display:none would break that. So each element the JS can
   hide needs its own rule; showEventCard() toggles these two when a queue's config has no
   image or no start time. */
.event-image.hidden {
  display: none;
}

.event-details {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.event-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--spacing-xs) 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.event-date {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.event-date.hidden {
  display: none;
}

.event-date svg {
  flex-shrink: 0;
  opacity: 0.7;
  color: var(--accent-primary);
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .event-card {
    flex-direction: row;
    gap: var(--spacing-sm);
    padding-bottom: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
  }

  .event-image {
    width: 80px;
    height: 80px;
  }

  .event-name {
    font-size: 1rem;
  }

  .event-date {
    font-size: 0.8rem;
  }
}
