/* ============================================================================
   Elliot X Games — main stylesheet
   Palette taken directly from the logo:
     --c-blue    #3b9fd5   logo sky-blue background
     --c-gold    #f5c518   "ELLIOT X" yellow text
     --c-white   #f0f0f0   "GAMES" white text
     --c-diamond #5de8db   diamond sword teal (links / accents)

   Every foreground/background pair listed here meets WCAG 2.2 AA:
     ≥ 4.5:1 for normal text, ≥ 3:1 for large text and UI components.
   ============================================================================ */

/* ── CUSTOM PROPERTIES ──────────────────────────────────────────────────── */
:root {
  /* Colours */
  --c-bg: #0e2233; /* page body — very dark navy                  */
  --c-surface: #132a3d; /* cards / alternate sections                  */
  --c-surface-2: #1a3d5c; /* raised surfaces — header, footer, chat bg   */
  --c-blue: #3b9fd5; /* logo sky-blue — borders, accents            */
  --c-gold: #f5c518; /* logo gold — headings, primary buttons       */
  --c-diamond: #5de8db; /* diamond teal — links (11:1 on --c-bg)       */
  --c-text: #f0f0f0; /* body text  (~14:1 on --c-bg)                */
  --c-text-muted: #a8c4d8; /* secondary text (~5:1 on --c-bg)             */
  --c-focus: #f5c518; /* keyboard focus ring (gold, high contrast)   */

  /* Typography */
  --font-display: "Bangers", "Arial Black", cursive;
  --font-body: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 4rem;

  /* Layout */
  --max-width: 1100px;
  --chat-width: 720px;
  --radius: 6px;
}

/* ── RESET & BASE ───────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100dvh;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── ACCESSIBILITY UTILITIES ────────────────────────────────────────────── */

/* Hides content visually while keeping it accessible to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link — only visible when focused; bypasses repeated nav (WCAG 2.4.1) */
.skip-link {
  position: absolute;
  top: -9999px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--c-gold);
  color: #1a1a1a;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  text-decoration: none;
  z-index: 9999;
  white-space: nowrap;
}
.skip-link:focus {
  top: 0.75rem;
}

/* Global focus indicator — gold ring, clearly visible (WCAG 2.4.7, 2.4.11) */
:focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 3px;
  border-radius: var(--radius);
}

/* ── LAYOUT HELPERS ─────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-lg);
}

/* ── TYPOGRAPHY ─────────────────────────────────────────────────────────── */
h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: 1px;
  line-height: 1.1;
}

h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: var(--c-gold);
  margin-bottom: var(--space-lg);
}

a {
  color: var(--c-diamond);
  text-decoration: underline;
  text-underline-offset: 3px;
}
a:hover {
  color: var(--c-text);
}

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 1px;
  text-decoration: none;
  cursor: pointer;
  border: 3px solid transparent;
  transition:
    background-color 0.15s,
    border-color 0.15s;
  line-height: 1.2;
}

/* Gold button — dark text for 11.5:1 contrast */
.btn-primary {
  background-color: var(--c-gold);
  color: #1a1a1a;
  border-color: var(--c-gold);
}
.btn-primary:hover {
  background-color: #d9a800;
  border-color: #d9a800;
  color: #1a1a1a;
}

/* Logo-blue button — dark text for 6.5:1 contrast */
.btn-secondary {
  background-color: var(--c-blue);
  color: #1a1a1a;
  border-color: var(--c-blue);
}
.btn-secondary:hover {
  background-color: #2d8ab8;
  border-color: #2d8ab8;
  color: #1a1a1a;
}

/* ── HEADER ─────────────────────────────────────────────────────────────── */
.site-header {
  background-color: var(--c-surface-2);
  border-bottom: 3px solid var(--c-blue);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-block: var(--space-sm);
  min-height: 68px;
}

.site-logo-link {
  flex-shrink: 0;
  line-height: 0; /* removes inline gap beneath the image */
  text-decoration: none;
}

/* Constrain logo height in the nav bar */
.site-logo {
  height: 52px;
  width: auto;
}

/* Pushes nav to the right whether or not a logo precedes it */
.header-inner nav {
  margin-inline-start: auto;
}

/* Navigation */
.nav-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.nav-list a {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 1px;
  color: var(--c-text);
  text-decoration: none;
}
.nav-list a:hover,
.nav-list a[aria-current="page"] {
  color: var(--c-gold);
}
.nav-list a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ── HERO ────────────────────────────────────────────────────────────────── */
/* Uses the logo's sky-blue as the background colour for instant brand recognition */
.hero {
  background-color: var(--c-blue);
}

.hero-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
}

.hero-logo {
  flex: 1;
  max-width: 50%;
  height: auto;
  order: 1;
  padding: 64px;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}

.hero-text {
  flex: 1;
  order: 2;
}

.hero-tagline {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.2;
  letter-spacing: 1.5px;
  color: #ffffff;
  text-shadow:
    3px 3px 0 #0e2233,
    -2px -2px 0 #0e2233,
    2px -2px 0 #0e2233,
    -2px 2px 0 #0e2233;
  margin-bottom: var(--space-lg);
  max-width: 20ch;
}

/* ── VIDEOS SECTION ─────────────────────────────────────────────────────── */
.section-videos {
  padding-block: var(--space-xl);
}

/* Fills however many columns fit at 280 px minimum; wraps on small screens */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.video-card {
  background-color: var(--c-surface);
  border: 2px solid var(--c-surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Intrinsic 16:9 wrapper so iframes are always the right ratio */
.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
}
.video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.view-all-link {
  text-align: center;
}
.view-all-link a {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 1px;
}

/* ── BLOKI PROMO SECTION ────────────────────────────────────────────────── */
.section-bloki-promo {
  background-color: var(--c-surface);
  border-top: 3px solid var(--c-blue);
  border-bottom: 3px solid var(--c-blue);
  padding-block: var(--space-xl);
}

.bloki-promo-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
}

.bloki-promo-text {
  flex: 1;
  max-width: 50%;
}
.bloki-promo-text p {
  margin-bottom: var(--space-lg);
  max-width: 48ch;
  color: var(--c-text-muted);
  font-size: 1.05rem;
}

.bloki-promo-img {
  flex: 1;
  max-width: 50%;
  height: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.4));
  display: block;
  margin-inline: auto;
}

/* ── FOOTER ─────────────────────────────────────────────────────────────── */
.site-footer {
  background-color: var(--c-surface-2);
  border-top: 3px solid var(--c-blue);
  padding-block: var(--space-lg);
  margin-top: auto;
}

.footer-inner {
  text-align: center;
  color: var(--c-text-muted);
  font-size: 0.9rem;
}
.footer-inner a {
  color: var(--c-diamond);
}

/* ── BLOKI PAGE LAYOUT ──────────────────────────────────────────────────── */
/* page-bloki stretches the chat to fill the viewport height */
.page-bloki {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.bloki-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: var(--chat-width);
  width: 100%;
  margin-inline: auto;
}

/* ── CHAT APP ────────────────────────────────────────────────────────────── */
.chat-app {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--c-surface);
}

.chat-header {
  padding: var(--space-md) var(--space-lg);
  background-color: var(--c-surface-2);
  border-bottom: 3px solid var(--c-blue);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Row that sits the headshot and h1 side by side */
.chat-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bloki-headshot {
  width: 52px;
  height: 52px;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-header h1 {
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  color: var(--c-gold);
}

.chat-subtitle {
  font-size: 0.9rem;
  color: var(--c-text-muted);
}

/* Mode toggle — "Standard" vs "Expert mode" */
.mode-toggle {
  display: flex;
  gap: var(--space-sm);
}

.mode-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--c-blue);
  background-color: var(--c-surface);
  color: var(--c-text);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color 0.15s;
}
.mode-btn:hover {
  background-color: var(--c-surface-2);
}
/* Active state — logo blue bg with dark text (6.5:1 contrast) */
.mode-btn.active {
  background-color: var(--c-blue);
  border-color: var(--c-blue);
  color: #1a1a1a;
  font-weight: 700;
}

/* Messages list */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  display: flex;
  max-width: 85%;
}
.msg-user {
  align-self: flex-end;
}
.msg-bot {
  align-self: flex-start;
  flex-direction: column;
}

.msg-bubble {
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  line-height: 1.5;
  word-wrap: break-word;
}

/* User bubble — dark navy bg, white text (~14:1 contrast) */
.msg-user .msg-bubble {
  background-color: var(--c-surface-2);
  color: var(--c-text);
  border-bottom-right-radius: 3px;
  border: 1px solid var(--c-blue);
}

/* Bot bubble — deepest dark bg, white text (~14:1 contrast) */
.msg-bot .msg-bubble {
  background-color: #0b1c2c;
  color: var(--c-text);
  border-bottom-left-radius: 3px;
  border: 1px solid var(--c-surface-2);
}

/* "Connected to X" label shown above each expert reply bubble */
.msg-specialist {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--c-blue);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
  padding-left: 0.25rem;
}

/* Specialist label shown underneath Bloki's reply in expert mode */
.msg-meta {
  font-size: 0.7rem;
  color: var(--c-text-muted);
  margin-top: var(--space-xs);
  font-style: italic;
  padding-left: var(--space-sm);
}

.msg-typing .msg-bubble {
  background-color: #0b1c2c;
  color: var(--c-text-muted);
  font-style: italic;
}

/* Triage / handoff status message shown during expert mode.
   Centred, muted, and pulses gently to signal something is happening. */
.msg-triage {
  align-self: center;
  max-width: 90%;
}
.msg-triage .msg-bubble {
  background-color: transparent;
  color: var(--c-text-muted);
  font-style: italic;
  font-size: 0.85rem;
  border: 1px dashed var(--c-surface-2);
  border-radius: 20px;
  padding: 0.4rem 1.2rem;
  text-align: center;
  animation: triage-pulse 1.4s ease-in-out infinite;
}

@keyframes triage-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Input row */
.chat-form {
  display: flex;
  gap: var(--space-sm);
  padding: 0.75rem;
  background-color: var(--c-bg);
  border-top: 2px solid var(--c-surface-2);
}

#chat-input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 2px solid var(--c-surface-2);
  background-color: var(--c-surface);
  color: var(--c-text);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
}
#chat-input:focus {
  /* Override the global :focus-visible so it stays inside the input */
  outline: 3px solid var(--c-focus);
  outline-offset: 2px;
  border-color: var(--c-blue);
}

/* Send button — gold bg, dark text (11.5:1 contrast) */
#send-btn {
  padding: 0.625rem 1.25rem;
  border: none;
  background-color: var(--c-gold);
  color: #1a1a1a;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 1px;
  transition: background-color 0.15s;
}
#send-btn:hover:not(:disabled) {
  background-color: #d9a800;
}
#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .container {
    padding-inline: var(--space-md);
  }

  /* Stack hero and promo sections vertically on small screens */
  .hero-inner,
  .bloki-promo-inner {
    flex-direction: column;
  }
  .hero-logo,
  .bloki-promo-img {
    max-width: 240px;
  }

  .nav-list {
    gap: var(--space-md);
  }
  .nav-list a {
    font-size: 1rem;
  }
}

/* Honour the user's reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
