/* =========================================================
   TURBOFAN ACADEMY — PREMIUM MOBILE-FIRST DESIGN SYSTEM
   Wspólny stylesheet dla index(5).html oraz Full.html
   ========================================================= */

:root {
  --bg-0: #060a10;
  --bg-1: #0b111a;
  --bg-2: #111a26;
  --surface: rgba(18, 27, 39, .86);
  --surface-solid: #121b27;
  --surface-soft: rgba(255, 255, 255, .045);
  --border: rgba(148, 163, 184, .16);
  --border-strong: rgba(148, 163, 184, .28);

  --text: #f4f7fb;
  --text-soft: #a9b5c5;
  --text-muted: #6f7d90;

  --accent: #55d6ff;
  --accent-2: #8b7cff;
  --accent-soft: rgba(85, 214, 255, .12);
  --success: #43e6a1;
  --warning: #ffc857;
  --danger: #ff6b7a;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --shadow-sm: 0 8px 24px rgba(0, 0, 0, .18);
  --shadow-md: 0 18px 50px rgba(0, 0, 0, .28);
  --shadow-glow: 0 0 36px rgba(85, 214, 255, .12);

  --content: 980px;
  --mobile-content: 560px;
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: var(--bg-0);
  color-scheme: dark;
}

body {
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -12%, rgba(85, 214, 255, .13), transparent 34%),
    radial-gradient(circle at 100% 42%, rgba(139, 124, 255, .08), transparent 28%),
    linear-gradient(145deg, var(--bg-0) 0%, var(--bg-1) 48%, #080d14 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(18px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button,
a {
  font: inherit;
}

button {
  border: 0;
}

button,
a,
.quiz-card,
.drop-zone {
  -webkit-user-select: none;
  user-select: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Shared header ---------- */

.header {
  position: relative;
  width: 100%;
  max-width: var(--mobile-content);
  text-align: left;
  margin: 4px auto 24px;
  padding: 4px 58px 0 2px;
}

.header h1 {
  color: var(--text);
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -.035em;
  margin: 0 0 8px;
}

.header h1::first-letter {
  color: var(--accent);
}

.header p {
  color: var(--text-soft);
  font-size: .82rem;
  line-height: 1.45;
  max-width: 42rem;
}

/* Unified FAB controls: lang + theme share identical chrome */
.lang-toggle,
.theme-toggle,
#themeBtn,
#ta-theme-btn,
.ta-theme-fab,
.btn.btn-ghost.theme-toggle {
  position: fixed !important;
  top: max(12px, env(safe-area-inset-top)) !important;
  z-index: 9100 !important;
  box-sizing: border-box !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  max-width: 44px !important;
  max-height: 44px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 14px !important;
  border: 1px solid rgba(148, 163, 184, 0.28) !important;
  background: rgba(18, 27, 39, 0.92) !important;
  color: #f4f7fb !important;
  font-size: 0.8rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.02em !important;
  line-height: 1 !important;
  cursor: pointer !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease !important;
  -webkit-tap-highlight-color: transparent !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  outline: none !important;
  text-decoration: none !important;
}

.theme-toggle,
#themeBtn,
#ta-theme-btn,
.ta-theme-fab,
.btn.btn-ghost.theme-toggle {
  right: max(12px, env(safe-area-inset-right)) !important;
  left: auto !important;
  font-size: 1.15rem !important;
}

.lang-toggle {
  right: calc(max(12px, env(safe-area-inset-right)) + 44px + 8px) !important;
  left: auto !important;
}

.lang-toggle:active,
.theme-toggle:active,
#themeBtn:active,
#ta-theme-btn:active,
.ta-theme-fab:active {
  transform: scale(0.94) !important;
}

html[data-theme="light"] .lang-toggle,
html[data-theme="light"] .theme-toggle,
html[data-theme="light"] #themeBtn,
html[data-theme="light"] #ta-theme-btn,
html[data-theme="light"] .ta-theme-fab,
html[data-theme="light"] .btn.btn-ghost.theme-toggle,
[data-theme="light"] .lang-toggle,
[data-theme="light"] .theme-toggle,
[data-theme="light"] #themeBtn,
[data-theme="light"] #ta-theme-btn,
[data-theme="light"] .ta-theme-fab,
[data-theme="light"] .btn.btn-ghost.theme-toggle {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: rgba(15, 23, 42, 0.12) !important;
  color: #0f172a !important;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1) !important;
}

/* ---------- Home / quiz selector ---------- */

.quiz-list {
  width: 100%;
  max-width: var(--mobile-content);
  display: grid;
  gap: 12px;
}

.quiz-card {
  position: relative;
  isolation: isolate;
  min-height: 86px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  background:
    linear-gradient(135deg, rgba(255,255,255,.055), rgba(255,255,255,.018)),
    var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  overflow: hidden;
  transition:
    transform .22s cubic-bezier(.2,.8,.2,1),
    border-color .22s ease,
    box-shadow .22s ease,
    background .22s ease;
  touch-action: manipulation;
}

.quiz-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: .7;
}

.quiz-card::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  right: -70px;
  top: -70px;
  border-radius: 50%;
  background: rgba(85, 214, 255, .08);
  filter: blur(2px);
  z-index: -1;
}

.quiz-card:hover,
.quiz-card:active {
  transform: translateY(-2px);
  border-color: rgba(85, 214, 255, .42);
  background:
    linear-gradient(135deg, rgba(85,214,255,.09), rgba(255,255,255,.025)),
    var(--surface-solid);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.quiz-icon {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(85, 214, 255, .15);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(85,214,255,.12), rgba(139,124,255,.08));
  font-size: 1.45rem;
  box-shadow: inset 0 1px rgba(255,255,255,.06);
}

.quiz-info {
  flex: 1;
  min-width: 0;
}

.quiz-title {
  margin-bottom: 4px;
  color: var(--text);
  font-size: .98rem;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.quiz-desc {
  color: var(--text-soft);
  font-size: .76rem;
  line-height: 1.38;
}

.arrow {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 500;
  opacity: .65;
  transition: transform .2s ease, opacity .2s ease;
}

.quiz-card:hover .arrow {
  opacity: 1;
  transform: translateX(3px);
}

.footer {
  width: 100%;
  max-width: var(--mobile-content);
  margin-top: 24px;
  padding: 0 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: .68rem;
  line-height: 1.5;
}

/* ---------- Full quiz ---------- */

.level-selector {
  width: 100%;
  max-width: var(--content);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 auto 12px;
}

.level-btn {
  min-height: 54px;
  padding: 9px 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-soft);
  background: rgba(255,255,255,.025);
  font-size: .73rem;
  font-weight: 750;
  line-height: 1.15;
  cursor: pointer;
  transition: all .2s ease;
  touch-action: manipulation;
}

.level-btn span {
  display: block;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: .63rem;
  font-weight: 500;
}

.level-btn:hover {
  border-color: rgba(85, 214, 255, .35);
  color: var(--text);
}

.level-btn.active {
  color: #041018;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #86e7ff);
  box-shadow: 0 8px 24px rgba(85, 214, 255, .18);
}

.level-btn.active span {
  color: rgba(4,16,24,.68);
}

.status-bar {
  width: 100%;
  max-width: var(--content);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 auto 10px;
  padding: 0 2px;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 650;
}

.score,
.level-label {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.025);
}

.score {
  color: var(--success);
}

.level-label {
  color: var(--warning);
}

.engine-wrapper {
  position: relative;
  width: 100%;
  max-width: var(--content);
  margin: 0 auto 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-lg);
  background: #0b1017;
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
}

.engine-wrapper::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,.035);
  border-radius: inherit;
}

.engine-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.drop-zones-layer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 42%;
  display: flex;
}

.drop-zone {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  border-top: 1px solid rgba(85, 214, 255, .45);
  border-right: 1px solid rgba(85, 214, 255, .24);
  background: rgba(5, 12, 20, .76);
  backdrop-filter: blur(3px);
  transition:
    background .22s ease,
    border-color .22s ease,
    box-shadow .22s ease;
}

.drop-zone:last-child {
  border-right: 0;
}

.drop-zone:hover {
  background: rgba(85, 214, 255, .10);
  border-top-color: rgba(85, 214, 255, .8);
}

.drop-zone.matched {
  background: linear-gradient(180deg, rgba(67,230,161,.22), rgba(67,230,161,.08));
  border-color: rgba(67,230,161,.55);
  box-shadow: inset 0 0 24px rgba(67,230,161,.08);
}

.drop-zone.wrong {
  background: rgba(255, 107, 122, .16);
  border-color: rgba(255, 107, 122, .7);
  animation: shake .38s ease;
}

.zone-text {
  max-width: 100%;
  padding: 5px 3px;
  color: var(--accent);
  font-size: clamp(.48rem, 1.45vw, .8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: .045em;
  text-align: center;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
}

.drop-zone.matched .zone-text {
  color: var(--success);
}

.zone-placeholder {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px dashed rgba(169,181,197,.35);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 700;
  background: rgba(255,255,255,.025);
}

.feedback {
  width: 100%;
  max-width: var(--content);
  min-height: 30px;
  margin: 0 auto 10px;
  padding: 4px 6px;
  color: var(--text-soft);
  text-align: center;
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.4;
}

.cards-container {
  width: 100%;
  max-width: var(--content);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0 auto 14px;
}

.quiz-card.selected {
  border-color: rgba(85, 214, 255, .78);
  background:
    linear-gradient(135deg, rgba(85,214,255,.16), rgba(139,124,255,.08)),
    var(--surface-solid);
  box-shadow: 0 0 0 1px rgba(85,214,255,.12), 0 10px 28px rgba(85,214,255,.13);
  transform: translateY(-1px);
}

.cards-container .quiz-card {
  min-height: 66px;
  justify-content: center;
  text-align: center;
  padding: 12px 10px;
  border-radius: 14px;
  font-size: .73rem;
  line-height: 1.35;
}

.cards-container .quiz-card.matched {
  pointer-events: none;
  opacity: 0;
  transform: scale(.82);
}

.cards-container .quiz-card:active {
  transform: scale(.97);
}

.controls {
  width: 100%;
  max-width: var(--content);
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 auto;
}

.ctrl-btn {
  min-height: 44px;
  width: 100%;
  max-width: 180px;
  padding: 10px 18px;
  border-radius: 13px;
  border: 1px solid var(--border);
  color: var(--text-soft);
  background: rgba(255,255,255,.025);
  font-size: .76rem;
  font-weight: 750;
  cursor: pointer;
  transition: all .2s ease;
  touch-action: manipulation;
}

.ctrl-btn.reset {
  color: var(--danger);
  border-color: rgba(255,107,122,.25);
  background: rgba(255,107,122,.06);
}

.ctrl-btn.reset:hover {
  border-color: rgba(255,107,122,.55);
  background: rgba(255,107,122,.11);
}

.ctrl-btn.hint {
  color: var(--warning);
  border-color: rgba(255,200,87,.25);
  background: rgba(255,200,87,.06);
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 12, .78);
  backdrop-filter: blur(14px);
}

.modal-box {
  width: min(100%, 360px);
  padding: 28px 22px 22px;
  text-align: center;
  border: 1px solid rgba(85,214,255,.28);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 50% 0, rgba(85,214,255,.12), transparent 42%),
    rgba(15, 23, 34, .96);
  box-shadow: 0 30px 90px rgba(0,0,0,.55), var(--shadow-glow);
  animation: popIn .28s cubic-bezier(.2,.8,.2,1);
}

.modal-box .icon {
  margin-bottom: 12px;
  font-size: 3rem;
}

.modal-box h2 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -.025em;
}

.modal-box p {
  margin-bottom: 22px;
  color: var(--text-soft);
  font-size: .82rem;
  line-height: 1.5;
}

.modal-btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  color: #041018;
  background: linear-gradient(135deg, var(--accent), #8de8ff);
  font-size: .84rem;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(85,214,255,.18);
  transition: transform .16s ease, box-shadow .16s ease;
}

.modal-btn:hover {
  box-shadow: 0 14px 34px rgba(85,214,255,.25);
}

.modal-btn:active {
  transform: scale(.98);
}

/* ---------- Motion ---------- */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes popIn {
  from {
    transform: translateY(10px) scale(.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ---------- Responsive ---------- */

@media (min-width: 600px) {
  body {
    padding-top: 30px;
  }

  .header {
    max-width: var(--content);
    margin-bottom: 26px;
    padding-right: 64px;
  }

  .header h1 {
    font-size: 1.65rem;
  }

  .header p {
    font-size: .86rem;
  }

  .quiz-list {
    max-width: 620px;
    gap: 14px;
  }

  .quiz-card {
    min-height: 94px;
    padding: 18px;
  }

  .quiz-title {
    font-size: 1.02rem;
  }

  .quiz-desc {
    font-size: .8rem;
  }

  .cards-container {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .cards-container .quiz-card {
    min-height: 76px;
  }
}

@media (min-width: 900px) {
  .header {
    margin-top: 8px;
  }

  .level-selector {
    gap: 10px;
  }

  .level-btn {
    min-height: 58px;
    font-size: .78rem;
  }

  .cards-container .quiz-card {
    font-size: .76rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* =========================================================
   LIGHT THEME
   ========================================================= */

[data-theme="light"] {
  --bg-0: #f1f5f9;
  --bg-1: #e8eef5;
  --bg-2: #dde6f0;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-soft: rgba(15, 23, 42, 0.04);
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);

  --text: #0f172a;
  --text-soft: #334155;
  --text-muted: #64748b;

  --accent: #0284c7;
  --accent-2: #6366f1;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;

  --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 18px 50px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 36px rgba(2, 132, 199, 0.1);
}

html {
  transition: background-color 0.35s ease, color 0.35s ease;
}

html[data-theme="light"] {
  background: var(--bg-0);
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="light"] body {
  background:
    radial-gradient(circle at 50% -12%, rgba(2, 132, 199, 0.1), transparent 34%),
    radial-gradient(circle at 100% 42%, rgba(99, 102, 241, 0.06), transparent 28%),
    linear-gradient(145deg, #f8fafc 0%, #eef2f7 48%, #e8eef5 100%);
  color: var(--text);
}

[data-theme="light"] body::before {
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
}

/* Page enter animation */
@keyframes ta-page-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

body {
  animation: ta-page-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Theme switch flash */
html.ta-theme-switching body {
  transition: background 0.35s ease, color 0.35s ease;
}

/* Card / interactive micro-transitions */
.quiz-card,
.section-card,
.term-card,
.level-btn,
.filter-chip {
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.15s ease,
    background 0.2s ease,
    color 0.2s ease;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  body {
    animation: none !important;
  }
  html {
    transition: none !important;
  }
}

