/* ============================================================
   Base Styles - Reset, Typography, Utilities
   ============================================================ */

/* ---- Modern Reset ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    height: 100%;
    font-family: var(--font-family);
    font-size: var(--text-base);
    line-height: var(--line-height-normal);
    color: var(--text-color);
    background-color: var(--secondary-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
}

/* ---- App Container ---- */
#app {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 8px);
}

/* ---- Links ---- */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

a:active {
    opacity: 0.7;
}

/* ---- Form Element Reset ---- */
input,
select,
textarea,
button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
    appearance: none;
    -webkit-appearance: none;
}

button {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

/* ---- Typography Scale ---- */
h1 {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: -0.02em;
    color: var(--text-color);
}

h2 {
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    line-height: var(--line-height-tight);
    letter-spacing: -0.01em;
    color: var(--text-color);
}

h3 {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: var(--line-height-tight);
    color: var(--text-color);
}

p {
    line-height: var(--line-height-relaxed);
}

/* ---- Utility: Text ---- */
.text-hint {
    color: var(--hint-color);
}

.text-subtitle {
    color: var(--subtitle-text);
    font-size: var(--text-sm);
}

.text-destructive {
    color: var(--destructive);
}

.text-accent {
    color: var(--accent-text);
}

.text-center {
    text-align: center;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Utility: Layout ---- */
.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }

/* ---- Utility: Spacing ---- */
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* ---- Utility: Visibility ---- */
.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;
}

/* ---- Image Reset ---- */
img,
svg {
    display: block;
    max-width: 100%;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* ---- Selection ---- */
::selection {
    background-color: rgba(0, 122, 255, 0.2);
    color: inherit;
}

/* ---- Focus Visible (keyboard navigation) ---- */
:focus-visible {
    outline: 2px solid var(--button-color);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}
