/*
 * Earlier usability refinements for SpotTheCopy.
 * Load after scanner.css, scanner-refinements.css and milestones.css.
 * This file intentionally adds presentation only; it does not alter behaviour.
 */

:where(button, input, select, summary, a, [tabindex]):focus-visible {
  outline: 3px solid #a45b16;
  outline-offset: 3px;
  box-shadow: 0 0 0 2px #f7f9f8;
}

:where(button, input, select) {
  font: inherit;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: .66;
}

/* Calm, unmistakable cancellation state — never styled like an error. */
#setup-view.cancelled #initial-selection,
#setup-view.cancelled .step-heading,
#setup-view.cancelled #start-controls .step-label,
#setup-view.cancelled #start-controls h2 {
  display: none;
}

#cancel-heading {
  margin: 0 0 14px;
  padding: 16px 18px;
  border: 1px solid #c5d9cb;
  border-left: 5px solid var(--green, #245a43);
  border-radius: 9px;
  background: var(--mint, #eaf4ee);
  color: var(--ink, #182b29);
}

#cancel-heading svg {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 0 8px;
  fill: none;
  stroke: var(--green, #245a43);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#setup-view.cancelled{display:flex;flex-direction:column}
#setup-view.cancelled #cancel-heading{display:flex;align-items:flex-start;gap:14px;order:1}
#setup-view.cancelled #cancel-heading svg{flex:0 0 34px;margin:0}
#setup-view.cancelled #start-controls{order:2}
#setup-view.cancelled #selection-wrap{order:3}
#setup-view.cancelled #cancelled-home{order:4;align-self:flex-start}
#setup-view.cancelled #setup-status{order:5}

#cancel-heading h2 {
  margin: 0 0 6px;
  color: var(--ink, #182b29);
  font-size: 24px;
  line-height: 1.25;
}

#cancel-heading p {
  max-width: 70ch;
  margin: 4px 0;
  color: #40564b;
  font-size: 16px;
  line-height: 1.5;
}

#setup-view.cancelled #start-controls {
  display: flex;
  align-items: center;
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}

#setup-view.cancelled #start-controls .step-number {
  display: none;
}

#setup-view.cancelled #start-controls .step-two-content {
  display: block;
}

#setup-view.cancelled #start-scan {
  min-width: 180px;
  min-height: 48px;
  font-size: 16px;
}

.selection-label-help {
  max-width: 66ch;
  margin: 4px 0 0;
  color: var(--muted, #53675d);
  font-size: 14px;
  line-height: 1.45;
}

/* Results view switcher */
.results-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 9px;
  padding: 4px;
  border: 1px solid var(--line, #d4dfd8);
  border-radius: 9px;
  background: #eef3ef;
}

.results-tabs button {
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #40564b;
  font-weight: 700;
  cursor: pointer;
}

.results-tabs button:hover {
  background: #e2ece5;
}

.results-tabs button[aria-pressed="true"] {
  border-color: #c5d9cb;
  background: var(--white, #fff);
  color: var(--green, #245a43);
  box-shadow: 0 1px 3px #193d281c;
}

/* Folder-first results: compact groups with a clear location hierarchy. */
#folder-list {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

#folder-list .folder-root {
  padding: 11px 13px 13px;
  border: 1px solid var(--line, #d4dfd8);
  border-radius: 10px;
  background: var(--white, #fff);
}

#folder-list .folder-root > h2 {
  margin: 0 0 8px;
  color: var(--green, #245a43);
  font-size: 17px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

#folder-list details.folder-group {
  margin-top: 7px;
  border: 1px solid #dce6df;
  border-radius: 7px;
  background: #fbfcfb;
}

#folder-list .folder-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 9px 12px;
  color: var(--ink, #182b29);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  list-style-position: inside;
}

#folder-list .folder-heading::marker {
  color: var(--green, #245a43);
}

#folder-list .folder-facts {
  flex: 0 1 auto;
  color: #52675b;
  font-size: 13px;
  font-weight: 500;
  text-align: right;
}
#folder-list details.folder-group>summary{padding:9px 12px;cursor:pointer}
#folder-list .folder-heading{display:inline;min-height:0;padding:0;font-size:16px}
#folder-list .folder-facts{display:block;margin-left:18px;font-size:14px;text-align:left}

#folder-list .folder-file-list {
  display: grid;
  gap: 6px;
  padding: 0 9px 9px;
}

#folder-list .folder-file {
  min-width: 0;
}

#folder-list .folder-file.member-card {
  border: 1px solid #dce6df;
  border-radius: 7px;
  background: var(--white, #fff);
}

#folder-list .folder-file .member-name {
  line-height: 1.4;
}

#folder-list .folder-file .view-copies {
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid #aabdb1;
  border-radius: 6px;
  background: #f7faf8;
  color: var(--green, #245a43);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

#folder-list .folder-file .view-copies:hover {
  background: var(--mint, #eaf4ee);
}

.folder-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}

.folder-pagination button {
  min-width: 42px;
  min-height: 42px;
}


/* Search matches and non-matching copies remain visually distinguishable. */
.filter-match {
  border-left: 4px solid var(--green, #245a43);
  background: #edf6ef;
}

.match-indicator,
.context-indicator {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  margin: 2px 0;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}
.member-card{grid-template-columns:minmax(0,1fr)}
.member-title-line{grid-column:1/-1;flex-wrap:wrap}
.member-actions{grid-column:1/-1;justify-content:flex-start}
.member-title-line .match-indicator,.member-title-line .context-indicator{font-size:14px}

.match-indicator {
  background: #dcefe1;
  color: #234d35;
}

.context-copy {
  color: #52675b;
}

.context-indicator {
  border: 1px solid #dce4de;
  background: #f1f4f2;
  color: #45594e;
}

.location-root,
.location-path {
  overflow-wrap: anywhere;
  word-break: normal;
}

.location-root {
  color: #334b3d;
  font-weight: 700;
}

.location-path {
  color: #52675b;
}


/* Keep one set-level preview compact and preserve the source aspect ratio. */
.group-content > .preview-control {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 7px 10px;
  margin: 7px 0 9px;
}

.group-content > .preview-control button {
  min-height: 40px;
}

.group-content > .preview-control .preview-output {
  flex: 1 0 100%;
}

.group-content > .preview-control .preview-output img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
  object-position: left top;
  border-radius: 6px;
}

/* Copy state must be apparent in addition to any live-region announcement. */
.copy-action.success {
  border-color: #245a43;
  background: #245a43;
  color: #fff;
}

.member-feedback[role="status"],
.copy-feedback[role="status"] {
  min-height: 1.35em;
  color: #245a43;
  font-size: 14px;
  font-weight: 650;
}

/* Print/PDF is the primary export; CSV remains available but visually quieter. */
.report-actions #print-report-button {
  border: 1px solid var(--green, #245a43);
  background: var(--green, #245a43);
  color: #fff;
  font-weight: 750;
}

.report-actions #print-report-button:hover {
  background: #1b4935;
}

.report-actions #download-csv {
  border: 1px solid #9eafa4;
  background: #f4f7f4;
  color: var(--green, #245a43);
}

.export-guidance {
  margin: 3px 0 9px;
  color: #52675b;
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 760px) {
  #folder-list .folder-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  #folder-list .folder-facts {
    text-align: left;
  }

  #folder-list .folder-file .view-copies {
    min-height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
