/*
 * pdm.css
 * Component-based stylesheet for KaiRise ICP-PDM activities.
 * Replaces canvas_v2.css + Tailwind utility classes.
 * Keep canvas.css (response, tooltip, citation styles stay there).
 *
 * Design tokens — Brand (slate) + Accent (indigo):
 *   brand-50 #f8fafc  brand-100 #f1f5f9  brand-200 #e2e8f0
 *   brand-300 #cbd5e1  brand-500 #64748b  brand-600 #475569
 *   brand-700 #334155  brand-800 #1e293b  brand-900 #0f172a
 *   accent-50 #eef2ff  accent-100 #e0e7ff
 *   accent-600 #4f46e5  accent-700 #4338ca
 */

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* ── CSS variables ───────────────────────────────────────────── */
:root {
  --brand-50:   #f8fafc;
  --brand-100:  #f1f5f9;
  --brand-200:  #e2e8f0;
  --brand-300:  #cbd5e1;
  --brand-500:  #64748b;
  --brand-600:  #475569;
  --brand-700:  #334155;
  --brand-800:  #1e293b;
  --brand-900:  #0f172a;
  --accent-50:  #eef2ff;
  --accent-100: #e0e7ff;
  --accent-400: #818cf8;
  --accent-600: #4f46e5;
  --accent-700: #4338ca;
  --radius:     8px;
  --shadow:     0 4px 20px -2px rgba(0,0,0,.05), 0 2px 10px -2px rgba(0,0,0,.04);
  --font:       'Manrope', sans-serif;
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base ────────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  color: var(--brand-800);
  background: transparent;
  padding: 1rem;
  min-height: 100vh;
}

/* Material icons sizing */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ── Page layout ─────────────────────────────────────────────── */
.pdm-page {
  max-width: 64rem;
  margin: 0 auto;
}

/* ── Intro block ─────────────────────────────────────────────── */
.pdm-intro {
  max-width: 48rem;
  margin-bottom: 2.5rem;
}

.lesson-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--brand-100);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-600);
  margin-bottom: 1rem;
}

.lesson-tag .dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  background: #22c55e;
  flex-shrink: 0;
}

.pdm-intro h2 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--brand-900);
  margin: 0 0 1rem;
  line-height: 2.25rem;
}

.pdm-intro .intro-text {
  font-size: 1.125rem;
  color: var(--brand-600);
  line-height: 1.625;
  margin: 0;
}

.pdm-intro a {
  color: var(--accent-600);
  text-decoration: none;
}
.pdm-intro a:hover { text-decoration: underline; }

/* Stage reference strip (2.2) */
.stage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.stage-pill {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--brand-200);
  color: var(--brand-500);
  background: var(--brand-50);
}

/* ── Activity stack ──────────────────────────────────────────── */
.pdm-stack {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ── Card ────────────────────────────────────────────────────── */
.pdm-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--brand-100);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Card header — tighter than before */
.pdm-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--card-header-bg, var(--brand-50));
  border-bottom: 1px solid var(--brand-100);
  padding: 0.625rem 1.5rem;   /* was py-4 (1rem) — now py-2.5 (0.625rem) */
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-600);
  color: #fff;
  padding: 0.375rem;
  border-radius: 0.375rem;
  flex-shrink: 0;
}

.card-icon .material-symbols-outlined {
  font-size: 1.1rem;
  display: block;
}

.card-header-text h3 {
  font-weight: 700;
  color: var(--brand-800);
  margin: 0;
  font-size: 0.9375rem;
}

.card-header-text p {
  font-size: 0.75rem;
  color: var(--brand-500);
  margin: 0.125rem 0 0;
}

/* Card body */
.pdm-card-body {
  padding: 1.5rem;
}

/* Two-column card body (guidance card in 1.6) */
.pdm-card-body-grid {
  padding: 1.5rem;
  display: grid;
  gap: 1.5rem;
}

/* ── Form elements ───────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand-700);
  margin-bottom: 0.5rem;
}

.field-sublabel {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-500);
  margin-bottom: 0.75rem;
}

textarea.pdm-input,
input.pdm-input {
  width: 100%;
  border: 1px solid var(--brand-200);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--brand-800);
  background: #fff;
  resize: vertical;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
  line-height: 1.5;
}

textarea.pdm-input::placeholder,
input.pdm-input::placeholder {
  color: var(--brand-300);
}

textarea.pdm-input:focus,
input.pdm-input:focus {
  outline: none;
  border-color: var(--accent-600);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

textarea.pdm-input.preloaded {
  border-color: #a5b4fc;
  background: var(--accent-50);
}

/* Context hints injected by PDM.initActivity() */
#pdm-context-hints { margin-bottom: 0.75rem; }

.pdm-hint {
  display: flex;
  gap: 0.6rem;
  font-size: 0.7rem;
  color: var(--brand-600);
  background: var(--accent-50);
  border: 1px solid var(--accent-100);
  border-left: 3px solid var(--accent-400);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem 0.5rem 0.875rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.pdm-hint .material-symbols-outlined {
  font-size: 0.875rem;
  color: var(--accent-600);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Guidance list (1.6 "What you'll do" card) ───────────────── */
.guidance-col-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand-500);
  margin: 0 0 0.75rem;
}

.guidance-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.guidance-list li {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--brand-600);
  line-height: 1.5;
}

.guidance-list li .bullet {
  color: var(--accent-600);
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Stage chips (2.2) ───────────────────────────────────────── */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stage-chip-label {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 1rem;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--brand-200);
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
}

.stage-chip-label:hover {
  border-color: var(--accent-100);
  background: rgba(238,242,255,0.3);
}

.stage-chip-label:has(input:checked) {
  background: var(--accent-50);
  border-color: var(--accent-600);
}

.stage-chip-label:has(input:checked) .chip-dot {
  background: var(--accent-600);
}

.stage-chip-label:has(input:checked) .chip-title {
  color: var(--accent-700);
}

.stage-checkbox { /* sr-only */
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

.chip-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--brand-300);
  flex-shrink: 0;
  margin-top: 0.25rem;
  margin-right: 0.5rem;
  transition: background 150ms var(--ease);
}

.chip-title {
  display: block;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--brand-800);
}

.chip-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--brand-500);
  margin-top: 0.125rem;
}

/* ── Behavior prompts list (2.2) ─────────────────────────────── */
.prompt-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.prompt-list li {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--brand-500);
}

.prompt-list li .bullet {
  color: var(--accent-600);
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Submit bar ──────────────────────────────────────────────── */
.pdm-submit-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--brand-200);
}

.submit-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--brand-500);
}

.submit-info .material-symbols-outlined {
  color: var(--accent-600);
  flex-shrink: 0;
}

.submit-info p {
  font-size: 0.875rem;
  font-style: italic;
  margin: 0;
}

.submit-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
  border: none;
}

.btn-secondary {
  padding: 0.625rem 1rem;
  background: transparent;
  border: 1px solid var(--brand-200);
  color: var(--brand-600);
}
.btn-secondary:hover { background: var(--brand-50); }

.btn-primary {
  padding: 0.75rem 2rem;
  background: var(--brand-900);
  color: #fff;
  font-weight: 700;
  font-size: 0.9375rem;
}
.btn-primary:hover { background: var(--brand-800); }

.btn-primary .material-symbols-outlined {
  font-size: 1.25rem;
  transition: transform 150ms var(--ease);
}
.btn-primary:hover .material-symbols-outlined {
  transform: translateX(0.25rem);
}

/* ── Preloaded pill ──────────────────────────────────────────── */
.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-700);
  background: var(--accent-50);
  border: 1px solid var(--accent-100);
  border-radius: 9999px;
  padding: 0.1rem 0.5rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* ── AskMike response area ───────────────────────────────────── */
#response {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
  line-height: 1.6;
}

#response ul li {
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

/* ── Tooltip / citations (from canvas.css) ───────────────────── */
.tooltip-container {
  display: inline-flex;
  position: relative;
  vertical-align: middle;
  align-items: center;
  gap: 4px;
}

.tooltip {
  cursor: help;
  display: inline-block;
}

.citation-num {
  font-size: 12px;
  color: #666;
  margin-left: 4px;
}

.tooltiptext {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 600px;
  max-height: 300px;
  overflow-y: auto;
  background: #333;
  color: #fff;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: opacity 0.15s ease;
  z-index: 1000;
  pointer-events: auto;
}

.tooltip-container:hover .tooltiptext,
.tooltip-container:focus-within .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .no-print { display: none !important; }
  .pdm-card { box-shadow: none; }

  /* Selected tiles and chips: browsers suppress backgrounds in print,
     so force a strong border + background and add a text indicator. */
  .pdm-tile-card.selected,
  .option-chip.selected {
    border-color: #1e1b4b !important;
    border-width: 2.5px !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    background: #ede9fe !important;
  }

  .pdm-tile-card.selected::after {
    content: '\2713 Selected';
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #4f46e5;
    margin-top: 0.375rem;
  }

  .option-chip.selected .chip-dot {
    background: #4f46e5 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (min-width: 640px) {
  body { padding: 1.5rem; }

  .pdm-card-body-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chip-grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  .pdm-submit-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}