/*
 * DPI Calculator — standalone widget styles
 *
 * Source of truth for the DPI / print-size / viewing-distance tool
 * (frontend_dpicalculator.php). Self-contained, "dpc-" prefixed classes so the
 * widget renders consistently regardless of the site theme's CSS framework.
 * Responsive from 320px to 4K using a fluid grid and clamps.
 */

/* Page background for the calculator page (this stylesheet only loads here) */
body {
  background-color: #f1f1f1;
}

/* Dark-blue sub-header band height */
.dpc-subheader {
  height: 200px;
}

:root {
  --dpc-brand: #de256f;
  --dpc-brand-dark: #c01f60;
  --dpc-ink: #222;
  --dpc-muted: #6b7280;
  --dpc-line: #e7e7ea;
  --dpc-bg-soft: #f7f7f9;
  --dpc-good: #19a974;
  --dpc-ok: #f3a712;
  --dpc-low: #e0533d;
  --dpc-radius: 12px;
}

.dpc {
  font-family: "Open Sans", "Source Sans Pro", Arial, sans-serif;
  color: var(--dpc-ink);
  margin: 40px auto 48px;
  max-width: 1040px;
}

/* Visually-hidden helper (self-contained, theme-independent) */
.dpc .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Two-column layout: controls on the left, results on the right */
.dpc-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: start;
}

.dpc-card {
  background: #fff;
  border: 1px solid var(--dpc-line);
  border-radius: var(--dpc-radius);
  padding: 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.dpc-card + .dpc-card {
  margin-top: 20px;
}

.dpc-section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--dpc-ink);
}

.dpc-section-title i {
  color: var(--dpc-brand);
  width: 20px;
  text-align: center;
}

.dpc-section-hint {
  font-size: 13px;
  color: var(--dpc-muted);
  margin: 0 0 16px;
}

/* ── Unit toggle ───────────────────────────────────────────────────────────── */
.dpc-units {
  display: inline-flex;
  border: 1px solid var(--dpc-line);
  border-radius: 999px;
  padding: 3px;
  background: var(--dpc-bg-soft);
  margin-left: auto;
}

.dpc-units button {
  border: 0;
  background: transparent;
  color: var(--dpc-muted);
  font-size: 13px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
}

.dpc-units button.is-active {
  background: var(--dpc-brand);
  color: #fff;
}

.dpc-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Dimension inputs ──────────────────────────────────────────────────────── */
.dpc-field-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

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

.dpc-field label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--dpc-muted);
}

.dpc-field input {
  width: 110px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  padding: 10px 8px;
  border: 1px solid var(--dpc-line);
  border-radius: 8px;
  color: var(--dpc-ink);
  -moz-appearance: textfield;
}

.dpc-field input:focus {
  outline: none;
  border-color: var(--dpc-brand);
  box-shadow: 0 0 0 3px rgba(222, 37, 111, 0.14);
}

.dpc-times {
  font-size: 18px;
  font-weight: 700;
  color: var(--dpc-muted);
  padding-bottom: 10px;
}

.dpc-unit-suffix {
  font-size: 14px;
  font-weight: 700;
  color: var(--dpc-muted);
  padding-bottom: 11px;
}

.dpc-input-error {
  font-size: 12px;
  color: var(--dpc-low);
  margin-top: 8px;
  min-height: 1em;
}

/* ── Preset buttons ────────────────────────────────────────────────────────── */
.dpc-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.dpc-chip {
  border: 1px solid var(--dpc-line);
  background: #fff;
  color: var(--dpc-ink);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.dpc-chip:hover {
  border-color: var(--dpc-brand);
  color: var(--dpc-brand);
}

.dpc-chip.is-active {
  background: var(--dpc-brand);
  border-color: var(--dpc-brand);
  color: #fff;
}

/* ── Viewing distance slider ───────────────────────────────────────────────── */
.dpc-distance-readout {
  font-size: 22px;
  font-weight: 800;
  color: var(--dpc-ink);
  margin: 4px 0 14px;
}

.dpc-distance-readout small {
  font-size: 14px;
  font-weight: 600;
  color: var(--dpc-muted);
}

.dpc-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--dpc-line);
  outline: none;
  margin: 6px 0 4px;
}

.dpc-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--dpc-brand);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.dpc-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--dpc-brand);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.dpc-range:focus {
  box-shadow: 0 0 0 3px rgba(222, 37, 111, 0.14);
}

.dpc-range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--dpc-muted);
  margin-bottom: 14px;
}

/* ── Results panel ─────────────────────────────────────────────────────────── */
.dpc-results .dpc-card {
  position: sticky;
  top: 16px;
}

.dpc-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.dpc-metric {
  background: var(--dpc-bg-soft);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.dpc-metric .dpc-metric-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--dpc-ink);
  line-height: 1.1;
}

.dpc-metric .dpc-metric-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--dpc-muted);
  margin-top: 6px;
}

.dpc-metric-wide {
  grid-column: 1 / -1;
}

/* Small note under a control (e.g. the local-file privacy line) */
.dpc-note {
  margin-top: 8px;
}

/* ── Quality verdict ───────────────────────────────────────────────────────── */
.dpc-verdict {
  display: none; /* shown (as flex) by the client script once an image is entered */
  align-items: center;
  gap: 14px;
  border-radius: 12px;
  padding: 16px;
  margin-top: 18px;
  border: 1px solid var(--dpc-line);
  background: var(--dpc-bg-soft);
}

.dpc-verdict-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  background: var(--dpc-muted);
}

.dpc-verdict-body {
  min-width: 0;
}

.dpc-verdict-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
}

.dpc-verdict-msg {
  font-size: 13px;
  color: var(--dpc-muted);
  margin: 2px 0 0;
}

.dpc-verdict.is-good {
  background: rgba(25, 169, 116, 0.08);
  border-color: rgba(25, 169, 116, 0.3);
}
.dpc-verdict.is-good .dpc-verdict-icon { background: var(--dpc-good); }
.dpc-verdict.is-good .dpc-verdict-title { color: var(--dpc-good); }

.dpc-verdict.is-ok {
  background: rgba(243, 167, 18, 0.09);
  border-color: rgba(243, 167, 18, 0.32);
}
.dpc-verdict.is-ok .dpc-verdict-icon { background: var(--dpc-ok); }
.dpc-verdict.is-ok .dpc-verdict-title { color: #b9790a; }

.dpc-verdict.is-low {
  background: rgba(224, 83, 61, 0.08);
  border-color: rgba(224, 83, 61, 0.3);
}
.dpc-verdict.is-low .dpc-verdict-icon { background: var(--dpc-low); }
.dpc-verdict.is-low .dpc-verdict-title { color: var(--dpc-low); }

/* ── File picker (client-side dimension read) ──────────────────────────────── */
.dpc-filepick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--dpc-brand);
  background: rgba(222, 37, 111, 0.08);
  border: 1px dashed rgba(222, 37, 111, 0.4);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  margin-top: 12px;
}

.dpc-filepick:hover {
  background: rgba(222, 37, 111, 0.14);
}

.dpc-filepick input[type="file"] {
  display: none;
}

.dpc-or {
  font-size: 12px;
  color: var(--dpc-muted);
  margin: 12px 0 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── CTA: order this size ──────────────────────────────────────────────────── */
.dpc-cta {
  margin-top: 18px;
}

.dpc-cta-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--dpc-muted);
  margin-bottom: 10px;
}

.dpc-cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dpc-product {
  flex: 1 1 auto;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--dpc-ink);
  background: #fff;
  border: 1px solid var(--dpc-line);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color 0.15s, color 0.15s;
}

.dpc-product:hover {
  border-color: var(--dpc-brand);
  color: var(--dpc-brand);
  text-decoration: none;
}

.dpc-product i {
  margin-right: 6px;
  opacity: 0.7;
}

.dpc-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.dpc-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid var(--dpc-line);
  background: #fff;
  color: var(--dpc-ink);
  text-decoration: none;
}

.dpc-btn:hover {
  border-color: var(--dpc-brand);
  color: var(--dpc-brand);
}

.dpc-btn-primary {
  background: var(--dpc-brand);
  border-color: var(--dpc-brand);
  color: #fff;
}

.dpc-btn-primary:hover {
  background: var(--dpc-brand-dark);
  border-color: var(--dpc-brand-dark);
  color: #fff;
}

/* ── Explanation (collapsible) ─────────────────────────────────────────────── */
.dpc-explain {
  margin-top: 24px;
}

.dpc-explain summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--dpc-brand);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dpc-explain summary::-webkit-details-marker {
  display: none;
}

.dpc-explain[open] summary i {
  transform: rotate(90deg);
}

.dpc-explain summary i {
  transition: transform 0.15s;
}

.dpc-explain-body {
  font-size: 14px;
  color: #444;
  line-height: 1.6;
  margin-top: 12px;
}

.dpc-explain-body ul {
  padding-left: 20px;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .dpc-grid {
    grid-template-columns: 1fr;
  }
  .dpc-results .dpc-card {
    position: static;
  }
}

@media (max-width: 420px) {
  .dpc-card {
    padding: 16px;
  }
  .dpc-field input {
    width: 100%;
    min-width: 90px;
  }
  .dpc-metrics {
    grid-template-columns: 1fr;
  }
}
