/* ============================================
   TrikAi Avatar - Base Styles
   Reset, Global, Utilities, Responsive Grid
   ============================================ */

/* === Reset === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: var(--weight-regular);
    font-size: var(--text-body);
    line-height: var(--leading-body);
    color: var(--color-text-primary);
    background-color: var(--color-bg);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--color-purple);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-purple-light);
}

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

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

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

ul, ol {
    list-style: none;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: var(--weight-bold);
    line-height: 1.3;
}

::selection {
    background: rgba(123, 104, 238, 0.3);
    color: var(--color-text-primary);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

/* === App Shell === */
#app {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100%;
    overflow-x: hidden;
}

#screen-container {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
}

/* When tab nav is visible, add bottom padding */
#app.has-tabs #screen-container {
    padding-bottom: calc(var(--tab-nav-height) + var(--safe-area-bottom));
}

/* === Desktop Phone Frame === */
@media (min-width: 768px) {
    body {
        background: #080610;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding: 24px 0;
    }

    #app {
        max-width: 430px;
        width: 430px;
        min-height: calc(100vh - 48px);
        border-radius: 32px;
        overflow: clip;
        box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.06),
            0 20px 60px rgba(0, 0, 0, 0.6),
            0 0 80px rgba(123, 104, 238, 0.1);
        position: relative;
        background: var(--color-bg);
    }

    #screen-container {
        min-height: calc(100vh - 48px);
    }

    /* Fixed elements are constrained in components.css */
}

/* === Screen base === */
.screen {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-4);
    animation: fadeIn 0.3s ease;
}

.screen--no-pad {
    padding: 0;
}

.screen--with-header {
    padding-top: calc(var(--header-height) + var(--space-4));
}

.screen--with-tabs {
    padding-bottom: calc(var(--tab-nav-height) + var(--space-8));
}

/* === Typography Classes === */
.text-display {
    font-family: var(--font-heading);
    font-size: var(--text-display);
    font-weight: var(--weight-extrabold);
    line-height: var(--leading-display);
    letter-spacing: var(--tracking-tight);
}

.text-h1 {
    font-family: var(--font-heading);
    font-size: var(--text-h1);
    font-weight: var(--weight-bold);
    line-height: var(--leading-h1);
    letter-spacing: -0.3px;
}

.text-h2 {
    font-family: var(--font-heading);
    font-size: var(--text-h2);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-h2);
    letter-spacing: -0.2px;
}

.text-h3 {
    font-family: var(--font-heading);
    font-size: var(--text-h3);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-h3);
}

.text-h4 {
    font-family: var(--font-heading);
    font-size: var(--text-h4);
    font-weight: var(--weight-medium);
    line-height: var(--leading-h4);
}

.text-body-lg {
    font-size: var(--text-body-lg);
    line-height: var(--leading-body-lg);
}

.text-body {
    font-size: var(--text-body);
    line-height: var(--leading-body);
}

.text-body-sm {
    font-size: var(--text-body-sm);
    line-height: var(--leading-body-sm);
}

.text-caption {
    font-size: var(--text-caption);
    line-height: var(--leading-caption);
    letter-spacing: 0.2px;
}

.text-overline {
    font-size: var(--text-overline);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-overline);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
}

/* Text Colors */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-muted { color: var(--color-text-muted); }
.text-purple { color: var(--color-purple); }
.text-coral { color: var(--color-coral); }
.text-teal { color: var(--color-teal); }
.text-gold { color: var(--color-gold); }
.text-lavender { color: var(--color-lavender); }
.text-error { color: var(--color-error); }
.text-success { color: var(--color-success); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Font Weights */
.font-regular { font-weight: var(--weight-regular); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }

/* === Layout Utilities === */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-start { justify-content: flex-start; }
.self-center { align-self: center; }
.self-end { align-self: flex-end; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* === Spacing Utilities === */
.p-0 { padding: 0; }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-5 { padding-left: var(--space-5); padding-right: var(--space-5); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }

.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }

.pt-4 { padding-top: var(--space-4); }
.pt-6 { padding-top: var(--space-6); }
.pb-4 { padding-bottom: var(--space-4); }
.pb-6 { padding-bottom: var(--space-6); }
.pb-8 { padding-bottom: var(--space-8); }

.m-0 { margin: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mx-auto { margin-left: auto; margin-right: auto; }

/* === Size Utilities === */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; min-height: 100dvh; }
.max-w-sm { max-width: 400px; }
.max-w-md { max-width: 600px; }
.max-w-lg { max-width: 800px; }
.max-w-xl { max-width: 1200px; }

/* === Position === */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }

/* === Display === */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }

/* === Overflow === */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* === Border === */
.border { border: 1px solid var(--color-border); }
.border-subtle { border: 1px solid var(--color-border-subtle); }
.border-t { border-top: 1px solid var(--color-border); }
.border-b { border-bottom: 1px solid var(--color-border); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded { border-radius: var(--radius-md); }
.rounded-default { border-radius: var(--radius-default); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* === Background === */
.bg-base { background-color: var(--color-bg); }
.bg-surface-1 { background-color: var(--color-surface-1); }
.bg-surface-2 { background-color: var(--color-surface-2); }
.bg-surface-3 { background-color: var(--color-surface-3); }
.bg-purple { background-color: var(--color-purple); }
.bg-purple-muted { background-color: var(--color-purple-muted); }
.bg-coral-muted { background-color: var(--color-coral-muted); }
.bg-teal-muted { background-color: var(--color-teal-muted); }
.bg-gold-muted { background-color: var(--color-gold-muted); }
.bg-gradient-primary { background: var(--gradient-primary); }
.bg-gradient-avatar { background: var(--gradient-avatar); }
.bg-gradient-cta { background: var(--gradient-cta); }
.bg-gradient-brand { background: var(--gradient-brand); }
.bg-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
}
.bg-glass-strong {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* === Opacity === */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* === Cursor === */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.select-none { user-select: none; }
.pointer-events-none { pointer-events: none; }

/* === Responsive Container === */
.container {
    width: 100%;
    max-width: var(--max-width-mobile);
    margin: 0 auto;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

@media (min-width: 768px) {
    .container {
        max-width: var(--max-width-tablet);
        padding-left: var(--space-6);
        padding-right: var(--space-6);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: var(--max-width-desktop);
        padding-left: var(--space-8);
        padding-right: var(--space-8);
    }
}

/* === Responsive Visibility === */
.mobile-only { display: block; }
.tablet-only { display: none; }
.desktop-only { display: none; }

@media (min-width: 768px) {
    .mobile-only { display: none; }
    .tablet-only { display: block; }

    .grid-tablet-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-tablet-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
    .tablet-only { display: none; }
    .desktop-only { display: block; }

    .grid-desktop-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-desktop-4 { grid-template-columns: repeat(4, 1fr); }
}

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

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

/* === Divider === */
.divider {
    height: 1px;
    background: var(--color-border);
    width: 100%;
}

.divider--subtle {
    background: var(--color-border-subtle);
}

/* === Gradient Text === */
.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text--brand {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text--cta {
    background: var(--gradient-cta);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* === Grain Texture Overlay === */
.grain-overlay::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.035;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 128px 128px;
}

/* === Gradient Border Card === */
.gradient-border {
    position: relative;
    border-radius: var(--glass-radius);
    background: var(--color-surface-1);
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(123, 104, 238, 0.5), rgba(6, 182, 212, 0.3), transparent 60%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    opacity: 0.5;
}

.gradient-border:hover::before {
    opacity: 1;
}

/* === Empty State === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.empty-state__icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state__title {
    font-family: var(--font-heading);
    font-size: var(--text-h3);
    font-weight: var(--weight-semibold);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state__text {
    font-size: var(--text-body);
    color: var(--color-text-muted);
    max-width: 280px;
}
