/* ABOUTME: Component styles for the Plumbline theme. */
/* ABOUTME: Buttons, UI primitives, and reusable visual patterns. */

@layer components {
  /* Buttons */
  .pl-button,
  .wp-block-button__link {
    display: inline-flex;
    align-items: center;
    gap: var(--pl-space-2);
    padding: var(--pl-space-3) var(--pl-space-5);
    font-family: var(--pl-font-body);
    font-size: var(--pl-text-base);
    font-weight: var(--pl-weight-semibold);
    line-height: var(--pl-leading-tight);
    text-decoration: none;
    border-radius: var(--pl-radius-md);
    border: var(--pl-border-medium) solid transparent;
    cursor: pointer;
    transition:
      background-color var(--pl-duration-fast) var(--pl-easing-default),
      border-color var(--pl-duration-fast) var(--pl-easing-default),
      color var(--pl-duration-fast) var(--pl-easing-default),
      box-shadow var(--pl-duration-fast) var(--pl-easing-default);
  }

  /* Primary button (default) */
  .pl-button,
  .wp-block-button:not(.is-style-secondary):not(.is-style-outline):not(.is-style-text-link) .wp-block-button__link,
  .wp-block-button.is-style-primary .wp-block-button__link {
    background-color: var(--pl-color-primary);
    color: var(--pl-color-text-inverse);
    border-color: var(--pl-color-primary);
  }

  .pl-button:hover,
  .wp-block-button:not(.is-style-secondary):not(.is-style-outline):not(.is-style-text-link) .wp-block-button__link:hover,
  .wp-block-button.is-style-primary .wp-block-button__link:hover {
    background-color: var(--pl-color-primary-dark);
    border-color: var(--pl-color-primary-dark);
    color: var(--pl-color-text-inverse);
  }

  /* Secondary button — neutral semantic, not brand amber */
  .wp-block-button.is-style-secondary .wp-block-button__link {
    background-color: var(--pl-color-button-secondary-bg);
    color: var(--pl-color-button-secondary-text);
    border-color: var(--pl-color-button-secondary-border);
    border-width: var(--pl-border-thin);
  }

  .wp-block-button.is-style-secondary .wp-block-button__link:hover {
    background-color: var(--pl-color-button-secondary-bg-hover);
    border-color: var(--pl-color-button-secondary-border);
    color: var(--pl-color-button-secondary-text);
  }

  /* Outline button */
  .wp-block-button.is-style-outline .wp-block-button__link {
    background-color: transparent;
    color: var(--pl-color-primary);
    border-color: var(--pl-color-primary);
  }

  .wp-block-button.is-style-outline .wp-block-button__link:hover {
    background-color: var(--pl-color-primary);
    color: var(--pl-color-text-inverse);
  }

  /* Text link button */
  .wp-block-button.is-style-text-link .wp-block-button__link {
    background-color: transparent;
    color: var(--pl-color-text-link);
    border-color: transparent;
    border-radius: 0;
    padding: 0;
    font-weight: var(--pl-weight-semibold);
    text-decoration-line: underline;
    text-decoration-color: var(--pl-link-underline-color);
    text-decoration-thickness: var(--pl-link-underline-thickness);
    text-underline-offset: var(--pl-link-underline-offset);
    text-decoration-skip-ink: auto;
    transition:
      color var(--pl-duration-fast) var(--pl-easing-default),
      text-decoration-color var(--pl-duration-fast) var(--pl-easing-default),
      text-decoration-thickness var(--pl-duration-fast) var(--pl-easing-default);
  }

  .wp-block-button.is-style-text-link .wp-block-button__link:hover {
    color: var(--pl-color-text-link-hover);
    text-decoration-color: var(--pl-link-underline-color-hover);
    text-decoration-thickness: var(--pl-link-underline-thickness-hover);
  }

  .wp-block-button__link:focus-visible,
  .wp-element-button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
  }

  /* Image styles */
  .wp-block-image.is-style-rounded img {
    border-radius: var(--pl-radius-lg);
  }

  .wp-block-image.is-style-shadow img {
    box-shadow: var(--pl-shadow-md);
  }

  /* Separator styles */
  .wp-block-separator.is-style-subtle {
    opacity: 0.5;
  }

  .wp-block-separator.is-style-accent {
    border-color: var(--pl-color-primary);
  }

  /* Quote accent-border style */
  .wp-block-quote.is-style-accent-border {
    border-left-color: var(--pl-color-secondary);
  }

  /* ========================================
     Back to Top
     ======================================== */

  .pl-back-to-top {
    position: fixed;
    bottom: var(--pl-space-6);
    right: var(--pl-space-6);
    z-index: var(--pl-z-sticky);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: var(--pl-radius-full);
    background: var(--pl-color-surface-raised);
    border: 1px solid var(--pl-color-border);
    box-shadow: var(--pl-shadow-md);
    color: var(--pl-color-text-secondary);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.15s var(--pl-spring), color 0.2s ease, box-shadow 0.2s ease;
    animation: pl-show-btt linear forwards;
    animation-timeline: scroll();
    animation-range: 100vh 100vh;
  }

  .pl-back-to-top:hover {
    transform: translateY(-2px);
    color: var(--pl-color-accent);
    box-shadow: var(--pl-shadow-lg);
  }

  .pl-back-to-top:active {
    transform: translateY(0) scale(0.95);
  }

  .pl-back-to-top:focus-visible {
    outline: 2px solid var(--pl-color-primary);
    outline-offset: 2px;
  }

  @keyframes pl-show-btt {
    from {
      opacity: 0;
      pointer-events: none;
    }
    to {
      opacity: 1;
      pointer-events: auto;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .pl-back-to-top {
      animation: none;
      opacity: 1;
      pointer-events: auto;
    }
  }

  /* ========================================
     Scroll Entrance Animations
     ======================================== */

  body.pl-animate-entrance [data-pl-section-style] {
    animation: pl-fade-in linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 35%;
  }

  body.pl-animate-entrance .wp-block-plumbline-hero {
    animation: none;
  }

  body.pl-animate-entrance [data-pl-no-entrance] {
    animation: none;
  }

  @keyframes pl-fade-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    body.pl-animate-entrance [data-pl-section-style] {
      animation: none;
    }
  }
}
