/* ============================================================================
   Components — buttons, chips, cards, forms, tables, overlays
   ========================================================================= */

/* ---- Buttons --------------------------------------------------------- */

.btn {
    --btn-bg: var(--ink);
    --btn-fg: var(--paper-2);
    --btn-line: transparent;
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6em;
    padding: 0.85em 1.5em;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--btn-fg);
    background: var(--btn-bg);
    border: 1px solid var(--btn-line);
    border-radius: var(--r-pill);
    transition: transform 0.35s var(--ease), background 0.3s var(--ease),
        color 0.3s var(--ease), box-shadow 0.35s var(--ease), border-color 0.3s var(--ease);
    white-space: nowrap;
    line-height: 1;
}
.btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 34%, rgba(255, 255, 255, 0.28) 50%, transparent 66%);
    transform: translateX(-130%);
    pointer-events: none;
    animation: sheen 6.5s var(--ease-out) infinite;
}
@keyframes sheen {
    0%, 78% { transform: translateX(-130%); opacity: 1; }
    98%, 100% { transform: translateX(130%); opacity: 0.85; }
}
.portal .btn::after { background: linear-gradient(115deg, transparent 34%, rgba(255, 255, 255, 0.14) 50%, transparent 66%); }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.is-busy { opacity: 0.55; pointer-events: none; }
.btn svg { width: 1.05em; height: 1.05em; }

.btn--accent { --btn-bg: var(--blue); --btn-fg: #fff; }
.btn--accent:hover { --btn-bg: var(--blue-deep); }
.btn--mint { --btn-bg: var(--mint); --btn-fg: #04302B; }
.btn--coral { --btn-bg: var(--coral); --btn-fg: #fff; }
.btn--ghost {
    --btn-bg: transparent;
    --btn-fg: var(--ink);
    --btn-line: var(--line-strong);
}
.btn--ghost:hover { --btn-bg: var(--ink); --btn-fg: var(--paper-2); --btn-line: var(--ink); }
.btn--subtle { --btn-bg: rgba(10,15,28,0.05); --btn-fg: var(--ink); }
.btn--sm { padding: 0.6em 1.05em; font-size: 0.85rem; }
.btn--lg { padding: 1.05em 1.9em; font-size: 1.02rem; }
.btn--block { width: 100%; }
.btn--icon { padding: 0.7em; border-radius: var(--r-pill); }
.btn--icon > * { pointer-events: none; }

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0;
    font-size: 0.86rem;
    font-weight: 500;
    color: inherit;
    background: none;
    border: none;
    transition: color 0.25s var(--ease), opacity 0.25s var(--ease);
}
.btn-link:hover { text-decoration: underline; }
.btn-link[disabled] { opacity: 0.45; pointer-events: none; }

/* ---- Tags & badges --------------------------------------------------- */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.32em 0.75em;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: var(--r-pill);
    background: rgba(10, 15, 28, 0.06);
    color: var(--ink-soft);
    white-space: nowrap;
    border: 1px solid transparent;
}
.tag--blue { background: rgba(0, 98, 155, 0.12); color: var(--blue); }
.tag--mint { background: rgba(16, 214, 190, 0.18); color: #067a6d; }
.tag--amber { background: rgba(255, 176, 32, 0.20); color: #9a6300; }
.tag--coral { background: rgba(255, 91, 58, 0.15); color: #c7341a; }
.tag--violet { background: rgba(108, 92, 231, 0.14); color: #4b3fbe; }
.tag--solid { background: var(--ink); color: var(--paper-2); }

/* ---- Cards ----------------------------------------------------------- */

.card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: clamp(20px, 2.6vw, 32px);
    box-shadow: var(--shadow-sm);
    transition: transform 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out),
        border-color 0.4s var(--ease);
}
.card--flush { padding: 0; overflow: hidden; }
.card--hover:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.tile {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 1.4rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* ---- Avatars --------------------------------------------------------- */

.avatar {
    --size: 44px;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: calc(var(--size) * 0.36);
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--violet));
    overflow: hidden;
    flex: none;
    letter-spacing: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { --size: 84px; }
.avatar--xl { --size: 108px; font-size: 2rem; }
.avatar--sm { --size: 34px; }
.avatar--mint { background: linear-gradient(135deg, var(--mint-deep), var(--blue)); }
.avatar--amber { background: linear-gradient(135deg, #C97A00, var(--coral)); }
.avatar--violet { background: linear-gradient(135deg, var(--violet), var(--blue)); }

/* ---- Forms ----------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 0.45rem; }
.field > label,
.flabel {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.input,
.select,
.textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--paper-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    font-size: 0.98rem;
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease);
}
.textarea { min-height: 120px; resize: vertical; }
.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(0, 98, 155, 0.14);
    background: #fff;
}
.input::placeholder, .textarea::placeholder { color: rgba(10, 15, 28, 0.34); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235A6478' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.6rem; }

.hint { font-size: 0.82rem; color: var(--ink-muted); }
.field-error { font-size: 0.82rem; color: var(--coral); }

/* ---- Tables ---------------------------------------------------------- */

.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 0.94rem; min-width: 560px; }
.table th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-muted);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    font-weight: 500;
}
.table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table tbody tr { transition: background 0.2s var(--ease); }
.table tbody tr:hover { background: rgba(10, 15, 28, 0.025); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- Empty / loading states ----------------------------------------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.6rem;
    padding: clamp(2.5rem, 6vw, 4.5rem) 1.5rem;
    color: var(--ink-muted);
}
.empty__glyph {
    width: 62px; height: 62px;
    border-radius: var(--r);
    display: grid;
    place-items: center;
    background: rgba(10, 15, 28, 0.05);
    margin-bottom: 0.5rem;
}
.empty h3 { font-size: 1.2rem; color: var(--ink); }

.skeleton, .skeleton-line {
    background: linear-gradient(90deg, rgba(10,15,28,0.07) 25%, rgba(10,15,28,0.12) 37%, rgba(10,15,28,0.07) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--r-sm);
}
.skeleton { height: 100%; min-height: 96px; }
.skeleton-line { height: 12px; border-radius: var(--r-pill); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.spinner {
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
}
.spinner--ink { border-color: rgba(10,15,28,0.2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Modal ----------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(6, 10, 20, 0.5);
    backdrop-filter: blur(6px);
    display: grid;
    place-items: center;
    padding: var(--gutter);
    animation: fade 0.25s var(--ease);
}
.modal {
    width: min(560px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    background: var(--paper-2);
    border-radius: var(--r-xl);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lift);
    padding: clamp(24px, 3vw, 38px);
    animation: pop 0.4s var(--ease-out);
}
.modal--wide { width: min(760px, 100%); }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.modal__title { font-size: 1.5rem; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(0.98); } }

/* ---- Toast ----------------------------------------------------------- */

.toast-stack {
    position: fixed;
    right: clamp(16px, 3vw, 32px);
    bottom: clamp(16px, 3vw, 32px);
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    width: min(360px, calc(100vw - 32px));
}
.toast {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    padding: 1rem 1.1rem;
    border-radius: var(--r);
    background: var(--ink);
    color: var(--paper-2);
    box-shadow: var(--shadow);
    animation: slide-in 0.4s var(--ease-out);
    border-left: 3px solid var(--mint);
}
.toast--error { border-left-color: var(--coral); }
.toast__title { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; }
.toast__body { font-size: 0.88rem; opacity: 0.8; }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } }

/* ---- Accordion ------------------------------------------------------- */

.acc { border-top: 1px solid var(--line); }
.acc summary {
    list-style: none;
    cursor: pointer;
    padding: 1.4rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after {
    content: "+";
    font-family: var(--font-mono);
    font-size: 1.4rem;
    line-height: 1;
    color: var(--ink-muted);
    transition: transform 0.3s var(--ease);
}
.acc[open] summary::after { content: "–"; }
.acc__body { padding-bottom: 1.4rem; color: var(--ink-soft); max-width: 62ch; }
.acc:last-of-type { border-bottom: 1px solid var(--line); }

/* ---- Progress -------------------------------------------------------- */

.meter { height: 8px; border-radius: var(--r-pill); background: rgba(10,15,28,0.08); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--violet)); transition: width 0.8s var(--ease-out); }

/* ---- Marquee --------------------------------------------------------- */

.marquee { overflow: hidden; display: flex; }
.marquee__track {
    display: flex;
    flex: none;
    gap: 2.5rem;
    padding-right: 2.5rem;
    animation: marquee 26s linear infinite;
    will-change: transform;
}
.marquee--slow .marquee__track { animation-duration: 42s; }
.marquee--reverse .marquee__track { animation-direction: reverse; }
@keyframes marquee { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .marquee__track { animation: none; } }
