/* =============================================================
   CV page — cv.css
   ============================================================= */

:root {
  --container-max: 56rem;
}

body { font-family: var(--font-sans-en); }
:lang(zh), .lang-zh { font-family: var(--font-sans-zh); }

main h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.75rem, 4vw, 2.1rem);
}

main {
  padding-top:    max(env(safe-area-inset-top,    0px), 3.5rem);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 3.5rem);
}

/* ===================== Download row ===================== */
.cv-download-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.cv-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  background: rgba(208, 221, 255, 0.80);
  border: 1px solid rgba(180, 200, 240, 0.45);
  color: rgba(25, 25, 45, 0.85);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
  white-space: nowrap;
}
.cv-download-btn:hover {
  background: rgba(208, 221, 255, 0.97);
  border-color: rgba(160, 180, 225, 0.70);
  color: rgba(10, 10, 25, 0.95);
}
.cv-download-btn:focus-visible {
  outline: 2px solid rgba(208, 221, 255, 0.60);
  outline-offset: 2px;
}

/* ===================== Accordion ===================== */
.cv-sections { margin-top: 0.25rem; }

.cv-section {
  border-top: 1px solid rgba(255,255,255,0.09);
}
.cv-section:last-child {
  border-bottom: 1px solid rgba(255,255,255,0.09);
}

.cv-section > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  scroll-margin-top: 2.5rem;
}
.cv-section > summary::-webkit-details-marker { display: none; }
.cv-section > summary:focus-visible {
  outline: 2px solid rgba(255,255,255,0.28);
  outline-offset: 3px;
  border-radius: 3px;
}

.cv-section-label {
  font-size: 0.94rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.38);
  transition: color .2s;
}
.cv-section[open] > summary .cv-section-label {
  color: rgba(255,255,255,0.82);
}

.cv-chevron {
  width: 0.85rem;
  height: 0.85rem;
  color: rgba(255,255,255,0.26);
  transition: transform .26s ease, color .2s;
  flex-shrink: 0;
}
.cv-section[open] > summary .cv-chevron {
  transform: rotate(180deg);
  color: rgba(255,255,255,0.50);
}

/* Body — max-height managed by JS */
.cv-section-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height .32s ease;
}

.cv-section-inner { padding-bottom: 1.75rem; }

@media (prefers-reduced-motion: reduce) {
  .cv-section-body    { transition: none; }
  .cv-chevron         { transition: none; }
  .cv-section-label   { transition: none; }
}

/* ===================== Content elements ===================== */

/* Prose */
.cv-prose {
  font-size: 0.875rem;
  line-height: 1.85;
  color: rgba(255,255,255,0.75);
}
.cv-prose p + p { margin-top: 0.8em; }
.cv-prose strong { font-weight: 500; color: rgba(255,255,255,0.90); }
.cv-prose em     { font-style: italic; font-family: var(--font-serif); }

/* Generic row list */
.cv-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.cv-row {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}
.cv-row-year {
  font-size: 0.74rem;
  font-weight: 300;
  color: rgba(255,255,255,0.30);
  min-width: 2.8rem;
  flex-shrink: 0;
  padding-top: 0.15em;
}
.cv-row-content { flex: 1; min-width: 0; }
.cv-row-title {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.86);
  line-height: 1.4;
  font-family: var(--font-serif);
}
.cv-row-event {
  font-size: 0.77rem;
  color: rgba(255,255,255,0.46);
  font-weight: 300;
  margin-top: 0.1rem;
}
.cv-row-location {
  font-size: 0.70rem;
  color: rgba(255,255,255,0.30);
  font-weight: 300;
}

/* Education */
.cv-edu-degree {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.86);
  font-family: var(--font-serif);
  line-height: 1.4;
}
.cv-edu-institution {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.48);
  margin-top: 0.1rem;
}

/* Teaching */
.cv-teach-title {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.82);
  line-height: 1.4;
}
.cv-teach-role {
  font-size: 0.77rem;
  color: rgba(255,255,255,0.42);
  font-weight: 300;
  margin-top: 0.1rem;
}
.cv-teach-institution {
  font-size: 0.70rem;
  color: rgba(255,255,255,0.28);
  font-weight: 300;
}

/* Skills grid */
.cv-skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 1.5rem 2.5rem;
}
.cv-skills-cat-title {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.30);
  margin-bottom: 0.45rem;
}
.cv-skills-items {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.cv-skill-item {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.68);
  line-height: 1.5;
}

/* Portfolio text */
.cv-porto-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cv-porto-group + .cv-porto-group {
  margin-top: 1.2rem;
}
.cv-porto-category {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(0,0,0,0.65);
  background: rgba(255,255,255,0.88);
  padding: 0.15em 0.55em;
  border-radius: 2px;
}
.cv-porto-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.cv-porto-item {
  display: flex;
  align-items: baseline;
  gap: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.76);
}
.cv-porto-item-body {
  flex: 1;
  min-width: 0;
}
.cv-porto-year {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.28);
  font-weight: 300;
  margin-right: 1.1em;
}
.cv-porto-company {
  color: rgba(255,255,255,0.44);
}
.cv-porto-title-text {
  font-family: var(--font-serif);
  font-weight: 500;
  color: rgba(255,255,255,0.86);
}
.cv-porto-roles {
  font-size: 0.76rem;
  color: rgba(255,255,255,0.42);
}

/* ===================== Print containers (hidden on screen) ===================== */
#print-resume,
#print-cv { display: none; }

/* ===================== @media print ===================== */
@media print {
  main > header,
  main > .cv-download-row,
  main > .cv-sections,
  main > footer,
  .lang-toggle,
  #site-bg {
    display: none !important;
  }
  body::before,
  body::after { display: none !important; }

  html, body {
    background: #fff !important;
    color: #111 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body[data-print-mode="resume"] #print-resume { display: block; }
  body[data-print-mode="cv"]     #print-cv     { display: block; }

  /* ---- Shared print type ---- */
  .prt-name {
    font-family: 'Shippori Mincho', serif;
    font-size: 17pt;
    font-weight: 600;
    color: #111;
    line-height: 1.2;
  }
  .prt-subtitle {
    font-size: 8.5pt;
    color: #555;
    letter-spacing: 0.05em;
    margin-top: 2pt;
  }
  .prt-contact {
    font-size: 8pt;
    color: #666;
    line-height: 1.75;
  }
  .prt-section-label {
    font-size: 6.5pt;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: #aaa;
    border-bottom: 0.5pt solid #e0e0e0;
    padding-bottom: 2pt;
    margin-bottom: 6pt;
    margin-top: 14pt;
  }
  .prt-row {
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
    margin-bottom: 4pt;
  }
  .prt-year {
    font-size: 7.5pt;
    color: #bbb;
    min-width: 2.4rem;
    flex-shrink: 0;
  }
  .prt-content { flex: 1; }
  .prt-title-text {
    font-size: 9pt;
    color: #111;
    font-weight: 500;
  }
  /* Shippori targets */
  .prt-award-title {
    font-family: 'Shippori Mincho', serif;
    font-size: 9pt;
    color: #111;
    font-weight: 500;
    line-height: 1.4;
  }
  .prt-edu-degree {
    font-family: 'Shippori Mincho', serif;
    font-size: 9pt;
    color: #111;
    font-weight: 500;
    line-height: 1.4;
  }
  .prt-porto-title-en {
    font-family: 'Shippori Mincho', serif;
    font-style: italic;
  }
  .prt-porto-title-zh {
    font-family: 'Shippori Mincho', serif;
  }
  /* Portfolio items: flex hanging indent */
  .prt-porto-item {
    display: flex;
    align-items: baseline;
  }
  .prt-porto-item-body { flex: 1; min-width: 0; }
  .prt-porto-year { flex-shrink: 0; margin-right: 1.2em; }
  .prt-meta {
    font-size: 8pt;
    color: #666;
    margin-top: 1pt;
  }
  .prt-skill-cat {
    margin-bottom: 6pt;
  }
  .prt-skill-cat-title {
    font-size: 6.5pt;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #bbb;
    margin-bottom: 2pt;
  }
  .prt-skill-items {
    font-size: 8.5pt;
    color: #444;
    line-height: 1.65;
  }

  /* ---- Resume layout (1-page, 2-col) ---- */
  #print-resume {
    font-family: 'Jost', system-ui, sans-serif;
    page: resume-page;
    overflow: hidden;
    /* Clamp to A4 content height (29.7cm - 1.5cm top - 1.4cm bottom) */
    max-height: 26.8cm;
  }
  /* Remove any trailing margin that might push content onto a second page */
  #print-resume > *:last-child { margin-bottom: 0 !important; }
  :lang(zh) .prt-bio-short { line-height: 1.95; }
  :lang(zh) .prt-bio-short p + p { margin-top: 6pt; }
  .prt-resume-header {
    padding-bottom: 8pt;
    border-bottom: 0.75pt solid #ccc;
    margin-bottom: 10pt;
  }
  .prt-resume-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 2.5rem;
    align-items: start;
  }
  .prt-bio-short {
    font-size: 8.5pt;
    color: #333;
    line-height: 1.65;
    margin-bottom: 4pt;
  }
  .prt-bio-short p + p { margin-top: 4pt; }
  .prt-bio-short strong { font-weight: 600; }
  .prt-bio-short em { font-style: italic; font-family: 'Shippori Mincho', serif; }

  /* ---- Full CV layout (3-page) ---- */
  #print-cv {
    font-family: 'Jost', system-ui, sans-serif;
  }
  /* Name + title: full-width, above 2-col */
  .prt-cv-name-block {
    padding-bottom: 7pt;
    border-bottom: 0.75pt solid #ccc;
    margin-bottom: 10pt;
  }
  .prt-cv-name-block .prt-subtitle {
    margin-top: 2pt;
  }
  /* 2-col content: bio (left) ↔ contact/awards/education (right) */
  .prt-cv-cols {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 0 2.5rem;
    margin-bottom: 10pt;
    align-items: start;
  }
  .prt-cv-bio {
    font-size: 8.5pt;
    color: #333;
    line-height: 2.0;
  }
  .prt-cv-bio p + p { margin-top: 10pt; }
  :lang(zh) .prt-cv-bio { line-height: 2.2; }
  :lang(zh) .prt-cv-bio p + p { margin-top: 11pt; }
  .prt-cv-bio strong { font-weight: 600; }
  .prt-cv-bio em { font-style: italic; font-family: 'Shippori Mincho', serif; }
  /* Force page break before Portfolio */
  .prt-page-start {
    page-break-before: always;
    break-before: page;
  }
  .prt-skills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 1.5rem;
  }
  .prt-skill-items { line-height: 1.75; }
  .prt-porto-item {
    font-size: 8.5pt;
    line-height: 1.65;
    margin-bottom: 4pt;
    color: #222;
  }
  .prt-porto-year { color: #bbb; }
  .prt-porto-cat-label {
    font-size: 6.5pt;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #bbb;
    margin-top: 10pt;
    margin-bottom: 3pt;
  }
  /* Resume: portfolio full-width 3-col grid */
  .prt-resume-porto-label { margin-top: 10pt; }
  .prt-resume-porto {
    display: block;
    margin-top: 4pt;
  }
  .prt-resume-porto-col { min-width: 0; }
  /* Print: title bold, company/roles normal */
  .prt-porto-title-en { font-weight: 600; }
  .prt-porto-title-zh { font-weight: 600; }
  .prt-porto-company  { font-weight: 400; }
  .prt-porto-roles    { font-weight: 400; }

  /* First section label in a column: no top margin (aligns Bio with Skills) */
  .prt-section-label:first-child { margin-top: 0; }

  /* ZH Resume: extra breathing room between sections */
  :lang(zh) .prt-section-label { margin-top: 18pt; }
  :lang(zh) .prt-section-label:first-child { margin-top: 0; }
  :lang(zh) .prt-porto-cat-label { margin-top: 13pt; }

  /* ZH Resume: left column wider (3:2) */
  :lang(zh) .prt-resume-cols { grid-template-columns: 3fr 2fr; }

  /* ZH PDF portfolio: reduce weights for lighter appearance */
  :lang(zh) .prt-porto-title-zh,
  :lang(zh) .prt-porto-title-en  { font-weight: 500; }   /* Shippori -100 */
  :lang(zh) .prt-porto-company   { font-weight: 200; }   /* Noto -200 */
  :lang(zh) .prt-porto-item-body { font-weight: 200; }   /* 《》 chars -200 */
  :lang(zh) .prt-porto-roles     { font-weight: 400; }   /* Noto roles: unchanged */

  /* CV (multi-page): generous margins + page numbers */
  @page {
    size: A4;
    margin: 2.5cm 2.2cm 2.2cm 2.2cm;
    @bottom-right {
      content: counter(page) " / " counter(pages);
      font-family: 'Jost', system-ui, sans-serif;
      font-size: 7pt;
      color: #bbb;
    }
  }
  /* Resume (1-page): tighter margins, no page number */
  @page resume-page {
    size: A4;
    margin: 1.5cm 1.9cm 1.4cm 1.9cm;
    @bottom-right { content: ""; }
  }

  /* Export timestamp — injected via JS before print */
  @page {
    @top-right {
      content: var(--prt-export-time, "");
      font-family: 'Jost', system-ui, sans-serif;
      font-size: 7pt;
      color: #bbb;
    }
  }
}
