/* ── FlashForge Pro — Front-end Viewer ── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ufc-f-primary : #6c63ff;
  --ufc-f-bg      : #070711;
  --ufc-f-surface : #0f0f1a;
  --ufc-f-card    : #14142a;
  --ufc-f-border  : rgba(255,255,255,0.08);
  --ufc-f-text    : #e8e8f5;
  --ufc-f-muted   : #7070a0;
  --ufc-f-success : #00d98b;
  --ufc-f-warn    : #fbbf24;
  --ufc-f-radius  : 20px;
  --ufc-f-shadow  : 0 24px 80px rgba(0,0,0,0.6);
}

/* ── Base reset inside viewer ── */
.ufc-viewer-wrap,
.ufc-viewer-wrap * { box-sizing: border-box; }

.ufc-viewer-wrap {
  font-family: 'Outfit', sans-serif;
  background: var(--ufc-f-bg);
  min-height: 580px;
  padding: 32px 20px 48px;
  position: relative;
  overflow: hidden;
  /* ensure it never breaks out of WP theme */
  width: 100%;
  max-width: 100%;
}

/* Ambient background glow */
.ufc-viewer-wrap::before {
  content: '';
  position: absolute;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 640px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(108,99,255,0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* All direct children sit above glow */
.ufc-viewer-wrap > * { position: relative; z-index: 1; }


/* ══════════════════════════════════════
   DECK HEADER
══════════════════════════════════════ */
.ufc-deck-header {
  text-align: center;
  margin-bottom: 24px;
}
.ufc-deck-title {
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 800;
  color: #fff;
  margin: 0 0 5px;
  letter-spacing: -0.4px;
  line-height: 1.2;
}
.ufc-deck-subtitle {
  font-size: 13px;
  color: var(--ufc-f-muted);
  margin: 0;
}


/* ══════════════════════════════════════
   TOOLBAR
══════════════════════════════════════ */
.ufc-toolbar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.ufc-tool-btn {
  padding: 8px 16px;
  border-radius: 99px;
  border: 1.5px solid var(--ufc-f-border);
  background: transparent;
  color: var(--ufc-f-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  /* finger-friendly tap target */
  min-height: 40px;
  touch-action: manipulation;
}
.ufc-tool-btn:hover  { color: var(--ufc-f-text); border-color: rgba(255,255,255,0.18); }
.ufc-tool-btn.active { color: var(--ufc-f-primary); border-color: rgba(108,99,255,0.45);
                        background: rgba(108,99,255,0.08); }


/* ══════════════════════════════════════
   PROGRESS BAR
══════════════════════════════════════ */
.ufc-progress-wrap {
  max-width: 680px;
  margin: 0 auto 24px;
}
.ufc-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--ufc-f-muted);
  margin-bottom: 8px;
}
.ufc-progress-counter span { color: #fff; }
.ufc-progress-track {
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
}
.ufc-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--ufc-f-primary), var(--ufc-f-success));
  transition: width 0.4s ease;
}


/* ══════════════════════════════════════
   3-D FLIP CARD
══════════════════════════════════════ */
.ufc-card-scene {
  perspective: 1100px;
  max-width: 680px;
  margin: 0 auto 24px;
  cursor: pointer;
  /* make sure the scene itself is tappable */
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;   /* allow vertical scroll outside card, capture horizontal */
  user-select: none;
  -webkit-user-select: none;
}

.ufc-flip-card {
  position: relative;
  height: clamp(260px, 45vw, 340px);
  transform-style: preserve-3d;
  transition: transform 0.52s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: var(--ufc-f-radius);
}
.ufc-flip-card.flipped { transform: rotateY(180deg); }

/* Suppress transition when we're programmatically resetting */
.ufc-flip-card.ufc-no-transition,
.ufc-flip-card.ufc-no-transition * { transition: none !important; }

.ufc-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--ufc-f-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vw, 40px);
  text-align: center;
  overflow: hidden;
}

.ufc-card-front {
  background: var(--ufc-f-card);
  border: 1px solid var(--ufc-f-border);
  box-shadow: var(--ufc-f-shadow);
}
.ufc-card-back {
  background: linear-gradient(145deg, #1a1a35 0%, #12122a 100%);
  border: 1px solid rgba(108,99,255,0.22);
  box-shadow: var(--ufc-f-shadow), 0 0 40px rgba(108,99,255,0.12);
  transform: rotateY(180deg);
}

/* Top accent line */
.ufc-card-front::before,
.ufc-card-back::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 20px 20px 0 0;
}
.ufc-card-front::before { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent); }
.ufc-card-back::before  { background: linear-gradient(90deg, transparent, var(--ufc-f-primary), transparent); }

/* Labels */
.ufc-face-label {
  position: absolute;
  top: 14px; left: 18px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ufc-f-muted);
  opacity: 0.6;
}
.ufc-card-number {
  position: absolute;
  top: 14px; right: 18px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--ufc-f-muted);
}

/* Card content */
.ufc-card-image {
  max-width: min(160px, 40%);
  max-height: 110px;
  border-radius: 10px;
  object-fit: cover;
  margin-bottom: 14px;
}
.ufc-card-text {
  font-size: clamp(15px, 3.5vw, 22px);
  font-weight: 600;
  color: #fff;
  line-height: 1.55;
  max-width: 100%;
  word-break: break-word;
}
/* ── MathJax (tex-chtml) inline fix ──────────────────────────
   mjx-container defaults to inline-block which creates a line
   break. Force it to inline so $x^2$ stays in the text flow.
   fixInline() in front.js also does this via JS after typeset.
────────────────────────────────────────────────────────────── */
.ufc-card-text mjx-container,
.ufc-card-hint-text mjx-container {
  display: inline !important;
  vertical-align: middle !important;
  line-height: normal !important;
  margin: 0 1px !important;
}

/* Hint */
.ufc-card-hint-btn {
  position: absolute;
  bottom: 14px; right: 16px;
  padding: 5px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--ufc-f-border);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ufc-f-muted);
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ufc-card-hint-btn:hover { color: var(--ufc-f-warn); border-color: var(--ufc-f-warn); }

.ufc-card-hint-text {
  display: none;
  position: absolute;
  bottom: 46px; left: 16px; right: 16px;
  background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ufc-f-warn);
  text-align: center;
}
.ufc-card-hint-text.visible {
  display: block;
  animation: ufc-hint-pop 0.2s ease;
}
@keyframes ufc-hint-pop {
  from { opacity:0; transform:translateY(5px); }
  to   { opacity:1; transform:none; }
}

/* "Tap to flip" nudge */
.ufc-flip-indicator {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--ufc-f-muted);
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  pointer-events: none;
}
.ufc-card-scene:hover .ufc-flip-indicator { opacity: 1; }


/* ══════════════════════════════════════
   CONTROLS  (Prev / Flip / Next)
══════════════════════════════════════ */
.ufc-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.ufc-ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px solid var(--ufc-f-border);
  background: var(--ufc-f-surface);
  color: var(--ufc-f-muted);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ufc-ctrl-btn:hover:not(:disabled) {
  color: #fff;
  border-color: rgba(255,255,255,0.22);
  transform: scale(1.06);
}
.ufc-ctrl-btn:disabled { opacity: 0.28; cursor: default; transform: none; }

.ufc-ctrl-flip {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--ufc-f-primary), #8b5cf6);
  border-color: transparent;
  color: #fff;
  font-size: 22px;
  box-shadow: 0 6px 24px rgba(108,99,255,0.38);
}
.ufc-ctrl-flip:hover:not(:disabled) {
  transform: scale(1.09);
  box-shadow: 0 8px 28px rgba(108,99,255,0.5);
}


/* ══════════════════════════════════════
   KEYBOARD HINT
══════════════════════════════════════ */
.ufc-kbd-hint {
  text-align: center;
  font-size: 11px;
  color: var(--ufc-f-muted);
  margin: 8px 0 0;
  line-height: 1.6;
}
/* Hide keyboard hint on touch-primary devices */
@media (hover: none) and (pointer: coarse) {
  .ufc-kbd-hint { display: none; }
}


/* ══════════════════════════════════════
   COMPLETION SCREEN
══════════════════════════════════════ */
.ufc-complete-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: clamp(260px, 45vw, 340px);
  padding: 40px 20px;
  text-align: center;
  background: var(--ufc-f-card);
  border: 1px solid var(--ufc-f-border);
  border-radius: var(--ufc-f-radius);
  box-shadow: var(--ufc-f-shadow);
  max-width: 680px;
  margin: 0 auto;
  animation: ufc-fade-in 0.4s ease;
}
.ufc-complete-icon  { font-size: 56px; margin-bottom: 14px; animation: ufc-pop 0.45s ease; }
.ufc-complete-title { font-size: clamp(20px,4vw,28px); font-weight: 800; color:#fff; margin:0 0 8px; }
.ufc-complete-sub   { font-size: 14px; color: var(--ufc-f-muted); margin: 0 0 24px; }
@keyframes ufc-pop  { from{transform:scale(0.5);opacity:0} to{transform:scale(1);opacity:1} }
@keyframes ufc-fade-in { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }


/* ══════════════════════════════════════
   PASSWORD GATE
══════════════════════════════════════ */
.ufc-password-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 20px;
}
.ufc-password-inner {
  text-align: center;
  background: var(--ufc-f-card);
  border: 1px solid var(--ufc-f-border);
  border-radius: var(--ufc-f-radius);
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
}
.ufc-lock-icon { font-size: 40px; margin-bottom: 10px; }
.ufc-password-inner h3 { color:#fff; margin: 0 0 20px; font-size:18px; }
.ufc-password-inner input {
  width: 100%;
  background: var(--ufc-f-surface);
  border: 1.5px solid var(--ufc-f-border);
  border-radius: 10px;
  padding: 13px 16px;
  color: var(--ufc-f-text);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  margin-bottom: 12px;
  -webkit-appearance: none;
}
.ufc-password-inner input:focus { outline:none; border-color:var(--ufc-f-primary); }
.ufc-password-inner button {
  width: 100%;
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--ufc-f-primary), #8b5cf6);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}


/* ══════════════════════════════════════
   FULLSCREEN OVERRIDE
══════════════════════════════════════ */
.ufc-viewer-wrap.ufc-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  overflow-y: auto !important;
  padding-top: 40px;
}


/* ══════════════════════════════════════
   MOBILE  — fine-tuned breakpoints
══════════════════════════════════════ */
@media (max-width: 480px) {

  .ufc-viewer-wrap { padding: 20px 12px 36px; min-height: 0; }

  .ufc-deck-title  { font-size: 20px; }
  .ufc-deck-subtitle { font-size: 12px; }

  .ufc-toolbar { gap: 6px; margin-bottom: 16px; }
  .ufc-tool-btn { padding: 7px 12px; font-size: 12px; }

  .ufc-flip-card { height: 240px; }
  .ufc-card-face { padding: 18px 16px; }
  .ufc-card-text { font-size: 15px; }

  .ufc-controls { gap: 10px; margin-bottom: 14px; }
  .ufc-ctrl-btn  { width: 46px; height: 46px; font-size: 18px; }
  .ufc-ctrl-flip { width: 58px; height: 58px; font-size: 20px; }

  .ufc-face-label, .ufc-card-number { font-size: 9px; }
}

@media (max-width: 380px) {
  .ufc-flip-card { height: 210px; }
  .ufc-card-text { font-size: 14px; }
  .ufc-ctrl-btn  { width: 42px; height: 42px; }
  .ufc-ctrl-flip { width: 52px; height: 52px; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
  .ufc-viewer-wrap { padding: 12px 16px 24px; }
  .ufc-deck-header { margin-bottom: 10px; }
  .ufc-flip-card   { height: 200px; }
  .ufc-toolbar     { display: none; }   /* hide toolbar in landscape to save space */
  .ufc-progress-wrap { margin-bottom: 12px; }
}

/* ── Scrollbar ── */
.ufc-viewer-wrap ::-webkit-scrollbar { width: 4px; }
.ufc-viewer-wrap ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius:99px; }
