/* ==========================================================================
   FichaAgil — Editorial Clinical Design System (Vanilla CSS)
   ========================================================================== */

:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-subtle: #eff4f2;
  --surface-dark: #0e1d21;
  --border: #dfe7e4;
  --border-strong: #c8d6d1;

  --ink: #0e1d21;
  --ink-secondary: #43575d;
  --ink-muted: #64787e;

  --teal: #0d7a6f;
  --teal-hover: #095e55;
  --teal-soft: #e6f4f1;
  --teal-ink: #084c45;

  --amber-soft: #fef3c7;
  --amber-ink: #92400e;
  --indigo-soft: #e0e7ff;
  --indigo-ink: #3730a3;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(14, 29, 33, 0.05);
  --shadow-md: 0 10px 28px -8px rgba(14, 29, 33, 0.08), 0 2px 6px rgba(14, 29, 33, 0.04);
  --shadow-lg: 0 22px 48px -14px rgba(14, 29, 33, 0.14);

  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --container: 1120px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}

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

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

a:hover {
  text-decoration: underline;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header / Navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(246, 248, 247, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.025em;
}

.brand:hover {
  text-decoration: none;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14.5px;
  font-weight: 500;
}

.nav-links a {
  color: var(--ink-secondary);
  transition: color 0.15s ease;
}

.nav-links a:hover {
  color: var(--ink);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-subtle);
  border-color: #aebfbd;
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(13, 122, 111, 0.22);
}

.btn-primary:hover {
  background: var(--teal-hover);
  border-color: var(--teal-hover);
  color: #ffffff;
}

.btn-lg {
  padding: 13px 22px;
  font-size: 15.5px;
  border-radius: 10px;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

/* ---------- Hero ---------- */
.hero {
  padding: 64px 0 56px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.06fr 0.94fr;
  gap: 48px;
  align-items: center;
}

.eyebrow {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 14px;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.025em;
}

.hero h1 {
  font-size: clamp(32px, 4.2vw, 46px);
  line-height: 1.12;
  font-weight: 800;
  margin-bottom: 18px;
}

.hero-lead {
  font-size: 17.5px;
  line-height: 1.62;
  color: var(--ink-secondary);
  margin: 0 0 28px;
  max-width: 540px;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 13.5px;
  color: var(--ink-muted);
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Interactive Hero Mockup ---------- */
.demo-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.demo-topbar {
  background: var(--surface-dark);
  color: #ffffff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.demo-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
}

.demo-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(94, 234, 212, 0.16);
  color: #5eead4;
}

.demo-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.demo-patient {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
}

.demo-patient strong {
  display: block;
  font-size: 13.5px;
  color: var(--ink);
}

.demo-patient .muted {
  color: var(--ink-muted);
  font-size: 12px;
}

.demo-status {
  font-size: 11px;
  font-weight: 700;
  color: var(--teal-ink);
  background: var(--teal-soft);
  padding: 3px 9px;
  border-radius: 999px;
}

.demo-pack-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.demo-tpl-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.demo-tpl-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 9px;
  padding: 9px 8px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  font-family: var(--font-body);
}

.demo-tpl-btn:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.demo-tpl-btn.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.demo-tpl-btn b {
  display: block;
  font-size: 12.5px;
  line-height: 1.25;
}

.demo-tpl-btn small {
  display: block;
  font-size: 10.5px;
  opacity: 0.78;
  margin-top: 2px;
}

.demo-output {
  background: #fbfcfc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.demo-field-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.demo-field-key {
  min-width: 96px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
}

.demo-field-val {
  color: var(--ink);
  flex: 1;
}

.demo-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.demo-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--teal-soft);
  color: var(--teal-ink);
  font-weight: 600;
}

.demo-footnote {
  font-size: 11.5px;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

/* ---------- Sections ---------- */
.section {
  padding: 68px 0;
}

.section-alt {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-head {
  max-width: 660px;
  margin-bottom: 36px;
}

.section-head h2 {
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.18;
  font-weight: 800;
  margin-bottom: 10px;
}

.section-head p {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 16px;
}

/* ---------- Pillars (3 clean columns) ---------- */
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.pillar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.pillar-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  margin-bottom: 10px;
}

.pillar h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.pillar p {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 14.5px;
}

/* ---------- Interactive Tutorial Stepper ---------- */
.tutorial-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 28px;
  align-items: start;
}

.step-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-tab {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 15px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.step-tab:hover {
  background: var(--surface-subtle);
}

.step-tab.is-active {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-tab.is-active .step-num {
  background: var(--teal);
  color: #ffffff;
}

.step-tab strong {
  display: block;
  font-size: 14.5px;
  color: var(--ink);
  font-weight: 700;
}

.step-tab span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.step-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-md);
}

.step-panel h3 {
  font-size: 22px;
  margin-bottom: 10px;
}

.step-panel p {
  margin: 0 0 18px;
  color: var(--ink-secondary);
  font-size: 15px;
}

.step-checklist {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-checklist li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14.5px;
  color: var(--ink);
}

.step-check {
  color: var(--teal);
  font-weight: 800;
  flex-shrink: 0;
}

.step-tip {
  background: var(--surface-subtle);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 15px;
  font-size: 13.5px;
  color: var(--ink-secondary);
}

/* ---------- Template Packs Repository ---------- */
.repo-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 0.14s ease;
}

.filter-pill:hover {
  border-color: var(--teal);
  color: var(--ink);
}

.filter-pill.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.search-box {
  position: relative;
  min-width: 260px;
  flex: 0 1 320px;
}

.search-box input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 122, 111, 0.14);
}

.packs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.pack-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.pack-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.pack-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pack-specialty {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-ink);
  background: var(--teal-soft);
  padding: 3px 10px;
  border-radius: 999px;
}

.pack-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

.pack-card h3 {
  font-size: 19px;
  font-weight: 700;
}

.pack-desc {
  margin: 0;
  font-size: 14px;
  color: var(--ink-secondary);
  flex: 1;
}

.pack-templates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tpl-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 6px;
}

.pack-card-actions {
  display: flex;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pack-card-actions .btn-primary {
  flex: 1;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 36px 20px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
}

/* ---------- Contribute Callout ---------- */
.contribute-box {
  margin-top: 32px;
  background: var(--surface-dark);
  color: #e6efed;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.contribute-box h3 {
  color: #ffffff;
  font-size: 20px;
  margin-bottom: 6px;
}

.contribute-box p {
  margin: 0;
  font-size: 14.5px;
  color: #b7cbc7;
  max-width: 620px;
}

.contribute-steps {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.contribute-pill {
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

/* ---------- FAQ Accordion ---------- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 820px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-item summary {
  list-style: none;
  padding: 16px 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

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

.faq-item summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--teal);
  font-weight: 500;
}

.faq-item[open] summary::after {
  content: '−';
}

.faq-body {
  padding: 0 20px 18px;
  color: var(--ink-secondary);
  font-size: 14.5px;
}

.faq-body p {
  margin: 0;
}

/* ---------- Modal (Pack Preview) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 29, 33, 0.56);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.modal-head h3 {
  font-size: 20px;
  margin-bottom: 4px;
}

.modal-close {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-tpl-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #fbfcfc;
}

.modal-tpl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.modal-tpl-head strong {
  font-family: var(--font-display);
  font-size: 15px;
}

.modal-tpl-meta {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
}

.modal-rule-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--ink-secondary);
}

.modal-rule-list b {
  color: var(--ink);
}

.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--bg);
}

/* ---------- Privacy Page Prose ---------- */
.prose-wrap {
  max-width: 780px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-sm);
}

.prose-wrap h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.prose-date {
  font-size: 13.5px;
  color: var(--ink-muted);
  margin-bottom: 28px;
}

.prose-wrap h2 {
  font-size: 20px;
  margin: 28px 0 10px;
}

.prose-wrap p,
.prose-wrap li {
  font-size: 15px;
  color: var(--ink-secondary);
}

.prose-wrap ul {
  padding-left: 20px;
}

.prose-highlight {
  background: var(--teal-soft);
  border: 1px solid #b5dfd7;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  color: var(--teal-ink);
  font-size: 14.5px;
  margin: 20px 0;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 36px 0 48px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--ink-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--ink-secondary);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-dark);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 120;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .hero-grid,
  .tutorial-layout {
    grid-template-columns: 1fr;
  }
  .pillars-grid {
    grid-template-columns: 1fr;
  }
  .packs-grid {
    grid-template-columns: 1fr;
  }
  .nav-links {
    display: none;
  }
}

@media (max-width: 560px) {
  .demo-tpl-row {
    grid-template-columns: 1fr;
  }
  .prose-wrap {
    padding: 24px;
  }
  .contribute-box {
    padding: 22px;
  }
}
