/* ================================================================
   Contentious brand component classes

   c-section        — page section with vertical padding and centred container
   c-section-header — section title + subtitle block
   c-feature-card   — borderless card with display heading and body text

   ================================================================ */

@layer components {

  /* ----------------------------------------------------------------
     c-section
     ---------------------------------------------------------------- */

  .c-section {
    padding-top: 5rem;
    padding-bottom: 5rem;
  }

  .c-section__inner {
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  @media (min-width: 640px) {
    .c-section__inner {
      padding-left: 1.5rem;
      padding-right: 1.5rem;
    }
  }

  @media (min-width: 1280px) {
    .c-section__inner {
      padding-left: 2rem;
      padding-right: 2rem;
    }
  }

  /* ----------------------------------------------------------------
     c-section-header
     ---------------------------------------------------------------- */

  .c-section-header {
    margin-bottom: 3rem;
  }

  .c-section-header--centred {
    text-align: center;
  }

  .c-section-header__title {
    font-family: var(--font-heading-display);
    font-size: var(--font-size-h2);
    line-height: var(--heading-line-height);
    font-weight: var(--font-weight-normal);
    color: var(--foreground);
    margin-bottom: 1rem;
  }

  .c-section-header__subtitle {
    font-size: calc(1.15em * var(--text-multiplier));
    line-height: var(--body-line-height);
    color: var(--muted-foreground);
    margin-bottom: 3rem;
    max-width: 42rem;
  }

  .c-section-header--centred .c-section-header__subtitle {
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
  }

  /* ----------------------------------------------------------------
     c-feature-card
     ---------------------------------------------------------------- */

  /* Two-class selector beats c-card's single-class border-radius */
  .c-card.c-feature-card {
    border: none;
    border-radius: 0.75rem;
    overflow: hidden;
  }

  @media (prefers-reduced-motion: no-preference) {
    .c-card.c-feature-card {
      transition: transform 350ms ease, box-shadow 350ms ease;
    }

    .c-card.c-feature-card:hover {
      transform: translateY(-3px);
      box-shadow:
        0 4px 16px 0 color-mix(in srgb, var(--gloaming-900) 10%, transparent),
        0 1px 4px 0 color-mix(in srgb, var(--gloaming-900) 6%, transparent);
    }
  }

  .c-feature-card__content {
    padding: 2rem;
  }

  .c-feature-card__accent {
    margin-bottom: 0.75rem;
  }

  .c-feature-card__title {
    font-family: var(--font-heading-display);
    font-size: var(--font-size-h3);
    line-height: var(--heading-line-height);
    font-weight: var(--font-weight-normal);
    margin-bottom: 1rem;
  }

  .c-feature-card__body {
    font-size: calc(1em * var(--text-multiplier));
    line-height: var(--line-height-relaxed);
    color: var(--muted-foreground);
  }

  /* ----------------------------------------------------------------
     c-hero — Above-the-fold entrance animations

     Add these classes to hero section elements. Keyframes (hero-drop,
     hero-fade) are defined in base.css.

     .c-hero__eyebrow   — eyebrow label above the heading
     .c-hero__heading   — main heading (wrap lines in <span> for per-line stagger)
     .c-hero__intro     — lead paragraph
     .c-hero__cta       — button group
     .c-hero__image     — hero image (pure fade, no drop)
     ---------------------------------------------------------------- */

  /* Auto-hyphenation with generous limits. Use &shy; (U+00AD) in source text
     to control specific break points. overflow-wrap catches anything else. */
  .c-hero__heading {
    hyphens: auto;
    hyphenate-limit-chars: 9 5 4;
    -webkit-hyphenate-limit-before: 5;
    -webkit-hyphenate-limit-after: 4;
    overflow-wrap: break-word;
  }

  @media (prefers-reduced-motion: no-preference) {
    .c-hero__eyebrow { animation: hero-drop 550ms ease-out both; animation-delay:  80ms; }
    .c-hero__heading { animation: hero-drop 550ms ease-out both; animation-delay: 180ms; }
    .c-hero__intro   { animation: hero-drop 550ms ease-out both; animation-delay: 300ms; }
    .c-hero__cta     { animation: hero-drop 550ms ease-out both; animation-delay: 420ms; }
    .c-hero__image   { animation: hero-fade 1400ms ease-out both; animation-delay: 180ms; }

    /* Per-line stagger when heading lines are wrapped in <span> */
    .c-hero__heading span {
      display: inline-block;
      animation: hero-drop 550ms ease-out both;
    }
    .c-hero__heading span:first-of-type { animation-delay:  80ms; }
    .c-hero__heading span:last-of-type  { animation-delay: 200ms; }
  }

}

/* ================================================================
   Shadcn-derived component classes — CSS replacements for Tailwind
   utilities previously baked into Radix-based components.

   c-accordion  — Radix accordion with open/close animations
   c-card       — Generic card surface with header/content/footer
   c-error      — ErrorBoundary fallback UI

   ================================================================ */

@layer components {

  /* ----------------------------------------------------------------
     c-accordion
     ---------------------------------------------------------------- */

  .c-accordion__item {
    border-bottom: 1px solid var(--border);
  }

  .c-accordion__header {
    display: flex;
  }

  .c-accordion__trigger {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    padding-bottom: 1rem;
    font-weight: var(--font-weight-medium);
    transition: all 150ms ease;
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    width: 100%;
  }

  .c-accordion__trigger:hover {
    text-decoration: underline;
  }

  /* Chevron rotation when panel is open */
  .c-accordion__trigger[data-state=open] > svg {
    transform: rotate(180deg);
  }

  .c-accordion__chevron {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    transition: transform 200ms ease;
  }

  .c-accordion__content {
    overflow: hidden;
    font-size: var(--font-size-sm);
  }

  .c-accordion__content[data-state=open] {
    animation: accordion-down 200ms ease-out;
  }

  .c-accordion__content[data-state=closed] {
    animation: accordion-up 200ms ease-out;
  }

  .c-accordion__content-inner {
    padding-bottom: 1rem;
    padding-top: 0;
  }

  /* ----------------------------------------------------------------
     c-card
     ---------------------------------------------------------------- */

  .c-card {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--card);
    color: var(--card-foreground);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  }

  .c-card__header {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 1.5rem;
  }

  .c-card__title {
    font-size: var(--font-size-h3);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    letter-spacing: -0.025em;
  }

  .c-card__description {
    font-size: var(--font-size-sm);
    color: var(--muted-foreground);
  }

  .c-card__content {
    padding: 1.5rem;
    padding-top: 0;
  }

  .c-card__footer {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    padding-top: 0;
  }

  /* ----------------------------------------------------------------
     c-error — ErrorBoundary fallback UI
     ---------------------------------------------------------------- */

  .c-error {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--background);
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .c-error__inner {
    width: 100%;
    max-width: 28rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  .c-error__heading-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .c-error__heading {
    font-family: var(--font-heading-display);
    font-size: var(--font-size-h3);
    font-weight: var(--font-weight-normal);
    color: var(--foreground);
  }

  .c-error__message {
    font-size: var(--font-size-sm);
    color: var(--muted-foreground);
  }

  .c-error__detail {
    text-align: left;
    font-size: var(--font-size-xs);
    background-color: var(--muted);
    color: var(--muted-foreground);
    border-radius: var(--radius);
    padding: 0.75rem;
    overflow: auto;
    max-height: 8rem;
  }

  .c-error__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
  }

  @media (min-width: 640px) {
    .c-error__actions {
      flex-direction: row;
    }
  }

  .c-error__btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--foreground);
    background: transparent;
    cursor: pointer;
    font-size: var(--font-size-base);
    font-family: inherit;
    transition: background-color 150ms ease;
    text-decoration: none;
    display: inline-block;
  }

  .c-error__btn:hover {
    background-color: var(--muted);
  }

  .c-error__btn--primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border-color: transparent;
  }

  .c-error__btn--primary:hover {
    opacity: 0.9;
  }

}

/* ================================================================
   Contentious component classes

   Layer order (declared in layers.css):
     @layer tokens, theme, base, components, utilities

   All component classes live in @layer components.

   Note on opacity variants: with hex-format tokens, HSL channel
   opacity modifiers (hsl(var(--x) / 0.85)) are invalid. Hover
   states use color-mix(in srgb, var(--x) N%, transparent) instead,
   which achieves the same visual result and works with any format.
   ================================================================ */

/* ----------------------------------------------------------------
   Button
   Variants: primary (default), outline, outline-light, ghost,
             link, secondary, destructive
   Sizes:    default, sm, lg, icon
   ---------------------------------------------------------------- */

@layer components {
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: var(--radius);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    cursor: pointer;
    /* Transparent border so filled and outline variants share the same box
       model; outline variants override the colour, not the border-width. */
    border: 1px solid transparent;
    text-decoration: none;
    transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
    height: 2.5rem;
    padding: 0.5rem 1rem;
  }

  .btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
  }

  .btn:disabled,
  .btn[aria-disabled="true"] {
    pointer-events: none;
    opacity: 0.5;
  }

  .btn svg {
    pointer-events: none;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
  }

  /* --- Variants --- */

  .btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
  }

  .btn-primary:hover {
    background-color: color-mix(in srgb, var(--primary) 85%, transparent);
  }

  .btn-outline {
    border: 1px solid var(--input);
    background-color: transparent;
    color: var(--foreground);
  }

  .btn-outline:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
  }

  .btn-outline-light {
    border: 1px solid var(--sorbet-700);
    background-color: transparent;
    color: var(--limestone-400);
  }

  .btn-outline-light:hover {
    background-color: var(--sorbet-800);
    color: var(--limestone-200);
  }

  .btn-secondary {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
  }

  .btn-secondary:hover {
    background-color: color-mix(in srgb, var(--secondary) 80%, transparent);
  }

  .btn-ghost {
    background-color: transparent;
    color: var(--foreground);
  }

  .btn-ghost:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
  }

  .btn-link {
    background-color: transparent;
    color: var(--primary);
    text-underline-offset: 4px;
  }

  .btn-link:hover {
    text-decoration: underline;
  }

  .btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
  }

  .btn-destructive:hover {
    background-color: color-mix(in srgb, var(--destructive) 85%, transparent);
  }

  /* --- Sizes --- */

  .btn-sm {
    height: 2.25rem;
    padding: 0.25rem 0.75rem;
    font-size: var(--font-size-sm);
  }

  .btn-lg {
    height: 2.75rem;
    padding: 0.5rem 2rem;
  }

  .btn-icon {
    height: 2.5rem;
    width: 2.5rem;
    padding: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    .btn {
      transition:
        background-color 200ms ease,
        color 200ms ease,
        border-color 200ms ease,
        transform 200ms ease,
        box-shadow 200ms ease;
    }

    .btn:hover  { transform: translateY(-1px); }
    .btn:active { transform: translateY(1px); transition-duration: 100ms; }
  }
}
