/* --- Modern Design System & Reset --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

script {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.hidden {
  display: none;
}

@media (min-width: 640px) {
  .sm\:flex {
    display: flex !important;
  }
  .sm\:inline {
    display: inline !important;
  }
  .sm\:block {
    display: block !important;
  }
}

:root {
  /* Modern Color Palette */
  --primary-blue: #1a73e8;
  --primary-blue-dark: #1557b0;
  --primary-blue-light: #4285f4;
  --success-green: #137333;
  --success-bg: #e6f4ea;
  --error-red: #a50e0e;
  --error-bg: #fce8e6;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --border-color: #dadce0;
  --bg-light: #f8f9fa;
  --bg-page: #f5f5f5;
  --white: #ffffff;

  /* Spacing */
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 50%;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
  --shadow-hover: 0 6px 20px rgba(26, 115, 232, 0.2);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f8fafc;
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

html.dark body,
body.dark,
.dark body {
  background: #020617 !important;
  color: #f8fafc !important;
}


/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes successPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-8px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(8px);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    max-height: 500px;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Main Question Container --- */
body div#home {
  counter-reset: esum;
}

#quiz-container {
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  height: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

div#home div {
  position: relative;
  counter-increment: esum;
  background: var(--white);
  padding: 48px;
  border-radius: var(--radius-md);
  margin: 12.5vh auto;
  width: 75%;
  max-width: 1200px;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  border: 1px solid rgba(0, 0, 0, 0.04);

  /* Scroll snap - centered */
  scroll-snap-align: center;
  scroll-snap-stop: always;
  min-height: 60vh;
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

div#home div:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(60, 64, 67, 0.12);
}

/* --- Question Number Counter --- */
div#home div:before {
  content: counter(esum);
  position: absolute;
  top: -12px;
  left: -12px;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
  color: var(--white);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  z-index: 1;
}

/* --- Question Stem (Text) --- */
div#home p {
  margin-bottom: var(--spacing-lg);
  font-size: 20px;
  line-height: 1.6;
  color: var(--text-primary);
  font-weight: 500;
}

/* --- Images within questions --- */
div#home img {
  display: block;
  clear: both;
  max-width: 100%;
  height: auto;
  margin: var(--spacing-md) 0;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);

}

/* --- Answer Options List --- */
div#home ul {
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

div#home li {
  color: var(--text-secondary);
  border: 2px solid transparent;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  word-break: break-word;
  border-radius: 12px;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 16px;
  background: transparent;
  position: relative;
}

/* Letter indicator badge */
div#home li::before {
  content: attr(data-letter);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #F8F9FA;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover State - Show Border and Shift */
div#home li:hover {
  border-color: var(--primary-blue);
  background: rgba(26, 115, 232, 0.04);
  transform: translateX(8px);
  padding-left: 24px;
}

div#home li:hover::before {
  background: var(--primary-blue);
  color: white;
  transform: scale(1.1);
}

/* Hover arrow indicator */
div#home li:hover::after {
  content: '→';
  position: absolute;
  right: 20px;
  color: var(--primary-blue);
  font-size: 18px;
  animation: slideInRight 250ms ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --- Answer States --- */
div#home li.right {
  background: var(--success-bg);
  border-color: var(--success-green);
  color: var(--success-green);
  font-weight: 500;
  animation: successPulse var(--transition-slow) ease;
  padding-left: 20px;
}

div#home li.right::before {
  background: var(--success-green);
  color: white;
  content: attr(data-letter);
}

div#home li.wrong {
  background: var(--error-bg);
  border-color: var(--error-red);
  color: var(--error-red);
  font-weight: 500;
  animation: shake 0.5s ease;
  padding-left: 20px;
}

div#home li.wrong::before {
  background: var(--error-red);
  color: white;
  content: attr(data-letter);
}

div#home li.selected {
  border-color: var(--primary-blue);
  background: rgba(26, 115, 232, 0.08);
}

/* --- Selection Feedback --- */
.selection-feedback {
  color: var(--primary-blue) !important;
  font-weight: 600 !important;
  text-align: center;
  margin-bottom: var(--spacing-md) !important;
  font-size: 14px;
  padding: var(--spacing-sm);
  background: rgba(26, 115, 232, 0.06);
  border-radius: var(--radius-sm);
}

/* --- Rationale/Feedback Panel --- */
div#home p.feedback {
  display: none;
  background: linear-gradient(135deg, #f8f9fa 0%, #e8eef5 100%);
  border-radius: var(--radius-sm);
  padding: var(--spacing-lg);
  margin-top: var(--spacing-lg);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  animation: slideDown var(--transition-slow) ease;

  /* Scroll only in feedback when content is too large */
  max-height: 30vh;
  overflow-y: auto;
  overflow-x: hidden;
}

div#home p.feedback.show {
  display: block;
  animation: fadeIn var(--transition-slow) ease;
}

div#home p.feedback span {
  display: block;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  border-radius: var(--radius-xs);
  border-left: 4px solid;
  line-height: 1.6;
}

div#home p.feedback span:last-child {
  margin-bottom: 0;
}

div#home p.feedback span strong {
  font-weight: 600;
  display: inline;
}

div#home p.feedback span.right {
  color: var(--success-green);
  border-left: 4px solid var(--success-green);
}

div#home p.feedback span.right strong {
  color: var(--success-green);
}

div#home p.feedback span.wrong {
  color: var(--text-secondary);
  border-left: 4px solid var(--border-color);
}

div#home p.feedback span.wrong strong {
  color: var(--text-primary);
}

/* --- Header Styles --- */
#main-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

html.dark #main-header,
.dark #main-header {
  background: rgba(15, 23, 42, 0.95) !important;
  border-bottom: 1px solid rgba(30, 41, 59, 0.85) !important;
}

#main-header.hidden {
  display: none;
}

#certification-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #1e293b;
}

html.dark #certification-title,
.dark #certification-title {
  color: #60a5fa !important;
}

/* --- Progress Bar --- */
#progress-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #e3f2fd 0%, #bbdefb 100%);
  z-index: 999;
  overflow: hidden;
}

#progress-bar-container.hidden {
  display: none;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
  transition: width var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(26, 115, 232, 0.5);
}

/* --- Presentation Mode --- */
body.presentation-mode {
  overflow-x: hidden;
  background: var(--white);
}

body.presentation-mode #main-header,
body.presentation-mode div#home div:before {
  display: none;
}

body.presentation-mode #quiz-container {
  padding: 0;
  margin: 0;
  max-width: 100vw;
}

body.presentation-mode div#home div {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--spacing-xl);
}

/* --- Scroll Indicator Arrow --- */
.scroll-indicator {
  position: fixed;
  bottom: 24px;
  display: none;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
  opacity: 0.6;
  transition: opacity var(--transition-base);
}

/* Show scroll indicator only when quiz is loaded */
body:not(.quiz-loaded) .scroll-indicator {
  display: none !important;
}

body.quiz-loaded .scroll-indicator {
  display: block;
}

.scroll-indicator:hover {
  opacity: 1;
}

.scroll-arrow {
  width: 32px;
  height: 32px;
  border-right: 3px solid var(--primary-blue);
  border-bottom: 3px solid var(--primary-blue);
  transform: rotate(45deg);
  animation: bounceDown 2s infinite;
}

@keyframes bounceDown {

  0%,
  20%,
  50%,
  80%,
  100% {
    transform: rotate(45deg) translateY(0);
  }

  40% {
    transform: rotate(45deg) translateY(-10px);
  }

  60% {
    transform: rotate(45deg) translateY(-5px);
  }
}

/* Hide scroll indicator in presentation mode */
body.presentation-mode .scroll-indicator {
  display: none;
}


/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  #quiz-container {
    scroll-snap-type: y proximity;
    /* Less strict on mobile */
  }

  div#home div {
    padding: var(--spacing-lg);
    margin: 0 8px;
    max-width: calc(100% - 16px);
    min-height: 90vh;
    /* Slightly less on mobile */
  }

  div#home p {
    font-size: 18px;
  }

  div#home li {
    padding: 14px 16px;
    font-size: 15px;
    gap: 12px;
  }

  div#home li::before {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  div#home li:hover {
    transform: none;
    /* Disable transform on mobile */
    padding-left: 16px;
  }

  div#home li:hover::after {
    display: none;
    /* Hide arrow on mobile */
  }

  div#home p.feedback {
    margin: var(--spacing-md) 0 0 0;
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
  }

  #main-header {
    padding: 10px 16px;
  }

  #certification-title {
    font-size: 16px;
  }

  #scoreboard {
    font-size: 13px;
    gap: var(--spacing-xs);
    padding-right: var(--spacing-xs);
    margin-right: var(--spacing-xs);
  }

  .score-item {
    font-size: 13px;
    padding: 2px 8px;
  }

  .score-item span {
    font-size: 16px;
  }

  .header-actions a {
    width: 36px;
    height: 36px;
  }
}

/* --- Loading Overlay --- */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#loading-overlay.hidden {
  display: none;
}

#loading-overlay p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: var(--spacing-md);
  font-weight: 500;
}

.spinner {
  animation: spin 1.5s linear infinite;
  width: 50px;
  height: 50px;
}

.spinner .path {
  stroke: var(--primary-blue);
  stroke-linecap: round;
  animation: dash 1.5s ease-in-out infinite;
}

@keyframes dash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }

  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

/* --- Focus States for Accessibility --- */
a:focus-visible,
button:focus-visible,
li:focus-visible {
  outline: 3px solid var(--primary-blue);
  outline-offset: 2px;
}

/* ========================================================================= */
/* CONTINUOUS QUIZ STUDY FEED - ESTILOS ADICIONAIS                           */
/* ========================================================================= */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.animate-expand {
  animation: slideDown 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 9999px;
}
.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

/* Suporte a Modo Zen */
body.zen-mode .zen-hidden {
  display: none !important;
}

/* Feed Mode Question Cards - Sharp and clear without blur */
.feed-question-card {
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.feed-question-card img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 12px 0;
  display: block;
}

/* ========================================================================= */
/* POSICIONAMENTO RESPONSIVO DO FLOATING MODE SWITCHER                       */
/* ========================================================================= */
@media (max-width: 639px) {
  /* No modo 1 a 1 no mobile, o switcher flutuante fica oculto para não tampar alternativas e o botão Próxima */
  body:not(.feed-mode) #floating-mode-switcher {
    display: none !important;
  }

  body.feed-mode #floating-mode-switcher {
    bottom: 1.25rem !important;
    right: 1rem !important;
    transform: scale(0.95);
    transform-origin: bottom right;
  }
}

/* ========================================================================= */
/* PLACAR RESPONSIVO: MOBILE VS DESKTOP                                      */
/* Mobile (<640px): Apenas quantidade de perguntas e em qual está (ex: 1/60) */
/* Desktop (>=640px): Exibe acertos, erros, marcados e total/posição         */
/* ========================================================================= */
@media (max-width: 639px) {
  #score-correct-wrap,
  #score-wrong-wrap,
  #score-bookmarks-wrap,
  .score-separator-desktop {
    display: none !important;
  }
}

@media (min-width: 640px) {
  #score-correct-wrap,
  #score-wrong-wrap,
  #score-bookmarks-wrap {
    display: flex !important;
  }
  .score-separator-desktop {
    display: inline !important;
  }
}