/* ============================================================
   CV Optimizer — app hooks for the reference template
   ------------------------------------------------------------
   cv_theme.css + themes.css are the design handoff, kept verbatim.
   They cover the reference markup only. This sheet adds what the
   real generated CV also needs:

     1. the legacy class hooks the Python injectors match on
        (.section, .section_col_left, .job, .skill-badge, …), so the
        markup can wear both vocabularies without losing the look;
     2. sections the reference does not show (languages,
        certifications) styled to match the ones it does;
     3. the profile photo in the classic/band layouts, which the
        reference drops but the app supports (and MiniCV shows);
     4. the on-page toolbar, which must never reach the PDF.

   Load order: cv_theme.css -> themes.css -> cv_app_hooks.css
   ============================================================ */

/* ------------------------------------------------------------
   1. Legacy hooks mapped onto the reference's visual rules
   ------------------------------------------------------------
   The injectors look for <div class="section"> and
   <div class="section_col_left">, not the <section> element the
   reference uses, so the spacing rule is mirrored onto the class.
*/
/* Ids are listed alongside the class on purpose: replace_section_by_ID…()
   swaps the whole container for the block the model returned, so the id
   survives but the class is only as reliable as the prompt. */
.cv .section,
.cv #id_profile,
.cv #id_professional_experience,
.cv #id_education,
.cv #id_certifications { margin-bottom: 24px; }
.cv .cv-main > *:last-child { margin-bottom: 0; }

/* Headline paragraph produced by update_name_and_header(). */
.cv .cv-header-block { margin: 0; }
.cv .cv-header { margin: 6px 0 0; }
.cv .cv-header .location-span { margin-inline-start: 6px; }
.cv .cv-header span + span { margin-inline-start: 4px; }

/* Skill chips: the injectors emit <span class="skill-badge">. Same tint
   treatment as .cv-chips — a filled accent chip was heavier than the
   experience it sits under. */
.cv .skill-badge {
  display: inline-block;
  background: var(--chip-fill);
  color: var(--accent-ink);
  border: 1px solid var(--chip-edge);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: calc(12px * var(--cv-type-scale));
  font-weight: 600;
}
.cv .skill-badge.soft {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.cv .skills { display: flex; flex-wrap: wrap; gap: 6px; }
/* Grouped skills ("Programming: <badges>"). The label is a small-caps
   lead-in on the same line as its chips: on its own line it cost the block
   an extra row per category, and the sidebar is only 34% wide. */
.cv .skills > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; width: 100%; }
.cv .skills > div > strong {
  font-size: calc(9.5px * var(--cv-type-scale));
  text-transform: uppercase;
  letter-spacing: .8px;
  font-weight: 800;
  color: var(--muted);
  align-self: center;
}

/* Experience / education entries: <div class="job"> is the legacy
   equivalent of the reference's .cv-item. */
.cv .job,
.cv .cv-item { margin-bottom: 15px; }
.cv .job:last-child,
.cv .cv-item:last-child { margin-bottom: 0; }
/* The reference puts a <strong> in .cv-item-head; the template and the
   prompts use <h3> there, which is better structure but would otherwise
   fall back to the browser's default heading size. */
.cv .job h3,
.cv .cv-item-head h3 {
  font-size: calc(14.5px * var(--cv-type-scale));
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  line-height: 1.25;
}
/* The role line, which the prompts return as <p><em><strong>Role</strong></em></p>.
   In the accent it reads as a distinct level between the company and the
   bullets instead of a third shade of grey. */
.cv .job > p {
  color: var(--accent-ink);
  font-size: calc(13px * var(--cv-type-scale));
  margin-top: 2px;
}
.cv .job > p em { font-style: italic; }
.cv .job ul,
.cv .cv-item ul {
  margin: 6px 0 0;
  padding-inline-start: 18px;
  font-size: calc(13.5px * var(--cv-type-scale));
  line-height: 1.6;
}
.cv .job li,
.cv .cv-item li { margin-bottom: 3px; }

/* ------------------------------------------------------------
   2. Sections the reference does not cover
   ------------------------------------------------------------ */

/* Languages. The bar used to be full width under the label — three of them
   in a column read like a loading screen. It is now a short gauge on the
   same line, right-aligned, so the block is three lines instead of six. */
.cv .language-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: calc(13px * var(--cv-type-scale));
}
.cv .language-item:last-child { margin-bottom: 0; }
.cv .language-item > div:first-child { min-width: 0; }
/* In the main column the row would be the full text measure wide, leaving
   the gauge stranded at the far edge, a hand's width from its label. */
.cv-main .language-item,
.cv-body > .cv-inline-languages .language-item { max-width: 340px; }
.cv .language-bar {
  height: 5px;
  width: 72px;
  flex: 0 0 72px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  margin-top: 0;
  overflow: hidden;
}
.cv .language-level { height: 100%; background: var(--accent); border-radius: 999px; }

/* Certifications: a plain list, spaced like .cv-item entries. */
.cv #id_certifications ul { margin: 0; padding-inline-start: 18px; font-size: calc(13.5px * var(--cv-type-scale)); line-height: 1.6; }
.cv #id_certifications li { margin-bottom: 10px; }
.cv #id_certifications em { color: var(--muted); }

/* Inline (main-column) mirrors of the sidebar-only blocks. The
   reference already hides .cv-inline-skills in the sidebar layout;
   languages needs the same treatment. */
.cv--sidebar .cv-inline-languages { display: none; }

/* ------------------------------------------------------------
   3. Profile photo
   ------------------------------------------------------------
   Sidebar layout uses the reference's .cv-photo slot. Classic and
   band place it top-right of the header, as MiniCV does.
*/
/* The header photo used to be absolutely positioned at a fixed 36/40px
   inset, so it floated above the name's cap-height and drifted out of
   alignment whenever the header padding changed (it did, for print). As a
   grid cell it sits in the header's own box: top-aligned with the name, and
   inset by the header padding whatever that padding is. */
.cv-head {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 24px;
  align-items: start;
}
.cv-head > * { grid-column: 1; }
.cv .cv-photo-head {
  grid-column: 2;
  grid-row: 1 / span 99;
  align-self: start;
  width: 74px;
  height: 74px;
  border-radius: 16px;
  overflow: hidden;
  line-height: 0;
}
.cv .cv-photo-head img { width: 100%; height: 100%; object-fit: cover; }
.cv--band .cv-photo-head { border: 2px solid color-mix(in srgb, var(--on-accent) 55%, transparent); }
.cv--sidebar .cv-photo-head { display: none; }
/* The accent bar is the first row, so the photo would align with it rather
   than with the name. Pull it out of the grid's first row. */
.cv--classic .cv-head .cv-accentbar { grid-row: 1; }
.cv--classic .cv .cv-photo-head { grid-row: 1 / span 99; }

/* The sidebar is a colour band down the page, not a box drawn around
   its own content. When the document has a height to fill — a preview
   frame, a print page — the band goes with it instead of stopping
   where the shorter column ends. On an ordinary screen document, whose
   height is its content, this changes nothing. */
.cv--sidebar { display: flex; flex-direction: column; }
.cv--sidebar .cv-body { flex: 1 1 auto; }

/* Sidebar photo: the reference's .cv-photo is an empty circle, the
   app puts a real <img> inside it. Centred in its column — left-aligned in
   a 34% band it read as slightly-off rather than as a decision. */
.cv .cv-side .cv-photo {
  overflow: hidden;
  padding: 0;
  flex-shrink: 0;
  line-height: 0;
  width: 104px;
  height: 104px;
  margin: 0 auto 4px;
}
.cv .cv-side .cv-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* update_profile_image() renames the class and, when the photo is
   turned off, drops in a sized placeholder div. Neither should show. */
.cv .profile-image,
.cv .profile-photo { display: block; }
.cv .img-placeholder { display: none !important; }

/* ------------------------------------------------------------
   4. Sidebar internals
   ------------------------------------------------------------
   The app's blocks use <h2> where the reference sidebar uses <h3>,
   and .cv h2 (accent text on an accent background) would vanish.
*/
.cv--sidebar .cv-side h2 {
  font-size: calc(12px * var(--cv-type-scale));
  text-transform: uppercase;
  letter-spacing: .6px;
  opacity: .85;
  color: var(--on-accent);
  border-bottom: 0;
  padding-bottom: 0;
  margin: 0 0 10px;
}
/* On the accent-filled sidebar every chip is tinted with the ink that reads
   on that accent — the .soft variant included, or its accent-on-accent text
   would vanish. --on-accent is white on most themes and a near-black on the
   ones where white does not reach 4.5:1 (Dark Elegant, Cyberpunk, Slate). */
.cv--sidebar .cv-side .skill-badge,
.cv--sidebar .cv-side .skill-badge.soft {
  background: color-mix(in srgb, var(--on-accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--on-accent) 32%, transparent);
  color: var(--on-accent);
}
.cv--sidebar .cv-side .skills > div > strong,
.cv--sidebar .cv-side .contact-info strong { color: var(--on-accent); opacity: .88; }
.cv--sidebar .cv-side .language-bar { background: color-mix(in srgb, var(--on-accent) 25%, transparent); }
.cv--sidebar .cv-side .language-level { background: var(--on-accent); }
.cv--sidebar .cv-side .section_col_left,
.cv--sidebar .cv-side .contact-info,
.cv--sidebar .cv-side .cv-photo,
.cv--sidebar .cv-side #id_skills,
.cv--sidebar .cv-side #id_languages { margin-bottom: 24px; }
.cv .cv-side > *:last-child { margin-bottom: 0; }

/* Contact rows: alternating icon / value divs, the structure
   build_contact_block() reads and rebuilds. The label is set above its
   value rather than run in front of it: "Fecha de nacimiento: Marzo 1995"
   wrapped mid-phrase in a 34% column, which looked like a mistake. As a
   two-line pair it looks deliberate and reads faster. */
.cv .contact-info {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px 9px;
  align-items: start;
  font-size: calc(12.5px * var(--cv-type-scale));
  line-height: 1.45;
}
.cv .contact-info strong {
  display: block;
  font-size: calc(9.5px * var(--cv-type-scale));
  text-transform: uppercase;
  letter-spacing: .7px;
  font-weight: 800;
  opacity: .88;
}
/* Rows whose <strong> is empty (email, phone, location) must not keep the
   blank line the block display would give them. */
.cv .contact-info strong:empty { display: none; }
/* The glyphs are inline SVG (cv_icons) drawn in currentColor, so each one
   takes the ink of the row it is in — dark on a white page, white on a
   coloured sidebar — with no filter and nothing to fetch at print time. */
.cv .contact-info .icon { font-size: 13px; line-height: 1; color: inherit; }
.cv .contact-info .icon svg { width: 13px; height: 13px; display: block; margin-top: 1px; }
/* Documents made before the inline set still carry CDN <img> icons. */
.cv .contact-info .icon img,
.cv .contact-info img.icon { width: 14px; height: 14px; display: block; }
.cv .contact-info a { color: inherit; text-decoration: none; word-break: break-word; }
.cv .contact-info a:hover { text-decoration: underline; }
.cv--sidebar .cv-side .contact-info { color: var(--on-accent); }
/* Legacy CDN icons only: the inline set needs no filter, it inherits. */
.cv--sidebar .cv-side .contact-info img.icon,
.cv--sidebar .cv-side .contact-info .icon img { filter: var(--icon-filter, brightness(0) invert(1)); }

/* Running footer: paper only (see @media print). */
.cv .cv-runner { display: none; }

/* ------------------------------------------------------------
   5. On-page toolbar — screen only
   ------------------------------------------------------------ */
.cv-toolbar { text-align: center; margin: 20px; }

/* The same button as the app's "Download CV as PDF", to the pixel: this one
   opens on its own in a tab, but it is still the same product and read side
   by side the two were visibly different — a shorter, smaller button with an
   emoji arrow where the app has a drawn icon. Values mirror .btn-grad in
   static/css/redesign.css; the accents are written out because a generated
   CV carries only its own stylesheets and has no --pri / --acc to read. */
.cv-toolbar .pdf-button {
  /* The toolbar sits outside .cv, and the document's typeface is declared on
     .cv — so `inherit` here reached <body>, which has none, and the button
     came out in the browser's default serif while every other button in the
     product is Plus Jakarta Sans. --cv-font is on :root, so it is in scope. */
  font-family: var(--cv-font, "Plus Jakarta Sans", system-ui, "Segoe UI", Arial, sans-serif);
  /* Not scaled by --cv-type-scale: this is the app's button, not the
     document, and the token is declared on .cv, which the toolbar sits
     outside of. It matches .btn-grad in the app and must keep matching it. */
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #1c56e9, #1cbce8);
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(28, 86, 233, .22);
  transition: transform .12s, box-shadow .12s;
}
.cv-toolbar .pdf-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(28, 86, 233, .28);
  color: #fff;
}
/* The icon is drawn, not typed: an emoji is a colour glyph that renders
   differently on every platform and never matched the app's line icons. */
.cv-toolbar .pdf-button svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The in-page "Download as PDF (A4)" button is window.print(), which uses
   whatever margins the browser's print dialog defaults to. The app's own
   download route prints through Playwright with margin: 0 (see
   html_to_pdf_generator.FULL_BLEED_MARGIN) — that difference is why the
   browser's copy came out framed in white with the CV's rounded corner drawn
   inside it, while the app's did not. Declaring the page makes the two agree:
   the design supplies its own margins as padding below, and the colour planes
   reach the paper edge either way.

   At the top level because @page only ever applies to paper, so wrapping it
   in the print media query would say the same thing twice. */
@page { size: A4; margin: 0; }

@media print {
  .cv-toolbar { display: none !important; }

  /* On paper the CV *is* the page: the card's frame belongs on screen. */
  .cv {
    border: 0;
    border-radius: 0;
    margin: 0;
    max-width: none;
  }

  /* Documents written before the reference template have no cv--* layout and
     none of the full-bleed elements, so they were relying on the page margin
     the line above just removed. Give it back as padding. */
  .cv:not(.cv--classic):not(.cv--band):not(.cv--sidebar) { padding: 20mm 16mm; }
  /* Keep themed backgrounds (band header, sidebar, chips) in the PDF.
     Without this Chromium drops them and the two dark themes print as
     dark text on white. */
  .cv,
  .cv * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ----------------------------------------------------------
     Full bleed
     ----------------------------------------------------------
     The colour is the design: the sidebar band and the page tint
     have to reach the paper edge, starting in the corner, while
     the text keeps ordinary margins.

     html_to_pdf_generator prints this design with zero page
     margins — Chromium clips everything, fixed elements included,
     to the page's content box, so any margin leaves a white frame
     no CSS can paint into. The margins therefore come back as
     padding, and box-decoration-break: clone repeats that padding
     on every page fragment instead of only the first.

     The two colour planes are position:fixed, which in print
     paints once per page: that is what carries the band down a
     two-page CV instead of stopping where the content stops.
     .cv gives up its own background so they show through. */
  /* The page's own 8px body margin would hold the band header off the
     top edge — the fixed planes ignore it, the header does not. */
  html,
  body {
    margin: 0;
    padding: 0;
  }

  .cv {
    background: transparent;
    overflow: visible;
  }

  .cv::before {
    content: "";
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: -2;
  }

  /* Same 34% as .cv--sidebar .cv-side in cv_theme.css: this plane is
     the part of that column the content does not reach. */
  .cv--sidebar::after {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: 34%;
    background: var(--accent);
    z-index: -1;
  }

  /* ----------------------------------------------------------
     Room for the running header and the page number
     ----------------------------------------------------------
     Printed through the app, the page carries two reserved bands —
     23 mm at the top for the name, contact line and company logo, 17 mm
     at the foot for "Página 2 de 3" (printer.FULL_BLEED_MARGIN). Change one of
     those two numbers and change the padding here by the same amount, and the
     negative margins that pay it back on page one with it.

     Every number below is a fifth larger than it was, bands included: the
     running header sat close enough to the first line, and the page number to
     the last one, that a full page read as printed to the edge. The
     proportions between them are unchanged, so page one still opens where the
     design put it — a little lower, and no differently.
     Chromium draws them there, but lays the document out from the paper
     edge all the same, because the @page rule above says margin: 0 — which
     is exactly what the colour planes need to reach the corners.

     So the text keeps clear of those bands itself, as padding. Padding is
     also what carries the clearance to page two and beyond:
     box-decoration-break: clone repeats it on every fragment, where a page
     margin would only have applied once.

     Page one is the exception: it is printed without the running header
     (pdfprint.replace_first_page), because it already carries the
     name, the contact line and the logo at the size the design chose. So its
     header block keeps the spacing the design asks for, and only the pages
     after it reserve the strip. The negative margin below is what pays for
     that difference: it takes back the extra top padding the body carries for
     the continuation pages, once, on page one. */
  .cv-head { padding: 23mm 16mm 0; margin-bottom: -14mm; }
  .cv--band .cv-head { padding: 22mm 16mm 18mm; margin-bottom: -14mm; }

  .cv-body {
    padding: 14mm 16mm 23mm;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  /* Continuation pages have no document header, so their first line would
     start at the paper edge, under the running header. */
  .cv--classic .cv-body,
  .cv--band .cv-body { padding-top: 28mm; }
  .cv--sidebar .cv-body { padding: 0; }
  .cv--sidebar .cv-side,
  .cv--sidebar .cv-main {
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .cv--sidebar .cv-side { padding: 28mm 9mm 23mm; }
  .cv--sidebar .cv-main { padding: 28mm 14mm 23mm; }
  /* The sidebar columns are the boxes that fragment, so they cannot use the
     margin trick above — nothing sits outside them to carry it. Their first
     child does the same job: it only exists in the first fragment, so this
     lifts page one and leaves the rest at 20 mm. */
  .cv--sidebar .cv-side > *:first-child,
  .cv--sidebar .cv-main > *:first-child { margin-top: -11mm; }

  /* The document's own running footer carried the name, which is what the
     printed header does now — and it sat where the page number goes. */
  .cv .cv-runner { display: none !important; }

  /* Page breaks. A CV runs to two pages often enough that where it breaks
     matters: keep an entry whole, keep a proficiency bar with its language,
     and never strand a section heading at the foot of a page. */
  .cv .job,
  .cv .cv-item,
  .cv .language-item,
  .cv .skills > div,
  .cv #id_certifications li { break-inside: avoid; }
  .cv h2,
  .cv h3,
  .cv .cv-item-head { break-after: avoid; }
}

/* ------------------------------------------------------------
   7. A phone — screen only, documents only
   ------------------------------------------------------------
   En un móvil, la barra lateral se llevaba un tercio de 360 px y la columna
   principal no podía estrecharse por debajo de su línea más larga: el CV se
   salía de su tarjeta y se cortaba. En un teléfono, la maquetación con barra
   lateral enseña la de una columna: la plantilla lleva las dos, con el mismo
   contenido (theme.sync_layout_mirrors), así que no se pierde nada. Todas
   las maquetaciones llevan además márgenes de móvil, y las fechas pasan
   debajo de la empresa en vez de apretarla.

   Sólo con .cv-fluid, la clase que documents.for_browser() y standalone()
   ponen en <body>: las miniaturas de los estilos son iframes estrechos con
   estas mismas hojas, y una regla sólo por ancho les enseñaría la versión del
   móvil en vez del estilo. El papel y el PDF del servidor son A4 (@media print). */
@media screen and (max-width: 640px) {
  .cv-fluid .cv { margin: 12px auto; }
  .cv-fluid .cv--sidebar .cv-head { display: grid; }
  .cv-fluid .cv--sidebar .cv-photo-head { display: block; }
  .cv-fluid .cv--sidebar .cv-side,
  .cv-fluid .cv--sidebar .cv-main-name { display: none; }
  .cv-fluid .cv--sidebar .cv-body { display: block; }
  .cv-fluid .cv--sidebar .cv-main { padding: 0; }
  .cv-fluid .cv--sidebar .cv-inline-skills,
  .cv-fluid .cv--sidebar .cv-inline-languages { display: block; }
  .cv-fluid .cv-head { padding: 26px 22px 0; column-gap: 14px; }
  .cv-fluid .cv--band .cv-head { padding: 26px 22px; }
  .cv-fluid .cv-body,
  .cv-fluid .cv--sidebar .cv-body { padding: 24px 22px 30px; }
  .cv-fluid .cv-item-head { flex-wrap: wrap; row-gap: 2px; }
}
