/* CyberSafer v2 — styles.css
   Aesthetic: Tactical minimalism
   Fonts: DM Sans (body) + DM Mono (chat/code)
   Mobile-first, single stylesheet
*/

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ---------- Variables ---------- */
:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface-2:    #1c2128;
  --border:       #30363d;
  --border-subtle:#21262d;

  --blue:         #58a6ff;
  --blue-dim:     rgba(88, 166, 255, 0.15);
  --blue-border:  rgba(88, 166, 255, 0.3);
  --green:        #3fb950;
  --green-dim:    rgba(63, 185, 80, 0.12);
  --green-border: rgba(63, 185, 80, 0.3);
  --amber:        #d29922;
  --amber-dim:    rgba(210, 153, 34, 0.12);
  --red:          #f85149;
  --red-dim:      rgba(248, 81, 73, 0.12);

  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-subtle:  #484f58;

  --radius:       8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --transition:   0.15s ease;

  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font-body); }
img { max-width: 100%; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
.container--wide {
  max-width: 960px;
}

/* ---------- Header ---------- */
.header {
  border-bottom: 1px solid var(--border-subtle);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}
.header__logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header__logo span { color: var(--blue); }
.header__nav { display: flex; gap: 1rem; }
.header__nav a {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}
.header__nav a:hover { color: var(--text); text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn--primary {
  background: var(--blue);
  color: #fff;
}
.btn--primary:hover { background: #79b8ff; }
.btn--secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn--ghost:hover { color: var(--text); border-color: var(--border); }
.btn--close {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn--close:hover { border-color: var(--red); color: var(--red); }
.btn--danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248,81,73,0.3);
}
.btn--danger:hover { background: rgba(248,81,73,0.25); }
.btn--lg { padding: 0.875rem 2rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn--sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn--full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color var(--transition);
}
.card--interactive { cursor: pointer; }
.card--interactive:hover { border-color: var(--blue); }
.card--interactive:active { transform: scale(0.99); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge--blue   { background: var(--blue-dim);  color: var(--blue);  border: 1px solid var(--blue-border); }
.badge--green  { background: var(--green-dim); color: var(--green); border: 1px solid var(--green-border); }
.badge--amber  { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(210,153,34,0.3); }
.badge--red    { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(248,81,73,0.3); }
.badge--subtle { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- Flag chip (animated) ---------- */
.flag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  background: var(--green-dim);
  border: 1px solid var(--green-border);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green);
  animation: flagPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes flagPop {
  0%   { transform: scale(0.6); opacity: 0; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Score ring ---------- */
.score-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.score-ring svg { transform: rotate(-90deg); }
.score-ring__label {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.score-ring__sublabel {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ---------- Category tabs ---------- */
.tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.tab {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  transition: all var(--transition);
}
.tab:hover { color: var(--text); border-color: var(--blue); }
.tab--active {
  background: var(--blue-dim);
  color: var(--blue);
  border-color: var(--blue-border);
}

/* ---------- Chat ---------- */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
.chat-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg);
  flex-shrink: 0;
}
.chat-header__info { flex: 1; min-width: 0; }
.chat-header__name {
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.chat-header__actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.flag-counter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  transition: all var(--transition);
}
.flag-counter.has-flags {
  color: var(--green);
  background: var(--green-dim);
  border-color: var(--green-border);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.message {
  display: flex;
  gap: 0.75rem;
  max-width: 85%;
  animation: msgIn 0.2s ease forwards;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message--adversary { align-self: flex-start; }
.message--system {
  align-self: center;
  max-width: 100%;
}

.message__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.message--user .message__avatar {
  background: var(--blue-dim);
  border-color: var(--blue-border);
}

.message__bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.55;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}
.message--adversary .message__bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text);
}
.message--user .message__bubble {
  background: var(--blue-dim);
  border: 1px solid var(--blue-border);
  border-top-right-radius: 4px;
  color: var(--text);
}
.message--system .message__bubble {
  background: var(--green-dim);
  border: 1px solid var(--green-border);
  color: var(--green);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  width: 100%;
}

.message__flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-top-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.chat-input-area {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  resize: none;
  min-height: 48px;
  max-height: 140px;
  line-height: 1.5;
  transition: border-color var(--transition);
  overflow-y: auto;
}
.chat-input:focus { outline: none; border-color: var(--blue); }
.chat-input::placeholder { color: var(--text-subtle); }
.chat-send {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--blue);
  border: none;
  color: #fff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.chat-send:hover { background: #79b8ff; }
.chat-send:disabled { background: var(--border); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.25rem;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal__icon { font-size: 2.5rem; margin-bottom: 1rem; }
.modal__title { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.75rem; }
.modal__body { color: var(--text-muted); line-height: 1.65; margin-bottom: 1.5rem; font-size: 0.9375rem; }
.modal__actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ---------- Page sections ---------- */
.page { padding: 2rem 0 4rem; }
.page__title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.page__subtitle { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.9375rem; }

.scenario-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
}

.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.scenario-card:hover { border-color: var(--blue); transform: translateY(-1px); }
.scenario-card:active { transform: translateY(0); }
.scenario-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.scenario-card__title { font-weight: 600; font-size: 0.9375rem; line-height: 1.3; }
.scenario-card__desc { font-size: 0.875rem; color: var(--text-muted); line-height: 1.5; }
.scenario-card__meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.scenario-card__done {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 22px; height: 22px;
  background: var(--green-dim);
  border: 1px solid var(--green-border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  color: var(--green);
}

/* ---------- Results / Debrief ---------- */
.results-page { padding: 2rem 1.25rem 4rem; max-width: 600px; margin: 0 auto; }
.results-header { text-align: center; margin-bottom: 2.5rem; }
.results-score { margin: 1.5rem auto; }
.results-flags { margin-bottom: 2rem; }
.results-flags__title { font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 0.75rem; }
.results-flags__list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.flag-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}
.flag-item--found { background: var(--green-dim); color: var(--green); border: 1px solid var(--green-border); }
.flag-item--missed { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.debrief-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.debrief-box p { margin-bottom: 0.75rem; }
.debrief-box p:last-child { margin-bottom: 0; }
.debrief-box strong { color: var(--text); }
.resources-box {
  background: var(--blue-dim);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.resources-box__title { font-weight: 600; margin-bottom: 0.75rem; font-size: 0.875rem; color: var(--blue); }
.resource-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.3rem 0;
}
.resource-link:hover { color: var(--blue); }
.learning-list { list-style: none; }
.learning-list li {
  padding: 0.5rem 0;
  padding-left: 1.25rem;
  position: relative;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}
.learning-list li:last-child { border-bottom: none; }
.learning-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--blue);
}

/* ---------- Hero (index) ---------- */
.hero {
  padding: 4rem 1.25rem 3rem;
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}
.hero__icon { font-size: 3.5rem; margin-bottom: 1.5rem; }
.hero__title {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
}
.hero__title span { color: var(--blue); }
.hero__desc {
  color: var(--text-muted);
  font-size: 1.0625rem;
  line-height: 1.65;
  margin-bottom: 2.5rem;
}
.hero__actions {
  display: flex;
  gap: 0.875rem;
  justify-content: center;
  flex-wrap: wrap;
}
.hero__stats {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-top: 3rem;
  flex-wrap: wrap;
}
.hero__stat { text-align: center; }
.hero__stat-num { font-size: 1.5rem; font-weight: 700; color: var(--blue); }
.hero__stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ---------- Warning banner ---------- */
.warning-banner {
  background: var(--amber-dim);
  border: 1px solid rgba(210,153,34,0.3);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.warning-banner__icon { font-size: 1.5rem; flex-shrink: 0; }
.warning-banner__title { font-weight: 600; color: var(--amber); margin-bottom: 0.4rem; }
.warning-banner__body { font-size: 0.875rem; color: var(--text-muted); line-height: 1.55; }

/* ---------- Utility ---------- */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--border-subtle); margin: 1.5rem 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ---------- Responsive ---------- */
@media (min-width: 600px) {
  .scenario-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 2.5rem; }
  .results-page { padding: 3rem 2rem 5rem; }
}
@media (min-width: 960px) {
  .scenario-grid { grid-template-columns: repeat(3, 1fr); }
}
