/* ==========================================================================
   Release-history timeline. It renders in the Changelog tab, which the
   settings page carries today (views/settings.ejs) — no other view uses
   these classes; the changelog modal is built from framework parts.
   @layer pages: above the framework layers, below utilities.
   ========================================================================== */

@layer pages {
  .changelog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .changelog-source-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--zr-text-muted);
    text-decoration: none;
    white-space: nowrap;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--zr-line);
    border-radius: 0.5rem;
    transition:
      color 0.15s ease,
      border-color 0.15s ease,
      background-color 0.15s ease;
  }

  .changelog-source-link:hover {
    color: var(--zr-brand);
    border-color: var(--zr-brand);
    background: var(--zr-surface-2);
  }

  .changelog-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
  }

  /* The vertical spine. It stops at the last dot instead of running past it. */
  .changelog-timeline::before {
    content: '';
    position: absolute;
    left: 0.4375rem;
    top: 0.75rem;
    bottom: 1.25rem;
    width: 2px;
    background: var(--zr-line);
  }

  .changelog-release {
    position: relative;
    padding-left: 1.75rem;
    padding-bottom: 0.5rem;
  }

  .changelog-release:last-child {
    padding-bottom: 0;
  }

  .changelog-dot {
    position: absolute;
    left: 0;
    top: 0.625rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--zr-surface);
    border: 2px solid var(--zr-line);
    box-sizing: border-box;
    z-index: 1;
  }

  .changelog-release--current .changelog-dot {
    border-color: var(--zr-brand);
    background: var(--zr-brand);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  }

  .changelog-details {
    border: 1px solid var(--zr-line);
    border-radius: 0.625rem;
    background: var(--zr-surface);
    overflow: hidden;
  }

  .changelog-release--current .changelog-details {
    border-color: var(--zr-brand);
  }

  .changelog-summary {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background-color 0.15s ease;
  }

  .changelog-summary:hover {
    background: var(--zr-surface-2);
  }

  .changelog-summary::-webkit-details-marker {
    display: none;
  }

  .changelog-summary:focus-visible {
    outline: 2px solid var(--zr-brand);
    outline-offset: -2px;
  }

  .changelog-version {
    font-family: var(--zr-font-mono);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--zr-text);
  }

  .changelog-current-pill {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background: var(--zr-brand);
    color: var(--zr-on-brand);
  }

  .changelog-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--zr-text-faint);
    white-space: nowrap;
  }

  .changelog-entries {
    list-style: none;
    margin: 0;
    padding: 0.875rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    border-top: 1px solid var(--zr-line);
  }

  .changelog-entry {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
  }

  .changelog-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    flex-shrink: 0;
    /* Fits the longest label ("Security") so entry texts align in a column. */
    min-width: 6.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.1875rem 0.5rem;
    border-radius: 0.375rem;
    margin-top: 0.0625rem;
  }

  .changelog-badge i {
    font-size: 0.625rem;
  }

  /* Category colours come from the tokens, so both themes and every contrast
     change are handled in one place — these used to be twelve hardcoded hexes
     plus six dark-mode overrides. */
  .changelog-badge--new {
    background: var(--zr-ok-soft);
    color: var(--zr-ok);
  }
  .changelog-badge--fix {
    background: var(--zr-warn-soft);
    color: var(--zr-warn);
  }
  .changelog-badge--improvement {
    background: var(--zr-info-soft);
    color: var(--zr-info);
  }
  .changelog-badge--removed {
    background: var(--zr-danger-soft);
    color: var(--zr-danger);
  }
  .changelog-badge--security {
    background: color-mix(in srgb, var(--zr-cat-4) 14%, var(--zr-surface));
    color: var(--zr-cat-4);
  }
  .changelog-badge--note {
    background: var(--zr-surface-sunken);
    color: var(--zr-text-muted);
  }

  .changelog-text {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--zr-text);
  }

  .changelog-text a {
    color: var(--zr-brand);
    text-decoration: underline;
  }

  :root[data-theme='dark'] .changelog-release--current .changelog-dot {
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.2);
  }

  @media (max-width: 640px) {
    .changelog-entry {
      flex-direction: column;
      gap: 0.25rem;
    }

    .changelog-badge {
      min-width: 0;
      align-self: flex-start;
    }

    .changelog-count {
      display: none;
    }
  }
}
