/* ==========================================
   JoeyGuide — Main Stylesheet
   ========================================== */

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

:root {
    --color-bg: #faf9f6;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-primary: #e63946;
    --color-primary-hover: #c1121f;
    --color-primary-light: #fef2f2;
    --color-accent: #457b9d;
    --color-accent-hover: #1d3557;
    --color-success: #059669;
    --color-error: #dc2626;
    --color-star: #f59e0b;
    --color-nl-bg: #f0f9ff;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
    --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --max-width: 1200px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--color-accent-hover); }

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

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }
.container-narrow { max-width: 800px; }

h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

p { margin-bottom: 1rem; }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .6rem 1.25rem; border-radius: var(--radius);
    font-weight: 600; font-size: .9rem; border: 2px solid transparent;
    cursor: pointer; transition: all .15s; text-decoration: none;
    font-family: inherit; line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn-outline:hover { border-color: var(--color-text); color: var(--color-text); }
.btn-lg { padding: .85rem 2rem; font-size: 1rem; }
.btn-sm { padding: .35rem .85rem; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; cursor: pointer; font: inherit; color: var(--color-accent); text-decoration: underline; }
.btn-danger { color: var(--color-error) !important; }
.btn-danger:hover { color: #b91c1c !important; }

/* --- Flash Messages --- */
.flash {
    padding: .85rem 1.25rem; border-radius: var(--radius); margin-bottom: 1.5rem;
    font-weight: 500; font-size: .9rem;
}
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* --- Header --- */
.site-header {
    background: var(--color-surface); border-bottom: 1px solid var(--color-border);
    position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.header-inner {
    display: flex; align-items: center; gap: 1.5rem; height: 64px;
}
.logo {
    display: flex; align-items: center; gap: .5rem; font-size: 1.35rem;
    font-weight: 700; color: var(--color-text); text-decoration: none;
    white-space: nowrap;
}
.logo:hover { color: var(--color-text); }
.logo-icon { font-size: 1.5rem; }
.logo-highlight { color: var(--color-primary); }

.main-nav {
    display: flex; align-items: center; gap: .15rem; flex: 1;
    overflow-x: auto;
}
.main-nav a {
    padding: .4rem .65rem; border-radius: var(--radius); font-size: .85rem;
    font-weight: 500; color: var(--color-text-muted); white-space: nowrap;
    transition: all .15s;
}
.main-nav a:hover, .main-nav a:focus { color: var(--color-text); background: var(--color-border); }
.nav-newsletter { color: var(--color-primary) !important; font-weight: 600; }

.header-actions { display: flex; align-items: center; gap: .75rem; }
.search-btn { font-size: 1.1rem; color: var(--color-text-muted); }
.search-btn:hover { color: var(--color-text); }
.user-menu { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.user-greeting { color: var(--color-text-muted); }

.mobile-nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; }
.mobile-nav-toggle span { display: block; width: 22px; height: 2px; background: var(--color-text); border-radius: 2px; transition: all .2s; }

/* --- Footer --- */
.site-footer {
    background: var(--color-text); color: #d1d5db; padding: 3rem 0 1.5rem; margin-top: 4rem;
}
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; margin-bottom: 2rem; }
.footer-logo { font-size: 1.25rem; font-weight: 700; color: #fff; margin-bottom: .5rem; }
.footer-brand p { font-size: .9rem; }
.footer-links h4 { color: #fff; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }
.footer-links a { display: block; font-size: .9rem; color: #9ca3af; margin-bottom: .35rem; }
.footer-links a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #374151; padding-top: 1.5rem; font-size: .8rem; color: #6b7280; text-align: center; }
.footer-disclosure { margin-top: .5rem; font-size: .75rem; color: #4b5563; }

/* --- Hero --- */
.hero {
    background: linear-gradient(135deg, var(--color-text) 0%, #16213e 100%);
    color: #fff; padding: 5rem 0; text-align: center;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 1rem; }
.hero-highlight { color: #fbbf24; }
.hero-subtitle { font-size: 1.15rem; max-width: 650px; margin: 0 auto 2rem; color: #9ca3af; line-height: 1.7; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.hero-actions .btn-outline { border-color: #4b5563; color: #d1d5db; }
.hero-actions .btn-outline:hover { border-color: #fff; color: #fff; }

/* --- Sections --- */
.section-title { font-size: 1.5rem; margin-bottom: 1.5rem; }
.featured-section, .categories-section, .recent-section { padding: 3rem 0; }
.page-section { padding: 3rem 0; }

/* --- Article Grid --- */
.article-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.5rem; }

/* --- Card --- */
.card {
    background: var(--color-surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); overflow: hidden; transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-image { display: block; aspect-ratio: 16/10; overflow: hidden; background: var(--color-border); }
.card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.card:hover .card-image img { transform: scale(1.03); }
.card-image-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 3rem; }
.card-body { padding: 1.25rem; }
.card-category { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; display: block; }
.card-category a { color: var(--color-primary); }
.card-category a:hover { color: var(--color-primary-hover); }
.card-title { font-size: 1.15rem; margin-bottom: .5rem; }
.card-title a { color: var(--color-text); }
.card-title a:hover { color: var(--color-accent); }
.card-excerpt { font-size: .9rem; color: var(--color-text-muted); margin-bottom: .75rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-rating { font-size: .8rem; margin-bottom: .35rem; }
.card-price { font-size: .85rem; color: var(--color-accent); font-weight: 600; margin-bottom: .35rem; }
.card-meta { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--color-text-muted); }
.card-read-more { font-weight: 600; color: var(--color-accent); }
.card-compact .card-body { padding: 1rem; }
.card-compact .card-title { font-size: 1rem; }

/* --- Category Grid --- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.category-card {
    display: block; background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 1.75rem; transition: all .2s; text-decoration: none;
}
.category-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.category-icon { font-size: 2rem; display: block; margin-bottom: .5rem; }
.category-card h3 { font-size: 1.1rem; margin-bottom: .35rem; color: var(--color-text); }
.category-card p { font-size: .85rem; color: var(--color-text-muted); margin: 0; }

/* --- Newsletter CTA --- */
.newsletter-cta {
    background: var(--color-nl-bg); padding: 3rem 0; text-align: center;
    margin-top: 3rem;
}
.newsletter-cta h2 { font-size: 1.5rem; margin-bottom: .5rem; }
.newsletter-cta p { color: var(--color-text-muted); max-width: 500px; margin: 0 auto 1.5rem; }
.subscribe-form {
    display: flex; gap: .5rem; max-width: 440px; margin: 0 auto;
}
.subscribe-form input[type="email"] {
    flex: 1; padding: .7rem 1rem; border: 2px solid var(--color-border);
    border-radius: var(--radius); font: inherit; font-size: .95rem;
    transition: border-color .15s;
}
.subscribe-form input[type="email"]:focus { border-color: var(--color-accent); outline: none; }
.subscribe-note { font-size: .8rem; color: var(--color-text-muted); margin-top: .75rem; }

/* --- Article Detail --- */
.article-detail { padding: 2rem 0 0; }
.article-breadcrumb { font-size: .85rem; color: var(--color-text-muted); margin-bottom: 1.5rem; }
.article-breadcrumb a { color: var(--color-text-muted); }
.article-breadcrumb a:hover { color: var(--color-accent); }
.article-header { margin-bottom: 2rem; }
.article-header h1 { font-size: 2rem; margin-bottom: .75rem; }
.article-header-meta { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: .9rem; color: var(--color-text-muted); }
.article-featured-image { margin-bottom: 2rem; border-radius: var(--radius-lg); overflow: hidden; }
.article-featured-image img { width: 100%; }
.article-content { font-size: 1.05rem; line-height: 1.8; }
.article-content h2 { font-size: 1.4rem; margin: 2rem 0 .75rem; }
.article-content h3 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
.article-content ul, .article-content ol { margin: 0 0 1rem 1.5rem; }
.article-content li { margin-bottom: .35rem; }
.article-content pre { background: #f3f4f6; padding: 1rem; border-radius: var(--radius); overflow-x: auto; font-size: .9rem; margin-bottom: 1rem; }
.article-content strong { font-weight: 600; }
.article-content a { text-decoration: underline; }

.affiliate-cta {
    background: #fffbeb; border: 1px solid #fcd34d; border-radius: var(--radius-lg);
    padding: 1.5rem; margin: 2rem 0; text-align: center;
}
.affiliate-disclosure { font-size: .75rem; color: var(--color-text-muted); margin: .5rem 0 0; }

.article-footer { display: flex; justify-content: space-between; align-items: center; padding: 2rem 0; border-top: 1px solid var(--color-border); margin-top: 2rem; flex-wrap: wrap; gap: 1rem; }
.article-views { font-size: .85rem; color: var(--color-text-muted); }
.article-share { display: flex; gap: .75rem; align-items: center; font-size: .9rem; }
.article-share a { font-size: 1.2rem; }

/* --- Category Page --- */
.category-header { background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 2rem 0; margin-bottom: 2rem; }
.category-breadcrumb { font-size: .85rem; color: var(--color-text-muted); }
.category-breadcrumb a { color: var(--color-text-muted); }
.category-header h1 { margin: .5rem 0; }
.category-description { color: var(--color-text-muted); max-width: 600px; font-size: 1.05rem; }

.category-articles { padding-bottom: 3rem; }

/* --- Pagination --- */
.pagination { display: flex; gap: .35rem; justify-content: center; margin-top: 2rem; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius); font-size: .9rem;
    font-weight: 500; color: var(--color-text); border: 1px solid var(--color-border);
    background: var(--color-surface);
}
.page-link:hover, .page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* --- Search --- */
.search-form { display: flex; gap: .5rem; margin-bottom: 2rem; }
.search-input-large {
    flex: 1; padding: .75rem 1rem; border: 2px solid var(--color-border);
    border-radius: var(--radius); font: inherit; font-size: 1rem;
}
.search-input-large:focus { border-color: var(--color-accent); outline: none; }
.search-count { color: var(--color-text-muted); margin-bottom: 1.5rem; }
.search-item {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 1.25rem; margin-bottom: .75rem;
}
.search-item h3 { margin-bottom: .35rem; }
.search-item p { font-size: .9rem; color: var(--color-text-muted); margin-bottom: .5rem; }

/* --- Auth --- */
.auth-card {
    background: var(--color-surface); border-radius: var(--radius-lg);
    padding: 2.5rem; max-width: 440px; margin: 0 auto; box-shadow: var(--shadow-md);
}
.auth-card h1 { text-align: center; }
.auth-subtitle { text-align: center; color: var(--color-text-muted); margin-bottom: 2rem; }
.auth-form label { display: block; margin-bottom: 1rem; font-size: .85rem; font-weight: 600; }
.auth-form input { display: block; width: 100%; margin-top: .3rem; padding: .65rem .85rem; border: 2px solid var(--color-border); border-radius: var(--radius); font: inherit; font-size: .95rem; transition: border-color .15s; }
.auth-form input:focus { border-color: var(--color-accent); outline: none; }
.auth-form button { margin-top: .5rem; }
.auth-alt { text-align: center; margin-top: 1.5rem; font-size: .9rem; color: var(--color-text-muted); }

/* --- Newsletter Page --- */
.newsletter-content { display: grid; grid-template-columns: 1fr 2fr; gap: 2rem; margin-top: 2rem; }
.newsletter-subscribe-card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 1.5rem; height: fit-content;
    position: sticky; top: 80px;
}
.newsletter-subscribe-card h2 { font-size: 1.2rem; margin-bottom: .5rem; }
.newsletter-subscribe-card p { font-size: .9rem; color: var(--color-text-muted); margin-bottom: 1rem; }
.newsletter-subscribe-card .subscribe-form { flex-direction: column; }
.newsletter-past-issues h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.newsletter-issue { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.newsletter-issue h3 { font-size: 1.05rem; }
.issue-date { font-size: .8rem; color: var(--color-text-muted); display: block; margin: .25rem 0 .75rem; }

/* --- Contact --- */
.contact-form { max-width: 560px; }
.contact-form label { display: block; margin-bottom: 1rem; font-size: .85rem; font-weight: 600; }
.contact-form input, .contact-form textarea { display: block; width: 100%; margin-top: .3rem; padding: .65rem .85rem; border: 2px solid var(--color-border); border-radius: var(--radius); font: inherit; font-size: .95rem; transition: border-color .15s; resize: vertical; }
.contact-form input:focus, .contact-form textarea:focus { border-color: var(--color-accent); outline: none; }
.required { color: var(--color-error); }

/* --- About --- */
.about-content h2 { font-size: 1.3rem; margin: 2rem 0 .75rem; }
.about-content ul { margin: 0 0 1rem 1.5rem; }
.about-content li { margin-bottom: .5rem; }

/* --- Page Subtitle --- */
.page-subtitle { color: var(--color-text-muted); font-size: 1.1rem; max-width: 600px; }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }

/* --- Admin --- */
.admin-header { background: var(--color-text); color: #fff; padding: .75rem 0; }
.admin-header .container { display: flex; align-items: center; gap: 1.5rem; height: auto; }
.admin-logo { color: #fff; font-size: 1.1rem; }
.admin-logo:hover { color: #d1d5db; }
.admin-nav { display: flex; gap: .5rem; flex: 1; overflow-x: auto; }
.admin-nav a { color: #9ca3af; font-size: .85rem; font-weight: 500; padding: .3rem .6rem; border-radius: var(--radius); white-space: nowrap; }
.admin-nav a:hover { color: #fff; background: rgba(255,255,255,.1); }

.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin: 1.5rem 0 2rem; }
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--color-primary); display: block; }
.stat-label { font-size: .8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.admin-actions { display: flex; gap: .75rem; margin-bottom: 2rem; }
.admin-section { margin: 2rem 0; }
.admin-section h2 { font-size: 1.2rem; margin-bottom: 1rem; }

.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.admin-table th { font-weight: 600; background: #f9fafb; }
.admin-table tr:hover td { background: #f9fafb; }

.status-badge {
    font-size: .75rem; font-weight: 600; padding: .15rem .5rem;
    border-radius: 20px; text-transform: uppercase; letter-spacing: .03em;
}
.status-published { background: #ecfdf5; color: #065f46; }
.status-draft { background: #fef3c7; color: #92400e; }
.status-sent { background: #ecfdf5; color: #065f46; }

.admin-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.admin-header-row h1 { margin: 0; }

.admin-form { max-width: 800px; }
.admin-form label { display: block; margin-bottom: 1rem; font-size: .85rem; font-weight: 600; }
.admin-form input[type="text"], .admin-form input[type="url"], .admin-form input[type="number"], .admin-form input[type="email"], .admin-form select, .admin-form textarea {
    display: block; width: 100%; margin-top: .3rem; padding: .55rem .75rem;
    border: 2px solid var(--color-border); border-radius: var(--radius);
    font: inherit; font-size: .9rem; transition: border-color .15s;
}
.admin-form input:focus, .admin-form select:focus, .admin-form textarea:focus { border-color: var(--color-accent); outline: none; }
.admin-form textarea.content-editor { font-family: 'SF Mono', 'Fira Code', monospace; font-size: .85rem; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; }

.message-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: .75rem; }
.message-header { font-size: .9rem; margin-bottom: .5rem; }
.message-subject { color: var(--color-text-muted); }
.message-date { font-size: .8rem; color: var(--color-text-muted); float: right; }

/* --- Soundtrack Player --- */
.soundtrack-player {
    display: inline-flex; align-items: center; gap: .3rem;
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: 50px; padding: .25rem .6rem;
    font-size: .78rem; white-space: nowrap; flex-shrink: 0;
    margin-right: .35rem; transition: background .3s, border-color .3s;
}
.soundtrack-player.sp-active { background: #ecfdf5; border-color: #a7f3d0; }
.soundtrack-player.sp-waiting { animation: sp-pulse 2s ease-in-out infinite; }
.soundtrack-player.sp-loading { opacity: .6; }
@keyframes sp-pulse {
    0%, 100% { border-color: #fecaca; }
    50% { border-color: #f87171; box-shadow: 0 0 0 2px rgba(248,113,113,.2); }
}
.sp-btn {
    background: none; border: none; cursor: pointer; font-size: .8rem;
    color: var(--color-text); padding: .2rem; border-radius: 50%;
    width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
    transition: all .15s; line-height: 1;
}
.sp-btn:hover { background: #fecaca; color: var(--color-primary); }
.sp-btn.playing { color: var(--color-primary); }
.sp-track {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 140px; font-weight: 500; color: var(--color-text);
    font-size: .75rem;
}

@media (max-width: 768px) {
    .soundtrack-player { order: -1; }
    .sp-track { max-width: 100px; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .header-inner { height: auto; flex-wrap: wrap; padding: .5rem 1rem; }
    .main-nav {
        display: none; flex-direction: column; width: 100%; order: 10;
        background: var(--color-surface); padding: .5rem; border-radius: var(--radius);
        box-shadow: var(--shadow-md);
    }
    .main-nav.open { display: flex; }
    .mobile-nav-toggle { display: flex; order: 10; }
    .hero { padding: 3rem 0; }
    .hero-actions { flex-direction: column; align-items: center; }
    .article-grid { grid-template-columns: 1fr; }
    .category-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .newsletter-content { grid-template-columns: 1fr; }
    .newsletter-subscribe-card { position: static; }
    .admin-header .container { flex-direction: column; align-items: flex-start; gap: .5rem; }
    .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .footer-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 1.5rem; }
    .admin-stats { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
