/* ---------- Tokens ---------- */
:root {
  --text:        #0f172a;
  --text-soft:   #334155;
  --text-mute:   #64748b;
  --border:      #e2e8f0;
  --border-soft: #f1f5f9;
  --accent:      #0e7490;
  --accent-deep: #0c5e6e;
  --accent-soft: #ecfeff;
  --bg:          #ffffff;
  --bg-soft:     #f6f7f9;
  --max-width:   880px;
  --radius:      6px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Lock the viewport: the page is the scroll container so the
   scrollbar shows at the CV's right edge, not the viewport's. */
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 120ms ease, color 120ms ease; }
a:hover { color: var(--accent-deep); border-bottom-color: currentColor; }

/* ---------- Body ---------- */
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg-soft);
  background-image: url('low-contrast-linen.png');
  background-repeat: repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

/* ---------- Scroll wrapper around the page ----------
   .page-scroll is the actual scroll container - .page is just a
   normal card inside it. This puts the scrollbar OUTSIDE the page
   card and lets wheel events anywhere in the wrapper drive the
   scroll. Mirrors noted's .notebook-cells-scroll / .notebook-page
   pattern. */
.page-scroll {
  /* Wrapper width = page max-width + room for the slim scrollbar
     gutter, centered horizontally. NO vertical margins on the
     wrapper - empty space at top/bottom inside the wrapper would
     show up as linen mid-scroll. The page card itself provides the
     32px above/below via its own margins. */
  max-width: calc(var(--max-width) + 24px);
  margin: 0 auto;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

/* Slim 8px scrollbar - matches the proven pattern. Width on the
   scrollbar + a styled track + styled thumb + hover variant. NO
   scrollbar-button rule: defining the standard pseudo-elements is
   what tells Chromium to drop its native scrollbar (with arrows)
   in favor of the themed one. */
.page-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.page-scroll::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 8px;
  margin: 32px 0;
}
/* Thumb is invisible by default - reveals only when the cursor is
   over the .page card (same trigger the .pdf-button uses), thanks to
   :has(). Direct thumb hover deepens the color. */
.page-scroll::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s ease;
}
.page-scroll:has(.page:hover)::-webkit-scrollbar-thumb {
  background: rgba(96, 150, 229, 0.60);
}
.page-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(72, 145, 255, 0.6);
  cursor: pointer;
}

/* ---------- Page shell ---------- */
.page {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  margin-top: 32px;
  margin-bottom: 32px;
  background: var(--bg);
  padding: 48px 56px 56px;
  border-top: 4px solid #5aa098;
  box-shadow: rgba(9, 30, 66, 0.25) 0px 1px 1px, rgba(9, 30, 66, 0.13) 0px 0px 1px 1px;
}

/* ---------- Save-as-PDF button (top-right, reveals on hover) ---------- */
.pdf-button {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-mute);
  cursor: pointer;
  opacity: 0;
  transition: opacity 180ms ease, color 180ms ease, border-color 180ms ease, transform 120ms ease;
  font: inherit;
}
.page:hover .pdf-button,
.pdf-button:focus-visible {
  opacity: 1;
}
.pdf-button:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.pdf-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pdf-button svg,
.pdf-button img {
  width: 24px;
  height: 24px;
  display: block;
}
@media (hover: none) {
  .pdf-button { opacity: 1; }
}

@media (min-width: 1024px) {
  .page { margin-top: 32px; margin-bottom: 32px; }
}

/* ---------- Header ---------- */
.cv-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 24px;
  margin-bottom: 72px;
}
.cv-header-text {
  flex: 1 1 auto;
  min-width: 0;
}
.photo {
  flex: 0 0 auto;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-soft);
  box-shadow: 0 0 0 1px var(--border), 0 6px 18px rgba(15, 23, 42, 0.10);
}
@media (max-width: 640px) {
  .cv-header { flex-direction: column-reverse; align-items: flex-start; gap: 16px; }
  .photo { width: 96px; height: 96px; }
}
.name {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--text);
}
.tagline {
  margin: 0 0 24px;
  font-size: 15px;
  color: var(--text-soft);
  max-width: 60ch;
}
.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  font-size: 13.5px;
  color: var(--text-mute);
}
.contact li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.contact .contact-icon {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--text-mute);
}
.contact a { color: var(--text-soft); }
.contact a:hover { color: var(--accent-deep); }

/* ---------- Section base ---------- */
section { margin-bottom: 32px; }
section h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
section .section-note {
  font-size: 13.5px;
  color: var(--text-mute);
  margin: -4px 0 16px;
}
p { margin: 0 0 10px; }

/* ---------- Summary ---------- */
.summary p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-soft);
}
.summary strong { color: var(--text); }

/* ---------- Skills ---------- */
.skill-blocks {
  margin: 0;
  display: grid;
  gap: 10px 24px;
}
.skill { display: grid; grid-template-columns: 180px 1fr; gap: 16px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--border-soft); }
.skill:last-child { border-bottom: 0; }
.skill dt {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
.skill dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.55;
}
.skill dd strong { color: var(--text); }

@media (max-width: 640px) {
  .skill { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- Projects ---------- */
.project {
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--border-soft);
  break-inside: avoid;
  page-break-inside: avoid;
}
.project:last-child { border-bottom: 0; }
.project h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 15.5px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -0.005em;
}
.project h3 .title-text {
  flex: 1 1 auto;
  min-width: 0;
}
.project h3 .title-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}
.project h3 .action-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.project h3 .action-pair + .action-pair::before {
  content: '·';
  color: var(--border);
  margin: 0 4px;
}
.project h3 .live-link {
  color: var(--accent);
  border-bottom: 1px solid transparent;
}
.project h3 .live-link:hover {
  color: var(--accent-deep);
  border-bottom-color: currentColor;
}
.project h3 .repo-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-mute);
  border: none;
}
.project h3 .repo-link:hover { color: var(--text); }
.project h3 .gh-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
  display: block;
}
.project p {
  font-size: 13.5px;
  color: var(--text-soft);
  margin: 0 0 8px;
}
.project ul {
  margin: 0 0 8px;
  padding-left: 18px;
  list-style: disc;
}
.project ul li {
  font-size: 13.5px;
  color: var(--text-soft);
  margin-bottom: 4px;
}
.project code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}
.project .tech {
  font-size: 12.5px;
  color: var(--text-mute);
  font-style: italic;
  margin: 6px 0 8px;
}
.project .links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: 0;
}
.project .links a {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #cffafe;
  border-radius: 999px;
  padding: 2px 10px;
  border-bottom: 1px solid #cffafe;
  transition: all 120ms ease;
}
.project .links a:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Experience ---------- */
.role {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
  break-inside: avoid;
  page-break-inside: avoid;
}
.role:last-of-type { border-bottom: 0; }
.role-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 2px;
}
.role-where {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.role-when {
  font-size: 13px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.role-title {
  font-size: 13.5px;
  color: var(--accent);
  font-weight: 500;
  margin: 0 0 8px;
}
.role-title .sub-when {
  color: var(--text-mute);
  font-weight: 400;
}
.role ul, .sub-role ul {
  margin: 6px 0 0;
  padding-left: 18px;
  list-style: disc;
}
.role ul li, .sub-role ul li {
  font-size: 13.5px;
  color: var(--text-soft);
  margin-bottom: 4px;
}
.sub-role { margin-top: 12px; }
.sub-role:first-of-type { margin-top: 8px; }

@media (max-width: 640px) {
  .role-head { flex-direction: column; gap: 2px; }
}

/* ---------- Former list ---------- */
.former-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 22px 0 10px;
}
.former-list {
  display: grid;
  gap: 4px;
}
.former-list li {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, 1.4fr) auto;
  gap: 12px;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border-soft);
}
.former-list li:last-child { border-bottom: 0; }
.former-role { color: var(--text); font-weight: 500; }
.former-where { color: var(--text-soft); }
.former-when { color: var(--text-mute); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 720px) {
  .former-list li { grid-template-columns: 1fr; gap: 1px; padding: 6px 0; }
  .former-when { font-size: 12px; }
}

/* ---------- Education ---------- */
.degree { padding: 10px 0; }
.degree:first-of-type { padding-top: 0; }
.degree p { font-size: 13.5px; color: var(--text-soft); margin: 6px 0 0; }

/* ---------- Languages ---------- */
.lang-list {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.lang-list li { font-size: 14px; color: var(--text-soft); }
.lang-list strong { color: var(--text); }

/* ---------- Certifications ---------- */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.cert-group h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.cert-group ul li {
  font-size: 12.5px;
  color: var(--text-soft);
  margin-bottom: 4px;
  padding-left: 12px;
  position: relative;
  line-height: 1.45;
}
.cert-group ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

@media (max-width: 880px) {
  .cert-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .cert-grid { grid-template-columns: 1fr; }
}

/* ---------- Achievements ---------- */
.achievements ul {
  display: grid;
  gap: 10px;
}
.achievements li {
  font-size: 13.5px;
  color: var(--text-soft);
  padding: 12px 14px;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  line-height: 1.55;
}
.achievements li strong { color: var(--text); }
.achievements li em { color: var(--text-soft); }

/* ---------- Footer ---------- */
.cv-footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12.5px;
  color: var(--text-mute);
  font-style: italic;
}

/* ---------- Print ---------- */
@media print {
  @page {
    size: A4;
    margin: 14mm 14mm 14mm 14mm;
  }
  /* Undo the on-screen scroll-container setup: for print we need
     unrestricted content height so it flows across pages, and no
     overflow clipping. Also clear the narrow-mode padding-top
     that reserves space for the launcher badge - that badge is
     hidden in print, so the reservation just becomes a giant gap. */
  html, body {
    background: #fff;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  .page-scroll {
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
  }
  .pdf-button { display: none; }
  body { font-size: 10.5pt; line-height: 1.4; color: #000; }
  .page {
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-top: 0;
  }
  .name { font-size: 24pt; }
  .tagline { font-size: 10pt; }
  .contact { font-size: 9pt; }
  .photo {
    width: 26mm;
    height: 26mm;
    box-shadow: none;
    border: 1px solid #c8c8c8;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .cv-header { gap: 16mm; }
  section h2 { font-size: 9.5pt; }
  .project h3 { font-size: 11pt; }
  .role-where { font-size: 10.5pt; }
  .role-when, .role-title { font-size: 9.5pt; }
  .project p, .role ul li, .sub-role ul li { font-size: 9.5pt; }
  .project .tech { font-size: 8.5pt; }
  .project .links a {
    background: transparent;
    border: 1px solid #999;
    color: #000;
    border-bottom: 1px solid #999;
    padding: 1px 6px;
  }
  .achievements li {
    background: transparent;
    border-left: 2px solid #555;
  }
  /* Anchors stay clickable in the printed PDF (Chrome preserves them
     automatically). No URL-after-text suffix. */
  a { color: #000; border-bottom: 0; }
  .project h3 { gap: 8px; }
  .project h3 .title-actions { font-size: 8.5pt; }
  .project h3 .gh-icon { width: 9pt; height: 9pt; }
  .page-break { page-break-before: always; break-before: page; }
  .project, .role, .sub-role, .degree, .achievements li, .cert-group {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  section h2, .project h3, .role-head, .former-heading {
    break-after: avoid;
    page-break-after: avoid;
  }
  .cv-footer { margin-top: 18px; }
}
