/* Reduce page. Built on the tokens and components of styles.css (same rem scale). */

/* ---------- Header row: same height as the Merge toolbar, so content lines up ---------- */
.reduce-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 3.9375rem;
}

.reduce-head h1 {
  margin: 0;
  color: var(--green-ink);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.reduce-head p {
  margin: 0.25rem 0 0;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.3;
}

/* The dropzone title is an h2 here (the page h1 is above). */
.dropzone h2 {
  margin: 0;
  color: var(--green-ink);
  font-family: "Sansation", sans-serif;
  font-size: 1.75rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1.2;
}

/* ---------- Selected PDF ---------- */
.source {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.6875rem;
  padding: 1rem 1.25rem 1rem 1rem;
  border: 1px solid var(--line-3);
  border-radius: 0.375rem;
  background: var(--surface);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.source.is-over {
  border-color: var(--green);
  border-style: dashed;
  background: var(--drop-hover-bg, #fff);
}

.source-thumb {
  width: 4.5rem;
  height: 5.8125rem;
  overflow: hidden;
  border: 1px solid var(--line-3);
  border-radius: 0.25rem;
  background: #fff;
}

.source-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.source-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.source-name {
  overflow: hidden;
  color: var(--red);
  font-family: "Sansation", sans-serif;
  font-size: 1.375rem;
  line-height: 1.3;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-meta {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.3;
}

.source-actions {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.btn--replace {
  height: 3rem;
  gap: 0.625rem;
  padding: 0 1.125rem;
  font-size: 1.125rem;
}

.replace-icon {
  flex: none;
  width: 1.125rem;
  height: 1.4375rem;
  background: currentColor;
  -webkit-mask: url("assets/icon--upload-file.svg") center / contain no-repeat;
  mask: url("assets/icon--upload-file.svg") center / contain no-repeat;
}

.btn--outline.btn--replace:hover,
.btn--outline.btn--preview:hover,
.btn--outline.btn--small:hover {
  border-color: var(--red-deep);
  background: var(--red);
  color: #fff8f6;
}

.source-remove {
  flex: none;
  width: 1.5rem;
  height: 1.875rem;
  border-radius: 0.1875rem;
}

.source-remove img {
  width: 100%;
  height: 100%;
}

.source-remove:hover {
  background: var(--red);
}

/* ---------- Compression level ---------- */
.levels {
  margin-top: 2.125rem;
}

.levels-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 1rem;
  row-gap: 0.25rem;
}

.levels-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.2;
}

.levels-head p {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  opacity: 0.8;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 0.875rem;
}

.level-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.375rem 1.5rem;
  border: 1px solid var(--field-line);
  border-radius: 0.375rem;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.level-card:hover {
  border-color: var(--green);
}

.level-card.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 0.125rem var(--green);
}

.level-card:has(input:focus-visible) {
  outline: 0.125rem solid var(--green);
  outline-offset: 0.3125rem;
}

.level-radio {
  position: relative;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.25rem;
  border: 0.125rem solid var(--red);
  border-radius: 50%;
  background: var(--field-bg);
  transition: border-color 0.2s ease;
}

.level-radio::after {
  content: "";
  position: absolute;
  inset: 0.25rem;
  border-radius: 50%;
  background: var(--green);
  transform: scale(0);
  transition: transform 0.15s ease;
}

.level-card.is-selected .level-radio {
  border-color: var(--green);
}

.level-card.is-selected .level-radio::after {
  transform: scale(1);
}

.level-body {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

.level-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.level-name {
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  height: 1.5rem;
  padding: 0 0.5rem;
  border: 1px solid var(--green-line);
  border-radius: 0.25rem;
  background: var(--green);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.level-badge--strong {
  border-color: var(--red);
  background: transparent;
  color: var(--red);
}

.level-lead {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
}

.level-desc {
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.45;
}

.level-risk {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-top: 0.375rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--notice-line);
  border-radius: 0.25rem;
  background: color-mix(in srgb, var(--red) 6%, var(--surface));
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.4;
}

.level-risk img {
  flex: none;
  width: 1.375rem;
  height: 1.25rem;
  margin-top: 0.0625rem;
}

.level-risk strong {
  color: var(--red);
  font-weight: 700;
}

.level-outcome {
  margin-top: 0.5rem;
  padding-top: 0.625rem;
  border-top: 1px dashed var(--line);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.level-outcome[data-tone="good"] { color: var(--green-ink); }
.level-outcome[data-tone="busy"],
.level-outcome[data-tone="muted"] { color: var(--text); font-weight: 400; opacity: 0.8; }

/* ---------- Result ---------- */
.result {
  margin-top: 1.5rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--line-3);
  border-radius: 0.375rem;
  background: var(--surface);
  animation: fade-in 0.2s ease both;
}

.result-working-head {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.spinner--inline {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  border-width: 0.1875rem;
}

.result-working-title {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.btn--small {
  height: 2.6875rem;
  justify-content: center;
  padding: 0 1.125rem;
  font-size: 1.125rem;
}

.progress {
  height: 0.625rem;
  margin-top: 1.125rem;
  overflow: hidden;
  border: 1px solid var(--field-line);
  border-radius: 0.375rem;
  background: var(--field-bg);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--red);
  transition: width 0.25s ease;
}

.progress-label {
  display: block;
  margin-top: 0.625rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.result-warning {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.375rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--notice-line);
  border-radius: 0.375rem;
  background: color-mix(in srgb, var(--red) 6%, var(--surface));
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.4;
}

.result-warning img {
  flex: none;
  width: 1.8125rem;
  height: 1.625rem;
}

.result-warning strong {
  color: var(--red);
  font-weight: 700;
}

.result-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2.5rem;
}

.result-percent {
  display: flex;
  flex-direction: column;
  min-width: 8.5rem;
  color: var(--green-ink);
  font-family: "Sansation", sans-serif;
  font-size: 3.5rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.result-percent small {
  margin-top: 0.375rem;
  font-family: "Cairo", sans-serif;
  font-size: 1.25rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0;
}

.result-bars {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr) 5.75rem;
  align-items: center;
  gap: 1rem;
}

.bar-label {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 400;
}

.bar {
  height: 0.875rem;
  overflow: hidden;
  border-radius: 0.375rem;
  background: var(--line-3);
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 0.375rem;
}

.bar-fill--before {
  width: 100%;
  background: var(--red-soft);
}

.bar-fill--after {
  width: 0;
  background: var(--green);
  transition: width 0.5s ease;
}

.bar-value {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar-value--after {
  color: var(--green-ink);
}

.result-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line-3);
}

.result-summary {
  flex: 1 1 14rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.4;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.result-actions .btn {
  justify-content: center;
}

.btn--preview {
  gap: 0.625rem;
}

.btn--preview svg {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
}

.result-message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.125rem;
}

.result-message-icon {
  width: 2rem;
  height: 2rem;
  background: var(--red);
  -webkit-mask: url("assets/icon--alert.svg") center / contain no-repeat;
  mask: url("assets/icon--alert.svg") center / contain no-repeat;
}

.result-message-icon[data-icon="check"] {
  background: var(--green-ink);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm0 1.8a8.2 8.2 0 1 1 0 16.4 8.2 8.2 0 0 1 0-16.4Zm4.1 4.6-5.3 5.3-2.9-2.9-1.3 1.3 4.2 4.2 6.6-6.6-1.3-1.3Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm0 1.8a8.2 8.2 0 1 1 0 16.4 8.2 8.2 0 0 1 0-16.4Zm4.1 4.6-5.3 5.3-2.9-2.9-1.3 1.3 4.2 4.2 6.6-6.6-1.3-1.3Z'/%3E%3C/svg%3E");
}

.result-message-icon[data-icon="info"] {
  background: var(--text);
  opacity: 0.7;
}

.result-message-text strong {
  display: block;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.result-message-text p {
  margin: 0.25rem 0 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.45;
}

/* ---------- Unavailable actions stay focusable and explain themselves on click ---------- */
.page-reduce .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-reduce .btn[aria-disabled="true"]:hover {
  transform: none;
}

.page-reduce .btn--download[aria-disabled="true"]:hover,
.page-reduce .btn--generate[aria-disabled="true"]:hover {
  border-color: var(--red-deep);
  background: var(--red);
}

.page-reduce .btn--share[aria-disabled="true"]:hover {
  border-color: var(--green-line);
  background: var(--green);
}

/* ---------- Privacy note ---------- */
.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  margin: 1.75rem 0 0;
  padding-bottom: 3.75rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
}

.privacy-note svg {
  flex: none;
  width: 0.875rem;
  height: 1.125rem;
  color: var(--green-ink);
}

/* ---------- Responsive (same breakpoints as styles.css) ---------- */
@media (max-width: 1279px) {
  .reduce-head { min-height: 0; }
}

@media (max-width: 960px) {
  .reduce-head h1 { font-size: 26px; }
  /* styles.css stretches Download/Share to full width for the Merge toolbar grid. */
  .result-actions .btn { width: auto; height: 52px; font-size: 18px; }
  .btn--replace { height: 48px; }
}

@media (max-width: 760px) {
  .level-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .reduce-head h1 { font-size: 24px; }
  .reduce-head p { font-size: 15px; }
  .dropzone h2 { font-size: 22px; }
  .source { grid-template-columns: auto minmax(0, 1fr); gap: 14px; margin-top: 20px; padding: 12px; }
  .source-thumb { width: 56px; height: 72px; }
  .source-name { font-size: 17px; }
  .source-meta { font-size: 14px; }
  .source-actions { grid-column: 1 / -1; }
  .btn--replace { flex: 1; justify-content: center; height: 44px; font-size: 16px; }
  .levels { margin-top: 28px; }
  .levels-head h2 { font-size: 20px; }
  .levels-head p { font-size: 14px; }
  .level-card { gap: 12px; padding: 16px; }
  .level-name { font-size: 20px; }
  .level-lead { font-size: 16px; }
  .level-desc, .level-risk { font-size: 14px; }
  .level-outcome { font-size: 16px; }
  .result { padding: 18px 16px; }
  .result-working-title { font-size: 16px; }
  .btn--small { height: 40px; padding: 0 14px; font-size: 16px; }
  .result-warning { align-items: flex-start; gap: 12px; font-size: 14px; }
  .result-warning img { width: 24px; height: 22px; }
  .result-main { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .result-percent { flex-direction: row; align-items: baseline; gap: 10px; font-size: 44px; }
  .result-percent small { font-size: 18px; }
  .bar-row { grid-template-columns: 68px minmax(0, 1fr) 72px; gap: 10px; }
  .bar-label, .bar-value { font-size: 15px; }
  .result-summary { flex-basis: 100%; font-size: 14px; }
  .result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 10px; }
  .result-actions .btn { width: 100%; height: 48px; padding: 0 10px; gap: 8px; font-size: 16px; }
  .result-actions .btn--preview { grid-column: 1 / -1; }
  .result-message { grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
  .result-message .btn { grid-column: 1 / -1; }
  .result-message-text strong { font-size: 17px; }
  .result-message-text p { font-size: 14px; }
  /* Inline icon so it stays next to the first word when the sentence wraps. */
  .privacy-note { display: block; font-size: 14px; padding-bottom: 40px; }
  .privacy-note svg { display: inline-block; margin-right: 6px; vertical-align: -2px; }
}
