/* strikes-back/shared.css
   Shared cinema-noir styling for the MSB study platform. */

:root {
  --bg:        #0b0b0d;
  --bg-2:      #14141a;
  --bg-3:      #1c1c24;
  --ink:       #f4ead5;
  --ink-dim:   #8a8273;
  --ink-mid:   #b8ad95;
  --rule:      rgba(244,234,213,0.12);
  --rule-2:    rgba(244,234,213,0.22);
  --accent:    #dc2626;
  --accent-2:  #ef3535;
  --accent-dim:#7a1818;
  --good:      #4ade80;
  --bad:       #f87171;
  --warn:      #fbbf24;
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
}

body::after {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0,0,0,0.65) 100%);
  pointer-events: none;
  z-index: 1;
}

.grain {
  position: fixed; inset: -50%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1   0 0 0 0 1   0 0 0 0 1   0 0 0 1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  animation: grain 0.5s steps(6) infinite;
  will-change: transform;
}

@keyframes grain {
  0%   { transform: translate(0,0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -2%); }
  60%  { transform: translate(-2%, -3%); }
  80%  { transform: translate(3%, 1%); }
  100% { transform: translate(0,0); }
}

/* --- Top brand bar (compact) --- */
.msb-topbar {
  position: relative;
  z-index: 3;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  gap: 1rem;
}
.msb-topbar a.brand {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.4em;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.msb-topbar a.brand::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
  animation: rec 1.6s ease-in-out infinite;
}
@keyframes rec {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}
.msb-topbar .breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.msb-topbar .topbar-right {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  align-items: center;
}
.msb-topbar .topbar-right a {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.2s;
}
.msb-topbar .topbar-right a:hover { color: var(--ink); }

/* --- Persistent progress strip --- */
.msb-pb {
  position: relative;
  z-index: 3;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem) 0.9rem;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(to bottom, rgba(0,0,0,0.35), transparent);
}
.msb-pb-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.msb-pb-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--ink-mid);
  text-transform: uppercase;
}
.msb-pb-stats {
  display: flex;
  gap: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.msb-pb-xp { color: var(--ink); }
.msb-pb-streak { color: var(--accent-2); }
.msb-pb-track {
  position: relative;
  height: 9px;
  background: rgba(244,234,213,0.06);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.msb-pb-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(to right, var(--accent-dim), var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(220,38,38,0.5);
  transition: width 0.6s cubic-bezier(.16,1,.3,1);
}
.msb-pb-tick {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(0,0,0,0.5);
}
.msb-pb-pct {
  position: absolute;
  right: clamp(1rem, 4vw, 2.5rem);
  bottom: 0.9rem;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  color: var(--ink);
  pointer-events: none;
  opacity: 0;
}

/* --- Page container --- */
.msb-page {
  position: relative;
  z-index: 3;
  padding: clamp(1.5rem, 4vh, 3rem) clamp(1rem, 4vw, 2.5rem);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* --- Headings --- */
.msb-h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  line-height: 0.9;
  letter-spacing: 0.005em;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.msb-h1 .dot { color: var(--accent); }
.msb-h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  letter-spacing: 0.08em;
  color: var(--ink);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
}
.msb-h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-transform: uppercase;
}
.msb-lede {
  color: var(--ink-mid);
  font-size: clamp(0.95rem, 1.3vw, 1.05rem);
  line-height: 1.55;
  max-width: 60ch;
  margin-bottom: 1.6rem;
}
.msb-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

/* --- Section header --- */
.msb-section-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin: 2rem 0 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
}
.msb-section-head .meta {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

/* --- Cards / tiles --- */
.msb-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.msb-tile {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  padding: 1.4rem;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}
.msb-tile:hover {
  transform: translateY(-2px);
  border-color: var(--rule-2);
  background: var(--bg-3);
}
.msb-tile::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.3s cubic-bezier(.16,1,.3,1);
}
.msb-tile:hover::before { transform: scaleY(1); }
.msb-tile-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.msb-tile-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.04em;
  line-height: 1;
}
.msb-tile-desc {
  font-size: 0.9rem;
  color: var(--ink-mid);
  line-height: 1.5;
  flex: 1;
}
.msb-tile-progress {
  height: 4px;
  background: rgba(244,234,213,0.08);
  position: relative;
}
.msb-tile-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(.16,1,.3,1);
}
.msb-tile-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.msb-tile-foot .enter {
  color: var(--ink-mid);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.msb-tile-foot .enter::after {
  content: '→';
  transition: transform 0.2s;
}
.msb-tile:hover .enter::after { transform: translateX(4px); color: var(--accent); }

/* --- Buttons --- */
.msb-btn {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.25em;
  padding: 0.85rem 1.6rem;
  background: var(--accent);
  color: var(--ink);
  border: 1px solid var(--accent);
  cursor: pointer;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: background 0.2s, transform 0.15s, opacity 0.2s;
}
.msb-btn:hover { background: var(--accent-2); transform: translateY(-1px); }
.msb-btn:active { transform: translateY(0); }
.msb-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.msb-btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-2);
}
.msb-btn.ghost:hover {
  background: rgba(244,234,213,0.04);
  border-color: var(--ink-dim);
}

/* --- Inputs --- */
.msb-input, .msb-textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 0;
  outline: none;
  transition: border-color 0.2s;
}
.msb-input:focus, .msb-textarea:focus { border-color: var(--accent); }
.msb-textarea {
  min-height: 160px;
  line-height: 1.55;
  resize: vertical;
  font-family: 'Inter', sans-serif;
}

/* --- Quiz layout --- */
.quiz-frame {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  padding: clamp(1.2rem, 3vw, 2rem);
  margin-top: 1rem;
}
.quiz-stem {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 1.4rem;
  max-width: 60ch;
}
.quiz-stem strong { color: var(--accent-2); }
.quiz-stimulus {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: var(--bg-3);
  border: 1px solid var(--rule);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  margin: 0.3rem 0.4rem 0.3rem 0;
}
.quiz-options {
  display: grid;
  gap: 0.6rem;
}
.quiz-option {
  background: var(--bg-3);
  border: 1px solid var(--rule);
  padding: 0.85rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.98rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.quiz-option:hover { background: rgba(244,234,213,0.04); border-color: var(--ink-dim); }
.quiz-option.is-correct { background: rgba(74,222,128,0.12); border-color: var(--good); }
.quiz-option.is-wrong { background: rgba(248,113,113,0.1); border-color: var(--bad); }
.quiz-option .marker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--ink-dim);
  width: 1.5em;
}
.quiz-option:disabled { cursor: default; }

.quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
  gap: 1rem;
}
.quiz-feedback {
  font-size: 0.95rem;
  color: var(--ink-mid);
  line-height: 1.5;
  max-width: 60ch;
}
.quiz-feedback.correct { color: var(--good); }
.quiz-feedback.wrong { color: var(--bad); }
.quiz-progress {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

/* --- Sort / drag groups --- */
.sort-buckets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}
.sort-bucket {
  background: var(--bg-3);
  border: 1px dashed var(--rule-2);
  padding: 0.9rem;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sort-bucket.is-target { border-style: solid; border-color: var(--accent); }
.sort-bucket .title {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.18em;
  font-size: 0.95rem;
}
.sort-bucket .desc {
  font-size: 0.78rem;
  color: var(--ink-dim);
  line-height: 1.4;
}
.sort-chip {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  padding: 0.45rem 0.7rem;
  font-size: 0.88rem;
  cursor: grab;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  user-select: none;
}
.sort-chip:active { cursor: grabbing; transform: scale(0.97); }
.sort-chip.is-correct { border-color: var(--good); background: rgba(74,222,128,0.1); }
.sort-chip.is-wrong   { border-color: var(--bad);  background: rgba(248,113,113,0.1); }
.sort-chip.is-dragging { opacity: 0.4; }

/* --- Badges grid --- */
.badges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}
.badge {
  background: var(--bg-2);
  border: 1px solid var(--rule);
  padding: 0.9rem;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: var(--ink-dim);
  text-transform: uppercase;
  opacity: 0.4;
  transition: opacity 0.3s, border-color 0.3s;
}
.badge.earned {
  opacity: 1;
  color: var(--ink);
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--bg-2), rgba(220,38,38,0.08));
}
.badge .icon {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  display: block;
  margin-bottom: 0.4rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.badge:not(.earned) .icon { color: var(--ink-dim); }

/* --- Onboarding modal --- */
.msb-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.msb-modal.open { display: flex; }
.msb-modal-card {
  background: var(--bg-2);
  border: 1px solid var(--rule-2);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  max-width: 460px;
  width: 100%;
}
.msb-modal-card h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}
.msb-modal-card p {
  color: var(--ink-mid);
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 1.2rem;
}

/* --- Footer --- */
.msb-credits {
  position: relative;
  z-index: 3;
  padding: 1.2rem clamp(1rem, 4vw, 2.5rem);
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.msb-credits a { color: var(--ink-dim); text-decoration: none; }
.msb-credits a:hover { color: var(--ink); }

/* --- Utility --- */
.row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.spacer { height: 1rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* --- Mobile --- */
@media (max-width: 640px) {
  .msb-topbar { padding-inline: 1rem; }
  .msb-topbar .breadcrumb { display: none; }
  .msb-pb-pct { font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  .grain, .msb-topbar a.brand::before { animation: none !important; }
  * { transition: none !important; }
}
