:root {
  --ink: #1f2530;
  --ink-soft: #5c6672;
  --paper: #f5f7fa;
  --panel: #ffffff;
  --line: #dde3ea;
  --accent: #2f6feb;
  --old-tint: #b42318;
  --new-tint: #1a7f37;
  --chg-tint: #b45309;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
} /* pushes the footer to the bottom on short pages */

.app-footer {
  background: linear-gradient(180deg, #343a42 0%, #2a2e35 100%);
  border-top: 2px solid;
  border-image: linear-gradient(
      90deg,
      var(--old-tint) 0%,
      var(--chg-tint) 50%,
      var(--new-tint) 100%
    )
    1;
  color: rgba(255, 255, 255, 0.75);

  h5 {
    font-size: 1rem; /* overrides Bootstrap's .h1 display size */
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
  }

  a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: color 0.15s ease;

    &:hover,
    &:focus-visible {
      color: #fff;
      text-decoration: underline;
    }
  }

  ul li {
    margin-bottom: 0.35rem;
  }
}

.app-header {
  border-bottom: 1px solid var(--line);
  background: var(--panel);

  .mainLogo {
    height: 2rem;
    width: auto;
  }

  .tagline {
    color: var(--ink-soft);
    font-size: 0.85rem;
  }
}

.input-card {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel);

  .card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    border-radius: calc(0.75rem - 1px) calc(0.75rem - 1px) 0 0;
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  &.old {
    border-top: 3px solid var(--old-tint);

    .card-header {
      color: var(--old-tint);
    }
  }

  &.new {
    border-top: 3px solid var(--new-tint);

    .card-header {
      color: var(--new-tint);
    }
  }
}

.diff-textarea {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  min-height: 240px;
  resize: vertical;
  border: none;
  border-radius: 0;
  background: var(--panel);

  &:focus {
    box-shadow: inset 0 0 0 2px rgba(47, 111, 235, 0.25);
    border: none;
  }
}

.card-toolbar {
  position: relative;
  border-top: 1px solid var(--line);
  border-radius: 0 0 calc(0.75rem - 1px) calc(0.75rem - 1px);
  background: #fafbfc;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.formats-info {
  position: static;
  display: inline-flex;
}

.info-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 1.15rem;
  height: 1.15rem;
  padding-top: 0.12rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.formats-tooltip {
  position: absolute;
  bottom: calc(100% + 0.25rem);
  left: 0.75rem;
  right: 0.75rem;
  z-index: 50;
  width: auto;
  max-width: 24rem;
  padding: 0.6rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1.25rem rgba(31, 37, 48, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .formats-info:hover .info-mark {
    color: var(--ink);
    border-color: var(--ink-soft);
  }

  .formats-info:hover .formats-tooltip {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
}

.formats-info:focus-visible .info-mark,
.formats-info.open .info-mark {
  color: var(--ink);
  border-color: var(--ink-soft);
}

.formats-info:focus-visible .formats-tooltip,
.formats-info.open .formats-tooltip {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.char-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.file-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--ink-soft);
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

#compareBtn {
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
  padding-inline: 2rem;
}

#compareModeWrap {
  .form-text {
    font-size: 0.72rem;
  }
}

#resultCard {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel);
  overflow: hidden;

  .card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
  }

  @media (prefers-reduced-motion: no-preference) {
    &.reveal {
      animation: rise 0.25s ease-out;
    }
  }
}

.diff-stats {
  font-family: var(--mono);
  font-size: 0.8rem;

  .added {
    color: var(--new-tint);
    font-weight: 700;
  }

  .removed {
    color: var(--old-tint);
    font-weight: 700;
  }
}

#diffOutput {
  max-height: 72vh;
  overflow: auto;

  .d2h-wrapper {
    margin: 0;
  }

  .d2h-file-wrapper {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
  }

  .d2h-code-linenumber,
  .d2h-code-side-linenumber {
    position: static;
    display: table-cell;
  }

  .d2h-code-line,
  .d2h-code-side-line {
    box-sizing: border-box;
    width: 100%;
    padding-left: 0;
    padding-right: 0.5em;
  }

  .d2h-file-header {
    display: None;
  }
}

/* Visual (pixel) comparison */
#visualOutput {
  max-height: 78vh;
  overflow: auto;
  padding: 1rem;
  background: #eef1f5;
}

.visual-page {
  margin-bottom: 1.5rem;

  &:last-child {
    margin-bottom: 0;
  }

  .page-label {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--ink-soft);
    margin-bottom: 0.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: baseline;

    .status-changed {
      color: var(--chg-tint);
      font-weight: 700;
    }

    .status-same {
      color: var(--new-tint);
      font-weight: 700;
    }
  }

  img {
    width: 100%;
    height: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 0.25rem;
    box-shadow: 0 1px 3px rgba(31, 37, 48, 0.08);
    cursor: zoom-in;
  }
}

.pane-title {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}

/* Lightbox */
#lightbox {
  .modal-dialog {
    max-width: min(96vw, 1400px);
  }

  .modal-header {
    font-family: var(--mono);
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
  }
}

#lightboxBody {
  background: #eef1f5;
  padding: 1rem;
  overflow: auto;
  max-height: calc(100vh - 8rem);
  text-align: center;
}

#lightboxImg {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(31, 37, 48, 0.15);
  max-width: 100%;
  height: auto;
  cursor: zoom-in;

  &.zoomed {
    max-width: none;
    cursor: zoom-out;
  }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
  align-items: center;

  .chip {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 2px;
    margin-right: 0.3rem;
    vertical-align: -1px;
  }
}

.chip {
  &.removed {
    background: #dc2626;
  }

  &.added {
    background: #16a34a;
  }

  &.changed {
    background: #d97706;
  }
}

#progressNote {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
