/* ==========================================================================
   Certificate Generator — page-scoped styles
   Reuses the site's canonical nav (design-system.css + simply-endorsed
   app.css) and theme-blue's geometry, but overrides the tool-accent /
   accent color family to a distinct teal so this reads as its own tool.
   ========================================================================== */

/* Guard the native [hidden] attribute against any class below that sets an
   explicit `display` (e.g. .cg-btn, .cg-photo-ready) — author rules always
   beat the UA [hidden] rule on specificity/origin, so without this an
   element could set hidden and still render. */
[hidden] {
  display: none !important;
}

body.certgen-view {
  --tool-accent: #0D9488;
  --tool-accent-bright: #14B8A6;
  --tool-accent-deep: #0F766E;
  --tool-soft: rgba(13, 148, 136, 0.12);
  --tool-line: rgba(13, 148, 136, 0.42);
  --tool-ink: #134E4A;
  --tool-glow: rgba(13, 148, 136, 0.5);

  --accent: #0D9488;
  --accent-strong: #0F766E;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --accent-ink: #134E4A;
}

/* .nav-wrap is position:fixed — push the page shell clear of the pill. */
.cg-shell {
  padding-top: 104px;
  padding-bottom: 48px;
  min-height: 100vh;
  box-sizing: border-box;
}

.cg-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------------------------------------------------- */
/* Page head                                                               */
/* ---------------------------------------------------------------------- */

.cg-kicker {
  margin: 0 0 6px;
  font-family: var(--mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tool-accent-deep);
}

.cg-page-head h1 {
  margin: 0 0 8px;
  font-family: var(--font-display, "Inter Tight", "Inter", sans-serif);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink, #0D1330);
}

.cg-sub {
  margin: 0 0 22px;
  max-width: 60ch;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--ink-muted, #4D5670);
}

/* ---------------------------------------------------------------------- */
/* Stepper                                                                 */
/* ---------------------------------------------------------------------- */

.cg-stepper {
  display: flex;
  align-items: stretch;
  gap: 8px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.cg-step {
  flex: 1 1 0;
  min-width: 0;
}

.cg-step-btn {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border: 1px solid var(--border, rgba(13, 19, 48, 0.10));
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-muted, #4D5670);
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  text-align: left;
  cursor: default;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

/* The stepper is freely clickable in either direction once a step's
   prerequisites are met (JS enables/disables the <button>), so the cursor
   should follow :disabled rather than the .is-done class. */
.cg-step-btn:not(:disabled) {
  cursor: pointer;
}

.cg-step-num {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(13, 19, 48, 0.08);
  color: var(--ink-muted, #4D5670);
  font-size: 0.78rem;
  font-weight: 700;
}

.cg-step-label {
  display: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cg-step.is-active .cg-step-btn {
  border-color: var(--tool-accent);
  background: var(--tool-soft);
  color: var(--tool-ink);
}

.cg-step.is-active .cg-step-num {
  background: var(--tool-accent);
  color: #fff;
}

.cg-step.is-done .cg-step-btn {
  color: var(--ink, #0D1330);
}

.cg-step.is-done .cg-step-num {
  background: var(--tool-accent-bright);
  color: #fff;
}

.cg-step-btn:not(:disabled):hover {
  border-color: var(--tool-line);
}

.cg-step-btn:focus-visible {
  outline: 2px solid var(--tool-accent);
  outline-offset: 2px;
}

/* Below 560px the label is hidden for every step except the active one —
   four bare circles don't tell you which step you're on until you tap it. */
.cg-step.is-active .cg-step-label { display: block; }

@media (min-width: 560px) {
  .cg-step-label { display: block; }
}

/* Give the visible active label room to breathe: let it flex to fill the
   row while the other (label-less) steps shrink back to their circle. */
@media (max-width: 559px) {
  .cg-step { flex: 0 0 auto; }

  .cg-step.is-active {
    flex: 1 1 auto;
    min-width: 0;
  }
}

.cg-status {
  margin: 0 0 20px;
  font-family: var(--mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--ink-muted, #4D5670);
}

/* ---------------------------------------------------------------------- */
/* Layout                                                                  */
/* ---------------------------------------------------------------------- */

.cg-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: start;
}

@media (min-width: 1024px) {
  .cg-layout {
    grid-template-columns: 1fr 420px;
  }
}

.cg-panel-col {
  min-width: 0;
}

.cg-panel-kicker {
  margin: 0 0 4px;
  font-family: var(--mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tool-accent-deep);
}

.cg-panel-heading {
  margin: 0 0 6px;
  font-family: var(--font-display, "Inter Tight", "Inter", sans-serif);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ink, #0D1330);
}

.cg-panel-copy {
  margin: 0 0 18px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-muted, #4D5670);
}

.cg-card {
  padding: 20px;
  border-radius: var(--r-card, 22px);
  background: var(--glass-bg-strong, rgba(255, 255, 255, 0.92));
  border: 1px solid var(--glass-edge, rgba(255, 255, 255, 0.8));
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(13, 19, 48, 0.05));
}

.cg-divider {
  height: 1px;
  margin: 20px 0;
  background: var(--border, rgba(13, 19, 48, 0.10));
}

/* ---------------------------------------------------------------------- */
/* Certificate picker                                                     */
/* ---------------------------------------------------------------------- */

.cg-template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 560px) {
  .cg-template-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .cg-template-grid { grid-template-columns: repeat(4, 1fr); }
}

.cg-cert-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 10px 12px 10px 14px;
  border: 1.5px solid var(--border, rgba(13, 19, 48, 0.10));
  border-radius: 14px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font: inherit;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.cg-cert-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--cert-accent);
  opacity: 0.28;
  transition: opacity 0.2s ease;
}

.cg-cert-btn:hover {
  border-color: var(--cert-line);
  background: var(--cert-soft);
  transform: translateY(-1px);
}

.cg-cert-btn:focus-visible {
  outline: 2px solid var(--cert-accent);
  outline-offset: 2px;
}

.cg-cert-btn.is-selected {
  background: var(--cert-soft);
  border-color: var(--cert-accent);
  box-shadow: 0 0 0 3px rgba(13, 19, 48, 0.12);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cert-accent) 22%, white);
}

.cg-cert-btn.is-selected::before {
  opacity: 1;
}

.cg-cert-btn.is-selected .cg-cert-title {
  color: var(--cert-ink);
}

.cg-cert-swatch {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--cert-accent);
}

.cg-cert-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cg-cert-title {
  display: block;
  overflow: hidden;
  font-family: var(--font-display, "Inter Tight", "Inter", sans-serif);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink, #0D1330);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cg-cert-sub {
  display: block;
  overflow: hidden;
  font-size: 0.7rem;
  line-height: 1.25;
  color: var(--ink-muted, #4D5670);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Fields                                                                  */
/* ---------------------------------------------------------------------- */

.cg-field-group-label {
  display: inline-block;
  margin-bottom: 12px;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--tool-soft);
  color: var(--tool-ink);
  font-family: var(--mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* .cg-field-group is a <fieldset> (for correct grouping semantics) and
   .cg-field-group-label its <legend> — reset the UA defaults for both so
   the pill label above keeps its look instead of browser fieldset/legend
   chrome (border box, inset margin, legend's special inline position). */
.cg-field-group {
  min-width: 0;   /* fieldsets default to min-content sizing and would break the grid */
  margin: 0;
  padding: 0;
  border: 0;
}

.cg-field-group-label {
  float: none;
  width: auto;
  padding: 3px 10px;   /* legend UA styles reset padding — keep the pill */
}

.cg-field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 480px) {
  .cg-field-row { grid-template-columns: 1fr 1fr; }
}

.cg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cg-field label,
.cg-field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink, #0D1330);
}

.cg-field input[type="text"] {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong, rgba(13, 19, 48, 0.18));
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 1rem;
  color: var(--ink, #0D1330);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cg-field input[type="text"]:focus-visible {
  outline: none;
  border-color: var(--tool-accent);
  box-shadow: 0 0 0 3px var(--tool-soft);
}

/* JS marks empty required fields .is-invalid + aria-invalid and focuses
   them on a failed Continue, instead of just leaving the button disabled. */
.cg-field input[type="text"].is-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

/* Keep the focus ring visible on an invalid field: red border stays (the
   error is still true), teal ring layers on top to show it's focused. */
.cg-field input[type="text"].is-invalid:focus-visible {
  outline: none;
  border-color: #dc2626;
  box-shadow: 0 0 0 3px var(--tool-soft);
}

.cg-rating-block {
  margin-top: 18px;
}

.cg-rating-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 8px;
}

.cg-rating-btn {
  min-height: 48px;
  border: 1px solid var(--border-strong, rgba(13, 19, 48, 0.18));
  border-radius: 12px;
  background: #fff;
  color: var(--ink-muted, #4D5670);
  font-family: var(--mono, "JetBrains Mono", ui-monospace, monospace);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.cg-rating-btn:hover {
  border-color: var(--tool-line);
}

.cg-rating-btn:focus-visible {
  outline: 2px solid var(--tool-accent);
  outline-offset: 2px;
}

.cg-rating-btn[aria-checked="true"] {
  border-color: var(--tool-accent);
  background: linear-gradient(160deg, var(--tool-accent-bright), var(--tool-accent-deep));
  color: #fff;
  box-shadow: 0 8px 18px -8px var(--tool-glow);
}

.cg-rating-helper {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-muted, #4D5670);
}

/* ---------------------------------------------------------------------- */
/* Photo step                                                              */
/* ---------------------------------------------------------------------- */

.cg-photo-drop {
  border: 2px dashed var(--tool-line);
  border-radius: 20px;
  background: var(--tool-soft);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cg-photo-drop.is-dragging {
  border-style: solid;
  border-color: var(--tool-accent);
  background: var(--tool-line);
}

.cg-photo-drop-actions {
  display: flex;
  flex-direction: row;
  gap: 1px;
  background: var(--tool-line);
  border-radius: 20px;
  overflow: hidden;
}

/* Narrow-screen overrides for this block live after the base rules below,
   so they win at equal specificity. */

.cg-photo-drop-btn {
  display: flex;
  width: 100%;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 20px;
  border: none;
  background: var(--tool-soft);
  font: inherit;
  cursor: pointer;
  text-align: center;
  border-radius: 0;
}

.cg-photo-drop-btn:hover .cg-photo-drop-icon {
  transform: scale(1.06);
}

.cg-photo-drop-btn:focus-visible {
  outline: 2px solid var(--tool-accent);
  outline-offset: 3px;
}

.cg-photo-drop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--tool-accent);
  color: #fff;
  transition: transform 0.2s ease;
}

.cg-photo-drop-icon svg {
  width: 26px;
  height: 26px;
}

.cg-photo-drop-text strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
  color: var(--ink, #0D1330);
}

.cg-photo-drop-text span {
  font-size: 0.85rem;
  color: var(--ink-muted, #4D5670);
}

/* On narrow screens the two actions stack, so lay each one out as a compact
   icon-beside-text row — two stacked column blocks eat most of the screen. */
@media (max-width: 480px) {
  .cg-photo-drop-actions {
    flex-direction: column;
  }

  .cg-photo-drop-btn {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    text-align: left;
  }

  .cg-photo-drop-icon {
    width: 44px;
    height: 44px;
  }

  .cg-photo-drop-icon svg {
    width: 22px;
    height: 22px;
  }

  .cg-photo-drop-text {
    flex: 1 1 auto;
    min-width: 0;
  }

  .cg-photo-drop-text strong {
    margin-bottom: 2px;
    font-size: 0.95rem;
  }

  .cg-photo-drop-text span {
    font-size: 0.8rem;
    line-height: 1.35;
  }
}

.cg-photo-ready {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

@media (min-width: 480px) {
  .cg-photo-ready { flex-direction: row; }
}

.cg-photo-thumb-wrap {
  width: 100%;
  max-width: 240px;
  flex: none;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--border, rgba(13, 19, 48, 0.10));
}

.cg-photo-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cg-photo-ready-body {
  flex: 1 1 auto;
  width: 100%;
}

.cg-photo-ready-body > p {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--ink-muted, #4D5670);
}

.cg-photo-ready-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cg-paste-hint {
  display: table;
  margin: 12px auto 0;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--tool-soft);
  color: var(--tool-ink);
  font-size: 0.82rem;
  text-align: center;
}

/* ---------------------------------------------------------------------- */
/* Review / summary                                                       */
/* ---------------------------------------------------------------------- */

.cg-summary {
  margin-bottom: 18px;
}

.cg-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  font-size: 0.9rem;
}

.cg-summary-row + .cg-summary-row {
  border-top: 1px solid var(--border, rgba(13, 19, 48, 0.10));
}

.cg-summary-label {
  color: var(--ink-muted, #4D5670);
}

.cg-summary-value {
  margin: 0;
  font-weight: 600;
  color: var(--ink, #0D1330);
  text-align: right;
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.cg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border-radius: var(--r-pill, 999px);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.cg-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.cg-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.cg-btn:focus-visible {
  outline: 2px solid var(--tool-accent-deep);
  outline-offset: 3px;
}

.cg-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cg-btn-primary {
  background: linear-gradient(160deg, var(--tool-accent-bright), var(--tool-accent) 55%, var(--tool-accent-deep));
  color: #fff;
  box-shadow: 0 12px 26px -10px var(--tool-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.cg-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px -10px var(--tool-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.cg-btn-secondary {
  background: #fff;
  color: var(--ink, #0D1330);
  border-color: var(--border-strong, rgba(13, 19, 48, 0.18));
}

.cg-btn-secondary:hover:not(:disabled) {
  border-color: var(--tool-line);
  color: var(--tool-ink);
}

.cg-btn-ghost {
  background: none;
  border-color: transparent;
  color: var(--ink-muted, #4D5670);
}

.cg-btn-ghost:hover:not(:disabled) {
  color: var(--ink, #0D1330);
}

.cg-btn-block {
  width: 100%;
}

.cg-nav-row {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.cg-nav-row .cg-btn-primary,
.cg-nav-row .cg-btn-secondary {
  flex: 1 1 auto;
}

@media (min-width: 640px) {
  .cg-nav-row .cg-btn-primary,
  .cg-nav-row .cg-btn-secondary {
    flex: 0 0 auto;
    min-width: 200px;
  }
}

/* Below 1024px the whole preview canvas sits above the nav row (see the
   Layout and Preview column comments), so pin Back/Continue to the bottom
   of the viewport instead of making the user scroll past it every step.
   .cg-nav-row is the last child of .cg-container, and the <footer> lives
   outside .cg-container, so `sticky` pins the bar until the container's
   end scrolls into view, then it settles naturally above the footer. */
@media (max-width: 1023px) {
  .cg-nav-row {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 28px -20px 0;                 /* bleed through .cg-container's 20px padding */
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border, rgba(13, 19, 48, 0.10));
  }

  /* Clear the pinned bar so it never sits on top of the last content. */
  .cg-layout { padding-bottom: 84px; }
}

.cg-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border-strong, rgba(13, 19, 48, 0.18));
  background: #fff;
  color: var(--ink, #0D1330);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.cg-icon-btn:hover {
  border-color: var(--tool-line);
  background: var(--tool-soft);
}

.cg-icon-btn:focus-visible {
  outline: 2px solid var(--tool-accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------- */
/* Preview column                                                          */
/* ---------------------------------------------------------------------- */

.cg-preview-sticky {
  position: static;
}

@media (min-width: 1024px) {
  .cg-preview-sticky {
    position: sticky;
    top: 104px;
  }
}

.cg-canvas-wrap {
  margin: 0 auto 16px;
  max-width: 420px;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-lg, 0 30px 70px -18px rgba(13, 19, 48, 0.22));
}

.cg-canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* The canvas bitmap is 1080x1920. Below 1024px .cg-layout collapses to a
   single column and the preview lands between the panel and the nav row —
   unconstrained, a 420px-wide wrap renders ~690px tall on a phone and
   pushes the Back/Continue buttons (and everything else) off-screen. Cap
   by height instead of width, with a matching aspect-ratio so nothing
   distorts. */
@media (max-width: 1023px) {
  .cg-canvas-wrap {
    height: 46vh;   /* fallback for browsers without svh support */
    height: 46svh;
    aspect-ratio: 9 / 16;   /* exactly 1080/1920 — matches the bitmap, no distortion */
    width: auto;
    max-width: 100%;
  }

  .cg-canvas {
    width: 100%;
    height: 100%;
  }
}

.cg-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
}

.cg-preview-caption {
  margin: 4px 0 0;
  text-align: center;
  font-family: var(--mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted, #4D5670);
}

.cg-saveimg-wrap {
  max-width: 420px;
  margin: 18px auto 0;
  text-align: center;
}

.cg-saveimg-note {
  margin: 0 0 10px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-muted, #4D5670);
}

.cg-saveimg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: var(--shadow-md, 0 14px 40px -12px rgba(13, 19, 48, 0.14));
}

/* ---------------------------------------------------------------------- */
/* Social caption                                                          */
/* ---------------------------------------------------------------------- */

.cg-caption {
  max-width: 420px;
  margin: 18px auto 0;
}

.cg-caption-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.cg-caption-heading {
  margin: 0;
  font-family: var(--mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tool-accent-deep);
}

.cg-caption-edit {
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-muted, #4D5670);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cg-caption-edit:hover {
  color: var(--tool-accent-deep);
}

.cg-caption-edit:focus-visible {
  outline: 2px solid var(--tool-accent);
  outline-offset: 2px;
}

.cg-caption-card {
  display: block;
  width: 100%;
  border: 1px solid var(--border-strong, rgba(13, 19, 48, 0.18));
  border-radius: 14px;
  background: #fff;
  padding: 14px 14px 12px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.cg-caption-card:hover {
  border-color: var(--tool-line);
  background: var(--tool-soft);
}

.cg-caption-card:focus-visible {
  outline: 2px solid var(--tool-accent);
  outline-offset: 2px;
}

.cg-caption-card.is-copied {
  border-color: var(--tool-accent);
  background: var(--tool-soft);
}

.cg-caption-text {
  display: block;
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink, #0D1330);
}

.cg-caption-hint {
  display: block;
  margin-top: 10px;
  font-family: var(--mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tool-accent-deep);
}

.cg-caption-input {
  display: block;
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--border-strong, rgba(13, 19, 48, 0.18));
  border-radius: 14px;
  background: #fff;
  padding: 14px 14px 12px;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink, #0D1330);
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cg-caption-input:focus-visible {
  outline: none;
  border-color: var(--tool-accent);
  box-shadow: 0 0 0 3px var(--tool-soft);
}

.cg-caption-edit-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.cg-caption-edit-actions .cg-btn {
  flex: 1 1 0;
  min-height: 42px;
}

/* ---------------------------------------------------------------------- */
/* Photo cropper overlay                                                   */
/* ---------------------------------------------------------------------- */

.cg-cropper {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  flex-direction: column;
  background: rgba(13, 19, 48, 0.92);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.cg-cropper.is-open {
  display: flex;
}

.cg-cropper-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
}

.cg-cropper-head h2 {
  margin: 0;
  font-family: var(--font-display, "Inter Tight", "Inter", sans-serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.cg-cropper-head p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.65);
}

.cg-cropper-head .cg-icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.cg-cropper-head .cg-icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.cg-cropper-stage {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
}

.cg-crop-box {
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 16px;
  border: 2px solid var(--tool-accent-bright, #14B8A6);
  background: #11151f;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.cg-crop-img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  pointer-events: none;
  transform-origin: top left;
}

.cg-crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
}

.cg-crop-grid span {
  position: absolute;
  background: rgba(255, 255, 255, 0.55);
}

.cg-crop-grid span:nth-child(1) { left: 33.333%; top: 0; width: 1px; height: 100%; }
.cg-crop-grid span:nth-child(2) { left: 66.666%; top: 0; width: 1px; height: 100%; }
.cg-crop-grid span:nth-child(3) { top: 33.333%; left: 0; height: 1px; width: 100%; }
.cg-crop-grid span:nth-child(4) { top: 66.666%; left: 0; height: 1px; width: 100%; }

.cg-cropper-controls {
  padding: 16px 20px 24px;
}

.cg-zoom-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.cg-zoom-slider {
  flex: 1 1 auto;
  height: 44px;
  accent-color: var(--tool-accent-bright, #14B8A6);
}

.cg-cropper-actions {
  display: flex;
  gap: 12px;
}

.cg-cropper-actions .cg-btn {
  flex: 1 1 0;
}

/* ---------------------------------------------------------------------- */
/* Utility                                                                 */
/* ---------------------------------------------------------------------- */

.cg-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------------- */
/* Footer (matches the .calc-footer pattern used on other tool pages)      */
/* ---------------------------------------------------------------------- */

.calc-footer {
  max-width: 1180px;
  margin: 12px auto 0;
  padding: 26px 24px 44px;
  text-align: center;
  color: #4d5670;
  font-size: 0.86rem;
  line-height: 1.6;
}

.calc-footer a {
  color: var(--tool-accent-deep, #0F766E);
  font-weight: 650;
  text-decoration: none;
}

.calc-footer a:hover { text-decoration: underline; }

.calc-footer .footer-designer {
  margin-top: 10px;
  font-family: var(--font-signature, "Pinyon Script", cursive);
  font-size: 1.25rem;
  color: #1C2142;
}

@media (max-width: 640px) {
  .cg-shell { padding-top: 96px; }
  .cg-page-head h1 { font-size: 1.7rem; }
}
