/* ============================================================
   ResourceHub — Button System
   ------------------------------------------------------------
   The single source of truth for every button on the site.
   Loaded by BOTH base.html (dashboard/Bootstrap pages) and
   landing.html (no Bootstrap), so a button looks and behaves
   identically wherever it appears.

   Structure:  .rh-btn  +  one variant  +  optional size
     <a class="rh-btn rh-btn--solid rh-btn--lg">
     <button class="rh-btn rh-btn--icon rh-btn--sm">

   Variants : --solid  --outline  --ghost  --danger  --success  --icon
   Sizes    : (default) --sm  --lg
   Modifiers: --plain (strip bg/border, for input adornments)
              --pulse (attention CTA)

   Colors come from --brand-color / --brand-color-rgb, which both
   stylesheets already define and flip in dark mode, so this file
   needs no per-page or per-theme forks for brand color.
   ============================================================ */

:root {
    /* One motion language for every button on the site. */
    --rh-btn-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
    --rh-btn-dur: 0.28s;
    --rh-btn-dur-press: 0.12s;
    --rh-btn-press: 0.97;
    --rh-btn-radius: 999px;

    /* Neutral (ghost/icon) palette — light theme. */
    --rh-btn-neutral-fg: #475569;
    --rh-btn-neutral-fg-strong: #1e293b;
    --rh-btn-neutral-border: rgba(0, 0, 0, 0.14);
    --rh-btn-neutral-bg: rgba(0, 0, 0, 0.05);
    --rh-btn-neutral-bg-hover: rgba(0, 0, 0, 0.09);
    --rh-btn-neutral-shadow: 0 6px 16px rgba(0, 0, 0, 0.10);

    /* Semantic accents (kept out of the brand token on purpose). */
    --rh-btn-danger: #ef4444;
    --rh-btn-danger-rgb: 239, 68, 68;
    --rh-btn-success: #10b981;
    --rh-btn-success-rgb: 16, 185, 129;
}

html.dark-mode {
    --rh-btn-neutral-fg: #94a3b8;
    --rh-btn-neutral-fg-strong: #f1f5f9;
    --rh-btn-neutral-border: rgba(255, 255, 255, 0.16);
    --rh-btn-neutral-bg: rgba(255, 255, 255, 0.06);
    --rh-btn-neutral-bg-hover: rgba(255, 255, 255, 0.12);
    --rh-btn-neutral-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

/* ---------- Base ---------- */
.rh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 40px;
    padding: 0 1.25rem;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--rh-btn-radius);
    border: 1.5px solid transparent;
    background: transparent;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: relative;
    box-sizing: border-box;
    /* Declared explicitly so the global `*` transition in style.css
       (0.45s, tuned for page-level color fades) never slows buttons down. */
    transition:
        background-color var(--rh-btn-dur) ease,
        border-color var(--rh-btn-dur) ease,
        color var(--rh-btn-dur) ease,
        box-shadow var(--rh-btn-dur) ease,
        transform var(--rh-btn-dur) var(--rh-btn-ease);
}

.rh-btn:hover {
    text-decoration: none;
}

/* Press feedback — deliberately much faster than hover so a click
   reads as a physical push rather than a slow squash. */
.rh-btn:active {
    transform: scale(var(--rh-btn-press));
    transition-duration: var(--rh-btn-dur-press);
}

.rh-btn:focus-visible {
    outline: 2px solid var(--brand-color);
    outline-offset: 2px;
}

.rh-btn:disabled,
.rh-btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    pointer-events: none;
}

.rh-btn i {
    font-size: 1.05em;
    line-height: 1;
}

/* ---------- Sizes ---------- */
.rh-btn--sm {
    height: 32px;
    padding: 0 0.9rem;
    font-size: 0.8rem;
    gap: 0.35rem;
}

.rh-btn--lg {
    height: 48px;
    padding: 0 1.9rem;
    font-size: 1rem;
}

/* ---------- Variant: solid (primary CTA) ---------- */
.rh-btn--solid,
.rh-btn--solid:visited {
    background-color: var(--brand-color);
    border-color: var(--brand-color);
    color: #ffffff;
    overflow: hidden;
}

.rh-btn--solid:hover,
.rh-btn--solid:hover:visited {
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(var(--brand-color-rgb), 0.35);
}

/* Signature sheen sweep — previously hand-applied to three unrelated
   classes; now an intrinsic property of the primary button. */
.rh-btn--solid::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.25) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-25deg);
    pointer-events: none;
    transition: left 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

.rh-btn--solid:hover::after {
    left: 150%;
}

/* ---------- Variant: outline (secondary CTA) ---------- */
.rh-btn--outline,
.rh-btn--outline:visited {
    background-color: transparent;
    border-color: var(--brand-color);
    color: var(--brand-color);
}

.rh-btn--outline:hover,
.rh-btn--outline:hover:visited {
    background-color: var(--brand-color);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(var(--brand-color-rgb), 0.30);
}

/* ---------- Variant: ghost (neutral / tertiary) ---------- */
.rh-btn--ghost,
.rh-btn--ghost:visited {
    background-color: transparent;
    border-color: var(--rh-btn-neutral-border);
    color: var(--rh-btn-neutral-fg);
}

.rh-btn--ghost:hover,
.rh-btn--ghost:hover:visited {
    background-color: var(--rh-btn-neutral-bg-hover);
    border-color: var(--rh-btn-neutral-border);
    color: var(--rh-btn-neutral-fg-strong);
    box-shadow: var(--rh-btn-neutral-shadow);
}

/* Selected state for ghost buttons used as toggles/filters. */
.rh-btn--ghost.active,
.rh-btn--ghost.active:visited {
    background-color: var(--brand-color);
    border-color: var(--brand-color);
    color: #ffffff;
}

.rh-btn--ghost.active:hover,
.rh-btn--ghost.active:hover:visited {
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(var(--brand-color-rgb), 0.30);
}

/* ---------- Variant: danger (destructive) ---------- */
.rh-btn--danger,
.rh-btn--danger:visited {
    background-color: transparent;
    border-color: var(--rh-btn-danger);
    color: var(--rh-btn-danger);
}

.rh-btn--danger:hover {
    background-color: var(--rh-btn-danger);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(var(--rh-btn-danger-rgb), 0.35);
}

/* ---------- Variant: success (restore / confirm-positive) ---------- */
.rh-btn--success {
    background-color: transparent;
    border-color: var(--rh-btn-success);
    color: var(--rh-btn-success);
}

.rh-btn--success:hover {
    background-color: var(--rh-btn-success);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(var(--rh-btn-success-rgb), 0.35);
}

/* ---------- Variant: google ("Continue with Google") ----------
   Google's brand guidelines call for a neutral (light) button chrome
   around the unaltered multi-colour "G" mark — kept the same, deliberately
   recognisable card, in both themes rather than re-tinted with the brand
   colour like everything else in this file. */
.rh-btn--google {
    background-color: #ffffff;
    border-color: rgba(0, 0, 0, 0.14);
    color: #3c4043;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.rh-btn--google:hover {
    background-color: #f8f9fa;
    border-color: rgba(0, 0, 0, 0.22);
    color: #3c4043;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

html.dark-mode .rh-btn--google {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

html.dark-mode .rh-btn--google:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

/* ---------- Variant: icon (square-ish, icon only) ---------- */
.rh-btn--icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background-color: var(--rh-btn-neutral-bg);
    border-color: transparent;
    color: var(--rh-btn-neutral-fg);
    flex-shrink: 0;
}

.rh-btn--icon:hover {
    background-color: var(--rh-btn-neutral-bg-hover);
    color: var(--brand-color);
    box-shadow: var(--rh-btn-neutral-shadow);
}

.rh-btn--icon.rh-btn--sm {
    width: 32px;
    height: 32px;
    padding: 0;
}

.rh-btn--icon.rh-btn--lg {
    width: 48px;
    height: 48px;
    padding: 0;
}

.rh-btn--icon i {
    font-size: 1.15rem;
}

.rh-btn--icon.rh-btn--sm i {
    font-size: 0.95rem;
}

/* Google avatar shown inside the navbar's profile .rh-btn--icon trigger,
   in place of the generic person glyph, when the signed-in user has one. */
.navbar-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* icon + danger keeps the red identity but the circular icon shape. */
.rh-btn--icon.rh-btn--danger {
    background-color: transparent;
    border-color: var(--rh-btn-danger);
    color: var(--rh-btn-danger);
}

.rh-btn--icon.rh-btn--danger:hover {
    background-color: var(--rh-btn-danger);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(var(--rh-btn-danger-rgb), 0.35);
}

/* ---------- Modifier: plain (input adornments, bare icon affordances) ---------- */
.rh-btn--plain {
    background-color: transparent;
    border-color: transparent;
    box-shadow: none;
}

.rh-btn--plain:hover {
    background-color: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--brand-color);
}

/* Bootstrap's .input-group squares off the corners of any child that
   isn't first, which mangles our round icon buttons used as field
   adornments. Its selector chains several :not()s and so out-specifies
   any reasonable plain selector here — !important is the targeted way
   to win against that one vendor rule. */
.input-group > .rh-btn--icon {
    border-radius: 50% !important;
    margin-left: 0 !important;
}

/* ---------- Modifier: pulse (single attention-drawing CTA) ---------- */
.rh-btn--pulse {
    animation: rh-btn-pulse 2.5s infinite;
}

.rh-btn--pulse:hover {
    animation: none;
}

@keyframes rh-btn-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(var(--brand-color-rgb), 0.40); }
    70%  { box-shadow: 0 0 0 10px rgba(var(--brand-color-rgb), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--brand-color-rgb), 0); }
}

/* ---------- Dark-mode contrast on brand fills ----------
   The dark-theme brand colour is amber (#F59E0B). White text on amber
   lands around 1.9:1 contrast, which is unreadable; near-black on amber
   is roughly 10:1. So every state that FILLS with the brand colour
   flips to dark ink in dark mode. (The light theme's brand is a deep
   brown, where white text is correct — hence the theme split.) */
html.dark-mode .rh-btn--solid,
html.dark-mode .rh-btn--solid:hover,
html.dark-mode .rh-btn--outline:hover,
html.dark-mode .rh-btn--ghost.active,
html.dark-mode .rh-btn--ghost.active:hover {
    color: #0b0c10;
    font-weight: 700;
}

/* The sheen sweep is a white gradient — too hot over amber. */
html.dark-mode .rh-btn--solid::after {
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.14) 50%, rgba(255,255,255,0) 100%);
}

/* ---------- Touch targets ----------
   The --sm size is 30px tall, which is fine for a mouse but below the
   ~44px comfortable tap target on touch screens. Grow it on coarse
   pointers only, so desktop density is untouched. */
@media (pointer: coarse) {
    .rh-btn {
        min-height: 44px;
    }

    .rh-btn--sm {
        min-height: 40px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .rh-btn--icon.rh-btn--sm {
        width: 40px;
        height: 40px;
        min-height: 0;
    }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
    .rh-btn,
    .rh-btn--solid::after {
        transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    }
    .rh-btn:hover,
    .rh-btn:active {
        transform: none;
    }
    .rh-btn--pulse {
        animation: none;
    }
}
