/* =========================================
   FLASHSTUDY – CONCURSOS PÚBLICOS
   Minimal, Focus-First Design System
   ========================================= */

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

:root {
  --bg: #0F1117;
  --surface: #1A1D27;
  --surface-2: #22263A;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.15);
  --text: #F0F0F8;
  --text-muted: #8A8BA8;
  --text-faint: #525570;

  --accent-portugues: #7C6DFA;
  --accent-matematica: #FF6B6B;
  --accent-informatica: #3ECDA0;
  --accent-gerais: #F7A440;

  --hard: #FF6B6B;
  --medium: #F7A440;
  --easy: #3ECDA0;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-card: 0 8px 40px rgba(0,0,0,0.5);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* --- UTILITY --- */
.hidden { display: none !important; }

/* =========================================
   HEADER
   ========================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px #7C6DFA88);
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.logo-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.progress-global {
  display: flex;
  align-items: center;
}

#globalProgressText {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

/* =========================================
   SUBJECT SELECTOR
   ========================================= */
.subject-section {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
  width: 100%;
}

.section-title {
  text-align: center;
  margin-bottom: 36px;
}

.section-title h1 {
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 8px;
}

.section-title p {
  font-size: 15px;
  color: var(--text-muted);
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* Subject Card */
.subject-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, var(--card-color, #7C6DFA) 0%, transparent 60%);
  opacity: 0.06;
  transition: opacity var(--transition);
}

.subject-card:hover {
  transform: translateY(-4px);
  border-color: var(--card-color, #7C6DFA);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 0 1px var(--card-color, #7C6DFA) inset;
}

.subject-card:hover::before { opacity: 0.12; }

.subject-card:active { transform: translateY(-2px); }

.sc-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sc-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.sc-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.sc-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sc-bar-wrap {
  background: var(--surface-2);
  border-radius: 99px;
  height: 4px;
  overflow: hidden;
}

.sc-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--card-color, #7C6DFA);
  width: 0%;
  transition: width 0.6s ease;
}

.sc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sc-topics {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
}

.sc-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--card-color, #7C6DFA);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =========================================
   STUDY VIEW
   ========================================= */
.study-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  width: 100%;
  gap: 0;
}

/* Study header */
.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 16px;
  gap: 12px;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition);
  padding: 6px 0;
  flex-shrink: 0;
}

.btn-back:hover { color: var(--text); }

.study-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
}

.study-subject-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.study-topic {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
}

.study-counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* Progress bar */
.progress-bar-wrap {
  margin-bottom: 20px;
}

.progress-bar-track {
  background: var(--surface-2);
  border-radius: 99px;
  height: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--current-accent, #7C6DFA), var(--current-accent-2, #A78BFA));
  width: 0%;
  transition: width 0.4s ease;
}

/* Card area */
.card-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  perspective: 1400px;
}

/* Flashcard */
.flashcard {
  width: 100%;
  max-width: 640px;
  min-height: 320px;
  cursor: pointer;
  position: relative;
  outline: none;
}

.flashcard:focus-visible .card-inner {
  box-shadow: 0 0 0 3px var(--current-accent, #7C6DFA), var(--shadow-card);
}

.card-inner {
  position: relative;
  width: 100%;
  min-height: 320px;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.card-inner.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--border);
}

/* FRONT */
.card-front {
  background: var(--surface);
}

.card-face-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pill-topic {
  font-size: 11px;
  font-weight: 600;
  color: var(--current-accent, #7C6DFA);
  background: rgba(124, 109, 250, 0.12);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid rgba(124, 109, 250, 0.25);
}

.hint-text {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 400;
}

.card-question {
  flex: 1;
  font-size: clamp(17px, 3.5vw, 21px);
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
}

.card-tip-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-hover);
}

.tip-icon { font-size: 14px; }

#hintPreview {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

/* BACK */
.card-back {
  background: var(--surface-2);
  transform: rotateY(180deg);
}

.back-label {
  justify-content: flex-start;
}

.pill-answer {
  font-size: 11px;
  font-weight: 600;
  color: var(--easy);
  background: rgba(62, 205, 160, 0.12);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid rgba(62, 205, 160, 0.25);
}

.card-answer {
  flex: 1;
  font-size: clamp(14px, 2.8vw, 16px);
  line-height: 1.7;
  color: var(--text);
  white-space: pre-line;
  overflow-y: auto;
}

.card-tip-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(247, 164, 64, 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(247, 164, 64, 0.2);
}

#cardTip {
  font-size: 13px;
  color: var(--medium);
  line-height: 1.5;
}

/* Swipe hint */
.swipe-hint {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  margin-top: -4px;
}

/* =========================================
   RATING AREA
   ========================================= */
.rating-area {
  padding: 12px 0;
}

.rating-label {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 500;
}

.rating-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-rate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
  flex: 1;
  max-width: 120px;
}

.rate-icon { font-size: 20px; }

.btn-hard:hover {
  border-color: var(--hard);
  color: var(--hard);
  background: rgba(255,107,107,0.08);
  transform: translateY(-2px);
}

.btn-medium:hover {
  border-color: var(--medium);
  color: var(--medium);
  background: rgba(247,164,64,0.08);
  transform: translateY(-2px);
}

.btn-easy:hover {
  border-color: var(--easy);
  color: var(--easy);
  background: rgba(62,205,160,0.08);
  transform: translateY(-2px);
}

.btn-rate:active { transform: translateY(0); }

/* =========================================
   NAVIGATION BUTTONS
   ========================================= */
.nav-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 12px 0;
}

.btn-nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-nav:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--surface-2);
}

.btn-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-flip {
  flex: 1;
  max-width: 240px;
  padding: 13px 24px;
  border-radius: 99px;
  border: none;
  background: var(--current-accent, #7C6DFA);
  color: white;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(124, 109, 250, 0.35);
}

.btn-flip:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(124, 109, 250, 0.45);
}

.btn-flip:active { transform: translateY(0); }

.btn-flip.revealed {
  background: var(--surface-2);
  color: var(--text-muted);
  box-shadow: none;
}

/* =========================================
   MINI STATS
   ========================================= */
.mini-stats-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding-top: 4px;
}

.mini-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 70px;
}

.mini-stat span:first-child {
  font-size: 20px;
  font-weight: 700;
}

.mini-stat span:last-child {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
}

.mini-stat.hard span:first-child { color: var(--hard); }
.mini-stat.medium span:first-child { color: var(--medium); }
.mini-stat.easy span:first-child { color: var(--easy); }

/* =========================================
   COMPLETION SCREEN
   ========================================= */
.completion-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.completion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 36px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-card);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.completion-emoji {
  font-size: 56px;
  margin-bottom: 20px;
  animation: bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes bounce {
  from { transform: scale(0) rotate(-20deg); }
  to { transform: scale(1) rotate(0); }
}

.completion-card h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}

.completion-card p {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.completion-stats {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.cs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 22px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex: 1;
}

.cs span:first-child {
  font-size: 28px;
  font-weight: 700;
}

.cs span:last-child {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
}

.cs.hard span:first-child { color: var(--hard); }
.cs.medium span:first-child { color: var(--medium); }
.cs.easy span:first-child { color: var(--easy); }

.completion-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-restart, .btn-home {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-restart {
  background: var(--current-accent, #7C6DFA);
  color: white;
  box-shadow: 0 4px 20px rgba(124,109,250,0.3);
}

.btn-restart:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-home {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-home:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.study-section:not(.hidden),
.subject-section:not(.hidden) {
  animation: fadeInUp 0.35s ease both;
}

.flashcard {
  animation: cardAppear 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes cardAppear {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================
   TOUCH / SWIPE FEEDBACK
   ========================================= */
.card-area.swiping-left .flashcard {
  transform: translateX(-20px) rotate(-3deg);
  opacity: 0.7;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.card-area.swiping-right .flashcard {
  transform: translateX(20px) rotate(3deg);
  opacity: 0.7;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 500px) {
  .subject-grid { grid-template-columns: 1fr; }
  .card-face { padding: 22px 18px 18px; }
  .rating-buttons { gap: 8px; }
  .btn-rate { padding: 10px 12px; max-width: 100px; }
  .completion-card { padding: 36px 22px; }
  .completion-stats { flex-direction: row; }
  .mini-stats-row { gap: 8px; }
  .mini-stat { min-width: 60px; padding: 8px 14px; }
}

@media (max-width: 360px) {
  .nav-buttons { gap: 8px; }
  .btn-flip { font-size: 13px; padding: 12px 16px; }
}
