/* ============================================================================
   ArcadeESL — Shared Touch Protection, Brand Logo, Classroom UX & Bug Modal
   ============================================================================ */

/* 1. Touch & Layout Protection (Prevent double-tap zoom & pull-to-refresh) */
html, body {
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  overscroll-behavior-x: none;
  touch-action: manipulation;
}

html, body, button, a, input, select, .game-tile, .game-card, .poster-card, .tile {
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* 2. Hub Brand Logo Image Helper */
.hero-logo {
  overflow: hidden;
  padding: 0;
}

.hero-logo-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: inherit;
}

/* 3. Classroom UX Top Utility Bar */
.ea-ux-bar {
  position: sticky;
  top: 0;
  z-index: 9000;
  width: 100%;
  background: rgba(15, 23, 42, 0.94);
  border-bottom: 1px solid #334155;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f8fafc;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 4px 16px rgba(2, 6, 23, 0.45);
}

.ea-ux-inner {
  max-width: 1280px;
  margin: 0 auto;
  min-height: 38px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ea-ux-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ea-ux-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ea-back-link,
.ea-brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 9px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #f8fafc;
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.ea-back-link:hover,
.ea-back-link:focus-visible {
  border-color: #38bdf8;
  background: #273549;
  color: #ffffff;
  outline: none;
}

.ea-brand-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: block;
  object-fit: cover;
  flex-shrink: 0;
}

.ea-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 9px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.ea-btn:hover,
.ea-btn:focus-visible {
  border-color: #38bdf8;
  background: #273549;
  color: #ffffff;
  outline: none;
}

.ea-btn:active {
  transform: translateY(1px);
}

.ea-btn--muted {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.65);
  color: #fecdd3;
}

.ea-btn--muted:hover,
.ea-btn--muted:focus-visible {
  background: rgba(244, 63, 94, 0.3);
  border-color: #fb7185;
  color: #ffffff;
}

.ea-btn--copied {
  background: rgba(16, 185, 129, 0.22);
  border-color: #34d399;
  color: #d1fae5;
}

.ea-btn--active {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #e0f2fe;
}

.ea-fs-tip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.ea-fs-tip-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 9500;
  min-width: 205px;
  max-width: 260px;
  padding: 8px 11px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid #38bdf8;
  color: #f8fafc;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.65);
  display: none;
  white-space: normal;
}

.ea-fs-tip-wrap.is-open .ea-fs-tip-popover,
.ea-fs-tip-wrap:hover .ea-fs-tip-popover {
  display: block;
}

@media (max-width: 560px) {
  .ea-ux-inner {
    padding: 5px 8px;
    gap: 6px;
  }

  .ea-back-link,
  .ea-brand-chip,
  .ea-btn {
    padding: 5px 8px;
    font-size: 0.76rem;
  }
}

/* Prevent bottom viewport clipping on game pages due to injected top bar */
body.ea-viewport-locked .app-shell {
  height: calc(100vh - var(--ea-bar-h, 40px)) !important;
  height: calc(100dvh - var(--ea-bar-h, 40px)) !important;
  min-height: 0 !important;
}

body.ea-game-page:not(.ea-viewport-locked) .app-shell {
  min-height: calc(100vh - var(--ea-bar-h, 40px)) !important;
  min-height: calc(100dvh - var(--ea-bar-h, 40px)) !important;
}

/* Hide duplicate per-game "← Arcade" button when Classroom UX top bar is active */
body.ea-game-page a[href="../"][title="Back to ESL Classroom Arcade"],
body.ea-game-page .arcade-back-btn {
  display: none !important;
}

body.ea-game-page .ea-ux-inner {
  max-width: 1440px;
}

/* 4. Formspree Bug / Idea Modal */
.ea-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.ea-modal-backdrop.is-open {
  display: flex;
}

.ea-modal {
  width: 100%;
  max-width: 460px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 20px;
  color: #f8fafc;
  box-shadow: 0 24px 56px rgba(2, 6, 23, 0.78);
}

.ea-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ea-modal-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  color: #f8fafc;
}

.ea-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ea-modal-close:hover,
.ea-modal-close:focus-visible {
  border-color: #38bdf8;
  color: #ffffff;
  outline: none;
}

.ea-modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ea-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ea-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e2e8f0;
}

.ea-textarea,
.ea-input {
  width: 100%;
  box-sizing: border-box;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 12px;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.45;
  user-select: text;
  -webkit-user-select: text;
}

.ea-textarea {
  min-height: 104px;
  resize: vertical;
}

.ea-textarea::placeholder,
.ea-input::placeholder {
  color: #94a3b8;
}

.ea-textarea:focus,
.ea-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
}

.ea-check-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
}

.ea-check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #38bdf8;
  cursor: pointer;
  flex-shrink: 0;
}

.ea-submit-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  background: #38bdf8;
  color: #0f172a;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.ea-submit-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.ea-submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.ea-submit-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.ea-form-msg {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.4;
}

.ea-form-msg--ok {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.5);
  color: #a7f3d0;
}

.ea-form-msg--err {
  background: rgba(244, 63, 94, 0.16);
  border: 1px solid rgba(251, 113, 133, 0.5);
  color: #fecdd3;
}
