/* Page-scoped styles for /apkg-to-csv/. Builds on /marketing.css tokens, same look as the other converters. */

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

.tool-hero { padding: clamp(8px, 3vw, 28px) 0 clamp(18px, 3vw, 28px); max-width: 780px; }
.tool-hero .eyebrow { color: var(--orange-dark); }
.tool-hero h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 4rem); line-height: 1; letter-spacing: -0.055em; }
.tool-hero .answer { margin: 16px 0 0; color: #3f3f3f; font-size: clamp(1.02rem, 2vw, 1.18rem); line-height: 1.6; }

.converter {
  position: relative;
  display: grid;
  gap: 16px;
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.converter label, .converter .label, .converter legend { font-weight: 850; }

/* Picking a file: one big obvious button (phones), plus the whole page as a drop target (mouse). */
.pick { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pick-button { position: relative; min-height: 56px; padding: 14px 26px; font-size: 1.08rem; cursor: pointer; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.file-button:focus-within { outline: 3px solid #1d4ed8; outline-offset: 3px; }
.pick-note { margin: -4px 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.drop-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .drop-hint { display: inline; } }
.mini-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--soft);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}
.mini-button:hover { border-color: #cfc8bd; }

.convert-status {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}
.convert-status[data-type="success"] { color: var(--green); background: var(--green-soft); }
.convert-status[data-type="success"]::before { content: "✓ "; }
.convert-status[data-type="warning"] { color: #6a4800; background: var(--yellow-soft); }
.convert-status[data-type="working"]::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 8px;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: apkg-spin 0.8s linear infinite;
}
@keyframes apkg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .convert-status[data-type="working"]::before { animation: none; } }
.converter.is-busy .pick-button { opacity: 0.6; pointer-events: none; }

.result { display: grid; gap: 14px; }
.result[hidden] { display: none; }
.detected { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

.options { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.segmented { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; padding: 0; border: 0; }
.segmented legend { float: left; margin-right: 6px; padding: 0; font-size: 0.95rem; }
.seg-input { position: absolute; opacity: 0; pointer-events: none; }
.seg-input + label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid #d6d0c6;
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
}
.seg-input:checked + label { border-color: var(--ink); background: var(--ink); color: white; }
.seg-input:focus-visible + label { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.field-hint { margin: 0; color: var(--muted); font-size: 0.86rem; font-weight: 500; line-height: 1.5; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-grid:not(:has(.field:not([hidden]))) { display: none; }
.field { display: grid; gap: 6px; font-size: 0.9rem; }
.field[hidden] { display: none; }
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #d6d0c6;
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font-size: 1rem;
}
.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.check { display: flex; align-items: center; gap: 9px; min-height: 32px; font-size: 0.95rem; }
.check[hidden] { display: none; }
.check input { width: 20px; height: 20px; accent-color: var(--orange); }

/* Soft edge shadows show that a wide preview scrolls sideways (they disappear at each end). */
.preview-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(to right, white 30%, rgba(255, 255, 255, 0)) left center / 40px 100% no-repeat local,
    linear-gradient(to left, white 30%, rgba(255, 255, 255, 0)) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(23, 23, 23, 0.16), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(23, 23, 23, 0.16), transparent) right center / 14px 100% no-repeat scroll,
    white;
}
.preview { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.preview th, .preview td { min-width: 120px; max-width: 360px; padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; line-height: 1.45; white-space: pre-line; word-break: break-word; }
.preview th { background: var(--soft); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; white-space: normal; }
.preview tr:last-child td { border-bottom: 0; }
.preview td.empty { color: #b3aca2; }
.preview-more { margin: -6px 0 0; color: var(--muted); font-size: 0.85rem; }
.media-note { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--yellow-soft); color: #6a4800; font-size: 0.9rem; line-height: 1.5; }
.media-note[hidden] { display: none; }

.download-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.download-row .button { width: 100%; cursor: pointer; font-size: 1rem; }
.button.outline { color: var(--ink); border-color: #d6d0c6; background: white; }
.button.outline:hover { border-color: var(--ink); }

.next-step {
  display: grid;
  gap: 12px;
  margin-top: 6px;
  padding: 18px;
  border-radius: 16px;
  color: white;
  background: var(--ink);
}
.next-step p { margin: 0; color: rgba(255,255,255,0.78); line-height: 1.55; }
.next-step strong { color: white; }
.next-step .study-note { color: #ffd2bf; font-size: 0.92rem; }
.next-step .study-note[hidden] { display: none; }
.next-step .button { width: 100%; font-size: 1.02rem; }
.next-step .button[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.noscript-note { margin: 0; }

.steps { counter-reset: step; display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: white; background: var(--orange); font-weight: 900; }
.steps strong { display: block; margin: 5px 0 4px; }
.steps p { margin: 0; color: var(--muted); line-height: 1.6; }

/* While a file is dragged over the page, the converter becomes one big, labelled target. */
.converter.is-dragging { outline: 3px dashed var(--orange); outline-offset: 6px; }
.converter.is-dragging::after {
  content: attr(data-drop-label);
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: inherit;
  background: rgba(255, 240, 232, 0.94);
  color: var(--orange-dark);
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
  pointer-events: none;
}

@media (max-width: 620px) {
  .pick { display: grid; grid-template-columns: 1fr; }
  .pick-button { width: 100%; justify-content: center; text-align: center; }
  .mini-button { justify-content: center; }
  .settings-grid { grid-template-columns: 1fr; }
  .segmented legend { float: none; display: block; width: 100%; margin: 0 0 2px; }
  .seg-input + label { flex: 1 1 0; justify-content: center; }
  .download-row { grid-template-columns: 1fr 1fr; }
  .download-row .button:first-child { grid-column: 1 / -1; }
  .converter { border-radius: 18px; box-shadow: 0 12px 30px rgba(23,23,23,0.06); }
  /* Wider columns that scroll sideways read better than words broken mid-way. */
  .preview th, .preview td { min-width: 150px; word-break: normal; overflow-wrap: break-word; }
  .next-step .button { text-align: center; }
}
