/* ════════════════════════════════════════════════════════════
   Selfolyx Bio — cv.css
   ATS-friendly CV public page
   ════════════════════════════════════════════════════════════ */

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

:root {
  --cv-bg:       #FAFAFA;
  --cv-surface:  #FFFFFF;
  --cv-border:   #E2E8F0;
  --cv-text:     #1A202C;
  --cv-muted:    #718096;
  --cv-accent:   #2B6CB0;
  --cv-tag-bg:   #EBF8FF;
  --cv-tag-text: #2B6CB0;
  --cv-max:      794px;
  --cv-radius:   8px;
}

html, body {
  min-height: 100vh;
  background: var(--cv-bg);
  color: var(--cv-text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Loading & Not Found ─────────────────────────────────── */
#cv-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cv-bg);
  z-index: 100;
}

.cv-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--cv-border);
  border-top-color: var(--cv-accent);
  border-radius: 50%;
  animation: cvSpin 0.7s linear infinite;
}

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

#cv-not-found {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  color: var(--cv-muted);
  padding: 24px;
}

#cv-not-found h1 {
  font-size: 4rem;
  font-weight: 700;
  color: var(--cv-border);
  line-height: 1;
  margin-bottom: 12px;
}

/* ── Page wrapper ────────────────────────────────────────── */
#cv-page {
  display: none;
  max-width: var(--cv-max);
  margin: 0 auto;
  padding: 40px 48px 100px;
}

/* ── Header ──────────────────────────────────────────────── */
.cv-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--cv-text);
}

.cv-photo {
  width: 100px;
  height: 100px;
  border-radius: var(--cv-radius);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--cv-border);
}

.cv-photo-placeholder {
  width: 100px;
  height: 100px;
  border-radius: var(--cv-radius);
  background: var(--cv-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--cv-muted);
}

.cv-header-info { flex: 1; min-width: 0; }

.cv-name {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--cv-text);
  margin-bottom: 4px;
}

.cv-title {
  font-size: 1rem;
  color: var(--cv-accent);
  font-weight: 500;
  margin-bottom: 12px;
}

.cv-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.cv-contact-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--cv-muted);
  text-decoration: none;
}

.cv-contact-item a {
  color: var(--cv-muted);
  text-decoration: none;
}

.cv-contact-item a:hover { color: var(--cv-accent); }

.cv-contact-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ── Section ─────────────────────────────────────────────── */
.cv-section {
  margin-bottom: 24px;
}

.cv-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cv-accent);
  border-bottom: 1px solid var(--cv-border);
  padding-bottom: 5px;
  margin-bottom: 14px;
}

/* ── Summary ─────────────────────────────────────────────── */
.cv-summary {
  font-size: 0.9rem;
  color: var(--cv-text);
  line-height: 1.7;
}

/* ── Experience & Education ──────────────────────────────── */
.cv-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--cv-border);
}

.cv-entry:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.cv-entry-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--cv-text);
  grid-column: 1;
}

.cv-entry-period {
  font-size: 0.78rem;
  color: var(--cv-muted);
  white-space: nowrap;
  grid-column: 2;
  grid-row: 1 / 3;
  text-align: right;
  padding-top: 2px;
}

.cv-entry-sub {
  font-size: 0.83rem;
  color: var(--cv-muted);
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cv-entry-desc {
  font-size: 0.83rem;
  color: var(--cv-text);
  line-height: 1.6;
  margin-top: 6px;
  grid-column: 1 / 3;
}

/* Badge magang */
.cv-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

/* ── Skills ──────────────────────────────────────────────── */
.cv-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cv-skill-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--cv-tag-bg);
  color: var(--cv-tag-text);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid #BEE3F8;
}

/* ── Certifications & Languages ──────────────────────────── */
.cv-cert-item,
.cv-lang-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--cv-border);
  font-size: 0.85rem;
}

.cv-cert-item:last-child,
.cv-lang-item:last-child { border-bottom: none; }

.cv-cert-name,
.cv-lang-name { font-weight: 500; color: var(--cv-text); }

.cv-cert-meta,
.cv-lang-level { font-size: 0.78rem; color: var(--cv-muted); }

.cv-cert-link {
  font-size: 0.75rem;
  color: var(--cv-accent);
  text-decoration: none;
  margin-left: 8px;
}

/* ── PDF viewer ──────────────────────────────────────────── */
.cv-pdf-section {
  margin-top: 32px;
  border-top: 2px solid var(--cv-text);
  padding-top: 20px;
}

.cv-pdf-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cv-accent);
  margin-bottom: 12px;
}

/* Thumbnail halaman 1 — ganti <embed> PDF browser bawaan. Rasio 210:297
   (proporsi kertas A4) dijaga lewat aspect-ratio supaya layout tidak loncat
   sebelum gambar selesai dimuat. */
.cv-pdf-thumb {
  position: relative;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 210 / 297;
  border: 1px solid var(--cv-border);
  border-radius: var(--cv-radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  overflow: hidden;
  cursor: pointer;
  background: #fff;
}

.cv-pdf-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}

.cv-pdf-thumb-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cv-muted);
  background: #fafafa;
}

/* Fallback icon dokumen sederhana (inline SVG via mask) — dipakai kalau
   thumbnail gagal digenerate saat upload, supaya kartu tidak kosong. */
.cv-pdf-icon {
  display: block;
  width: 40px;
  height: 40px;
  background-color: var(--cv-muted);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.cv-pdf-thumb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0);
  transition: background 0.15s ease;
}

.cv-pdf-thumb-overlay span {
  opacity: 0;
  transition: opacity 0.15s ease;
  background: #fff;
  color: var(--cv-text);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 999px;
}

.cv-pdf-thumb:hover .cv-pdf-thumb-overlay,
.cv-pdf-thumb:focus-visible .cv-pdf-thumb-overlay {
  background: rgba(0,0,0,0.35);
}
.cv-pdf-thumb:hover .cv-pdf-thumb-overlay span,
.cv-pdf-thumb:focus-visible .cv-pdf-thumb-overlay span {
  opacity: 1;
}

.cv-pdf-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.cv-pdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid var(--cv-border);
  background: #fff;
  color: var(--cv-text);
}

.cv-pdf-btn--view {
  background: var(--cv-accent);
  color: #fff;
  border-color: var(--cv-accent);
}

/* ── Modal PDF (dirender via PDF.js, lihat cv.js) ─────────── */
.cv-pdf-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.cv-pdf-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.cv-pdf-modal-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: #fff;
  border-radius: var(--cv-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.cv-pdf-modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--cv-border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--cv-text);
}

.cv-pdf-modal-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--cv-muted);
  padding: 4px 8px;
}

/* Area body ini satu-satunya yang scroll (scroll halaman biasa, vertikal
   saja) — menggantikan scrollbar internal <embed> yang bikin "kotak dalam
   kotak" di versi sebelumnya. */
.cv-pdf-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f5f5f5;
}

.cv-pdf-modal-loading,
.cv-pdf-modal-error {
  text-align: center;
  padding: 48px 16px;
  color: var(--cv-muted);
  font-size: 0.85rem;
}

.cv-pdf-modal-error a {
  display: inline-block;
  margin-top: 10px;
  color: var(--cv-accent);
}

/* Tiap halaman PDF: lebar selalu 100% dari body modal, tidak pernah lebih
   lebar dari container — ini yang menghilangkan scroll horizontal. */
.cv-pdf-modal-page {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--cv-border);
}

@media (max-width: 640px) {
  .cv-pdf-modal-panel { max-height: 100vh; border-radius: 0; }
  .cv-pdf-modal { padding: 0; }
}

/* ── Watermark fixed pojok kanan bawah ──────────────────── */
.cv-footer {
  position: fixed;
  bottom: 16px;
  right: 20px;
  font-size: 0.68rem;
  color: rgba(160,174,192,0.55);
  letter-spacing: 0.02em;
  pointer-events: none;
  z-index: 50;
  line-height: 1.4;
  text-align: right;
}

.cv-footer strong { color: rgba(100,120,140,0.65); font-weight: 600; }
.cv-footer span   { color: rgba(100,150,200,0.55); }
.cv-footer a      { color: inherit; text-decoration: none; pointer-events: all; }

/* ── Print / Save as PDF ─────────────────────────────────── */
@media print {
  body { background: #fff; }

  #cv-page {
    padding: 0;
    max-width: 100%;
  }

  .cv-pdf-section { display: none; }

  /* Watermark: fixed → static di footer dokumen pojok kanan */
  .cv-footer {
    position: running(footer);
    display: block;
    text-align: right;
    font-size: 0.6rem;
    color: rgba(160,174,192,0.3);
    bottom: auto;
    right: auto;
  }

  @page {
    margin: 16mm 16mm 24mm 16mm;
    @bottom-right {
      content: "selfolyx.fyi";
      font-size: 7pt;
      color: rgba(160,174,192,0.3);
    }
  }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 520px) {
  .cv-header { flex-direction: column; gap: 16px; }
  .cv-photo,
  .cv-photo-placeholder { width: 72px; height: 72px; }
  .cv-name { font-size: 1.4rem; }
  .cv-entry { grid-template-columns: 1fr; }
  .cv-entry-period { grid-column: 1; grid-row: auto; text-align: left; }
  .cv-entry-desc { grid-column: 1; }
}

/* ── Floating Bubble ─────────────────────────────────────── */
/* Background gelap (token resmi MEA Ecosystem, --mea-bg) terlepas dari
   tema CV yang aktif (termasuk template terang seperti Harvard) — supaya
   logo (logo-dark.svg, didesain untuk latar gelap) tetap kontras jelas
   sebagai tombol, bukan menyatu/hilang dengan background halaman. */
#cv-bubble {
  position: fixed;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--mea-bg, #0A0A0A);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.08);
  cursor: grab;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: box-shadow 0.15s;
}

#cv-bubble:active { cursor: grabbing; }
#cv-bubble:hover  { box-shadow: 0 4px 20px rgba(0,0,0,0.32), 0 0 0 1px rgba(255,255,255,0.12); }

#cv-bubble img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
}

/* ── Mini menu ───────────────────────────────────────────── */
#cv-bubble-menu {
  position: absolute;
  bottom: 56px;
  right: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.13), 0 0 0 1px rgba(0,0,0,0.06);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 130px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.15s, transform 0.15s;
}

#cv-bubble.open #cv-bubble-menu {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

#cv-bubble-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #1A202C;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  font-family: inherit;
}

#cv-bubble-menu button:hover { background: #F7FAFC; }

#cv-btn-print { color: #2B6CB0; }
#cv-btn-print:hover { background: #EBF8FF; }

/* ── Print — sembunyikan bubble ──────────────────────────── */
@media print {
  #cv-bubble { display: none; }
}
