/* ================================================================
   MEDIAWIJS – DE BRONNENLADDER
   style.css
   Mobile-first. Custom font. SortableJS states. PDF worksheet.
   ================================================================ */

/* ----------------------------------------------------------------
   1. CUSTOM FONT
   ---------------------------------------------------------------- */
@font-face {
  font-family: 'Amsi Pro';
  src: url('../fonts/Stawix-AmsiPro.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ----------------------------------------------------------------
   2. CSS VARIABLES (DESIGN TOKENS)
   ---------------------------------------------------------------- */
:root {
  /* Brand colours */
  --pink:         #ff3c99;
  --pink-hover:   #e0007a;
  --pink-glow:    rgba(255, 60, 153, 0.35);
  --blue:         #2f2e99;
  --blue-light:   #4f4ec0;
  --blue-dark:    #1e1d6b;
  --blue-faint:   #ebe9ff;

  /* Neutral palette */
  --white:        #ffffff;
  --off-white:    #f5f4fc;
  --gray-100:     #ececf6;
  --gray-200:     #d8d7eb;
  --gray-400:     #9898b8;
  --text-dark:    #1a1a2e;
  --text-mid:     #44446a;

  /* Status colours */
  --green:        #00b85c;
  --red:          #e5001e;

  /* Radii */
  --r-sm:  8px;
  --r-md:  14px;
  --r-lg:  22px;
  --r-xl:  32px;

  /* Shadows */
  --shadow-card:    0 2px 12px rgba(47, 46, 153, 0.10);
  --shadow-lifted:  0 6px 28px rgba(47, 46, 153, 0.18);
  --shadow-float:   0 12px 48px rgba(47, 46, 153, 0.22);

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.22s ease;
}

/* ----------------------------------------------------------------
   3. RESET & BASE
   ---------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Amsi Pro', 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--off-white);
  color: var(--text-dark);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

a {
  text-decoration: none;
  color: inherit;
}

/* ----------------------------------------------------------------
   4. SHARED COMPONENTS
   ---------------------------------------------------------------- */

/* Logo */
.logo {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.logo--small {
  height: 34px;
}

/* ----------------------------------------------------------------
   5. INDEX PAGE
   ---------------------------------------------------------------- */
.page-index {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(47, 46, 153, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 80%, rgba(255, 60, 153, 0.07) 0%, transparent 55%),
    var(--off-white);
}

/* Header */
.index-header {
  display: flex;
  justify-content: center;
  padding: 28px 20px 16px;
}

/* Hero text */
.index-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 20px 48px;
}

.hero {
  text-align: center;
  max-width: 440px;
  margin-bottom: 36px;
}

.hero-title {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 900;
  color: var(--blue);
  line-height: 1.15;
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-mid);
  line-height: 1.65;
}

/* Category cards grid */
.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 480px;
}

/* Base card */
.category-card {
  display: block;
  border-radius: var(--r-xl);
  overflow: hidden;
  transition: transform var(--t-normal), box-shadow var(--t-normal);
  -webkit-tap-highlight-color: transparent;
}

.category-card:hover,
.category-card:focus-visible {
  transform: translateY(-3px);
}

.category-card:active {
  transform: scale(0.97);
}

.card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
  min-height: 180px;
  text-align: center;
}

/* Online variant — Blue */
.card--online {
  background: linear-gradient(140deg, var(--blue-dark) 0%, var(--blue-light) 100%);
  box-shadow: 0 8px 36px rgba(47, 46, 153, 0.32);
}

.card--online:hover {
  box-shadow: 0 14px 48px rgba(47, 46, 153, 0.42);
}

/* Fysiek variant — Pink */
.card--fysiek {
  background: linear-gradient(140deg, var(--pink-hover) 0%, var(--pink) 100%);
  box-shadow: 0 8px 36px var(--pink-glow);
}

.card--fysiek:hover {
  box-shadow: 0 14px 48px rgba(255, 60, 153, 0.48);
}

.card-icon {
  font-size: 2.8rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.15));
}

.card-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--white);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 16px;
}

.card-cta {
  display: inline-block;
  padding: 8px 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: background var(--t-fast);
}

.category-card:hover .card-cta {
  background: rgba(255, 255, 255, 0.3);
}

/* Footer */
.index-footer {
  text-align: center;
  padding: 16px 20px 24px;
  font-size: 0.8rem;
  color: var(--gray-400);
}

/* ----------------------------------------------------------------
   6. LADDER PAGE
   ---------------------------------------------------------------- */
.page-ladder {
  background: var(--off-white);
  /* Extra bottom padding for fixed bottom bar */
  padding-bottom: 104px;
}

/* ---- Sticky header ---- */
.ladder-header {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-100);
  box-shadow: 0 1px 8px rgba(47, 46, 153, 0.06);
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--gray-100);
  color: var(--blue);
  font-size: 1.3rem;
  font-weight: 700;
  transition: background var(--t-fast), transform var(--t-fast);
  flex-shrink: 0;
}

.back-btn:hover {
  background: var(--gray-200);
  transform: translateX(-2px);
}

.back-btn:active {
  transform: scale(0.93);
}

/* Keeps logo centred between back-btn and spacer */
.header-spacer {
  width: 44px;
  flex-shrink: 0;
}

/* ---- Intro section ---- */
.ladder-intro {
  max-width: 600px;
  margin: 0 auto;
  padding: 22px 20px 8px;
}

.ladder-title {
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 900;
  color: var(--blue);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.ladder-desc {
  font-size: 0.93rem;
  color: var(--text-mid);
  line-height: 1.55;
}

.handle-hint {
  font-weight: 700;
  color: var(--blue-light);
  background: var(--blue-faint);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---- Trust labels ---- */
.trust-label {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 600px;
  margin: 10px auto 2px;
  padding: 6px 20px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trust-label--high { color: var(--green); }
.trust-label--low  { color: var(--red); margin-top: 4px; }

.trust-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.trust-dot--green { background: var(--green); }
.trust-dot--red   { background: var(--red); }

/* ---- Sortable list ---- */
.sortable-list {
  list-style: none;
  max-width: 600px;
  margin: 0 auto;
  padding: 6px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- Individual source item ---- */
.source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--r-md);
  padding: 10px 14px;
  min-height: 80px;         /* Thumb-friendly tap target */
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  user-select: none;
  -webkit-user-select: none;
  transition:
    box-shadow var(--t-normal),
    border-color var(--t-normal),
    transform var(--t-normal);
  will-change: transform;
}

.source-item:hover {
  box-shadow: var(--shadow-lifted);
  border-color: var(--gray-100);
}

/* ---- Drag handle ---- */
.drag-handle {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--gray-200);
  cursor: grab;
  padding: 6px 4px;
  flex-shrink: 0;
  touch-action: none;   /* Prevents page scroll on touch drag */
  transition: color var(--t-fast), transform var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.drag-handle:hover  { color: var(--blue-light); }
.drag-handle:active { cursor: grabbing; transform: scale(1.1); }

/* ---- Source image ---- */
.source-img {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  object-fit: contain;
  flex-shrink: 0;
  background: var(--gray-100);
  border: 1px solid var(--gray-100);
  transition: transform var(--t-normal);
}

.source-img:hover {
  transform: scale(1.1);
}

/* ---- Source name ---- */
.source-info {
  flex: 1;
  min-width: 0;
}

.source-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Rank badge ---- */
.rank-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  font-size: 0.82rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--t-fast);
}

/* ---- SortableJS states ---- */

/* Ghost = placeholder left behind while dragging */
.sortable-ghost {
  opacity: 0.35 !important;
  background: var(--blue-faint) !important;
  box-shadow: none !important;
  border: 2px dashed var(--blue-light) !important;
  transform: none !important;
}

/* Chosen = the item currently held */
.sortable-chosen {
  box-shadow: var(--shadow-float) !important;
  transform: scale(1.025) rotate(0.5deg) !important;
  border-color: var(--blue-light) !important;
  z-index: 10;
}

/* Drag clone in transit */
.sortable-drag {
  opacity: 1 !important;
  box-shadow: var(--shadow-float) !important;
}

/* ----------------------------------------------------------------
   6.5. IMAGE MODAL
   ---------------------------------------------------------------- */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-float);
}

.modal-img {
  max-width: 80vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--r-md);
}

.modal-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 40px;
  height: 40px;
  background: var(--pink);
  color: var(--white);
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
}

.modal-close:hover {
  background: var(--pink-hover);
}

/* ----------------------------------------------------------------
   7. FIXED BOTTOM BAR & DOWNLOAD BUTTON
   ---------------------------------------------------------------- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  padding: 12px 16px max(20px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--gray-100);
}

.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 568px;
  margin: 0 auto;
  padding: 18px 24px;
  background: var(--pink);
  color: var(--white);
  border: none;
  border-radius: var(--r-lg);
  font-family: 'Amsi Pro', sans-serif;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 24px var(--pink-glow);
  transition:
    background var(--t-fast),
    box-shadow var(--t-fast),
    transform var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.download-btn:hover {
  background: var(--pink-hover);
  box-shadow: 0 6px 32px rgba(255, 60, 153, 0.48);
  transform: translateY(-1px);
}

.download-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 12px var(--pink-glow);
}

.download-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.download-icon {
  font-size: 1.1rem;
}

/* ----------------------------------------------------------------
   8. PDF TEMPLATE  (hidden off-screen — rendered by html2pdf.js)
   ---------------------------------------------------------------- */

/*
 * The template sits off-screen at all times.
 * Just before PDF export, app.js temporarily repositions it
 * so html2pdf.js can measure and render it correctly.
 */
#pdf-template {
  position: fixed;
  left: -9999px;
  top: 0;
  visibility: hidden;

  /* A4 dimensions */
  width: 210mm;
  min-height: 297mm;
  background: var(--white);
  font-family: 'Amsi Pro', 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-dark);
  padding: 6mm 12mm 8mm;
  box-sizing: border-box;
}

/* PDF Header — logo left, date right */
.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 5mm;
  margin-bottom: 4mm;
  border-bottom: 2.5px solid var(--blue);
}

.pdf-logo {
  height: 28px;
  width: auto;
}

.pdf-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9pt;
  color: #666;
}

.pdf-meta__label { font-weight: 700; }
.pdf-meta__line  { letter-spacing: 0.1em; color: #999; }

/* PDF Title */
.pdf-main-title {
  font-size: 20pt;
  font-weight: 900;
  color: var(--blue);
  margin-bottom: 1.5mm;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.pdf-subtitle {
  font-size: 9.5pt;
  color: #666;
  margin-bottom: 3mm;
}

/* Decorative horizontal rule */
.pdf-rule {
  height: 3px;
  border-radius: 2px;
  margin-bottom: 4mm;
}

.pdf-rule--pink { background: var(--pink); }

/* Scale indicator row */
.pdf-scale {
  display: flex;
  justify-content: space-between;
  font-size: 8pt;
  color: #888;
  margin-bottom: 4mm;
  padding-bottom: 3mm;
  border-bottom: 1px solid var(--gray-100);
}

/* ---- PDF list ---- */
.pdf-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/*
 * Each PDF row = left column (rank + image + name) + right column (question + lines)
 * Layout: fixed-width left (32mm) + flex-grow right
 */
.pdf-item {
  display: flex;
  align-items: flex-start;
  gap: 5mm;
  padding: 4mm 0;
  border-bottom: 1px solid #e0e0ea;
  page-break-inside: avoid;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  overflow: hidden; /* helpt html2canvas bij paginabreuk */
}

/* Left column */
.pdf-item__left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5mm;
  flex-shrink: 0;
  width: 28mm;
}

.pdf-item__rank {
  width: 7mm;
  height: 7mm;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  font-size: 8pt;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-item__img {
  width: 22mm;
  height: 22mm;
  object-fit: contain;
  background: #f4f3fb; /* lichte achtergrond als afbeelding niet vierkant is */
  border-radius: 2.5mm;
  border: 1px solid #ddd;
  display: block;
}

.pdf-item__name {
  font-size: 8.5pt;
  font-weight: 700;
  color: var(--text-dark);
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
}

/* Right column */
.pdf-item__right {
  flex: 1;
  padding-top: 1mm;
}

.pdf-item__question {
  font-size: 8pt;
  font-weight: 800;
  color: var(--blue);
  margin-bottom: 3.5mm;
  line-height: 1.4;
}

/*
 * Writing lines: full-width dotted underscores.
 * Rendered as empty <span> blocks with a bottom border.
 */
.pdf-line {
  display: block;
  width: 100%;
  height: 0;
  border: none;
  border-bottom: 1.2px dotted #b0b0c8;
  margin-bottom: 4.5mm;
}

/* PDF Footer */
.pdf-footer {
  display: flex;
  justify-content: space-between;
  font-size: 7.5pt;
  color: #aaa;
  margin-top: 6mm;
  padding-top: 3mm;
  border-top: 1px solid #e0e0ea;
}

/* ----------------------------------------------------------------
   9. RESPONSIVE — TABLET / DESKTOP ENHANCEMENTS
   ---------------------------------------------------------------- */
@media (min-width: 480px) {
  .cards-grid {
    flex-direction: row;
  }

  .category-card {
    flex: 1;
  }

  .card-inner {
    min-height: 200px;
  }
}

@media (min-width: 600px) {
  .sortable-list {
    padding-left: 24px;
    padding-right: 24px;
  }

  .trust-label {
    padding-left: 24px;
    padding-right: 24px;
  }

  .source-img {
    width: 64px;
    height: 64px;
  }
}

/* ----------------------------------------------------------------
   10. PRINT (fallback, for browsers without html2pdf.js)
   ---------------------------------------------------------------- */
@media print {
  body > *:not(#pdf-template) {
    display: none !important;
  }

  #pdf-template {
    position: static !important;
    left: auto !important;
    visibility: visible !important;
    width: 100% !important;
    box-shadow: none !important;
  }
}
