/* ==========================================================================
   Free tools — /scan-dpi-calculator and its future siblings
   Loaded after styles.css, only on tool pages; reuses its tokens and the
   .field / .step / .faq / .cta blocks.
   ========================================================================== */

.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;
}

/* ── hero ────────────────────────────────────────────────────────────────── */
.tool-hero { padding-bottom: clamp(48px, 7vw, 90px); }
.tool-hero > .wrap { position: relative; }
.tool-hero__head { max-width: 760px; margin: 0 auto clamp(28px, 4vw, 44px); text-align: center; }
.tool-hero__title { font-size: clamp(2.2rem, 5vw, 3.6rem); margin-bottom: 18px; }
.tool-hero__head .hero__sub { max-width: 54ch; margin-inline: auto; }

/* ── calculator ──────────────────────────────────────────────────────────── */
.calc {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  max-width: 1000px; margin-inline: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  overflow: hidden;
}
.calc__inputs { padding: clamp(22px, 3.2vw, 34px); }
.calc__inputs .field:last-child { margin-bottom: 0; }
.calc__row, .calc__size { display: grid; gap: 0 14px; }
.calc__row  { grid-template-columns: 1fr 1fr; }
.calc__size { grid-template-columns: 1fr 1fr 1fr; }
.calc__size[hidden], [data-goal-panel][hidden] { display: none; }

.field select {
  width: 100%; padding: 13px 40px 13px 15px;
  background: var(--ink-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font: inherit; font-size: .96rem;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A5A0BC' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px;
  cursor: pointer;
  transition: border-color .2s var(--ease);
}
[dir="rtl"] .field select { padding: 13px 15px 13px 40px; background-position: left 14px center; }
.field select:focus { outline: none; border-color: var(--accent-brand); }
.field select option, .field select optgroup { background: var(--surface); color: var(--text); }

.calc__goal { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.calc__goal legend { padding: 0; margin-bottom: 7px; font-size: .86rem; font-weight: 600; }
.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.seg__opt { position: relative; }
.seg__opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg__opt span {
  display: block; padding: 9px 6px; border-radius: 8px; text-align: center;
  color: var(--muted); font-size: .9rem; font-weight: 600; line-height: 1.25;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.seg__opt input:checked + span { background: var(--accent-brand); color: var(--text); }
.seg__opt input:focus-visible + span { outline: 2px solid var(--violet); outline-offset: 2px; }
.seg__opt:hover input:not(:checked) + span { color: var(--text); }

.calc__hint { font-size: .9rem; color: var(--muted); }

.calc__result {
  display: block; padding: clamp(22px, 3.2vw, 34px);
  background: var(--surface-2); border-inline-start: 1px solid var(--line);
}
.calc__label { font-size: .86rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.calc__dpi {
  margin: 4px 0 18px; font-size: clamp(3rem, 7vw, 4.4rem); font-weight: 800;
  line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.calc__dpi [data-out="dpi"] {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.calc__dpi-unit { font-size: .4em; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.is-invalid .calc__dpi, .is-invalid .calc__facts { opacity: .35; }

.calc__facts { display: grid; gap: 10px; margin: 0 0 16px; font-size: .92rem; }
.calc__facts > div { display: grid; gap: 1px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.calc__facts > div[hidden] { display: none; }
.calc__facts dt { color: var(--muted); font-size: .8rem; }
.calc__facts dt small { font-size: inherit; opacity: .75; }
.calc__facts dd { margin: 0; font-variant-numeric: tabular-nums; }

.calc__note {
  margin-bottom: 10px; padding: 10px 13px;
  border: 1px solid rgba(255,180,60,.35); border-radius: var(--r-sm);
  background: rgba(255,180,60,.06); color: #FFD9A0; font-size: .84rem; line-height: 1.5;
}
.calc__note--err { border-color: rgba(240,69,155,.45); background: rgba(240,69,155,.07); color: #FFB7D6; }
.calc__cta { margin-top: 14px; font-size: .86rem; color: var(--muted); }
.calc__cta a { color: var(--violet); font-weight: 600; text-decoration: none; white-space: nowrap; }
.calc__cta a:hover { text-decoration: underline; }

/* ── formula ─────────────────────────────────────────────────────────────── */
.prose p { color: var(--muted); }
.prose p + p { margin-top: 16px; }
.formula {
  padding: 18px 22px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text) !important; font-weight: 700; font-size: 1.1rem; text-align: center;
}

/* ── chart ───────────────────────────────────────────────────────────────── */
.chart {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.chart table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: .95rem; }
.chart th, .chart td { padding: 13px 16px; text-align: center; border-bottom: 1px solid var(--line); }
.chart thead th { color: var(--muted); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.chart tbody th { text-align: start; font-weight: 600; white-space: nowrap; }
.chart tbody tr:last-child > * { border-bottom: 0; }
.chart td { font-variant-numeric: tabular-nums; }
.chart tbody tr:hover { background: var(--surface-2); }
.chart__note { margin-top: 14px; font-size: .86rem; color: var(--muted); }

.steps--4 { grid-template-columns: repeat(4, 1fr); }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1020px) {
  .steps--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 880px) {
  .calc { grid-template-columns: 1fr; }
  .calc__result { border-inline-start: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .steps--4 { grid-template-columns: 1fr; }
  .calc__row { grid-template-columns: 1fr; }
  .calc__size { grid-template-columns: 1fr 1fr; }
  .calc__size .field:last-child { grid-column: 1 / -1; }
}

/* "8 × 12 in · 20.3 × 30.5 cm": metric pages (data-metric="1") put cm first. */
.dual { display: flex; flex-wrap: wrap; gap: 0 .4em; }
.dual__sep { order: 1; color: var(--muted); }
.dual__in { order: 0; }
.dual__cm { order: 2; }
[data-metric="1"] .dual__in { order: 2; }
[data-metric="1"] .dual__cm { order: 0; }
