/* Practice Handout Generator - Styles (Practice pillar: green) */
/* Matches SeekerPNW design system with meaning-aligned colors */

:root {
    /* Colors - Meaning Aligned */
    --spiritual: #7c3aed;    /* Purple - Mystery & Depth */
    --readings: #eab308;     /* Gold - Joy & Illumination */
    --art-science: #0d9488;  /* Teal - Calm & Creative */
    --learning: #1d4ed8;     /* Blue - Trust & Clarity */
    --practice: #16a34a;     /* Green - Growth & Vitality */
    
    /* UI Colors - Practice pillar green (Growth & Vitality) */
    --primary: #16a34a;
    --primary-hover: #15803d;
    --secondary: #22c55e;
    --secondary-hover: #16a34a;
    
    /* Neutrals */
    --background: #ffffff;
    --background-subtle: #f8f9fa;
    --foreground: #212529;
    --foreground-muted: #495057;
    --foreground-subtle: #868e96;
    --border: #dee2e6;
    
    /* Feedback */
    --error: #dc2626;
    --error-bg: #fef2f2;
    --success: #16a34a;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: var(--foreground);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-link {
    text-decoration: none;
    color: inherit;
    display: inline-block;
}
.logo-link:hover {
    opacity: 0.85;
}
.logo svg {
    height: 44px;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--foreground-muted);
    font-size: 1.0625rem;
}

/* Input Section — Lectionary-style: header + centered input-container */
.input-section {
    text-align: center;
    padding: 3rem 0;
    min-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
}

.generator-header {
    margin-bottom: 2.5rem;
}

.generator-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.input-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.input-group {
    width: 100%;
    text-align: left;
}

.input-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--foreground-subtle);
    margin-bottom: 0.5rem;
}

.topic-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--foreground);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.topic-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

.topic-input::placeholder {
    color: var(--foreground-subtle);
}

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

.form-group:last-of-type {
    margin-bottom: 1.5rem;
}

.required {
    color: var(--error);
}

.optional {
    color: var(--foreground-subtle);
    font-weight: 400;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    color: var(--foreground);
}

/* Generate button - proportional to text, centered, mixed case like Register Your Group */
.form-submit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.combo-status {
    margin-top: 0.75rem;
    font-size: 0.95rem;
    color: var(--foreground-muted);
    text-align: center;
}
.combo-status-exhausted {
    color: var(--foreground);
    font-weight: 500;
}

.allow-repeat-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    color: var(--foreground-muted);
    margin-bottom: 0.75rem;
}
.allow-repeat-wrap input { margin: 0; }

.already-generated-notice {
    font-size: 0.95rem;
    color: var(--foreground-muted);
    background: var(--background-subtle);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary);
}

.form-submit .btn-primary {
    width: auto;
    padding: 0.875rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: white !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

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

.btn-secondary {
    background: var(--background);
    color: var(--foreground);
    border: 1px solid var(--border);
}

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

.logo-link:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-text-only:focus-visible,
.btn-find-another:focus-visible,
.about-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-text,
.btn-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Spinner */
.spinner,
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 3rem 1rem;
}

.loading-message {
    color: var(--foreground-muted);
    font-size: 1rem;
}

/* Confirmation Section */
.confirm-section {
    animation: fadeIn 0.3s ease;
}

.confirm-box {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.confirm-box h3 {
    font-size: 1.125rem;
    color: var(--foreground-muted);
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.confirm-book-info {
    margin-bottom: 1.5rem;
}

.confirm-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.25rem;
}

.confirm-author {
    font-size: 1.125rem;
    color: var(--foreground-muted);
}

.confirm-year {
    color: var(--foreground-subtle);
}

.confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.confirm-actions .btn-primary {
    width: 100%;
    max-width: 280px;
}

.confirm-actions .btn-secondary {
    width: 100%;
    max-width: 280px;
    background: transparent;
    border: 1px solid var(--border);
}

.btn-text-only {
    background: none;
    border: none;
    color: var(--foreground-muted);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: color 0.2s ease;
}

.btn-text-only:hover {
    color: var(--foreground);
    text-decoration: underline;
}

.confirm-box .form-group {
    text-align: left;
    margin-bottom: 1rem;
}

.confirm-box .form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: var(--foreground-muted);
}

.confirm-box .form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

/* Output Section — Lectionary-style: starts at top when shown */
.output-section {
    animation: fadeIn 0.3s ease;
    padding-top: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Handout card (matches Lectionary) */
.handout {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.handout-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.handout-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground);
    margin: 0;
}

/* Mobile-only hint: content continues below (embedded in iframe) */
.scroll-hint {
    display: none;
}
@media (max-width: 640px) {
    .scroll-hint {
        display: block;
        font-size: 0.875rem;
        color: var(--foreground-muted);
        margin: 0.5rem 0 0;
        font-weight: 500;
    }
}

.output-author {
    color: var(--foreground-muted);
    font-style: italic;
}

.content-box {
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.section {
    margin-bottom: 1.5rem;
}

.section:last-child {
    margin-bottom: 0;
}

.section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
}

/* Practice summaries */
.practice-summary {
  margin-bottom: 1rem;
}
.practice-summary h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.25rem;
}
.practice-summary p {
  font-size: 0.9375rem;
  color: var(--foreground-muted);
  line-height: 1.6;
}

/* Summary */
#summaryContent {
    color: var(--foreground);
    line-height: 1.7;
}

#summaryContent h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 1rem 0 0.5rem 0;
}

#summaryContent h4:first-child {
    margin-top: 0;
}

#summaryContent p {
    margin: 0 0 0.75rem 0;
}

#summaryContent ul {
    margin: 0.5rem 0 1rem 0;
    padding-left: 1.25rem;
}

#summaryContent li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

#summaryContent li:last-child {
    margin-bottom: 0;
}

/* Articles */
.articles-note {
    font-size: 0.8125rem;
    color: var(--foreground-subtle);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.article {
    background: var(--background-subtle);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.article:last-child {
    margin-bottom: 0;
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.article-title {
    font-weight: 600;
    color: var(--foreground);
    flex: 1;
}

.article-title a {
    color: #374151;
    text-decoration: none;
}

.article-title a:hover {
    color: #1f2937;
    text-decoration: underline;
}

.article-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.article-status.verified {
    background: #dcfce7;
    color: #166534;
}

.article-status.paywall {
    background: #fef3c7;
    color: #92400e;
}

.article-status.not-found {
    background: #fee2e2;
    color: #991b1b;
}

.article-status.unknown {
    background: #f3f4f6;
    color: #6b7280;
}

.article-status.search-needed {
    color: #92400e;
    background: #fef3c7;
}

.article-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.article-title .no-link-title {
    color: var(--foreground);
    font-weight: 500;
}

.article-title a.unverified-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: underline;
}

.article-title a.unverified-link:hover {
    color: var(--primary-hover);
}

.article-search-fallback {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border);
    font-size: 0.875rem;
}

.article-search-fallback .fallback-note {
    color: var(--foreground-muted);
    margin-right: 0.5rem;
}

.article-title a.title-search-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: underline;
}

.article-title a.title-search-link:hover {
    color: var(--primary-hover);
}

.search-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: underline;
}

.search-link:hover {
    color: var(--primary-hover);
}

.status-icon {
    font-size: 0.875rem;
}

.article-author {
    font-size: 0.875rem;
    color: var(--foreground-muted);
    margin-bottom: 0.5rem;
}

.article-description {
    font-size: 0.9375rem;
    color: var(--foreground);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.article-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.btn-find-another {
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--foreground-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-find-another:hover {
    background: var(--background);
    border-color: var(--foreground-muted);
    color: var(--foreground);
}

.btn-find-another:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-find-another.loading {
    color: var(--foreground-subtle);
}

.article.replacing {
    opacity: 0.6;
}

/* Questions */
.question {
    background: var(--background-subtle);
    border-left: 4px solid var(--primary);
    border-radius: 0 8px 8px 0;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.question:last-child {
    margin-bottom: 0;
}

.question-number {
    font-weight: 600;
    color: var(--primary-hover);
    margin-bottom: 0.5rem;
}

.question-setup {
    font-size: 0.9375rem;
    color: var(--foreground-muted);
    margin-bottom: 0.5rem;
    font-style: italic;
}

.question-text {
    font-size: 1rem;
    color: var(--foreground);
    font-weight: 500;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 1rem;
}

.action-buttons button {
    flex: 1 1 160px;
    min-width: 140px;
    max-width: 220px;
    min-height: 44px;
}

.action-buttons svg {
    flex-shrink: 0;
}

/* Copied feedback */
.btn-secondary.copied {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* Error Section */
.error-section {
    animation: fadeIn 0.3s ease;
}

.error-box {
    background: var(--error-bg);
    border: 1px solid var(--error);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.error-box p {
    color: var(--error);
    margin-bottom: 1rem;
}

.error-box .btn-primary {
    width: auto;
    background: var(--error);
    color: white;
}

.error-box .btn-primary:hover {
    background: #b91c1c;
}

/* About Section - gray block for subdued look (matches Lectionary) */
.about-section {
    margin-top: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    border: 1px solid #e5e5e5;
}

.about-toggle {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--foreground-subtle);
    cursor: pointer;
    padding: 0.5rem 0;
    letter-spacing: 0.03em;
    transition: color 0.2s ease;
}

.about-toggle:hover {
    color: var(--foreground-muted);
}

.about-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}

.about-section.open .about-toggle {
    color: var(--foreground-muted);
}

.about-section.open .about-content {
    max-height: 400px;
    opacity: 1;
}

.about-content p {
    font-size: 0.95rem;
    color: var(--foreground-muted);
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.about-content p:last-child {
    margin-bottom: 0;
}

.about-content a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.about-content a:hover {
    text-decoration: underline;
}

/* Footer / Attribution */
footer.attribution,
.attribution {
    margin-top: 2rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.75rem;
    color: var(--foreground-subtle);
    line-height: 1.6;
}

footer.attribution p,
.attribution p {
    margin: 0 0 0.5rem 0;
}

.footer-links {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

footer a {
    color: #374151;
    text-decoration: none;
}

footer a:hover {
    color: #1f2937;
    text-decoration: underline;
}

/* Consistent link styling throughout */
a {
    color: #374151;
    text-decoration: none;
}

a:hover {
    color: #1f2937;
    text-decoration: underline;
}

.license {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--foreground-subtle);
}

/* Article link styles */
.article-title a.direct-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: underline;
}

.article-title a.direct-link:hover {
    color: var(--primary-hover);
}

.article-title a.unverified-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: underline;
}

.article-title a.unverified-link:hover {
    color: var(--primary-hover);
}

.article-title .no-link-title {
    color: var(--foreground);
    font-weight: 500;
}

/* Search fallback section */
.article-search-fallback {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border);
    font-size: 0.875rem;
}

.article-search-fallback .fallback-note {
    color: var(--foreground-muted);
    margin-right: 0.5rem;
}

.search-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: underline;
}

.search-link:hover {
    color: var(--primary-hover);
}

/* Legacy styles for backwards compatibility */
.broken-title {
    color: var(--foreground-muted);
    text-decoration: line-through;
    font-size: 0.9em;
}

.verify-title {
    color: var(--foreground);
    font-weight: 500;
    font-size: 0.95em;
}

/* Status for search needed */
.article-status.search_needed {
    color: #92400e;
    background: #fef3c7;
}

/* Print Styles */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .input-section,
    .action-buttons,
    .loading-section,
    .error-section,
    footer {
        display: none !important;
    }
    
    .output-section {
        display: block !important;
    }
    
    .handout {
        border: none;
        box-shadow: none;
        padding: 1.5rem;
    }
    
    .section h3 {
        border-bottom-color: #333;
    }
    
    .article,
    .question {
        background: #f5f5f5;
        break-inside: avoid;
    }
    
    .question {
        border-left-color: #333;
    }
    
    .article-title a {
        color: #333;
    }
}

/* Save to Database button (Admin mode only) */
.btn-save-database {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-save-database:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-save-database:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons button {
        width: 100%;
        max-width: none;
    }
}

/* Compact layout when embedded in admin modal (?admin=true) */
body.embed {
    min-height: auto;
}
body.embed .container {
    padding: 1rem 1.25rem;
}
body.embed .generator-header {
    margin-bottom: 1rem;
}
body.embed .logo svg {
    height: 28px;
    margin-bottom: 0.5rem;
}
body.embed .generator-title {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}
body.embed .subtitle {
    font-size: 0.875rem;
}
body.embed .input-section {
    padding: 0 0 1rem;
}
body.embed .input-group {
    margin-bottom: 1rem;
}
body.embed .attribution {
    margin-top: 1rem;
    padding-top: 1rem;
    font-size: 0.7rem;
}
