/* =========================================================
   Award & Certificate Generator — tool-specific styles.
   Layered on /tools/_shared/tool.css.
   Certificates always render on white paper regardless of the
   surrounding app theme; only the widget chrome flips.
   ========================================================= */

.widget-card { max-width: 880px; }

/* ---------- Mode segment (Single | Batch) ---------- */
.cert-mode {
  display: inline-flex;
  padding: 4px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 var(--space-6);
}
.cert-segment {
  position: relative;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: calc(var(--radius) - 4px);
  transition: var(--transition-colors);
  white-space: nowrap;
}
.cert-segment input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.cert-segment:hover { color: var(--text); }
.cert-segment:has(input:checked) {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ---------- Form fields ---------- */
.cert-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.cert-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 640px) {
  .cert-row { grid-template-columns: 1.4fr 1fr; }
}

.cert-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.cert-field > label,
.cert-field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}
.cert-optional {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-subtle);
  margin-left: 6px;
}

.cert-field input[type="text"],
.cert-field input[type="date"],
.cert-field select,
.cert-field textarea {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: 15px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: var(--transition-colors);
  font-family: var(--font-sans);
}
.cert-field textarea {
  min-height: 150px;
  line-height: 1.5;
  resize: vertical;
}
.cert-field input:focus,
.cert-field select:focus,
.cert-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.cert-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.cert-field[hidden] { display: none !important; }

/* ---------- Template picker ---------- */
.cert-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cert-template {
  position: relative;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition-colors);
}
.cert-template input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.cert-template:hover { border-color: var(--border-strong); }
.cert-template:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft-bg);
}
.cert-template:has(input:focus-visible) {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

/* ---------- Actions ---------- */
.cert-actions { margin-bottom: var(--space-6); }
.cert-actions .btn { font-size: 16px; min-height: 52px; }

/* ---------- Preview ---------- */
.cert-preview {
  border-top: 1px solid var(--border);
  padding-top: var(--space-5);
}
.cert-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.cert-preview .section-eyebrow { margin-bottom: 0; }
.cert-preview-count {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.cert-preview-scroll {
  max-height: 560px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: var(--space-4);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* Batch mode: lay the certificates out as smaller grid thumbnails so a
   whole class is visible at a glance instead of one tall card per row.
   Container-query (cqi) typography scales each cert down proportionally.
   Screen-only — the print block forces full-size, one-per-page. */
.cert-preview-scroll.is-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-content: start;
  max-height: 620px;
}
/* Two columns is unreadably small on a phone — drop to one there. */
@media (max-width: 480px) {
  .cert-preview-scroll.is-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   Certificate paper
   ---------------------------------------------------------
   Fixed neutral "paper" colors — always white with dark text,
   even when the app is in dark mode. container-type: inline-size
   lets typography scale with the certificate's own width via
   cqi units, so the same rules render both the on-screen
   preview and the 11-inch printed sheet.
   ========================================================= */
.cert-page {
  container-type: inline-size;
  aspect-ratio: 11 / 8.5;
  width: 100%;
  background: #FFFFFF;
  color: #1A1A1A;
  font-family: var(--font-sans);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08),
              0 6px 18px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Decorative frame layer — the template-specific look sits here */
.cert-frame {
  position: relative;
  flex: 1;
  margin: 3%;
  padding: 3% 4%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-body {
  width: 100%;
  text-align: center;
  padding: 0 3%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2%;
}

.cert-school {
  font-size: 2cqi;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #2a2a2a;
  margin: 0 0 3.5%;
  line-height: 1.15;
}
.cert-class {
  font-size: 1.3cqi;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #777;
  font-weight: 500;
  margin: 0;
}
.cert-eyebrow {
  font-size: 1.4cqi;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #666;
  font-weight: 600;
  margin: 0;
}
.cert-title {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 5.4cqi;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #111;
  margin: 0;
  line-height: 1.05;
}
.cert-presented {
  font-size: 1.35cqi;
  color: #666;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  margin: 1.6% 0 0;
  font-weight: 500;
}
.cert-recipient {
  font-size: 4.6cqi;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -0.01em;
  margin: 0.5% 0 0;
  line-height: 1.1;
  min-height: 4.6cqi;
  font-family: 'Georgia', 'Times New Roman', serif;
}
.cert-reason {
  font-size: 1.7cqi;
  color: #333;
  max-width: 78%;
  margin: 1.6% auto 0;
  line-height: 1.5;
}
.cert-signoff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6%;
  padding: 0 4%;
  margin-top: 4%;
  width: 100%;
  max-width: 82%;
  margin-left: auto;
  margin-right: auto;
}
.cert-sig {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.cert-sig-value {
  font-size: 1.9cqi;
  color: #222;
  border-bottom: 1px solid #999;
  padding: 4px 8px 4px;
  min-height: 2.6cqi;
  width: 100%;
  text-align: center;
  font-family: 'Georgia', 'Times New Roman', serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cert-sig-label {
  font-size: 1.05cqi;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-weight: 600;
  margin-top: 6px;
}

/* ---------- Template: Classic (double border) ---------- */
.cert-page[data-template="classic"] .cert-frame {
  border: 2px solid #1a1a1a;
  outline: 1px solid #1a1a1a;
  outline-offset: 7px;
}

/* ---------- Template: Rounded ---------- */
.cert-page[data-template="rounded"] .cert-frame {
  border: 2px solid #333;
  border-radius: 22px;
}

/* ---------- Template: Stars (thin border + star corners) ---------- */
.cert-page[data-template="stars"] .cert-frame {
  border: 1.5px solid #444;
}
.cert-orn {
  position: absolute;
  pointer-events: none;
  line-height: 0;
}
.cert-orn svg {
  width: 100%;
  height: 100%;
  display: block;
}
.cert-orn-star {
  width: 5.2%;
  aspect-ratio: 1;
  color: #B8860B;
}
.cert-orn-tl { top: 2.6%; left: 2.6%; }
.cert-orn-tr { top: 2.6%; right: 2.6%; }
.cert-orn-bl { bottom: 2.6%; left: 2.6%; }
.cert-orn-br { bottom: 2.6%; right: 2.6%; }

/* ---------- Template: Wreath (thin border + flanking laurels) ---------- */
.cert-page[data-template="wreath"] .cert-frame {
  border: 1.5px solid #444;
}
.cert-orn-wreath {
  width: 6.2%;
  height: 42%;
  top: 22%;
  color: #6B7F4A;
}
.cert-orn-wreath-l { left: 11%; }
.cert-orn-wreath-r { right: 11%; transform: scaleX(-1); }

/* ---------- Template: Minimal ---------- */
.cert-page[data-template="minimal"] .cert-frame {
  border: none;
}
.cert-page[data-template="minimal"] .cert-body::before {
  content: "";
  display: block;
  width: 2.4cqi;
  height: 2px;
  background: #1a1a1a;
  margin: 0 auto 2%;
}
.cert-page[data-template="minimal"] .cert-title {
  padding-bottom: 2%;
  border-bottom: 1px solid #333;
  display: inline-block;
  align-self: center;
}

/* ---------- Template: Deco (double + corner ornaments) ---------- */
.cert-page[data-template="deco"] .cert-frame {
  border: 3px double #1a1a1a;
}
.cert-orn-deco {
  width: 5%;
  aspect-ratio: 1;
  color: #333;
}

/* ---------- Template: Graduation (formal frame + mortarboard) ---------- */
.cert-page[data-template="grad"] .cert-frame {
  border: 2.5px solid #1a1a1a;
  border-radius: 6px;
}
.cert-orn-grad {
  width: 8.5%;
  aspect-ratio: 64 / 44;
  top: 7.4%;
  left: 50%;
  transform: translateX(-50%);
  color: #1a1a1a;
}

/* =========================================================
   BrushingDaydreams recommendation — a compact "shop card"
   grounded in the real Etsy shop (avatar + true star-seller
   stats). Etsy brand coral (#F4846C) is spent only on the
   avatar, the star row, and the pill CTA. On-page only.
   Selectors are .cert-partner-scoped so they clear .article p.
   ========================================================= */
.cert-partner {
  --etsy: #F4846C;
  --etsy-deep: #dd6a51;
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  margin: var(--space-8) 0 var(--space-12);
  padding: var(--space-6);
  border: 1px solid rgba(244, 132, 108, 0.28);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(244, 132, 108, 0.10), rgba(244, 132, 108, 0.03));
}
.cert-partner-avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--etsy);
  color: #fff;
  box-shadow: 0 5px 14px rgba(244, 132, 108, 0.40);
}
.cert-partner-avatar svg { width: 26px; height: 26px; }
.cert-partner-body { min-width: 0; }
.cert-partner .cert-partner-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin: 0 0 5px;
}
.cert-partner h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  padding: 0;
  border: none;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.cert-partner .cert-partner-desc {
  font-size: 14.5px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.55;
}
.cert-partner .cert-partner-rating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 16px;
}
.cert-partner-stars {
  color: var(--etsy);
  letter-spacing: 2px;
  font-size: 12px;
}
.cert-partner .cert-partner-cta { margin: 0; }
.cert-partner .cert-partner-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--etsy);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s ease;
}
.cert-partner .cert-partner-link:hover { background: var(--etsy-deep); }
.cert-partner-link .arrow { transition: transform 0.15s ease; }
.cert-partner .cert-partner-link:hover .arrow { transform: translateX(3px); }
.cert-partner .cert-partner-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 12px 0 0;
}
@media (max-width: 520px) {
  .cert-partner { flex-direction: column; gap: var(--space-4); }
}

/* =========================================================
   Print
   ========================================================= */
@media print {
  html, body {
    background: #fff !important;
    color: #000 !important;
  }
  .tool-header,
  .tool-footer,
  .widget-header,
  .cert-mode,
  .cert-fields,
  .cert-actions,
  .cert-preview-head,
  .article,
  .attenda-cta,
  .cert-partner,
  .skip-link { display: none !important; }

  main,
  .widget-wrap {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }
  .widget-card {
    width: 100% !important;
    max-width: none !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    background: #fff !important;
  }
  .cert-preview {
    border-top: none !important;
    padding-top: 0 !important;
  }
  .cert-preview-scroll {
    max-height: none !important;
    overflow: visible !important;
    background: #fff !important;
    border: none !important;
    padding: 0 !important;
    gap: 0 !important;
    display: block !important;
  }

  .cert-page {
    width: 100% !important;
    aspect-ratio: auto !important;
    height: auto !important;
    min-height: 7.4in;
    box-shadow: none !important;
    background: #fff !important;
    color: #000 !important;
    display: flex !important;
    flex-direction: column;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .cert-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  .cert-frame { flex: 1; }

  @page { size: letter landscape; margin: 0.4in; }
}
