@import url('fonts.css');

:root {
  --paper:       #efeae0;   /* warm page ground */
  --sheet:       #fffdf8;   /* the A4 card */
  --ink:         #1b1813;   /* warm near-black */
  --mid:         #5c554a;   /* warm muted */
  --faint:       #9c9283;   /* warm faint */
  --rule:        #e4ddcf;   /* warm hairline */
  --accent:      #b04e2c;   /* clay / terracotta */
  --accent-soft: #f4e6db;   /* accent tint */

  --display: 'Liberation Serif', 'Times New Roman', Georgia, serif;
  --sans:    'Hanken Grotesk', -apple-system, system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, 'Courier New', monospace;

  --page-width: 210mm;
  --gutter:     48px;
}

/* Secret "vibe-code" theme — Catppuccin Mocha */
body.theme-mocha {
  --paper:       #181825;   /* mantle — page ground */
  --sheet:       #1e1e2e;   /* base — the card */
  --ink:         #cdd6f4;   /* text */
  --mid:         #a6adc8;   /* subtext0 */
  --faint:       #6c7086;   /* overlay0 */
  --rule:        #313244;   /* surface0 */
  --accent:      #fab387;   /* peach */
  --accent-soft: #45475a;   /* surface1 */
}

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

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  padding: 48px 20px 96px;
  position: relative;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle paper grain for atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--page-width);
  margin: 0 auto 20px;
}

.forward-link {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mid);
  text-decoration: none;
  padding-bottom: 2px;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.3s, color 0.3s;
}
.forward-link:hover { color: var(--ink); background-size: 100% 1px; }

.toolbar button {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--sheet);
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.25s, transform 0.25s;
}
.toolbar button:hover { background: var(--accent); transform: translateY(-1px); }

.loading {
  text-align: center;
  margin-top: 120px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cv {
  counter-reset: sec;
  max-width: var(--page-width);
  margin: 0 auto;
  background: var(--sheet);
  padding: var(--gutter) var(--gutter) 56px;
  box-shadow: 0 1px 2px rgba(30,22,12,0.05), 0 24px 60px -24px rgba(30,22,12,0.25);
}

.cv::before {
  content: "Curriculum Vit\00E6";
  display: block;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 24px;
}

.hidden { display: none; }

.cv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}

.cv-header-main { min-width: 0; }

.cv-photo {
  flex-shrink: 0;
  width: 110px;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.cv-header h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 3.4rem;
  line-height: 0.98;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-bottom: 10px;
}

.cv-title {
  font-size: 0.92rem;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 18px;
}

.cv-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--mid);
}

.cv-contacts a {
  color: var(--mid);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.3s, color 0.3s;
}
.cv-contacts a:hover { color: var(--ink); background-size: 100% 1px; }

.cv-summary {
  margin-bottom: 34px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--rule);
  font-size: 1.02rem;
  color: var(--ink);
  line-height: 1.75;
  max-width: 64ch;
  text-align: justify;
}

.cv-section {
  margin-bottom: 34px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--rule);
}

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

.cv-section h2 {
  display: flex;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink);
  margin-bottom: 22px;
}

.cv-section h2::before {
  counter-increment: sec;
  content: counter(sec, decimal-leading-zero);
  color: var(--accent);
  margin-right: 0.9em;
}

.entry { margin-bottom: 24px; }
.entry:last-child { margin-bottom: 0; }

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 3px;
}

.entry-title { font-size: 1rem; font-weight: 600; color: var(--ink); }

.entry-date {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--faint);
  white-space: nowrap;
}

.entry-sub {
  font-size: 0.86rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 8px;
}

.entry-gpa {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--mid);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 2px;
  margin-bottom: 8px;
}

.entry ul { padding-left: 18px; margin-top: 6px; }
.entry ul li {
  font-size: 0.9rem;
  color: var(--mid);
  line-height: 1.7;
  margin-bottom: 3px;
  text-align: justify;
}
.entry ul li::marker { color: var(--accent); }

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 22px;
}

.skill-group h3 {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-bottom: 10px;
}

.skill-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.skill-tag {
  font-size: 0.8rem;
  color: var(--ink);
  background: transparent;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  transition: border-color 0.25s, color 0.25s;
}
.skill-tag:hover { border-color: var(--accent); color: var(--accent); }

.project {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px dashed var(--rule);
}
.project:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.project-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.project-name { font-size: 1rem; font-weight: 600; color: var(--ink); }

.status-badge {
  font-family: var(--mono);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 999px;
}
.status-complete    { background: #e7efe7; color: #3d6b46; }
.status-maintained  { background: #e6eef5; color: #3a5f8a; }
.status-development { background: var(--accent-soft); color: var(--accent); }
.status-planned     { background: #efece4; color: var(--faint); }

.project-stack {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--mid);
  margin-bottom: 6px;
}

.project-desc { font-size: 0.9rem; color: var(--mid); line-height: 1.7; text-align: justify; }

.project-link {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--accent);
  text-decoration: none;
  margin-top: 6px;
  display: inline-block;
}
.project-link:hover { text-decoration: underline; }

.award { margin-bottom: 12px; display: flex; gap: 12px; align-items: baseline; }
.award-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 8px;
}
.award-title { font-size: 0.92rem; font-weight: 600; color: var(--ink); }
.award-desc { font-size: 0.86rem; color: var(--mid); text-align: justify; }

.languages-list { display: flex; gap: 18px; flex-wrap: wrap; }
.lang-item { font-size: 0.9rem; color: var(--ink); }
.lang-level {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--faint);
  margin-left: 6px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.cv > * { animation: rise 0.6s cubic-bezier(0.2, 0.6, 0.2, 1) both; }
.cv > *:nth-child(1) { animation-delay: 0.05s; }
.cv > *:nth-child(2) { animation-delay: 0.12s; }
.cv > *:nth-child(3) { animation-delay: 0.19s; }
.cv > *:nth-child(4) { animation-delay: 0.26s; }
.cv > *:nth-child(5) { animation-delay: 0.33s; }
.cv > *:nth-child(6) { animation-delay: 0.40s; }
.cv > *:nth-child(7) { animation-delay: 0.47s; }
.cv > *:nth-child(8) { animation-delay: 0.54s; }
.cv > *:nth-child(n+9) { animation-delay: 0.6s; }

/* scoped to screen so print/PDF (A4 ≈ 793px) is unaffected */
@media screen and (max-width: 820px) {
  body { padding: 26px 14px 64px; }
  .cv { padding: 34px 24px 44px; }
  .cv-header h1 { font-size: 2.7rem; }
}

/* Real @page margins so every page — not only the first and last — gets safe
   space. The cream still reaches the paper edge because the root element's
   background propagates to the page canvas, which covers the margin box too. */
@page { size: A4; margin: 14mm 15mm; }

@media print {
  html {
    background: var(--sheet);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body {
    background: transparent;
    padding: 0;
    margin: 0;
  }
  body::before { display: none; }
  .no-print { display: none !important; }
  .cv {
    background: transparent;
    box-shadow: none;
    max-width: 100%;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;  /* render accent, skill tags, award dots */
  }

  /* Justified text opens rivers at this measure; ragged right reads cleaner. */
  .cv-summary, .entry ul li, .project-desc, .award-desc { text-align: left; }

  /* Keep the smallest meaningful units whole, but let long sections flow —
     a section taller than a page must be breakable or it leaves a blank page. */
  .entry, .award, .skill-group, .cv-header { break-inside: avoid; }
  .cv-section, .project { break-inside: auto; }

  /* Nothing gets stranded at a page foot: no lone heading, no orphaned link. */
  .cv-section h2, .skill-group h3,
  .entry-header, .entry-sub,
  .project-header, .project-stack, .project-desc { break-after: avoid; }
  .cv-summary, .project-desc, .award-desc, .entry ul li { orphans: 3; widows: 3; }

  /* Tighter rhythm on paper: screen spacing spills a few lines onto an extra sheet. */
  body { line-height: 1.5; }
  .cv-header { margin-bottom: 26px; padding-bottom: 20px; }
  .cv-summary { margin-bottom: 24px; padding-bottom: 20px; line-height: 1.6; }
  .cv-section { padding-bottom: 16px; margin-bottom: 20px; }
  .cv-section h2 { margin-bottom: 16px; }
  .entry { margin-bottom: 16px; }
  .entry ul li, .project-desc, .award-desc { line-height: 1.55; }
  .project { margin-bottom: 16px; padding-bottom: 16px; }
  .skills-grid { gap: 16px; }

  * { animation: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
  .forward-link, .toolbar button, .cv-contacts a, .skill-tag { transition: none; }
}
