/* Design System for Responsible & Safe AI Use
   Aligned with putongren.org / DESIGN.md
*/

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

:root {
  /* Brand Primary: Purple */
  --primary: #5e40e0;
  --primary-dim: #5130d4;
  --primary-container: #c3b8ff;
  --on-primary: #fcf7ff;
  --on-primary-container: #3a00bd;

  /* Secondary: Deep Blue (Information) */
  --secondary: #455e93;
  --secondary-container: #d8e2ff;
  --on-secondary: #f9f8ff;
  --on-secondary-container: #375184;

  /* Tertiary: Gold / Amber (Action & Highlights) */
  --tertiary: #715e00;
  --tertiary-container: #fdd400;
  --on-tertiary: #fff8ed;
  --on-tertiary-container: #594a00;

  /* Neutrals & Surfaces */
  --bg-light: #f7f9fc;
  --surface-light: #f7f9fc;
  --surface-lowest: #ffffff;
  --surface-low: #f1f4f7;
  --surface-container: #eaeef3;
  --surface-high: #e3e9ee;
  --on-surface: #2d3338;
  --on-surface-variant: #596065;
  --outline: #757c81;
  --outline-variant: #acb3b8;
  --border-light: #e5e9ef;

  /* Dark mode */
  --bg-dark: #0d1117;
  --surface-dark: #161b22;
  --surface-lowest-dark: #1a202c;
  --surface-low-dark: #12161f;
  --on-surface-dark: #f0f6fc;
  --on-surface-variant-dark: #8b949e;
  --border-dark: #2d333b;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  font-family: 'Plus Jakarta Sans', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-light);
  color: var(--on-surface);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.dark body {
  background-color: var(--bg-dark);
  color: var(--on-surface-dark);
}

/* Accessibility Focus Visible */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.dark :focus-visible {
  outline: 2px solid var(--primary-container);
  outline-offset: 2px;
}

/* Hand-drawn Underline - Soft Editorial Highlighter (F-10) */
.hand-drawn-underline {
  position: relative;
  display: inline;
  white-space: normal;
}

.hand-drawn-underline::after {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 2px;
  height: 8px;
  background: rgba(94, 64, 224, 0.18);
  border-radius: 100% 10% 80% 20%;
  z-index: -1;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.dark .hand-drawn-underline::after {
  background: rgba(195, 184, 255, 0.22);
}

/* Glassmorphism Navbar */
.nav-glass {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
}

.dark .nav-glass {
  background: rgba(13, 17, 23, 0.90);
  border-bottom: 1px solid var(--border-dark);
}

/* Skill Card - Refined Editorial Card Aesthetics (F-07, F-08) */
.skill-card {
  border-radius: 1.25rem;
  background-color: var(--surface-lowest);
  border: 1px solid var(--border-light);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.dark .skill-card {
  background-color: var(--surface-dark);
  border-color: rgba(255, 255, 255, 0.08);
}

.skill-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -6px rgba(94, 64, 224, 0.09);
  border-color: rgba(94, 64, 224, 0.4);
}

.dark .skill-card:hover {
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.6);
  border-color: rgba(195, 184, 255, 0.35);
}

/* Interactive Navigation Link Underline Animation */
.nav-link-animated {
  position: relative;
  transition: color 0.2s ease;
}

.nav-link-animated::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--primary);
  transition: width 0.25s ease;
  border-radius: 9999px;
}

.nav-link-animated:hover::after,
.nav-link-animated.active::after {
  width: 100%;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary);
  color: var(--on-primary);
  border: 1px solid transparent;
  border-radius: 9999px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.25;
  box-sizing: border-box;
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn-primary:hover {
  background-color: var(--primary-dim);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px rgba(94, 64, 224, 0.35);
}

/* Metrics Row Grid (Responsive 2 cols on mobile, 4 cols on desktop) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 640px) {
  .metrics-grid {
    gap: 1.5rem;
  }
}

@media (min-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Toast styling */
#toast {
  visibility: hidden;
  min-width: 260px;
  background-color: var(--on-surface);
  color: var(--surface-lowest);
  text-align: center;
  border-radius: 9999px;
  padding: 12px 24px;
  position: fixed;
  z-index: 1000;
  bottom: 32px;
  right: 32px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s, transform 0.3s;
  transform: translateY(16px);
}

#toast.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.dark #toast {
  background-color: #1a202c;
  color: #f0f6fc;
  border: 1px solid var(--border-dark);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
.dark ::-webkit-scrollbar-thumb {
  background: #334155;
}

/* Enhanced Interactive Filter Buttons */
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background-color: #ffffff;
  color: #475569;
  border: 1.5px solid #e2e8f0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.dark .filter-btn {
  background-color: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.filter-btn .filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9999px;
  background-color: #f1f5f9;
  color: #64748b;
  transition: all 0.2s ease;
}

.dark .filter-btn .filter-count {
  background-color: #0f172a;
  color: #94a3b8;
}

/* Unified Active Filter Buttons - Harmonized Brand Identity (F-05) */
.filter-btn.active,
.filter-btn.active-cat,
.filter-btn.active-timing,
.filter-btn.active-client {
  background-color: var(--primary) !important;
  color: #ffffff !important;
  border-color: var(--primary) !important;
  font-weight: 700;
  box-shadow: 0 3px 10px -1px rgba(94, 64, 224, 0.35) !important;
}

.filter-btn.active .filter-count,
.filter-btn.active-cat .filter-count,
.filter-btn.active-timing .filter-count,
.filter-btn.active-client .filter-count {
  background-color: rgba(255, 255, 255, 0.22) !important;
  color: #ffffff !important;
}

/* Detail Modal Animations & Focus */
#detail-modal {
  transition: opacity 0.2s ease-in-out;
}

#detail-modal.active {
  display: flex !important;
}

#detail-modal .modal-panel {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease-in-out;
}

/* Guide Specific Styles - Harmonized Purple Reading Progress Bar (F-09) */
.guide-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #7c3aed, #a855f7);
  z-index: 9999;
  transform-origin: left center;
  transform: scaleX(0);
  /* CSS scroll-driven animation — performant, no JS jank */
  animation: reading-progress linear both;
  animation-timeline: scroll(root block);
}

@keyframes reading-progress {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.guide-toc-link {
  display: block;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.25rem;
  color: #64748b;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}

.dark .guide-toc-link {
  color: #94a3b8;
}

.guide-toc-link:hover {
  color: var(--primary);
  background-color: rgba(94, 64, 224, 0.05);
}

.dark .guide-toc-link:hover {
  color: var(--primary-container);
  background-color: rgba(195, 184, 255, 0.08);
}

.guide-toc-link.active {
  color: var(--primary);
  font-weight: 700;
  border-left-color: var(--primary);
  background-color: rgba(94, 64, 224, 0.08);
}

.dark .guide-toc-link.active {
  color: #ffffff;
  border-left-color: var(--primary-container);
  background-color: rgba(195, 184, 255, 0.15);
}

/* Inline Interactive Skill Pill */
.inline-skill-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  margin: 0.1rem 0.15rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.15s ease;
  max-width: 100%;
}

.inline-skill-pill svg {
  width: 13px !important;
  height: 13px !important;
  min-width: 13px !important;
  max-width: 13px !important;
  display: inline-block !important;
  flex-shrink: 0 !important;
  vertical-align: -1px;
}

.dark .inline-skill-pill {
  background-color: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

.inline-skill-pill:hover {
  background-color: #ede9fe;
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px -1px rgba(94, 64, 224, 0.2);
}

.dark .inline-skill-pill:hover {
  background-color: #312e81;
  color: #e0e7ff;
  border-color: #818cf8;
}

/* Inline Interactive Incident Pill */
.inline-incident-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  margin: 0.1rem 0.15rem;
  background-color: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.15s ease;
  text-decoration: none;
  max-width: 100%;
}

.dark .inline-incident-pill {
  background-color: #4c0519;
  color: #fda4af;
  border-color: #881337;
}

.inline-incident-pill:hover {
  background-color: #ffe4e6;
  color: #9f1239;
  border-color: #f43f5e;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px -1px rgba(244, 63, 94, 0.2);
}

.dark .inline-incident-pill:hover {
  background-color: #881337;
  color: #fff1f2;
  border-color: #fb7185;
}

.inline-incident-pill:focus-visible {
  outline: 2px solid #f43f5e;
  outline-offset: 2px;
}

/* Callout & Scenario Containers - Strict Semantic Convergence (F-06) */
.scenario-box {
  border-radius: 0.875rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid #e2e8f0;
  background-color: #f8fafc;
}
.dark .scenario-box {
  border-color: #334155;
  background-color: rgba(15, 23, 42, 0.5);
}

.scenario-box-danger {
  border-radius: 0.875rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-left: 3.5px solid #ef4444;
  background-color: rgba(239, 68, 68, 0.03);
}
.dark .scenario-box-danger {
  border-color: rgba(239, 68, 68, 0.3);
  border-left-color: #f87171;
  background-color: rgba(239, 68, 68, 0.07);
}

.scenario-box-success {
  border-radius: 0.875rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-left: 3.5px solid #10b981;
  background-color: rgba(16, 185, 129, 0.03);
}
.dark .scenario-box-success {
  border-color: rgba(16, 185, 129, 0.3);
  border-left-color: #34d399;
  background-color: rgba(16, 185, 129, 0.07);
}

.callout-info {
  background-color: rgba(94, 64, 224, 0.04);
  border: 1px solid rgba(94, 64, 224, 0.15);
  border-left: 4px solid var(--primary);
  border-radius: 0.75rem;
  padding: 1.15rem 1.35rem;
}
.dark .callout-info {
  background-color: rgba(94, 64, 224, 0.1);
  border-color: rgba(195, 184, 255, 0.2);
  border-left-color: var(--primary-container);
}

.callout-warning {
  background-color: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-left: 4px solid #d97706;
  border-radius: 0.75rem;
  padding: 1.15rem 1.35rem;
}
.dark .callout-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
  border-left-color: #f59e0b;
}

.callout-danger {
  background-color: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-left: 4px solid #dc2626;
  border-radius: 0.75rem;
  padding: 1.15rem 1.35rem;
}
.dark .callout-danger {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
  border-left-color: #ef4444;
}

/* Card Hierarchy Accent for Ready-to-Use Skills (F-07) */
.skill-card.card-ready {
  border-top: 3px solid #10b981;
}
.dark .skill-card.card-ready {
  border-top: 3px solid #059669;
}

/* Guide Modal — enter animation */
#guide-modal {
  opacity: 0;
  transition: opacity 0.2s ease;
}

#guide-modal.modal-open {
  opacity: 1;
}

#guide-modal .modal-panel {
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  opacity: 0;
}

#guide-modal.modal-open .modal-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Firefox fallback: progress bar via JS width (when scroll-driven animations unsupported) */
@supports not (animation-timeline: scroll()) {
  .guide-progress-bar {
    transform: none;
    width: 0%;
    transition: width 0.1s linear;
  }
}

/* Chapter section dividers — subtle top accent */
.chapter-label {
  display: inline-block;
  letter-spacing: 0.08em;
}

/* Improved skill pill focus state for keyboard nav */
.inline-skill-pill:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* TOC sidebar smooth entry on page load */
@media (prefers-reduced-motion: no-preference) {
  aside > div {
    animation: sidebar-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 0.1s;
  }
}

@keyframes sidebar-enter {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Hero section content entrance */
@media (prefers-reduced-motion: no-preference) {
  .hero-animate {
    animation: hero-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
}

@keyframes hero-enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile table scroll hint — fade gradient on right edge */
@media (max-width: 767px) {
  .overflow-x-auto {
    position: relative;
    -webkit-overflow-scrolling: touch;
  }

  .overflow-x-auto::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 32px;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--bg-light));
    flex-shrink: 0;
  }

  .dark .overflow-x-auto::after {
    background: linear-gradient(to right, transparent, var(--bg-dark));
  }
}

/* Responsive Adaptive Details: Expanded Editorial Cards on Desktop (>= 1024px), Compact Accordion on Mobile (< 1024px) */
.adaptive-details {
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.adaptive-details summary::-webkit-details-marker {
  display: none;
}

@media (min-width: 1024px) {
  .adaptive-details summary {
    cursor: pointer;
  }
  .adaptive-details .adaptive-toggle-hint {
    display: none !important;
  }
  .adaptive-details .adaptive-desktop-badge {
    display: inline-flex !important;
  }
}

@media (max-width: 1023.98px) {
  .adaptive-details summary {
    cursor: pointer;
  }
  .adaptive-details .adaptive-toggle-hint {
    display: inline-flex !important;
  }
  .adaptive-details .adaptive-desktop-badge {
    display: none !important;
  }
}

/* ==========================================================================
   V2 Design Exploration: Lightweight Cards ("A tease, not a summary") & Themed Bands
   Inspired by Harvard Civic Skill Exchange architecture
   ========================================================================== */

/* 1. Themed Bands (Full-bleed Rhythm & Governance) */
.v2-band {
  position: relative;
  border-radius: 1.5rem;
  overflow: hidden;
  border: 1px solid rgba(94, 64, 224, 0.15);
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
  color: #f8fafc;
}
.dark .v2-band {
  border-color: rgba(195, 184, 255, 0.2);
  background: linear-gradient(135deg, #13112c 0%, #090d16 100%);
}

.v2-band-title {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.v2-band-pillar {
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.15rem 1.25rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.v2-band-pillar:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

/* 2. V2 Streamlined Cards ("A tease, not a summary") */
.v2-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  padding: 1.25rem 1.35rem;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.02);
}

.dark .v2-card {
  background-color: #161b22;
  border-color: #30363d;
}

.v2-card:hover {
  transform: translateY(-3px);
  border-color: rgba(94, 64, 224, 0.35);
  box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.06), 0 4px 8px -4px rgba(0, 0, 0, 0.03);
}

.dark .v2-card:hover {
  border-color: rgba(195, 184, 255, 0.35);
  box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.35);
}

.v2-card.card-ready {
  border-top: 3px solid #10b981;
}
.dark .v2-card.card-ready {
  border-top: 3px solid #059669;
}

.v2-card.card-setup {
  border-top: 3px solid #f59e0b;
}
.dark .v2-card.card-setup {
  border-top: 3px solid #d97706;
}

.v2-card-lede {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #475569;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dark .v2-card-lede {
  color: #94a3b8;
}

.v2-tag-client {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.dark .v2-tag-client {
  background-color: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}

.v2-btn-details {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  background-color: rgba(94, 64, 224, 0.08);
  color: var(--primary);
  border: 1px solid rgba(94, 64, 224, 0.15);
  transition: all 0.15s ease;
  cursor: pointer;
}
.dark .v2-btn-details {
  background-color: rgba(195, 184, 255, 0.1);
  color: var(--primary-container);
  border-color: rgba(195, 184, 255, 0.2);
}
.v2-btn-details:hover {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateX(2px);
}
.dark .v2-btn-details:hover {
  background-color: var(--primary);
  color: #ffffff;
}

.v2-btn-copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border-radius: 0.5rem;
  font-size: 0.6875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background-color: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  transition: all 0.15s ease;
  cursor: pointer;
  max-width: 140px;
}
.v2-btn-copy-chip:hover {
  background-color: #1e293b;
  border-color: #334155;
  color: #ffffff;
}

/* Co-equal indicator dots */
.dot-amber {
  background-color: #f59e0b;
}
.dot-brand {
  background-color: #5e40e0;
}
.dot-timing {
  background-color: #10b981;
}



