/* ====== CSS Custom Properties (Light / Dark) ====== */
:root {
    --background: #fef9f6;
    --foreground: #1e1a1c;
    --surface: #ffffff;
    --surface-hover: #f5f0ed;
    --border-subtle: #e5dfda;
    --primary: #d97706;
    --primary-foreground: #ffffff;
    --foreground-muted: #78716c;
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1);
    --font-sans: 'Space Grotesk', sans-serif;
}

.dark {
    --background: #1e1a1c;
    --foreground: #fef9f6;
    --surface: #2a2628;
    --surface-hover: #3a3638;
    --border-subtle: #3a3638;
    --primary: #f59e0b;
    --primary-foreground: #1e1a1c;
    --foreground-muted: #a8a29e;
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.4);
}

/* ====== Base Resets & Typography ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-family: var(--font-sans); }

body {
    background: var(--background);
    color: var(--foreground);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ====== Background Gradient + Noise Overlay ====== */
.fixed-bg {
    position: fixed;
    inset: 0;
    z-index: -10;
    background: linear-gradient(135deg, #f5f0ed 0%, #e8e0db 100%);
}

.dark .fixed-bg {
    background: linear-gradient(135deg, #2a2628 0%, #1e1a1c 100%);
}

.noise-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* ====== Layout Wrappers ====== */
.app-shell {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    overflow-x: clip;
}
.app-content {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    padding-bottom: 6rem; /* space for mobile nav */
}
@media (min-width: 640px) {
    .app-content { padding-bottom: 3rem; }
}

/* ====== Header ====== */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 2rem 1rem;
}
@media (min-width: 640px) {
    .site-header { padding: 3rem 1.5rem; }
}
.logo-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground);
}
.header-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ====== Common Button Styles ====== */
.btn-surface {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    border-radius: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    color: var(--foreground);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-surface:hover { background: var(--surface-hover); }

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.5rem;
    min-width: 2.5rem;
    padding: 0 0.75rem;
    border-radius: 0.75rem;
    background: var(--primary);
    color: var(--primary-foreground);
    text-decoration: none;
    transition: filter 0.2s;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ====== Mobile Bottom Navigation ====== */
.mobile-nav {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    justify-content: center;
    pointer-events: auto;
}
@media (min-width: 640px) { .mobile-nav { display: none; } }

.nav-pill {
    position: relative;
    width: fit-content;
    border-radius: 9999px;
    box-shadow: var(--shadow-lg);
}
.nav-glass {
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: 9999px;
    backdrop-filter: blur(16px) saturate(180%);
    background: rgba(255,255,255,0.7);
}
.dark .nav-glass {
    background: rgba(42,38,40,0.7);
}
.nav-tabs {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0 0.5rem;
    height: 3.75rem;
    border-radius: 9999px;
    overflow: hidden;
}
.nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 2.75rem;
    border-radius: 9999px;
    text-decoration: none;
    color: var(--foreground-muted);
    transition: color 0.2s;
}
.nav-item.active {
    color: var(--primary);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: var(--primary);
    opacity: 0.1;
}
.nav-icon {
    width: 1.15rem;
    height: 1.15rem;
}
.nav-label {
    font-size: 0.625rem;
    margin-top: 0.125rem;
    font-weight: 500;
    line-height: 1;
}

/* ====== Utility ====== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}