/* ═══════════════════════════════════════════════════════════════
   BASE · Reset · Global · Atoms
   Inspired by Apple / Nothing.tech / Linear — minimal & premium
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Inter+Tight:wght@500;600;700;800;900&family=JetBrains+Mono:wght@500;600&display=swap');

/* ─── Reset (modern, ergonomic) ─── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    color-scheme: light;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-body);
    line-height: var(--lh-normal);
    color: var(--ink);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
    overflow-x: hidden;
    min-height: 100vh;
}

img, svg, video {
    display: block;
    max-width: 100%;
}

img { -webkit-user-drag: none; }

svg {
    flex-shrink: 0;
    fill: none;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}
button:disabled { cursor: not-allowed; }

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: transparent;
    border: none;
}

input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

a {
    color: inherit;
    text-decoration: none;
}

ul, ol { list-style: none; }

/* Scroll target offset for sticky header */
:target { scroll-margin-top: calc(var(--header-h) + 24px); }

/* ─── Premium focus ring (keyboard only) ─── */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: none;
    box-shadow: var(--glow-accent-sm);
    border-radius: var(--r-xs);
}

/* ─── Utilities ─── */
.is-hidden { display: none !important; }
.is-invisible { visibility: hidden !important; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 28px;
}
@media (max-width: 880px) { .container { padding: 0 20px; } }
@media (max-width: 480px) { .container { padding: 0 16px; } }

/* ─── Scrollbar — minimal, premium ─── */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--ink-5);
    border-radius: var(--r-pill);
    border: 2px solid var(--bg-page);
    transition: background var(--dur-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--ink-5) transparent; }

/* ─── Selection ─── */
::selection {
    background: var(--accent);
    color: #fff;
    text-shadow: none;
}

/* ─── Toast — premium glass pill, bottom-center ─── */
.toast {
    position: fixed;
    bottom: calc(28px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(96px) scale(.96);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px 12px 18px;
    background: var(--bg-elev);
    color: var(--ink-on-dark);
    border: 1px solid var(--line-dark-2);
    border-radius: var(--r-pill);
    font-size: var(--fs-body-sm);
    font-weight: 500;
    letter-spacing: -.1px;
    box-shadow:
        0 24px 56px rgba(7, 7, 11, .35),
        0 8px 18px rgba(7, 7, 11, .20),
        var(--inset-frame);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    z-index: var(--z-toast);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        transform var(--dur-3) var(--ease-spring),
        opacity var(--dur-2) var(--ease-out),
        visibility 0s linear var(--dur-2);
    max-width: calc(100vw - 32px);
}
.toast.is-show {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition:
        transform var(--dur-3) var(--ease-spring),
        opacity var(--dur-2) var(--ease-out),
        visibility 0s linear 0s;
}
.toast::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ink-on-dark-3);
    flex-shrink: 0;
}
.toast.is-success { background: linear-gradient(135deg, #047857, #065f46); }
.toast.is-success::before { background: #6ee7b7; box-shadow: 0 0 12px #6ee7b7; }
.toast.is-error   { background: linear-gradient(135deg, #b91c1c, #7f1d1d); }
.toast.is-error::before { background: #fca5a5; box-shadow: 0 0 12px #fca5a5; }

@media (max-width: 480px) {
    .toast { width: calc(100vw - 24px); justify-content: center; }
}

/* ─── Spinner atom ─── (keyframes in animations.css) */
.spinner {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid var(--line-strong);
    border-top-color: currentColor;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}
.spinner--lg { width: 28px; height: 28px; border-width: 2.5px; }

/* ─── Skeleton shimmer ─── (keyframes in animations.css) */
.skel-pulse {
    background: linear-gradient(110deg,
        var(--surface-2) 35%,
        var(--surface-3) 50%,
        var(--surface-2) 65%);
    background-size: 220% 100%;
    animation: skel-shimmer 1.6s var(--ease-in-out) infinite;
}

/* ─── Smooth focus on programmatic scroll targets ─── */
[tabindex="-1"]:focus { outline: none; }
