/* Letter Finder - Main Stylesheet */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #e8e8e8;
    --text-secondary: #a8a8b3;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --success: #4ecca3;
    --warning: #ffc857;
    --border: #2a2a4a;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --radius: 8px;
    --transition: 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: var(--bg-secondary);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.main-nav {
    display: flex;
    gap: 25px;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.main-nav a:hover {
    color: var(--text-primary);
}

/* Hero */
.hero {
    padding: 60px 0 40px;
    text-align: center;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Filters */
.filters {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition);
}

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

/* Letters Grid */
.letters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.letter-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid var(--border);
}

.letter-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.letter-card .scenario {
    display: inline-block;
    padding: 4px 12px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.letter-card .tone {
    display: inline-block;
    padding: 4px 12px;
    background: var(--accent);
    border-radius: 20px;
    font-size: 0.8rem;
    color: white;
    margin-left: 8px;
}

.letter-card h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.letter-card .preview {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.letter-card .context {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

/* Editor Section */
.editor-section {
    padding: 60px 0;
    background: var(--bg-secondary);
}

.editor-section h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.editor-section > .container > p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
}

.editor-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color var(--transition);
}

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

.form-group textarea {
    min-height: 300px;
    line-height: 1.6;
}

.editor-sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

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

.saved-drafts {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
}

.saved-drafts h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.no-drafts {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

.draft-item {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 10px;
    cursor: pointer;
    transition: background var(--transition);
}

.draft-item:hover {
    background: var(--border);
}

.draft-item .draft-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.draft-item .draft-preview {
    font-size: 0.9rem;
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Guide Section */
.guide-section {
    padding: 60px 0;
}

.guide-section h2 {
    font-size: 1.8rem;
    margin-bottom: 30px;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.guide-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    border: 1px solid var(--border);
}

.guide-card h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--accent);
}

.guide-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.guide-examples {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 40px;
}

.guide-examples h3 {
    font-size: 1.3rem;
    margin-bottom: 25px;
}

.example-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.example-before,
.example-after {
    padding: 20px;
    border-radius: var(--radius);
}

.example-before {
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid var(--accent);
}

.example-after {
    background: rgba(78, 204, 163, 0.1);
    border: 1px solid var(--success);
}

.example-before h4,
.example-after h4 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.example-before h4 {
    color: var(--accent);
}

.example-after h4 {
    color: var(--success);
}

.example-before blockquote,
.example-after blockquote {
    font-style: italic;
    line-height: 1.6;
    color: var(--text-primary);
}

.example-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

/* FAQ Section */
.faq-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 30px;
}

.faq-section h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
}

.faq-section details {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.faq-section details:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.faq-section summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    padding: 10px 0;
}

.faq-section summary:hover {
    color: var(--accent);
}

.faq-section details p {
    color: var(--text-secondary);
    padding: 10px 0 10px 20px;
    line-height: 1.6;
}

/* Footer */
.site-footer {
    background: var(--bg-secondary);
    padding: 40px 0 20px;
    border-top: 1px solid var(--border);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 30px;
}

.footer-brand h3 {
    font-size: 1.2rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.footer-brand p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    gap: 25px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--text-primary);
}

.copyright {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--accent);
}

.modal-content h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    padding-right: 30px;
}

.modal-content .letter-text {
    line-height: 1.8;
    white-space: pre-wrap;
    margin-bottom: 20px;
}

.modal-content .modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--success);
    color: var(--bg-primary);
    padding: 15px 25px;
    border-radius: var(--radius);
    font-weight: 500;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .site-header .container {
        flex-direction: column;
        gap: 15px;
    }
    
    .main-nav {
        gap: 15px;
    }
    
    .hero h2 {
        font-size: 1.8rem;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .editor-layout {
        grid-template-columns: 1fr;
    }
    
    .example-pair {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 40px 0 30px;
    }
    
    .hero h2 {
        font-size: 1.5rem;
    }
    
    .letters-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 20px;
    }
}

/* Print Styles */
@media print {
    .site-header,
    .site-footer,
    .browse-section,
    .editor-sidebar,
    .guide-section,
    .filters {
        display: none;
    }
    
    .editor-section {
        background: white;
        color: black;
    }
    
    .form-group textarea {
        border: none;
        background: transparent;
        color: black;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--accent);
    color: white;
}


/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
