/* =============================================================
   Oficio Perú — generador de oficios
   1. Tokens
   ============================================================= */
:root {
  --navy: #0f2c52;
  --navy-700: #16386a;
  --navy-100: #e8eefa;
  --red: #c8102e;
  --red-dark: #a30d26;
  --ink: #14181f;
  --ink-2: #414b5a;
  --ink-3: #6b7788;
  --line: #dfe4ec;
  --line-2: #eef1f6;
  --bg: #f5f7fb;
  --paper: #ffffff;
  --ok: #12805c;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Source Serif 4", Georgia, "Times New Roman", serif;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 44, 82, .06), 0 1px 3px rgba(15, 44, 82, .07);
  --shadow-md: 0 4px 12px rgba(15, 44, 82, .08), 0 12px 32px rgba(15, 44, 82, .08);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --gutter: clamp(1rem, 4vw, 2.5rem);
  --maxw: 1320px;
  --sheet-scale: 1;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: var(--navy-700); text-decoration: none; }
a:hover { text-decoration: underline; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.015em; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--navy); color: #fff; }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--navy); color: #fff;
  border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Header
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 62px; }
.logo { display: inline-flex; align-items: center; gap: .55rem; color: var(--navy); }
.logo:hover { text-decoration: none; }
.logo-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px; background: var(--navy); color: #fff;
}
.logo-text { font-family: var(--display); font-size: 1.2rem; font-weight: 600; letter-spacing: -.02em; }
.logo-text strong { color: var(--red); font-weight: 700; }
.header-nav { display: none; gap: 1.4rem; font-size: .93rem; font-weight: 500; }
.header-nav a { color: var(--ink-2); }
@media (min-width: 720px) { .header-nav { display: flex; } }

/* =============================================================
   4. Hero + tool
   ============================================================= */
.hero { padding: clamp(1.5rem, 4vw, 2.75rem) 0 1.5rem; }
h1 {
  font-family: var(--display);
  font-size: clamp(1.85rem, 4.2vw, 2.9rem);
  color: var(--navy);
  font-weight: 700;
}
.hero-sub {
  margin-top: .6rem; max-width: 70ch;
  color: var(--ink-2); font-size: clamp(.98rem, 1.6vw, 1.08rem);
}
.hero-sub strong { color: var(--ink); font-weight: 600; }

.tool { margin-top: 1.5rem; }
.tool-grid { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 1100px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 1.75rem; }
}

.noscript-msg {
  padding: 1rem; border: 1px solid var(--red); border-radius: var(--radius);
  background: #fff5f6; color: var(--red-dark); font-weight: 500;
}

/* ---------- Formulario ---------- */
.form-col { display: grid; gap: 1rem; min-width: 0; }
.field-group {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); padding: 1.1rem 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.field-group[hidden] { display: none; }
.field-group > legend {
  font-weight: 600; font-size: .82rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--navy); padding: 0 .45rem; margin-left: -.45rem;
}
.row { display: grid; gap: .75rem; }
@media (min-width: 540px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .row-3 { grid-template-columns: repeat(3, 1fr); }
}
.field { display: grid; gap: .3rem; margin-top: .75rem; }
.field:first-of-type { margin-top: .4rem; }
.row .field { margin-top: .75rem; }
.field > label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.field input[type="text"], .field input[type="date"], .field input[type="time"],
.field select, .field textarea {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink);
  padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px var(--navy-100);
}
.field input[type="file"] { font-size: .86rem; padding: .45rem 0; }
.field.check { margin-top: .85rem; }
.field.check label { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.field.check input { width: 17px; height: 17px; accent-color: var(--navy); }
.micro { font-size: .78rem; color: var(--ink-3); }
.hint { margin-top: .7rem; font-size: .85rem; color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.chip span {
  display: block; padding: .45rem .85rem; font-size: .88rem; font-weight: 500;
  border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink-2);
  transition: all .18s var(--ease-out);
}
.chip input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }
.chip:hover span { border-color: var(--navy); }

.logo-preview { display: flex; align-items: center; gap: .8rem; margin-top: .7rem; }
.logo-preview img { max-height: 54px; width: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
.btn-link { font-size: .84rem; color: var(--red); text-decoration: underline; }

.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .72rem 1.15rem; border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 600; line-height: 1;
  transition: transform .15s var(--ease-out), background .18s var(--ease-out), border-color .18s var(--ease-out);
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-700); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { padding: .5rem .8rem; font-size: .86rem; }
.btn-block { width: 100%; }

/* ---------- Vista previa ---------- */
.preview-col { min-width: 0; }
@media (min-width: 1100px) {
  .preview-sticky { position: sticky; top: 78px; }
}
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem .2rem; font-size: .82rem; color: var(--ink-3);
}
.preview-title { font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.preview-tools { display: inline-flex; align-items: center; gap: .7rem; }
.preview-meta { font-variant-numeric: tabular-nums; }
.btn-zoom {
  font-size: .78rem; font-weight: 600; color: var(--navy);
  border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: .22rem .6rem;
}
.btn-zoom[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

.sheet-scroll {
  background: #dde3ed;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  overflow: auto;
  max-height: min(74vh, 900px);
}
.sheet-scaler { position: relative; overflow: hidden; }
.sheet {
  transform: scale(var(--sheet-scale));
  transform-origin: top left;
  width: 210mm;
  min-height: 297mm;
  background: var(--paper);
  box-shadow: var(--shadow-md);
  padding: 25mm 25mm 25mm 30mm;
  color: #000;
  font-family: "Times New Roman", Times, serif;
  font-size: 12pt;
  line-height: 1.5;
}
.sheet[data-fuente="arial"] { font-family: Arial, Helvetica, sans-serif; }
.sheet-inner > * { margin: 0; }
.doc-logo { max-height: 24mm; width: auto; margin: 0 auto 3mm; }
.doc-membrete { text-align: center; line-height: 1.25; }
.doc-membrete .m-nombre { font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.doc-membrete .m-sub { font-size: .92em; }
.doc-membrete .m-dir { font-size: .82em; color: #333; }
.doc-rule { border: 0; border-top: 1.2pt solid #000; margin: 3mm 0 7mm; }
.doc-num { font-weight: 700; }
.doc-fecha { text-align: right; margin-top: 2mm; }
.doc-block { margin-top: 6mm; }
.doc-line { }
.doc-mayus { text-transform: uppercase; font-weight: 700; }
.doc-presente { margin-top: 2mm; }
.doc-asunto { margin-top: 6mm; display: grid; grid-template-columns: 24mm 1fr; gap: 0 2mm; }
.doc-asunto dt { font-weight: 700; text-transform: uppercase; }
.doc-asunto dd { margin: 0; text-align: justify; }
.doc-saludo { margin-top: 6mm; }
.doc-p { margin-top: 3mm; text-align: justify; hyphens: auto; }
.doc-p.indent { text-indent: 12mm; }
.doc-cierre { margin-top: 7mm; }
.doc-firma { margin-top: 18mm; text-align: center; }
.doc-firma .f-linea { width: 62mm; margin: 0 auto 1mm; border-top: 1pt solid #000; }
.doc-firma .f-nombre { font-weight: 700; text-transform: uppercase; }
.doc-firma .f-cargo, .doc-firma .f-entidad { font-size: .95em; }
.doc-cc { margin-top: 12mm; font-size: .88em; }
.doc-box { width: 90mm; border: .8pt solid #000; padding: 2mm 3mm; font-size: .85em; line-height: 1.7; }
.doc-dist { margin-top: 8mm; font-size: .92em; }
.doc-dist .d-title { font-weight: 700; text-transform: uppercase; }
.doc-dist ul { margin: 1mm 0 0; padding-left: 6mm; }
.doc-empty { color: #9aa3b0; font-style: italic; text-align: center; padding-top: 40mm; font-family: var(--sans); font-size: 11pt; }

.download-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .9rem; }
.download-row .btn { flex: 1 1 auto; }
.privacy-badge {
  margin-top: .8rem; padding: .7rem .85rem;
  background: #eef7f2; border: 1px solid #cfe8dc; border-radius: var(--radius-sm);
  font-size: .84rem; color: #1c4f3c;
}
.privacy-badge strong { color: var(--ok); }
.status { margin-top: .6rem; font-size: .86rem; color: var(--ink-3); min-height: 1.2em; }
.status[data-kind="ok"] { color: var(--ok); font-weight: 600; }
.status[data-kind="error"] { color: var(--red-dark); font-weight: 600; }

/* =============================================================
   5. Ad slots (placeholders — el propietario pega su código)
   ============================================================= */
.ad-slot {
  position: relative;
  display: grid; place-items: center;
  border: 1px dashed #b9c2d2; border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, #f0f3f9, #f0f3f9 10px, #eaeef6 10px, #eaeef6 20px);
  color: #8a93a5;
}
.ad-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase; color: #8a93a5;
}
.ad-leaderboard { margin: 1.75rem 0 .5rem; min-height: 90px; }
.ad-incontent { margin: 1.5rem auto; min-height: 250px; max-width: 336px; }
.ad-popup { width: 100%; min-height: 250px; margin-bottom: 1rem; }
.ad-corner { width: 100%; min-height: 100px; }

.ad-dialog {
  border: 0; border-radius: var(--radius); padding: 1.1rem;
  width: min(92vw, 360px); box-shadow: var(--shadow-md);
  background: #fff; color: var(--ink);
}
.ad-dialog::backdrop { background: rgba(15, 24, 40, .55); }
.ad-dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.ad-dialog-head p { font-weight: 600; font-size: 1rem; }
.ad-dialog-x { font-size: 1.6rem; line-height: 1; color: var(--ink-3); padding: 0 .2rem; }
.ad-dialog-x:hover { color: var(--ink); }

.ad-toast {
  position: fixed; right: 14px; bottom: 14px; z-index: 70;
  width: min(88vw, 320px); padding: .75rem;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: toast-in .45s var(--ease-out) both;
}
.ad-toast[hidden] { display: none; }
.ad-toast-x {
  position: absolute; top: -10px; right: -10px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 1rem; line-height: 1;
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* =============================================================
   6. Secciones de contenido
   ============================================================= */
.section { padding: clamp(2.25rem, 5vw, 3.5rem) 0; }
.section-alt { background: #fff; border-block: 1px solid var(--line); }
.section h2 {
  font-family: var(--display); font-size: clamp(1.4rem, 3vw, 2rem); color: var(--navy); font-weight: 700;
}
.section-sub { margin-top: .5rem; color: var(--ink-2); max-width: 65ch; }

.steps { list-style: none; padding: 0; margin-top: 1.6rem; display: grid; gap: 1rem; }
@media (min-width: 860px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; } }
.steps li {
  position: relative; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem 1.25rem 1.25rem; box-shadow: var(--shadow-sm);
}
.step-num {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--navy-100); color: var(--navy); font-weight: 700; font-size: 1rem; margin-bottom: .7rem;
}
.steps h3 { font-size: 1.08rem; color: var(--navy); }
.steps p { margin-top: .4rem; color: var(--ink-2); font-size: .95rem; }

.prose { max-width: 78ch; }
.prose h2 { margin-bottom: .8rem; }
.prose h3 { margin-top: 1.8rem; font-size: 1.12rem; color: var(--navy); }
.prose p { margin-top: .8rem; color: var(--ink-2); }
.prose ul { margin-top: .8rem; padding-left: 1.2rem; color: var(--ink-2); display: grid; gap: .35rem; }
.prose strong { color: var(--ink); }
.prose details {
  margin-top: .7rem; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1.1rem;
}
.prose details[open] { box-shadow: var(--shadow-sm); }
.prose summary { font-weight: 600; color: var(--navy); cursor: pointer; list-style: none; position: relative; padding-right: 1.75rem; }
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after {
  content: "+"; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  font-size: 1.25rem; color: var(--ink-3); line-height: 1;
}
.prose details[open] summary::after { content: "–"; }
.prose details p { margin-top: .6rem; font-size: .95rem; }

.examples { margin-top: 1.6rem; display: grid; gap: 1rem; }
@media (min-width: 720px) { .examples { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .examples { grid-template-columns: repeat(4, 1fr); } }
.example-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: .55rem;
}
.example-card h3 { font-size: 1.03rem; color: var(--navy); }
.example-card p { font-size: .9rem; color: var(--ink-2); flex: 1; }
.example-card .btn { align-self: flex-start; }

.tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.2rem; }
.tag {
  padding: .4rem .8rem; border-radius: 999px; background: #fff;
  border: 1px solid var(--line); font-size: .86rem; color: var(--ink-2);
}

/* =============================================================
   7. Footer
   ============================================================= */
.site-footer { background: var(--navy); color: #cfd9ea; padding: 2.25rem 0; margin-top: 1rem; }
.footer-inner { display: grid; gap: .8rem; }
.site-footer strong { color: #fff; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: .92rem; }
.site-footer a { color: #cfd9ea; }
.footer-legal { font-size: .82rem; color: #93a4c1; max-width: 70ch; }

/* =============================================================
   8. Impresión — solo la hoja
   ============================================================= */
@media print {
  body { background: #fff; }
  .site-header, .site-footer, .form-col, .preview-bar, .download-row,
  .privacy-badge, .status, .ad-slot, .ad-toast, .ad-dialog, .section, .hero-sub, h1, .skip-link { display: none !important; }
  .sheet-scroll { max-height: none; overflow: visible; padding: 0; border: 0; background: #fff; }
  .sheet-scaler { width: auto !important; height: auto !important; overflow: visible; }
  .sheet { transform: none !important; box-shadow: none; width: auto; min-height: 0; padding: 0; }
  .hero { padding: 0; }
  @page { size: A4; margin: 25mm 25mm 25mm 30mm; }
}

/* =============================================================
   9. Reduced motion (solo efectos intrusivos)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ad-toast { animation: none; }
}
