/* Brand Colors */
:root {
    --brand-beige: #E8E4DF;
    --brand-charcoal: #2D2D2D;
    --brand-black: #000000;
    --brand-gray: #8E8E93;
    --brand-gray-dark: #1C1C1E;
    --brand-gray-elevated: #2C2C2E;
    --brand-red: #FF3B30;
    --brand-orange: #c66240;
    --brand-blue: #007AFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--brand-black);
    color: var(--brand-beige);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== */
/* Landing Page         */
/* ==================== */
.landing {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.landing .logo {
    width: 280px;
    max-width: 80vw;
    margin-bottom: 1.5rem;
}

.landing .tagline {
    font-size: 1rem;
    color: var(--brand-gray);
    margin-bottom: 4rem;
}

.landing .coming-soon {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--brand-beige);
    opacity: 0.6;
}

.landing .ios-badge {
    display: inline-block;
    text-decoration: none;
    transition: transform 0.2s, opacity 0.2s;
}

.landing .ios-badge:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

/* ==================== */
/* Auth Screen          */
/* ==================== */
.auth-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 3rem;
}

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

.auth-logo img {
    width: 260px;
    margin-bottom: 1rem;
}

.auth-logo .tagline {
    color: var(--brand-gray);
}

.auth-form {
    width: 100%;
    max-width: 360px;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--brand-gray);
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    outline: none;
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.form-group input:focus {
    border-color: var(--brand-beige);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--brand-charcoal);
    background: var(--brand-beige);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--brand-beige);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
}

.btn-ghost {
    padding: 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: rgba(232, 228, 223, 0.6);
    background: transparent;
    border: none;
    cursor: pointer;
}

/* ==================== */
/* App Container        */
/* ==================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 1rem;
    background: var(--brand-black);
    border-bottom: 1px solid var(--brand-gray-elevated);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-logo {
    height: 32px;
    width: auto;
}

.search-bar {
    flex: 1;
}

.search-bar input {
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: white;
    background: var(--brand-gray-elevated);
    border: none;
    border-radius: 8px;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--brand-gray);
}

.app-content {
    flex: 1;
    overflow-y: auto;
}

/* ==================== */
/* Tab Bar              */
/* ==================== */
.tab-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    background: var(--brand-gray-dark);
    border-top: 1px solid var(--brand-gray-elevated);
}

.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--brand-gray);
    cursor: pointer;
    transition: color 0.2s;
}

.tab.active {
    color: var(--brand-orange);
}

.tab-icon {
    font-size: 1.25rem;
}

.tab-label {
    font-size: 0.625rem;
    font-weight: 500;
}

/* ==================== */
/* Meme Grid (Waterfall)*/
/* ==================== */
.meme-grid {
    padding: 1px;
}

.meme-grid.waterfall {
    column-count: 2;
    column-gap: 1px;
}

.meme-item {
    position: relative;
    break-inside: avoid;
    margin-bottom: 1px;
    overflow: hidden;
    cursor: pointer;
}

.meme-item img {
    width: 100%;
    display: block;
}

.meme-badges {
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.badge {
    font-size: 9px;
    font-weight: 700;
    color: white;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
}

.badge.heart {
    color: var(--brand-red);
}

.meme-watermark {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 8px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

/* ==================== */
/* Profile              */
/* ==================== */
.profile-view,
.profile-guest {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    gap: 1.5rem;
}

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

.avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--brand-gray-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    color: var(--brand-beige);
    margin: 0 auto 1rem;
}

.email {
    color: var(--brand-gray);
}

/* ==================== */
/* Empty States         */
/* ==================== */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--brand-gray);
}

/* ==================== */
/* Meme Viewer          */
/* ==================== */
.meme-viewer {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-black);
    padding: 1rem;
}

.meme-display {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 90vh;
}

.meme-media {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.meme-viewer .loading {
    color: var(--brand-gray);
    font-size: 1rem;
}

.meme-viewer .error {
    text-align: center;
    color: var(--brand-beige);
}

.meme-viewer .error h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.back-btn {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    color: var(--brand-charcoal);
    background: var(--brand-beige);
    border-radius: 8px;
    text-decoration: none;
}

/* ==================== */
/* Responsive           */
/* ==================== */
@media (min-width: 768px) {
    .meme-grid.waterfall {
        column-count: 3;
    }

    .auth-form {
        max-width: 400px;
    }

    .meme-media {
        max-height: 80vh;
    }
}

@media (min-width: 1024px) {
    .meme-grid.waterfall {
        column-count: 4;
    }
}
