@layer components {
  /* .btn* classes style both <a> and native <button>/<input type=submit>
     elements. Anchors have no border/cursor by default, but buttons do
     (a UA-stylesheet border and cursor:default) -- reset both explicitly
     here so every button-like element looks and behaves the same
     regardless of which tag renders it. */
  .btn,
  .btn-primary,
  .btn-light,
  .btn-secondary,
  .btn-ghost {
    cursor: pointer;
  }

  .btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm) var(--spacing-md);

    color: var(--text-on-dark);
    font-weight: 600;
  }
  .btn:hover {
    background: var(--accent-hover);
  }

  .btn-primary {
    background: var(--accent);
    color: var(--text-on-dark);
    border: none;
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-lg);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    gap: var(--spacing-xs);
    align-items: center;
    transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s;
  }
  .btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-accent);
  }
  .btn-primary:hover::after {
    transform: translateX(3px);
  }
  .btn-primary::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    background-color: currentColor;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3 8h10m0 0L9 4m4 4L9 12' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    mask-size: contain;
    mask-repeat: no-repeat;
    transition: transform 0.25s;
  }

  .btn-light {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--surface-page);
    color: var(--text-primary);
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s;
  }
  .btn-light:hover {
    background: var(--surface-card);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(250, 247, 242, 0.2); /* cream glow for dark surfaces */
  }
  .btn-light:after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    background: currentColor;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 8h10m0 0L9 4m4 4L9 12' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }

  .btn-secondary {
    display: inline-block;
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border-default);
    transition: border-color 0.2s, color 0.2s;
  }
  .btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  .btn-ghost {
    color: var(--text-primary);
    background: none;
    border: none;
    font-weight: 500;
    text-decoration: none;
    padding: var(--spacing-sm) var(--spacing-xs);
    transition: color 0.25s;
  }
  .btn-ghost:hover {
    color: var(--accent);
  }

  /* Compact variant for app topbars, toolbars, and modal actions */
  .btn-sm {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
  }
  .btn-sm.btn-primary::after {
    display: none;
  }
}
