/* Ezeet — Shared design system (Session 2.5)
 * Augments page-local tokens with semantic states, button system, toast, modal,
 * focus rings, and motion. Page-local :root tokens (--bg, --text, --border…)
 * remain authoritative; this file adds an --ez-* namespace alongside them.
 */

:root {
    /* Semantic state colors */
    --ez-success: #15803d;
    --ez-success-bg: #f0fdf4;
    --ez-success-border: #bbf7d0;
    --ez-danger: #dc2626;
    --ez-danger-bg: #fef2f2;
    --ez-danger-border: #fecaca;
    --ez-info: #1e40af;
    --ez-info-bg: #eff6ff;
    --ez-info-border: #bfdbfe;
    --ez-warn: #92400e;
    --ez-warn-bg: #fef3c7;
    --ez-warn-border: #fde68a;

    /* Elevation */
    --ez-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --ez-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --ez-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
    --ez-shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.12), 0 8px 20px rgba(0, 0, 0, 0.06);

    /* Motion */
    --ez-ease: cubic-bezier(0.2, 0, 0, 1);
    --ez-fast: 120ms var(--ez-ease);
    --ez-base: 180ms var(--ez-ease);
    --ez-slow: 280ms var(--ez-ease);

    /* Stack */
    --ez-z-toast: 9000;
    --ez-z-modal: 9500;
}

/* === Focus ring (a11y) ===
 * :focus-visible only paints for keyboard / programmatic focus, so mouse
 * users keep the existing visual; assistive users get a clear ring.
 */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--text, #1a1a1a);
    outline-offset: 2px;
    border-radius: 6px;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.nav-cta:focus-visible,
.aud-btn:focus-visible,
.ez-btn:focus-visible {
    outline-offset: 3px;
    border-radius: 999px;
}

input:not([type="checkbox"]):not([type="radio"]):focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--text, #1a1a1a) !important;
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

/* === Microinteractions on existing buttons ===
 * Adds tactile feedback to existing button classes without changing palette
 * or layout. Hover lifts, active settles, disabled goes still.
 */
.btn-primary,
.btn-secondary,
.nav-cta,
.aud-btn,
.action-btn,
.ez-btn,
.login-btn,
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    transition: transform var(--ez-base),
                opacity var(--ez-base),
                background-color var(--ez-base),
                border-color var(--ez-base),
                box-shadow var(--ez-base),
                color var(--ez-base);
}

.btn-primary:hover,
.nav-cta:hover,
.ez-btn--primary:hover,
.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--ez-shadow-md);
}

.btn-primary:active,
.btn-secondary:active,
.nav-cta:active,
.aud-btn:active,
.action-btn:active,
.ez-btn:active,
.login-btn:active {
    transform: translateY(0) scale(0.98);
}

button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.nav-cta:disabled,
.ez-btn:disabled,
.ez-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
    box-shadow: none !important;
}

/* === Unified button system (.ez-btn) === */

.ez-btn {
    --ez-btn-fg: var(--text, #1a1a1a);
    --ez-btn-bg: transparent;
    --ez-btn-border: transparent;
    --ez-btn-pad-y: 14px;
    --ez-btn-pad-x: 28px;
    --ez-btn-font-size: 15px;
    --ez-btn-radius: 999px;

    font-family: var(--sans, 'Instrument Sans', -apple-system, sans-serif);
    font-size: var(--ez-btn-font-size);
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1;
    padding: var(--ez-btn-pad-y) var(--ez-btn-pad-x);
    border-radius: var(--ez-btn-radius);
    border: 1px solid var(--ez-btn-border);
    background: var(--ez-btn-bg);
    color: var(--ez-btn-fg);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    min-width: 44px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.ez-btn--primary {
    --ez-btn-bg: var(--text, #1a1a1a);
    --ez-btn-fg: var(--bg, #faf8f5);
    --ez-btn-border: var(--text, #1a1a1a);
}

.ez-btn--secondary {
    --ez-btn-fg: var(--text, #1a1a1a);
    --ez-btn-border: var(--border, #e7e5e0);
}

.ez-btn--secondary:hover {
    --ez-btn-border: var(--text, #1a1a1a);
}

.ez-btn--tertiary {
    --ez-btn-fg: var(--text, #1a1a1a);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
}

.ez-btn--tertiary:hover {
    text-decoration-thickness: 2px;
}

.ez-btn--ghost {
    --ez-btn-fg: var(--text-dim, #6b665f);
}

.ez-btn--ghost:hover {
    --ez-btn-fg: var(--text, #1a1a1a);
    --ez-btn-bg: rgba(0, 0, 0, 0.04);
}

.ez-btn--danger {
    --ez-btn-bg: var(--ez-danger);
    --ez-btn-fg: #fff;
    --ez-btn-border: var(--ez-danger);
}

.ez-btn--sm {
    --ez-btn-pad-y: 8px;
    --ez-btn-pad-x: 16px;
    --ez-btn-font-size: 13px;
    min-height: 36px;
}

.ez-btn.is-loading {
    color: transparent !important;
    pointer-events: none;
    position: relative;
}

.ez-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--ez-btn-fg);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: ez-spin 0.8s linear infinite;
    color: var(--ez-btn-fg);
}

@keyframes ez-spin {
    to { transform: rotate(360deg); }
}

/* === Toast === */

.ez-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: var(--ez-z-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: calc(100vw - 48px);
}

@media (max-width: 540px) {
    .ez-toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        align-items: stretch;
    }
}

.ez-toast {
    pointer-events: auto;
    background: var(--surface, #fff);
    color: var(--text, #1a1a1a);
    border: 1px solid var(--border, #e7e5e0);
    border-left: 3px solid var(--text, #1a1a1a);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: var(--ez-shadow-lg);
    font-family: var(--sans, 'Instrument Sans', -apple-system, sans-serif);
    font-size: 14px;
    line-height: 1.45;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 280px;
    max-width: 380px;
    animation: ez-toast-in 240ms var(--ez-ease) both;
}

.ez-toast.is-leaving { animation: ez-toast-out 200ms var(--ez-ease) both; }

.ez-toast--success { border-left-color: var(--ez-success); }
.ez-toast--danger  { border-left-color: var(--ez-danger); }
.ez-toast--info    { border-left-color: var(--ez-info); }
.ez-toast--warn    { border-left-color: var(--ez-warn); }

.ez-toast__icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
    background: var(--text, #1a1a1a);
    color: var(--bg, #fff);
}

.ez-toast--success .ez-toast__icon { background: var(--ez-success); color: #fff; }
.ez-toast--danger  .ez-toast__icon { background: var(--ez-danger); color: #fff; }
.ez-toast--info    .ez-toast__icon { background: var(--ez-info); color: #fff; }
.ez-toast--warn    .ez-toast__icon { background: var(--ez-warn); color: #fff; }

.ez-toast__body { flex: 1; min-width: 0; }

.ez-toast__title {
    font-weight: 600;
    margin-bottom: 2px;
}

.ez-toast__msg {
    color: var(--text-dim, #6b665f);
    font-size: 13px;
}

.ez-toast__close {
    background: transparent;
    border: none;
    color: var(--text-light, #a8a29e);
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: -2px;
    transition: color var(--ez-fast);
}

.ez-toast__close:hover { color: var(--text, #1a1a1a); }

@keyframes ez-toast-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ez-toast-out {
    to { opacity: 0; transform: translateY(-6px) scale(0.98); }
}

/* === Modal === */

.ez-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--ez-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: ez-fade-in 200ms var(--ez-ease) both;
}

.ez-modal-backdrop.is-leaving { animation: ez-fade-out 160ms var(--ez-ease) both; }

.ez-modal {
    background: var(--surface, #fff);
    color: var(--text, #1a1a1a);
    border-radius: 16px;
    padding: 28px 28px 22px;
    box-shadow: var(--ez-shadow-xl);
    max-width: 420px;
    width: 100%;
    animation: ez-modal-in 220ms var(--ez-ease) both;
    font-family: var(--sans, 'Instrument Sans', -apple-system, sans-serif);
}

.ez-modal.is-leaving { animation: ez-modal-out 160ms var(--ez-ease) both; }

.ez-modal__title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 8px;
}

.ez-modal__body {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-dim, #6b665f);
    margin-bottom: 22px;
}

.ez-modal__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

@keyframes ez-fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes ez-fade-out  { to { opacity: 0; } }
@keyframes ez-modal-in  {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes ez-modal-out { to { opacity: 0; transform: translateY(4px) scale(0.98); } }

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
