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

:root {
    /* Slate Purple Light */
    --color-primary: #2E3142;
    --color-primary-dark: #1E1F26;
    --color-accent: #5D5D8D;
    --color-accent-light: #DCDEE6;
    --color-accent-warm: #7575A3;
    --color-bg: #EEEFF3;
    --color-surface: #FFFFFF;
    --color-text: #2E3142;
    --color-text-muted: #5D6070;
    --color-border: #DCDEE6;
    --color-success: #7A9A7D;
    --color-error: #B07A8A;
    
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: Georgia, 'Times New Roman', serif;
    
    --shadow-sm: 0px 5px 15px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Slate Purple Dark Mode */
[data-mode="dark"] {
    --color-primary: #E8E9ED;
    --color-primary-dark: #F4F5F7;
    --color-accent: #7575A3;
    --color-accent-light: #2A2B35;
    --color-accent-warm: #9090B8;
    --color-bg: #15161B;
    --color-surface: #1E1F26;
    --color-text: #E8E9ED;
    --color-text-muted: #9A9BA8;
    --color-border: #3A3B45;
    --color-success: #7A9A7D;
    --color-error: #C08090;
    
    --shadow-sm: 0px 5px 15px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.3);
}

html {
    font-size: 16px;
    line-height: 1.6;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============ Typography ============ */
h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============ Layout ============ */
header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    gap: 0.75rem;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.logo:hover {
    text-decoration: none;
}

/* Nav Icons */
.nav-icons {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    position: relative;
}

.nav-btn:hover {
    background: var(--color-border);
    color: var(--color-text);
    text-decoration: none;
}

.nav-btn.active {
    color: var(--color-accent);
}

.nav-btn svg {
    width: 22px;
    height: 22px;
}

/* Search Container */
.search-container {
    display: flex;
    align-items: center;
    position: relative;
}

.search-icon-btn {
    display: flex;
}

.search-container.expanded .search-icon-btn {
    display: none;
}

.search-bar {
    display: none;
    position: relative;
    width: 200px;
}

.search-container.expanded .search-bar {
    display: block;
}

.search-bar input {
    width: 100%;
    padding: 0.5rem 2.25rem 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(136, 120, 168, 0.15);
}

.search-bar input::placeholder {
    color: var(--color-text-muted);
}

.search-bar button {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}

.search-bar button:hover {
    color: var(--color-accent);
}

.search-bar button svg {
    width: 18px;
    height: 18px;
}

/* Search Results Dropdown */
.search-results-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    z-index: 200;
    min-width: 200px;
}

.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--color-bg);
    text-decoration: none;
}

.search-result-item.success {
    color: var(--color-success);
}

.search-result-item.error {
    color: var(--color-error);
}

.search-result-item.muted {
    color: var(--color-text-muted);
}

.search-result-item strong {
    display: block;
}

.search-result-item span {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.search-loading {
    padding: 0.75rem 1rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

main {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--color-text-muted);
    margin-left: 1rem;
}

/* Mobile responsive nav */
@media (max-width: 600px) {
    .logo-text {
        font-size: 0.75rem !important;
    }
    
    .search-bar {
        width: 160px;
    }
    
    .search-bar input {
        font-size: 0.8rem;
        padding: 0.4rem 2rem 0.4rem 0.5rem;
    }
    
    header {
        padding: 0 0.5rem;
    }
}

/* ============ Hamburger Menu ============ */
.hamburger {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

.hamburger svg {
    width: 24px;
    height: 24px;
}

/* Mobile Drawer */
.drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-overlay.open {
    opacity: 1;
}

.drawer {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100%;
    background: var(--color-surface);
    z-index: 300;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

.drawer.open {
    right: 0;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.drawer-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.drawer-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

.drawer-close svg {
    width: 24px;
    height: 24px;
}

.drawer-links {
    flex: 1;
    padding: 1rem 0;
}

.drawer-links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 1rem;
}

.drawer-links a:hover {
    background: var(--color-bg);
}

.drawer-links a svg {
    width: 22px;
    height: 22px;
    color: var(--color-text-muted);
}

.drawer-footer {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
}

.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.theme-toggle-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

.theme-toggle-btn svg {
    width: 22px;
    height: 22px;
}

/* Mobile: Hide nav-icons, show hamburger */
@media (max-width: 640px) {
    .nav-icons {
        display: none;
    }
    
    .hamburger {
        display: flex;
    }
    
    nav {
        position: relative;
    }
    
    .drawer-overlay {
        display: block;
    }
}

/* ============ Components ============ */

/* Cards */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.card-content {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.7;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--color-accent);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: var(--color-text-muted);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-ghost.active {
    background: var(--color-accent-light);
    color: var(--color-primary-dark);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="email"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
}

textarea {
    min-height: 150px;
    resize: vertical;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.form-error {
    color: var(--color-error);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Interaction buttons */
.interactions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.interaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.interaction-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.interaction-btn.active {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
    color: var(--color-primary-dark);
}

.interaction-btn .count {
    font-weight: 600;
}

/* Verse picker */
.verse-picker {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.verse-picker select,
.verse-picker input {
    flex: 1;
}

.verse-picker .book-input {
    flex: 2;
}

/* Passphrase display */
.passphrase-display {
    background: var(--color-bg);
    border: 2px dashed var(--color-accent);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    margin: 1.5rem 0;
}

.passphrase-display .phrase {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-accent);
    letter-spacing: 0.05em;
}

.passphrase-display .hint {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

/* Church badge */
.church-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    background: var(--color-accent-light);
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--color-primary-dark);
}

/* Verse tags */
.verse-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.verse-tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--color-accent);
    text-decoration: none;
    transition: all 0.2s;
}

a.verse-tag:hover {
    background: var(--color-accent);
    color: white;
    text-decoration: none;
}

/* Loading & States */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

/* Alert/Message */
.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.alert-success {
    background: #c6f6d5;
    color: #22543d;
}

.alert-error {
    background: #fed7d7;
    color: #742a2a;
}

.alert-info {
    background: #bee3f8;
    color: #2a4365;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

/* Turnstile container */
.cf-turnstile {
    margin: 1rem 0;
}

/* ============ Page-specific ============ */

/* Home/Feed */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.church-filter {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Create post */
.create-form {
    max-width: 600px;
    margin: 0 auto;
}

/* My post lookup */
.lookup-form {
    max-width: 400px;
    margin: 0 auto;
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
    header {
        padding: 1rem;
    }
    
    nav {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        gap: 1rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .verse-picker {
        flex-direction: column;
    }
    
    .interactions {
        justify-content: center;
    }
}
