/* ============================================
   NOVELIA - Design System
   Mobile-first | Dark Mode | Premium Feel
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Playfair+Display:ital,wght@0,700;1,700&display=swap');

:root {
    /* Core palette - warm amber + deep charcoal */
    --bg-primary: #0D0D0F;
    --bg-secondary: #16161A;
    --bg-card: #1E1E24;
    --bg-elevated: #26262E;
    --bg-glass: rgba(30, 30, 36, 0.75);

    --text-primary: #F2F0ED;
    --text-secondary: #9B9A97;
    --text-muted: #5E5D5A;

    --accent: #E8A838;
    --accent-hover: #F0BC5E;
    --accent-glow: rgba(232, 168, 56, 0.25);
    --accent-soft: rgba(232, 168, 56, 0.1);

    --success: #34D399;
    --danger: #F87171;
    --warning: #FBBF24;
    --info: #60A5FA;

    --streak-fire: #FF6B35;
    --streak-glow: rgba(255, 107, 53, 0.3);

    /* Typography */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;

    /* Spacing (8pt grid) */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
    --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

    /* Radius */
    --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Transitions */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-fast: 150ms; --t-normal: 250ms; --t-slow: 400ms;

    /* Layout */
    --max-w: 480px;
    --nav-h: 64px;
    --bottom-nav-h: 72px;
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ============ LAYOUT ============ */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--sp-4); }
.page { min-height: 100dvh; padding-bottom: calc(var(--bottom-nav-h) + var(--sp-4)); }
.page-content { padding-top: var(--sp-4); }

/* ============ TYPOGRAPHY ============ */
.display-xl { font-family: var(--font-display); font-size: 2.5rem; line-height: 1.1; font-weight: 700; }
.display-lg { font-family: var(--font-display); font-size: 2rem; line-height: 1.15; font-weight: 700; }
h1, .h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
h2, .h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.25; }
h3, .h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.3; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.font-mono { font-family: 'SF Mono', monospace; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-6); border-radius: var(--r-md); font-weight: 600;
    font-size: 0.9375rem; transition: all var(--t-normal) var(--ease-out);
    min-height: 48px; position: relative; overflow: hidden;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #D4922E);
    color: #0D0D0F; box-shadow: var(--shadow-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 30px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
    background: var(--bg-elevated); color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.08);
}
.btn-secondary:hover { background: var(--bg-card); border-color: rgba(255,255,255,0.15); }
.btn-ghost { color: var(--text-secondary); padding: var(--sp-2) var(--sp-3); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }
.btn-full { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.0625rem; padding: var(--sp-4) var(--sp-8); border-radius: var(--r-lg); }
.btn-sm { min-height: 36px; font-size: 0.8125rem; padding: var(--sp-2) var(--sp-4); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ============ CARDS ============ */
.card {
    background: var(--bg-card); border-radius: var(--r-lg); padding: var(--sp-5);
    border: 1px solid rgba(255,255,255,0.05);
    transition: all var(--t-normal) var(--ease-out);
}
.card:hover { border-color: rgba(255,255,255,0.1); }
.card-glass {
    background: var(--bg-glass); backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-lg); padding: var(--sp-5);
}

/* ============ INPUTS ============ */
.input-group { margin-bottom: var(--sp-4); }
.input-group label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: var(--sp-2); }
.input {
    width: 100%; padding: var(--sp-3) var(--sp-4); background: var(--bg-elevated);
    border: 1px solid rgba(255,255,255,0.08); border-radius: var(--r-md);
    color: var(--text-primary); font-size: 1rem; min-height: 48px;
    transition: border-color var(--t-fast);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-muted); }
textarea.input { min-height: 100px; resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239B9A97' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }

/* ============ STREAK ============ */
.streak-badge {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3); border-radius: var(--r-full);
    background: linear-gradient(135deg, rgba(255,107,53,0.15), rgba(232,168,56,0.15));
    border: 1px solid rgba(255,107,53,0.2); font-weight: 700; font-size: 0.9375rem;
}
.streak-badge .fire { font-size: 1.25rem; animation: fireWiggle 1s ease-in-out infinite; }
@keyframes fireWiggle {
    0%, 100% { transform: rotate(-5deg) scale(1); }
    50% { transform: rotate(5deg) scale(1.15); }
}
.streak-counter {
    display: flex; flex-direction: column; align-items: center; padding: var(--sp-6);
    background: linear-gradient(180deg, rgba(255,107,53,0.1) 0%, transparent 100%);
    border-radius: var(--r-xl); text-align: center;
}
.streak-number { font-size: 4rem; font-weight: 900; color: var(--streak-fire); line-height: 1; }
.streak-label { font-size: 0.875rem; color: var(--text-secondary); margin-top: var(--sp-1); }

/* ============ BADGES ============ */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.badge-item {
    display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
    padding: var(--sp-4); background: var(--bg-card); border-radius: var(--r-lg);
    border: 1px solid rgba(255,255,255,0.05); text-align: center;
    transition: all var(--t-normal) var(--ease-out);
}
.badge-item.earned { border-color: var(--accent); background: var(--accent-soft); }
.badge-item.locked { opacity: 0.4; filter: grayscale(1); }
.badge-icon { font-size: 2rem; }
.badge-name { font-size: 0.6875rem; font-weight: 600; }

/* ============ NOVEL CARD ============ */
.novel-card {
    background: var(--bg-card); border-radius: var(--r-lg); padding: var(--sp-5);
    border: 1px solid rgba(255,255,255,0.05);
    transition: all var(--t-normal) var(--ease-out); position: relative;
}
.novel-card:active { transform: scale(0.98); }
.novel-card .genre-tag {
    display: inline-block; padding: var(--sp-1) var(--sp-3);
    background: var(--accent-soft); color: var(--accent); border-radius: var(--r-full);
    font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.novel-card .new-badge {
    position: absolute; top: var(--sp-3); right: var(--sp-3);
    width: 10px; height: 10px; background: var(--accent); border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 0 8px transparent; }
}

/* ============ READER ============ */
.reader { max-width: 640px; margin: 0 auto; padding: var(--sp-4); }
.reader-header { text-align: center; padding: var(--sp-6) 0 var(--sp-8); }
.reader-chapter-num { font-size: 0.75rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; }
.reader-title { font-family: var(--font-display); font-size: 1.75rem; margin-top: var(--sp-2); }
.reader-body { font-size: 1.0625rem; line-height: 1.85; color: var(--text-primary); }
.reader-body p { margin-bottom: var(--sp-5); text-indent: 1.5em; }
.reader-body p:first-child { text-indent: 0; }
.reader-body p:first-child::first-letter {
    font-family: var(--font-display); font-size: 3.5rem; float: left;
    line-height: 0.8; padding-right: var(--sp-2); padding-top: var(--sp-1);
    color: var(--accent);
}
.reader-nav { display: flex; gap: var(--sp-3); padding: var(--sp-8) 0; }
.reader-nav .btn { flex: 1; }

/* Audio player */
.audio-player {
    display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4);
    background: var(--bg-elevated); border-radius: var(--r-lg); margin: var(--sp-6) 0;
}
.audio-player .play-btn {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--accent); color: #0D0D0F; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.audio-player .progress-bar {
    flex: 1; height: 4px; background: rgba(255,255,255,0.1);
    border-radius: 2px; position: relative; cursor: pointer;
}
.audio-player .progress-fill {
    height: 100%; background: var(--accent); border-radius: 2px;
    transition: width 100ms linear;
}

/* ============ BOTTOM NAV ============ */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-nav-h);
    background: var(--bg-secondary); border-top: 1px solid rgba(255,255,255,0.05);
    display: flex; align-items: center; justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom); z-index: 100;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: var(--sp-2) var(--sp-3); color: var(--text-muted);
    font-size: 0.625rem; font-weight: 500; transition: color var(--t-fast);
    position: relative;
}
.nav-item.active { color: var(--accent); }
.nav-item .nav-icon { font-size: 1.5rem; }
.nav-item .nav-dot {
    position: absolute; top: 2px; right: 8px; width: 6px; height: 6px;
    background: var(--accent); border-radius: 50%;
}

/* ============ ONBOARDING ============ */
.onboarding-step { animation: fadeSlide 0.4s var(--ease-out); }
@keyframes fadeSlide {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
.step-indicator { display: flex; gap: var(--sp-2); justify-content: center; margin-bottom: var(--sp-8); }
.step-dot {
    width: 32px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1);
    transition: all var(--t-normal) var(--ease-out);
}
.step-dot.active { background: var(--accent); width: 48px; }
.step-dot.done { background: var(--success); }

.genre-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.genre-card {
    padding: var(--sp-5); border-radius: var(--r-lg); text-align: center;
    background: var(--bg-card); border: 2px solid transparent;
    transition: all var(--t-normal) var(--ease-spring); cursor: pointer;
}
.genre-card:active { transform: scale(0.95); }
.genre-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.genre-card .genre-emoji { font-size: 2rem; margin-bottom: var(--sp-2); }
.genre-card .genre-name { font-weight: 600; font-size: 0.9375rem; }

/* ============ PRICING ============ */
.pricing-cards { display: flex; flex-direction: column; gap: var(--sp-4); }
.pricing-card {
    padding: var(--sp-6); border-radius: var(--r-xl);
    background: var(--bg-card); border: 1px solid rgba(255,255,255,0.05);
    position: relative;
}
.pricing-card.featured {
    border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg-card) 40%);
}
.pricing-card.featured::before {
    content: '🔥 MAIS POPULAR'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
    padding: var(--sp-1) var(--sp-4); background: var(--accent); color: #0D0D0F;
    font-size: 0.6875rem; font-weight: 800; border-radius: var(--r-full);
    letter-spacing: 0.05em;
}
.pricing-card .price {
    font-size: 2.5rem; font-weight: 900; color: var(--text-primary);
}
.pricing-card .price span { font-size: 1rem; font-weight: 400; color: var(--text-secondary); }
.pricing-card .features { margin: var(--sp-5) 0; }
.pricing-card .features li {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) 0; font-size: 0.875rem; color: var(--text-secondary);
}
.pricing-card .features li::before { content: '✓'; color: var(--success); font-weight: 700; }

.cycle-tabs { display: flex; gap: var(--sp-1); background: var(--bg-elevated); border-radius: var(--r-md); padding: var(--sp-1); margin-bottom: var(--sp-6); }
.cycle-tab {
    flex: 1; padding: var(--sp-2); border-radius: var(--r-sm); font-size: 0.75rem;
    font-weight: 600; text-align: center; color: var(--text-muted);
    transition: all var(--t-fast);
}
.cycle-tab.active { background: var(--accent); color: #0D0D0F; }
.cycle-tab .discount { display: block; font-size: 0.625rem; font-weight: 400; opacity: 0.8; }

/* ============ LANDING PAGE ============ */
.landing-hero {
    min-height: 100dvh; display: flex; flex-direction: column;
    justify-content: center; padding: var(--sp-8) var(--sp-4);
    position: relative; overflow: hidden;
}
.landing-hero::before {
    content: ''; position: absolute; top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 60% 40%, var(--accent-glow) 0%, transparent 50%);
    animation: heroGlow 8s ease-in-out infinite alternate;
}
@keyframes heroGlow {
    from { transform: translate(0, 0); }
    to { transform: translate(-5%, 5%); }
}
.landing-hero .content { position: relative; z-index: 1; }
.landing-tagline {
    font-size: 0.8125rem; font-weight: 600; color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.15em; margin-bottom: var(--sp-3);
}
.landing-title { font-family: var(--font-display); font-size: clamp(2rem, 8vw, 3.5rem); line-height: 1.1; margin-bottom: var(--sp-4); }
.landing-title em { font-style: italic; color: var(--accent); }
.landing-desc { font-size: 1.0625rem; color: var(--text-secondary); margin-bottom: var(--sp-8); max-width: 380px; }

.features-grid { display: grid; gap: var(--sp-4); padding: var(--sp-4); }
.feature-card {
    padding: var(--sp-6); border-radius: var(--r-lg);
    background: var(--bg-card); border: 1px solid rgba(255,255,255,0.05);
}
.feature-card .feat-icon { font-size: 2rem; margin-bottom: var(--sp-3); }
.feature-card h3 { font-size: 1.0625rem; margin-bottom: var(--sp-2); }
.feature-card p { font-size: 0.875rem; color: var(--text-secondary); }

/* ============ LOADING ============ */
.loading-spinner {
    width: 32px; height: 32px; border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: var(--sp-8) auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ============ TOAST ============ */
.toast-container { position: fixed; top: var(--sp-4); left: 50%; transform: translateX(-50%); z-index: 1000; width: 90%; max-width: 400px; }
.toast {
    padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
    background: var(--bg-elevated); border: 1px solid rgba(255,255,255,0.1);
    box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: var(--sp-3);
    animation: toastIn 0.4s var(--ease-spring);
    margin-bottom: var(--sp-2);
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px); z-index: 200; display: flex;
    align-items: flex-end; justify-content: center;
    animation: fadeIn var(--t-normal) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
    background: var(--bg-secondary); border-radius: var(--r-xl) var(--r-xl) 0 0;
    width: 100%; max-width: var(--max-w); max-height: 85dvh; overflow-y: auto;
    padding: var(--sp-6); animation: slideUp var(--t-slow) var(--ease-spring);
}
@keyframes slideUp { from { transform: translateY(100%); } }
.modal-handle {
    width: 40px; height: 4px; background: rgba(255,255,255,0.2);
    border-radius: 2px; margin: 0 auto var(--sp-5);
}

/* ============ UTILITIES ============ */
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.p-4 { padding: var(--sp-4); } .p-6 { padding: var(--sp-6); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ MEDIA QUERIES ============ */
@media (min-width: 768px) {
    :root { --max-w: 520px; }
    .genre-grid { grid-template-columns: repeat(3, 1fr); }
    .badge-grid { grid-template-columns: repeat(4, 1fr); }
}
