/* EduVault public styles. Mobile first; wider layouts live in responsive.css */

:root {
  --navy: #123B6D;
  --navy-900: #0C2A4F;
  --emerald: #16A36A;
  --emerald-700: #0E8458;   /* darker emerald for text and button fills: white text passes WCAG AA */
  --emerald-50: #E8F6F0;
  --white: #FFFFFF;
  --bg: #F5F7FA;
  --text: #334155;
  --text-soft: #64748B;
  --border: #E2E8F0;
  --danger: #B42318;
  --danger-50: #FEF3F2;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(18, 59, 109, .06), 0 1px 3px rgba(18, 59, 109, .06);
  --shadow-lg: 0 10px 30px rgba(12, 42, 79, .18);
  --container: 1180px;
  --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { color: var(--navy); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5.4vw, 3.25rem); font-weight: 800; letter-spacing: -.025em; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2rem); font-weight: 750; }
h3 { font-size: 1.125rem; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--emerald-700); text-underline-offset: 3px; }
a:hover { color: var(--navy); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--emerald); outline-offset: 2px; border-radius: 4px; }
.on-dark :focus-visible { outline-color: #fff; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; color: #fff; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.icon { width: 1.25em; height: 1.25em; flex: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; background: var(--white);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.brand img { width: 46px; height: auto; }
.brand-v { color: var(--emerald); }
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border: 1px solid var(--border); background: var(--white); border-radius: var(--radius-sm); color: var(--navy);
}
.nav-toggle .icon { width: 24px; height: 24px; }
.nav-toggle .icon-close { display: none; }
.nav-toggle[aria-expanded="true"] .icon-open { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }
.site-nav {
  display: none; position: absolute; left: 0; right: 0; top: var(--header-h);
  background: var(--white); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: 8px 20px 16px;
}
.site-nav.is-open { display: block; }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 14px 4px; text-decoration: none; color: var(--navy); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.site-nav li:last-child a { border-bottom: 0; }
.site-nav a[aria-current="page"] { color: var(--emerald-700); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 650; font-size: .975rem; text-decoration: none; line-height: 1; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--emerald-700); color: #fff; }
.btn-primary:hover { background: var(--navy); color: #fff; }
.btn-outline { background: var(--white); color: var(--navy); border-color: var(--border); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .9rem; }
.btn-ghost-light { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn-ghost-light:hover { background: #fff; color: var(--navy); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; font-weight: inherit; }
.link-btn:hover { color: var(--emerald-700); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Hero ---------- */
.hero { background: var(--navy); color: #dbe6f3; padding: 56px 0 64px; }
.hero h1 { color: #fff; max-width: 16ch; margin-bottom: 16px; }
.hero-lead { font-size: 1.125rem; max-width: 56ch; margin-bottom: 28px; color: #dbe6f3; }
.search-form { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.search-field {
  display: flex; align-items: center; gap: 10px; background: #fff; border-radius: var(--radius);
  padding: 0 14px; min-height: 56px; border: 2px solid transparent;
}
.search-field:focus-within { border-color: var(--emerald); }
.search-field .icon { color: var(--text-soft); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 1.05rem; color: var(--navy); padding: 12px 0; }
.search-field input::placeholder { color: var(--text-soft); }
.search-form .btn { min-height: 56px; font-size: 1.05rem; }
.quick-links { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; padding: 0; }
.quick-links a { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .35); color: #fff; text-decoration: none; font-weight: 600; font-size: .95rem; }
.quick-links a:hover { background: #fff; color: var(--navy); }

/* ---------- Page header (inner pages) ---------- */
.page-head { background: var(--bg); border-bottom: 1px solid var(--border); padding: 36px 0 28px; }
.page-head h1 { font-size: clamp(1.75rem, 4.4vw, 2.5rem); margin-bottom: 8px; }
.page-head p { max-width: 64ch; color: var(--text); margin-bottom: 20px; }
.page-head .search-field { border: 1px solid var(--border); max-width: 680px; }
.page-head .search-field:focus-within { border-color: var(--emerald); }

/* ---------- Sections ---------- */
.section { padding: 56px 0; }
.section-alt { background: var(--bg); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 24px; margin-bottom: 28px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--text-soft); }
.section-link { font-weight: 650; text-decoration: none; }
.section-link:hover { text-decoration: underline; }

/* ---------- Category cards ---------- */
.cat-grid { display: grid; gap: 16px; }
.cat-card {
  display: flex; flex-direction: column; gap: 10px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--white); text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.cat-card:hover { border-color: var(--emerald); color: var(--text); box-shadow: 0 4px 14px rgba(18, 59, 109, .1); }
.cat-icon { width: 48px; height: 48px; border-radius: 10px; background: var(--emerald-50); color: var(--emerald-700); display: grid; place-items: center; }
.cat-icon .icon { width: 26px; height: 26px; }
.cat-card h3 { margin: 6px 0 0; }
.cat-card p { margin: 0; color: var(--text-soft); }
.cat-card .go { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; color: var(--emerald-700); font-weight: 650; }

/* ---------- Subject chips ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--white); color: var(--navy); font-weight: 600; text-decoration: none; font-size: .95rem; min-height: 40px;
}
.chip:hover { border-color: var(--emerald); color: var(--navy); }
.chip-count { color: var(--text-soft); font-weight: 500; font-size: .85rem; }
.chip[aria-pressed="true"], .chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip[aria-pressed="true"] .chip-count, .chip.is-active .chip-count { color: #cfe0f2; }

/* ---------- Resource cards ---------- */
.grid { display: grid; gap: 16px; }
.card {
  display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--emerald-50); color: var(--emerald-700); }
.badge-ext { background: var(--bg); color: var(--navy); border: 1px solid var(--border); }
.card-title { font-size: 1.05rem; margin: 0 0 10px; line-height: 1.3; overflow-wrap: anywhere; }
.card-title .link-btn { color: var(--navy); }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 14px; }
.tags li { font-size: .85rem; padding: 2px 8px; border-radius: 4px; background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.card-desc { font-size: .9rem; color: var(--text-soft); margin: 0 0 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.card-size { font-size: .85rem; color: var(--text-soft); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card-actions .btn { flex: 1 1 auto; white-space: normal; text-align: center; line-height: 1.25; padding-top: 8px; padding-bottom: 8px; }

/* ---------- Skeleton / states ---------- */
.skeleton { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-height: 190px; }
.skeleton span { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eef2f6, #e2e8f0, #eef2f6); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; margin-bottom: 14px; }
.skeleton span:nth-child(1) { width: 30%; }
.skeleton span:nth-child(2) { width: 85%; height: 16px; }
.skeleton span:nth-child(3) { width: 60%; }
.skeleton span:nth-child(4) { width: 40%; margin-top: 26px; height: 32px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.state { text-align: center; padding: 48px 20px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--white); grid-column: 1 / -1; }
.state .icon { width: 36px; height: 36px; margin: 0 auto 12px; color: var(--text-soft); }
.state h3 { margin-bottom: 6px; }
.state p { margin: 0 auto 16px; max-width: 46ch; color: var(--text-soft); }
.state-error { border-color: #f1b5b0; background: var(--danger-50); }
.state-error .icon, .state-error h3 { color: var(--danger); }

/* ---------- Library layout (listing pages) ---------- */
.library { padding: 28px 0 64px; }
.library-layout { display: grid; gap: 20px; }
.filters-toggle { width: 100%; justify-content: space-between; }
.filters { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: none; align-self: start; }
.filters.is-open { display: block; }
.filters h2 { font-size: 1rem; margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 650; font-size: .875rem; color: var(--navy); margin-bottom: 6px; }
.select, .input {
  width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm); background: var(--white); color: var(--text);
}
.select:focus-visible, .input:focus-visible { outline: 3px solid var(--emerald); outline-offset: 1px; border-color: var(--emerald); }
.filters-actions { display: flex; gap: 8px; margin-top: 6px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.result-count { margin: 0; font-weight: 600; color: var(--navy); }
.sort { display: flex; align-items: center; gap: 8px; }
.sort label { font-size: .9rem; color: var(--text-soft); white-space: nowrap; }
.sort .select { width: auto; min-width: 170px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--emerald-50); border: 1px solid #bfe6d4; color: var(--navy); font-size: .875rem; font-weight: 600; }
.pill-btn .icon { width: 16px; height: 16px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 28px; }
.pagination button {
  min-width: 42px; min-height: 42px; padding: 0 12px; border: 1px solid var(--border); background: var(--white); border-radius: var(--radius-sm); color: var(--navy); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.pagination button:hover:not([disabled]) { border-color: var(--navy); }
.pagination button[aria-current="page"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination button[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Why EduVault ---------- */
.why-grid { display: grid; gap: 24px; }
.why-item { display: flex; gap: 14px; }
.why-item .cat-icon { flex: none; width: 44px; height: 44px; }
.why-item h3 { margin-bottom: 4px; font-size: 1.05rem; }
.why-item p { margin: 0; color: var(--text-soft); font-size: .95rem; }

/* ---------- About ---------- */
.prose { max-width: 70ch; }
.prose h2 { margin-top: 0; }
.about-block { padding: 40px 0; border-bottom: 1px solid var(--border); }
.about-block:last-of-type { border-bottom: 0; }
.statement { font-size: 1.25rem; line-height: 1.5; color: var(--navy); font-weight: 600; max-width: 40ch; margin: 0; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.check-list li { display: flex; gap: 12px; align-items: flex-start; }
.check-list .icon { color: var(--emerald-700); margin-top: 3px; }
.audience-grid { display: grid; gap: 16px; }
.audience { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); }
.audience h3 { margin-bottom: 6px; }
.audience p { margin: 0; color: var(--text-soft); font-size: .95rem; }
.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.contact-list a { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Modal ---------- */
dialog.modal { width: min(920px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); color: var(--text); }
dialog.modal::backdrop { background: rgba(12, 42, 79, .55); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--white); z-index: 1; }
.modal-head h2 { font-size: 1.25rem; margin: 0; overflow-wrap: anywhere; }
.modal-close { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--border); background: var(--white); border-radius: var(--radius-sm); color: var(--navy); }
.modal-body { padding: 18px 20px 20px; }
.facts { display: grid; gap: 0; margin: 0 0 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.facts div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--text-soft); font-size: .9rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.preview-box { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg); }
.preview-box iframe { width: 100%; height: 60vh; min-height: 360px; border: 0; display: block; background: #fff; }
.preview-note { font-size: .875rem; color: var(--text-soft); margin: 8px 0 0; }
.report { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: .9rem; color: var(--text-soft); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.report a { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy-900); color: #c3d2e4; padding: 48px 0 24px; }
.footer-grid { display: grid; gap: 32px; }
.footer-brand img { width: 120px; height: auto; background: #fff; border-radius: 10px; padding: 10px; margin-bottom: 14px; }
.footer-brand p { max-width: 38ch; margin: 0; }
.site-footer h2 { color: #fff; font-size: 1rem; margin-bottom: 12px; letter-spacing: 0; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.site-footer a { color: #c3d2e4; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-bottom { margin-top: 36px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .15); font-size: .875rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }

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

/* ---------- Library layout helpers ---------- */
.filters-col { display: grid; gap: 12px; align-content: start; }
.filters-toggle > span { display: inline-flex; align-items: center; gap: 8px; }
.footer-report { margin: 12px 0 0; font-size: .875rem; }
.footer-report br { display: none; }
#search-tabs { margin-bottom: 20px; }

/* ---------- Guide video ---------- */
.video-frame { position: relative; width: 100%; max-width: 880px; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--navy-900); box-shadow: var(--shadow-lg); }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Message toast ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200; max-width: min(92vw, 520px); padding: 12px 16px; border-radius: var(--radius-sm); background: var(--navy); color: #fff; box-shadow: var(--shadow-lg); font-weight: 600; }
.toast-error { background: var(--danger); }
