/* ==========================================================
   MCode for Youth — Single Stylesheet
   Mobile-first responsive design
   ========================================================== */

/* --- CUSTOM PROPERTIES --- */
:root {
  /* Profile colors */
  --challenge-seeker: #E8553A;
  --headliner: #8B5CF6;
  --striver: #E5A716;
  --team-player: #2D9CDB;
  --explorer: #10B981;
  --creator: #F472B6;
  --persuader: #F59E0B;
  --fixer: #64748B;
  --go-getter: #06B6D4;

  /* Light variants (20% opacity) */
  --challenge-seeker-light: #E8553A33;
  --headliner-light: #8B5CF633;
  --striver-light: #E5A71633;
  --team-player-light: #2D9CDB33;
  --explorer-light: #10B98133;
  --creator-light: #F472B633;
  --persuader-light: #F59E0B33;
  --fixer-light: #64748B33;
  --go-getter-light: #06B6D433;

  /* Layout */
  --max-width: 830px;
  --padding: 1.25rem;
  --radius: 12px;

  /* Typography */
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-size-base: 1rem;
  --font-size-sm: 0.875rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.75rem;
  --font-size-2xl: 2.25rem;

  /* Surfaces */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --text-primary: #1E293B;
  --text-secondary: #64748B;
  --border: #E2E8F0;
}


/* --- RESET & BASE --- */
*,
*::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);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--challenge-seeker);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}


/* --- TYPOGRAPHY --- */
h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 700;
  color: var(--text-primary);
}

h1 {
  font-size: var(--font-size-2xl);
}

h2 {
  font-size: var(--font-size-xl);
  margin-bottom: 1rem;
}

h3 {
  font-size: var(--font-size-lg);
  margin-bottom: 0.75rem;
}

p {
  margin-bottom: 1rem;
}

p:last-child {
  margin-bottom: 0;
}


/* --- LAYOUT --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--padding);
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
}


/* --- PROGRESS BAR --- */
.progress-bar-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--border);
  z-index: 100;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 0 2px 2px 0;
}


/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 2rem;
  font-size: var(--font-size-base);
  font-weight: 600;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background-color: var(--challenge-seeker);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-secondary {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 2px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--text-primary);
}

.btn-full {
  width: 100%;
}


/* --- FORM ELEMENTS --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: var(--font-size-base);
  font-family: var(--font-body);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--challenge-seeker);
}

.form-input::placeholder {
  color: var(--text-secondary);
}

textarea.form-input {
  resize: vertical;
  min-height: 120px;
}

.char-counter {
  text-align: right;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: 0.375rem;
}

.char-counter.near-limit {
  color: var(--challenge-seeker);
  font-weight: 600;
}


/* --- CARDS --- */
.card {
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.2s ease, transform 0.15s ease, background-color 0.2s ease, color 0.2s ease;
}

.card:hover {
  border-color: var(--text-secondary);
}


/* ==========================================================
   LANDING PAGE
   ========================================================== */

.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero-title {
  font-size: var(--font-size-2xl);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  margin-bottom: 2rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.hero-actions .btn-primary {
  font-size: var(--font-size-lg);
  padding: 1rem 2.5rem;
}

.hero-actions .btn-secondary {
  font-size: var(--font-size-base);
}

.how-it-works {
  padding: 2.5rem 0;
}

.how-it-works h2 {
  text-align: center;
  margin-bottom: 2rem;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.step-number {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-primary);
  color: #FFFFFF;
  border-radius: 50%;
  font-weight: 700;
  font-size: var(--font-size-lg);
}

.step-text {
  padding-top: 0.375rem;
}

.step-text strong {
  display: block;
  margin-bottom: 0.125rem;
}

.site-footer {
  padding: 2rem 0;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.site-footer a {
  color: var(--text-primary);
  font-weight: 600;
}


/* ==========================================================
   ASSESSMENT PAGE
   ========================================================== */

.assess-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.assess-header {
  text-align: center;
  padding: 2rem 0 0.5rem;
}

.assess-header .question-counter {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.assess-header h2 {
  font-size: var(--font-size-xl);
  margin-bottom: 0;
}

.assess-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem 0 2rem;
}


/* --- OPTION CARDS (Phase 1) --- */
.option-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.option-card {
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  font-size: var(--font-size-base);
  line-height: 1.5;
  text-align: left;
  transition: border-color 0.2s ease, transform 0.15s ease, background-color 0.2s ease, color 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.option-card:hover {
  border-color: var(--text-secondary);
  transform: translateY(-2px);
}

.option-card:active {
  transform: translateY(0);
}

.option-card.selected {
  color: #FFFFFF;
  border-color: transparent;
  animation: cardPop 0.3s ease;
}

.option-card.disabled {
  pointer-events: none;
  opacity: 0.5;
}

@keyframes cardPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}


/* --- SORT CARDS (Phase 2) --- */
.sort-section {
  padding: 1rem 0;
}

.sort-instructions {
  text-align: center;
  margin-bottom: 1.5rem;
}

.sort-instructions h2 {
  font-size: var(--font-size-xl);
  margin-bottom: 0.5rem;
}

.sort-instructions p {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
}

.ranked-area {
  min-height: 2rem;
  margin-bottom: 1.5rem;
}

.ranked-area:empty {
  display: none;
}

.ranked-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg-primary);
  border-radius: var(--radius);
  margin-bottom: 0.625rem;
  border: 2px solid var(--border);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rank-badge {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: #FFFFFF;
}

.ranked-card-text {
  flex: 1;
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

.ranked-card-profile {
  font-weight: 700;
  font-size: var(--font-size-base);
}

.sort-divider {
  padding: 0.75rem 0;
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.unranked-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sort-card {
  display: flex;
  align-items: stretch;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease, opacity 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sort-card:hover {
  border-color: var(--text-secondary);
  transform: translateY(-2px);
}

.sort-card:active {
  transform: translateY(0);
}

.sort-card-color {
  width: 6px;
  flex-shrink: 0;
}

.sort-card-content {
  padding: 1.25rem;
  flex: 1;
}

.sort-card-name {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.sort-card-desc {
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--text-primary);
}

.sort-card.ranked-out {
  opacity: 0;
  pointer-events: none;
  height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
}


/* --- PHASE 3: MICRO-STORY --- */
.story-section {
  padding: 2rem 0;
}

.story-section h2 {
  font-size: var(--font-size-xl);
  margin-bottom: 0.5rem;
}

.story-section .story-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.story-section .btn {
  margin-top: 1.5rem;
}


/* ==========================================================
   RESULTS / REPORT PAGE
   ========================================================== */

.results-wrap {
  padding-bottom: 3rem;
  background-color: #F1F5F9;
}

/* Multi-page report layout */
.report-page {
  background: var(--bg-primary);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  display: none;
}

.report-page.active {
  display: block;
}

.report-page:first-child {
  margin-top: 1rem;
}

/* Page navigation */
.report-nav {
  display: none;
}

.report-nav.visible {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-top: 0.5rem;
}

.report-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.report-nav-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--text-secondary);
}

.report-nav-btn.primary {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
}

.report-nav-btn.primary:hover {
  background: #334155;
  border-color: #334155;
}

.report-nav-btn.hidden {
  visibility: hidden;
}

.report-page-indicator {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.report-page-dots {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.report-page-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background-color 0.2s;
}

.report-page-dot.active {
  background: var(--text-primary);
}

.report-page .section-header {
  margin-top: 0;
}

.report-page .section-header:first-child {
  margin-top: 0;
}

/* Radar chart */
.radar-container {
  display: flex;
  justify-content: center;
  padding: 1rem 0 0.5rem;
}

.radar-container canvas {
  max-width: 100%;
  height: auto;
}

/* Report title */
.report-title {
  text-align: center;
  font-size: var(--font-size-2xl);
  margin: 0.5rem 0 1rem;
}

/* Report intro */
.report-intro {
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 0;
  white-space: pre-line;
}

/* Section headers */
.section-header {
  font-size: var(--font-size-xl);
  margin: 0 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

/* Top 2 profiles */
.profile-full {
  background: var(--bg-primary);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.profile-full-header {
  padding: 1rem 1.5rem;
  color: #FFFFFF;
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.profile-full-body {
  padding: 1.5rem;
}

.profile-full-body .profile-description {
  white-space: pre-line;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.profile-subsection {
  margin-bottom: 1.25rem;
}

.profile-subsection:last-child {
  margin-bottom: 0;
}

.profile-subsection h4 {
  font-size: var(--font-size-base);
  margin-bottom: 0.375rem;
}

.profile-subsection p {
  line-height: 1.6;
}

/* Ranked profiles 3-9 */
.profile-light {
  display: flex;
  gap: 0;
  background: var(--bg-primary);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}

.profile-light-bar {
  width: 4px;
  flex-shrink: 0;
}

.profile-light-content {
  padding: 1rem 1.25rem;
  flex: 1;
}

.profile-light-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}

.profile-light-rank {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.profile-light-name {
  font-weight: 700;
  font-size: var(--font-size-base);
}

.profile-light-desc {
  font-size: var(--font-size-sm);
  line-height: 1.6;
  color: var(--text-primary);
}

/* Story section */
.story-reflection {
  background: var(--bg-primary);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  white-space: pre-line;
  line-height: 1.7;
}

/* What's next section */
.whats-next {
  white-space: pre-line;
  line-height: 1.7;
}

.whats-next a {
  font-weight: 600;
}

/* Profile full — last in page has no bottom margin */
.report-page .profile-full:last-child {
  margin-bottom: 0;
}

/* Profile light — last in page has no bottom margin */
.report-page .profile-light:last-child {
  margin-bottom: 0;
}

/* Save prompt */
.save-prompt {
  margin-top: 0;
}

.save-prompt h3 {
  margin-bottom: 0.5rem;
}

.save-prompt .save-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.save-prompt .btn {
  margin-top: 0.5rem;
}

/* Save states */
.save-message {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  margin-top: 1rem;
}

.save-message.success {
  background: var(--explorer-light);
  color: var(--text-primary);
}

.save-message.exists {
  background: var(--striver-light);
  color: var(--text-primary);
}

.save-message.error {
  background: var(--challenge-seeker-light);
  color: var(--text-primary);
}

.save-spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid var(--border);
  border-top-color: var(--challenge-seeker);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ==========================================================
   SHARE SECTION (report.html)
   ========================================================== */

.share-section {
  margin-top: 0;
}

.share-section h3 {
  margin-bottom: 0.5rem;
}

.share-section p {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.share-inline-form {
  display: flex;
  gap: 0.75rem;
  flex-direction: column;
}


/* ==========================================================
   FIND MY REPORT PAGE
   ========================================================== */

.find-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.find-card {
  background: var(--bg-primary);
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--border);
  text-align: center;
}

.find-card h1 {
  margin-bottom: 0.5rem;
}

.find-card .find-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.find-card .form-group {
  text-align: left;
}

.find-result {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--explorer-light);
  color: var(--text-primary);
  font-weight: 600;
}


/* ==========================================================
   ERROR / LOADING STATES
   ========================================================== */

.loading-state {
  text-align: center;
  padding: 3rem 0;
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
}

.error-state {
  text-align: center;
  padding: 3rem 0;
}

.error-state h2 {
  margin-bottom: 0.5rem;
}

.error-state p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}


/* ==========================================================
   NOSCRIPT
   ========================================================== */

noscript .noscript-msg {
  text-align: center;
  padding: 3rem var(--padding);
  font-size: var(--font-size-lg);
}


/* ==========================================================
   UTILITY CLASSES
   ========================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.text-center {
  text-align: center;
}

.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; }

.hidden {
  display: none !important;
}


/* ==========================================================
   MEDIUM BREAKPOINT: 480px+
   ========================================================== */

@media (min-width: 480px) {
  :root {
    --font-size-2xl: 2.5rem;
    --font-size-xl: 2rem;
  }

  .hero {
    padding: 4rem 0 3rem;
  }

  .option-card {
    padding: 1.75rem;
    font-size: var(--font-size-lg);
  }

  .sort-card-content {
    padding: 1.5rem;
  }

  .share-inline-form {
    flex-direction: row;
  }

  .share-inline-form .form-input {
    flex: 1;
  }

  .share-inline-form .btn {
    flex-shrink: 0;
  }
}


/* ==========================================================
   LARGE BREAKPOINT: 768px+
   ========================================================== */

@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }

  .report-page {
    padding: 3rem 2.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }

  .hero {
    padding: 5rem 0 3rem;
  }

  .hero-actions {
    flex-direction: row;
    justify-content: center;
  }

  .option-cards {
    flex-direction: row;
  }

  .option-card {
    flex: 1;
    padding: 2rem;
  }

  .steps {
    flex-direction: row;
    gap: 2rem;
  }

  .step {
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
  }

}
