/* ══════════════════════════════════════════════════════════════
   WORKSHEET.CSS — Interactive Grammar Worksheet Styles
   Features: 3D floating backgrounds, drag-drop zones, inputs
   ══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Warm dark study surface, matching the practice app and the academy family.
     Text colours verified at 4.5:1 or better against --bg and --card. */
  --bg: #1A1008;
  --card: #2C1E10;
  --card-hover: #3A2817;
  --border: #8B7A66;
  --text: #F3EBDD;
  --muted: #C9B8A4;
  --accent: #C9A84C;
  --correct: #22c55e;
  --wrong: #E08977;
  --blue: #E8B87A;
  --purple: #C98AA6;
  --cyan: #9BC4B0;
  --a1: #22c55e;
  --a2: #E8B87A;
  --b1: #C9A84C;
  --b2: #C98AA6;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(26,16,8,.42);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── 3D BACKGROUND SCENE ──
   Fixed decorative layer. Clipped here rather than by hiding page overflow,
   so a genuine horizontal overflow elsewhere stays visible instead of hidden. */
.bg-scene {
  overflow: clip;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  perspective: 1200px;
  overflow: hidden;
}

.bg-sphere {
  position: absolute;
  border-radius: 50%;
  animation: float 20s infinite ease-in-out;
}
.sphere-1 {
  width: 300px; height: 300px;
  top: -80px; right: -60px;
  background: radial-gradient(circle at 30% 30%, rgba(201,138,166,.25), rgba(201,138,166,.02));
  box-shadow: inset 0 0 60px rgba(201,138,166,.1), 0 0 80px rgba(201,138,166,.05);
  animation-delay: 0s;
}
.sphere-2 {
  width: 200px; height: 200px;
  bottom: 10%; left: -40px;
  background: radial-gradient(circle at 40% 40%, rgba(6,182,212,.2), rgba(6,182,212,.01));
  box-shadow: inset 0 0 40px rgba(6,182,212,.1), 0 0 60px rgba(6,182,212,.04);
  animation-delay: -7s;
}
.sphere-3 {
  width: 150px; height: 150px;
  top: 40%; right: 10%;
  background: radial-gradient(circle at 35% 35%, rgba(240,165,0,.15), rgba(240,165,0,.01));
  box-shadow: inset 0 0 30px rgba(240,165,0,.08);
  animation-delay: -12s;
}

.bg-cube {
  position: absolute;
  width: 80px; height: 80px;
  border: 2px solid rgba(232,184,122,.15);
  border-radius: 12px;
  animation: spin-float 25s infinite linear;
}
.cube-1 { top: 20%; left: 5%; animation-delay: -3s; }
.cube-2 { bottom: 20%; right: 8%; border-color: rgba(201,138,166,.12); animation-delay: -10s; }

.bg-ring {
  position: absolute;
  width: 200px; height: 200px;
  border: 3px solid rgba(240,165,0,.08);
  border-radius: 50%;
  animation: ring-pulse 15s infinite ease-in-out;
}
.ring-1 { top: 60%; left: 15%; }
.ring-2 { top: 10%; left: 50%; border-color: rgba(6,182,212,.06); animation-delay: -5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotateX(0deg); }
  25% { transform: translateY(-20px) rotateX(3deg); }
  50% { transform: translateY(-40px) rotateX(-2deg); }
  75% { transform: translateY(-15px) rotateX(1deg); }
}
@keyframes spin-float {
  0% { transform: translateY(0) rotate(0deg) rotateX(0deg); }
  50% { transform: translateY(-30px) rotate(180deg) rotateX(15deg); }
  100% { transform: translateY(0) rotate(360deg) rotateX(0deg); }
}
@keyframes ring-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: .6; }
  50% { transform: scale(1.15) rotate(180deg); opacity: .3; }
}

/* ── NAVIGATION ── */
.skip-link {
  position: absolute; left: 8px; top: 8px; z-index: 200;
  background: var(--accent); color: #1A1008; padding: .6rem 1rem;
  border-radius: 8px; font-weight: 700; text-decoration: none;
  transform: translateY(-150%); transition: transform .15s;
}
.skip-link:focus { transform: translateY(0); outline: 3px solid #1A1008; outline-offset: 2px; }
.ws-nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.5rem;
  background: rgba(10,14,26,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-back {
  color: var(--accent); text-decoration: none; font-weight: 600; font-size: .85rem;
  transition: color .2s;
}
.nav-back:hover { color: #ffd060; }
.nav-title { color: var(--muted); font-size: .85rem; flex: 1; }
.nav-controls { display: flex; gap: .6rem; align-items: center; }
.nav-controls select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  padding: .5rem .8rem; border-radius: 8px; font-size: .8rem; cursor: pointer; min-height: 40px;
}
.btn-check-all, .btn-reset {
  padding: .55rem 1rem; border-radius: 8px; font-size: .8rem; font-weight: 600; min-height: 40px;
  cursor: pointer; border: none; transition: background-color .2s, border-color .2s, transform .2s;
}
.btn-check-all { background: var(--correct); color: #fff; }
.btn-check-all:hover { background: #16a34a; transform: translateY(-1px); }
.btn-reset { background: var(--card); color: var(--muted); border: 1px solid var(--border); }
.btn-reset:hover { background: var(--card-hover); color: var(--text); }

/* ── HEADER ── */
.ws-header {
  position: relative; z-index: 1;
  padding: 3rem 2rem 2rem;
  text-align: center;
}
.ws-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  margin-bottom: .4rem;
}
.ws-header h1 span { color: var(--accent); }
.ws-subtitle { color: var(--muted); font-size: 1rem; margin-bottom: 1rem; }
.ws-stats { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.stat-pill {
  background: var(--card); border: 1px solid var(--border);
  padding: .35rem .9rem; border-radius: 20px; font-size: .78rem; color: var(--muted);
}
.score-pill { color: var(--accent); border-color: rgba(240,165,0,.3); }

/* ── MAIN CONTENT ── */
.ws-content {
  position: relative; z-index: 1;
  max-width: 900px; margin: 0 auto;
  padding: 0 1.5rem 4rem;
}
.ws-loading {
  text-align: center; padding: 4rem 0; color: var(--muted);
}
.loader {
  width: 40px; height: 40px; margin: 0 auto 1rem;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOPIC SECTION ── */
.ws-topic {
  margin-bottom: 2.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s;
}
.ws-topic:hover { transform: translateY(-2px); }
.ws-topic-header {
  padding: 1.2rem 1.5rem;
  background: linear-gradient(135deg, rgba(232,184,122,.08), rgba(201,138,166,.05));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
}
.topic-icon-big { font-size: 1.8rem; }
.topic-header-text h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem; margin-bottom: .15rem;
}
.topic-header-text p { font-size: .8rem; color: var(--muted); }
.topic-level-pill {
  margin-left: auto; padding: .25rem .7rem; border-radius: 6px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
}
.topic-level-pill.a1 { background: rgba(34,197,94,.15); color: var(--a1); }
.topic-level-pill.a2 { background: rgba(232,184,122,.15); color: var(--a2); }
.topic-level-pill.b1 { background: rgba(240,165,0,.15); color: var(--b1); }
.topic-level-pill.b2 { background: rgba(201,138,166,.15); color: var(--b2); }

.ws-topic-body { padding: 1.5rem; }
.ws-rule-box {
  background: rgba(240,165,0,.05); border: 1px solid rgba(240,165,0,.15);
  border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 1.5rem;
  font-size: .82rem; line-height: 1.7; color: var(--muted);
}
.ws-rule-box strong { color: var(--accent); }
.ws-rule-box em { color: var(--cyan); font-style: normal; }

/* ── QUESTION CARDS ── */
.ws-question {
  margin-bottom: 1.2rem;
  padding: 1.2rem;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .3s, box-shadow .3s;
}
.ws-question.correct {
  border-color: var(--correct);
  box-shadow: 0 0 20px rgba(34,197,94,.1);
}
.ws-question.wrong {
  border-color: var(--wrong);
  box-shadow: 0 0 20px rgba(239,68,68,.1);
}
.q-number {
  font-size: .7rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: .5rem;
}
.q-type-badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 4px;
  font-size: .65rem; font-weight: 600; margin-left: .5rem;
}
.q-type-badge.mcq { background: rgba(232,184,122,.15); color: var(--blue); }
.q-type-badge.fill { background: rgba(6,182,212,.15); color: var(--cyan); }

.q-sentence {
  font-size: 1rem; margin-bottom: 1rem; line-height: 1.8;
  color: var(--text);
}

/* ── DROP ZONE (for MCQ drag-drop) ── */
.drop-zone {
  display: inline-block;
  min-width: 100px; min-height: 32px;
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: .3rem .6rem;
  margin: 0 .2rem;
  vertical-align: middle;
  transition: background-color .2s, border-color .2s, transform .2s, box-shadow .2s;
  background: rgba(255,255,255,.02);
  position: relative;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(240,165,0,.08);
  box-shadow: 0 0 12px rgba(240,165,0,.15);
}
.drop-zone.filled {
  border-style: solid;
  border-color: var(--blue);
  background: rgba(232,184,122,.08);
  color: var(--text);
  font-weight: 500;
}
.drop-zone.correct-answer { border-color: var(--correct); background: rgba(34,197,94,.1); }
.drop-zone.wrong-answer { border-color: var(--wrong); background: rgba(239,68,68,.08); }

/* ── DRAG OPTIONS ── */
.drag-options {
  display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem;
}
.drag-chip {
  padding: .45rem .9rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .85rem;
  cursor: grab;
  transition: background-color .2s, border-color .2s, transform .2s, box-shadow .2s;
  user-select: none;
  touch-action: none;
}
.drag-chip:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26,16,8,.3);
}
.drag-chip:active { cursor: grabbing; transform: scale(.95); }
.drag-chip.dragging { opacity: .5; transform: scale(.9); }
.drag-chip.used { opacity: .4; pointer-events: none; border-style: dashed; }
.drag-chip.correct-chip { border-color: var(--correct); background: rgba(34,197,94,.1); }
.drag-chip.wrong-chip { border-color: var(--wrong); background: rgba(239,68,68,.08); }

/* ── FILL INPUT ── */
.fill-input {
  display: inline-block;
  min-width: 120px; width: auto;
  background: rgba(255,255,255,.03);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: .35rem .7rem;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  vertical-align: middle;
  margin: 0 .2rem;
  transition: border-color .3s, box-shadow .3s;
  outline: none;
}
.fill-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(240,165,0,.15);
}
.fill-input.correct-answer {
  border-color: var(--correct);
  background: rgba(34,197,94,.08);
}
.fill-input.wrong-answer {
  border-color: var(--wrong);
  background: rgba(239,68,68,.06);
}

/* ── FEEDBACK ── */
.q-feedback {
  margin-top: .7rem; padding: .6rem .9rem;
  border-radius: 8px; font-size: .8rem;
  display: none;
}
.q-feedback.show { display: block; }
.q-feedback.correct-fb {
  background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.2); color: var(--correct);
}
.q-feedback.wrong-fb {
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.2); color: var(--wrong);
}
.q-hint {
  font-size: .75rem; color: var(--muted); margin-top: .4rem;
  cursor: pointer; opacity: .7; transition: opacity .2s;
}
.q-hint:hover { opacity: 1; }
.q-hint.revealed { color: var(--cyan); }

/* ── SCORE MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(26,16,8,.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.5rem; text-align: center;
  max-width: 380px; width: 90%; box-shadow: var(--shadow);
}
.modal-icon { font-size: 3rem; margin-bottom: .8rem; }
.modal-card h2 { font-family: 'Playfair Display', serif; margin-bottom: .5rem; }
.modal-card p { color: var(--muted); margin-bottom: 1.2rem; }
.modal-bar-wrap {
  height: 8px; background: var(--border); border-radius: 4px;
  overflow: hidden; margin-bottom: 1.5rem;
}
.modal-bar {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--correct), var(--cyan));
  transition: width 1s ease;
}
.btn-modal-close {
  background: var(--accent); color: #1A1008; border: none;
  padding: .6rem 1.5rem; border-radius: 8px; font-weight: 700;
  cursor: pointer; transition: transform .2s;
}
.btn-modal-close:hover { transform: scale(1.05); }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .ws-nav { flex-wrap: wrap; gap: .5rem; padding: .75rem 1rem; }
  .nav-title { min-width: 0; overflow-wrap: anywhere; }
  .nav-controls { width: 100%; min-width: 0; justify-content: flex-start; flex-wrap: wrap; }
  .nav-controls select { flex: 1 1 100%; min-width: 0; min-height: 44px; }
  .btn-check-all, .btn-reset { flex: 1 1 120px; min-width: 0; min-height: 44px; }
  .ws-header { padding: 2rem 1rem 1.5rem; }
  .ws-content { padding: 0 1rem 3rem; }
  .ws-topic-body { padding: 1rem; }
  .drag-chip { font-size: .78rem; padding: .35rem .7rem; }
}
