@font-face {
  font-family: 'Manjari';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/Manjari-Regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Manjari';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/Manjari-Bold.ttf') format('truetype');
}

:root {
    --bg-color: #f7f9fa;
    --surface: #ffffff;
    --primary: #1a3630;
    --primary-light: #244b43;
    --accent: #d46a54;
    --accent-light: #fbeae7;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 14px -2px rgba(0, 0, 0, 0.04), 0 2px 4px -2px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    
    --radius-sm: 8px;
    --radius: 16px;
    --radius-lg: 24px;
    
    --font-stack: "Manjari", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    background: var(--bg-color);
}

body {
    margin: 0;
    color: var(--text-main);
    background: var(--bg-color);
    font-family: var(--font-stack);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.shell {
    width: min(800px, calc(100% - 32px));
    margin-inline: auto;
}

/* Header */
.masthead {
    background: var(--surface);
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.masthead__inner {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    color: var(--surface);
    background: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    font-weight: 800;
    flex-shrink: 0;
}

.masthead h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.masthead__copy {
    display: none;
}

/* Mandatory Disclaimer */
.legal-disclaimer {
    display: flex;
    gap: 16px;
    background: var(--accent-light);
    border: 1px solid rgba(212, 106, 84, 0.2);
    padding: 16px;
    border-radius: var(--radius);
    margin: 32px 0;
}

.disclaimer-icon {
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 2px;
}

.disclaimer-content strong {
    display: block;
    color: #9e3621;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.disclaimer-content p {
    margin: 0;
    font-size: 0.85rem;
    color: #9e3621;
    line-height: 1.6;
}

/* Search Area */
.search-card {
    background: var(--surface);
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.search-card__intro {
    text-align: center;
    margin-bottom: 24px;
}

.section-kicker {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#search-heading, .results__header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Form */
.search-form {
    display: flex;
    gap: 12px;
}

.search-form input {
    flex: 1;
    min-width: 0;
    height: 52px;
    padding: 0 20px;
    background: var(--bg-color);
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.search-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(26, 54, 48, 0.1);
}

.search-form input::placeholder {
    color: #9ca3af;
}

.search-form button, .button-primary, .load-more {
    height: 52px;
    padding: 0 28px;
    color: var(--surface);
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.search-form button:hover, .button-primary:hover, .load-more:hover {
    background: var(--primary-light);
}

.search-form button:active, .button-primary:active, .load-more:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Quick Search */
.quick-search {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 24px;
    font-size: 0.9rem;
}

.quick-search span {
    color: var(--text-muted);
    font-weight: 500;
}

.quick-search button {
    height: 36px;
    padding: 0 16px;
    color: var(--primary);
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-search button:hover {
    background: var(--primary);
    color: var(--surface);
    border-color: var(--primary);
}

/* Stats */
.library-facts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.library-facts > div {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.library-facts strong {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
}

.library-facts span {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
    font-weight: 500;
}

/* Results Area */
.results {
    padding-bottom: 80px;
}

.results__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

#result-summary {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.result-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.result-card__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.result-badge {
    display: inline-flex;
    padding: 6px 10px;
    color: var(--primary);
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.result-badge--muted {
    color: var(--text-main);
    background: var(--border-light);
}

.result-page {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.result-card h3 {
    margin: 0 0 8px;
    color: var(--text-main);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.4;
}

.result-meta {
    margin: 0;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
}

.result-snippet {
    margin: 16px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Actions inside cards */
.result-actions, .dialog-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 20px;
    color: var(--primary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.button-primary {
    height: 44px;
}

.button-secondary:hover {
    background: var(--bg-color);
    border-color: var(--primary);
}

/* Modals */
.section-dialog, .pdf-dialog {
    width: min(100% - 32px, 720px);
    max-height: 85vh;
    padding: 32px;
    color: var(--text-main);
    background: var(--surface);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.section-dialog::backdrop, .pdf-dialog::backdrop {
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(4px);
}

.dialog-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dialog-toolbar button, .pdf-dialog-toolbar button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--text-muted);
    background: var(--bg-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.dialog-toolbar button:hover, .pdf-dialog-toolbar button:hover:not(:disabled) {
    background: var(--border);
    color: var(--text-main);
}

.section-dialog h2 {
    margin: 20px 0 0;
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 700;
}

.dialog-content {
    margin-top: 24px;
    white-space: pre-wrap;
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.7;
    overflow-y: auto;
    max-height: 50vh;
}

.dialog-actions {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

/* PDF Viewer Specifics */
.pdf-dialog {
    width: min(100% - 32px, 860px);
    height: 90vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.pdf-dialog:not([open]) { display: none !important; }

.pdf-dialog-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.pdf-dialog-title {
    font-weight: 700;
    color: var(--primary);
}

.pdf-dialog-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pdf-dialog-nav button {
    font-size: 1.8rem !important;
    line-height: 0;
}

.pdf-dialog-toolbar button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pdf-dialog-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: #e5e5e5;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 24px;
}

.pdf-canvas-wrap {
    display: flex;
    justify-content: center;
    min-height: 100%;
}

#pdf-canvas {
    max-width: 100%;
    height: auto !important;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    user-select: none;
    -webkit-user-select: none;
}

.pdf-loading-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(229, 229, 229, 0.9);
    z-index: 10;
}

.pdf-loading-state span, .loading-state span {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin: 0 4px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 1s infinite alternate;
}

.pdf-loading-state span:nth-child(2), .loading-state span:nth-child(2) { animation-delay: .2s; }
.pdf-loading-state span:nth-child(3), .loading-state span:nth-child(3) { animation-delay: .4s; }

.pdf-loading-state p, .loading-state p {
    margin-top: 16px;
    font-weight: 600;
    color: var(--primary);
}

/* Utilities & States */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

[hidden] { display: none !important; }

.loading-state, .empty-state {
    padding: 48px 24px;
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.empty-state strong {
    display: block;
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.empty-state p { margin: 0; color: var(--text-muted); }

.subsection-heading {
    margin: 32px 0 16px;
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.load-more-wrap {
    display: grid;
    place-items: center;
    margin-top: 32px;
}

/* Help Strip & Footer */
.help-strip { display: none; } /* Kept clean, removing bulky text areas for mobile-first feel */

.site-footer {
    padding: 32px 0;
    text-align: center;
    color: var(--text-muted);
}

.site-footer p {
    margin: 0 0 8px;
    font-size: 0.85rem;
}

@keyframes pulse { to { transform: translateY(-6px); opacity: 0.5; } }

/* Responsive */
@media (max-width: 640px) {
    .masthead { padding: 16px 0; }
    .search-card { padding: 20px; }
    .search-form { flex-direction: column; }
    .search-form button { width: 100%; }
    .library-facts { grid-template-columns: 1fr; gap: 12px; margin-bottom: 32px; }
    .library-facts > div { padding: 16px; flex-direction: row; justify-content: space-between; align-items: center; }
    .library-facts span { margin-top: 0; }
    .results__header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .section-dialog, .pdf-dialog { padding: 20px; width: min(100% - 16px, 100%); height: 95vh; max-height: 95vh; border-radius: var(--radius); }
    .pdf-dialog-content { padding: 12px; }
    .dialog-actions { flex-direction: column; }
    .dialog-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
