/* Електронна библиотека „Луи Брайл 1928“
   Теми: светла, тъмна, висок контраст. Размери на текста: m, l, xl.
   Без външни шрифтове и без изображения — бързо и предвидимо за екранни четци. */

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --text: #1a1e23;
  --muted: #4a5561;
  --border: #6b7480;
  --hairline: #dcd8ce;
  --accent: #0b57a4;
  --accent-hover: #083f78;
  --on-accent: #ffffff;
  --accent-soft: #e4eefa;
  --header-bg: #10294a;
  --header-text: #ffffff;
  --error: #a61b1b;
  --error-soft: #fdeaea;
  --success: #17633a;
  --success-soft: #e6f4ea;
  --focus: #b45309;
  --shadow: 0 1px 2px rgba(16, 41, 74, .08), 0 4px 16px rgba(16, 41, 74, .06);
  --radius: 12px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #11151a;
  --surface: #1a2029;
  --text: #f2f4f6;
  --muted: #b6bfca;
  --border: #8b96a5;
  --hairline: #2e3743;
  --accent: #8cc2ff;
  --accent-hover: #b9daff;
  --on-accent: #0a1420;
  --accent-soft: #1d2f45;
  --header-bg: #0b0f14;
  --header-text: #f2f4f6;
  --error: #ff9c9c;
  --error-soft: #3a1c1c;
  --success: #8fe0ad;
  --success-soft: #16301f;
  --focus: #ffd24a;
  --shadow: none;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #11151a;
    --surface: #1a2029;
    --text: #f2f4f6;
    --muted: #b6bfca;
    --border: #8b96a5;
    --hairline: #2e3743;
    --accent: #8cc2ff;
    --accent-hover: #b9daff;
    --on-accent: #0a1420;
    --accent-soft: #1d2f45;
    --header-bg: #0b0f14;
    --header-text: #f2f4f6;
    --error: #ff9c9c;
    --error-soft: #3a1c1c;
    --success: #8fe0ad;
    --success-soft: #16301f;
    --focus: #ffd24a;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="contrast"] {
  --bg: #000000;
  --surface: #000000;
  --text: #ffffff;
  --muted: #ffffff;
  --border: #ffffff;
  --hairline: #ffffff;
  --accent: #ffe600;
  --accent-hover: #ffffff;
  --on-accent: #000000;
  --accent-soft: #000000;
  --header-bg: #000000;
  --header-text: #ffffff;
  --error: #ff8a8a;
  --error-soft: #000000;
  --success: #7dffb0;
  --success-soft: #000000;
  --focus: #00e5ff;
  --shadow: none;
  color-scheme: dark;
}

html { font-size: 112.5%; -webkit-text-size-adjust: 100%; }
html[data-size="l"] { font-size: 131.25%; }
html[data-size="xl"] { font-size: 162.5%; }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  line-height: 1.6;
}

.wrap { width: 100%; max-width: 68rem; margin-inline: auto; padding-inline: 1.25rem; }
.narrow { max-width: 44rem; margin-inline: auto; }
main { flex: 1; padding-block: 2rem 3rem; }
main:focus { outline: none; }

/* ------------------------------------------------------------ текст */

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 1.25rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 2.25rem 0 .75rem; }
h3 { font-size: 1.1rem; line-height: 1.35; margin: 0; }
p, ul, ol, dl { margin: 0 0 1rem; }
.prose { max-width: 44rem; }
.prose li { margin-bottom: .5rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; margin: .35rem 0 0; }

a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: .08em; }
a:hover { color: var(--accent-hover); text-decoration-thickness: .14em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 1rem; top: -6rem; z-index: 10;
  background: var(--accent); color: var(--on-accent);
  padding: .75rem 1.25rem; border-radius: 0 0 var(--radius) var(--radius); font-weight: 700;
}
.skip-link:focus { top: 0; color: var(--on-accent); }

/* ------------------------------------------------------------ глава */

.site-header { background: var(--header-bg); color: var(--header-text); border-bottom: 1px solid var(--hairline); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 2rem; padding-block: .75rem; }
.brand { display: inline-flex; align-items: center; gap: .85rem; color: inherit; text-decoration: none; }
.brand:hover { color: inherit; }
.brand-logo { flex: none; width: 3.25rem; height: 3.25rem; border-radius: 12px; background: #ffffff; object-fit: contain; }
.brand-text { line-height: 1.25; }
.brand-name { font-size: 1.25rem; font-weight: 700; }
.brand-sub { font-size: .85rem; opacity: .9; }

.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.site-nav form { margin: 0; }
.site-nav a, .link-button {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: .5rem .9rem;
  color: var(--header-text); text-decoration: none; font: inherit; font-weight: 600;
  background: none; border: 0; border-bottom: 4px solid transparent; cursor: pointer;
}
.site-nav a:hover, .link-button:hover { color: var(--header-text); border-bottom-color: currentColor; }
.site-nav a[aria-current="page"] { border-bottom-color: #f2b632; }
:root[data-theme="contrast"] .site-nav a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--accent); }

.site-footer { border-top: 1px solid var(--hairline); padding-block: 1.5rem 2rem; font-size: .92rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1rem 3rem; align-items: flex-start; }
.footer-nav, .contact { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.footer-nav a, .contact a { display: inline-flex; align-items: center; min-height: 2.75rem; }
.footer-nav a[aria-current="page"] { font-weight: 700; text-decoration-thickness: .14em; }
.footer-heading { font-size: .92rem; margin: 0; color: var(--muted); }
.copyright { flex-basis: 100%; margin: 0; color: var(--muted); }
.prose .contact { margin-bottom: 1rem; }

/* ------------------------------------------------------- компоненти */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.75rem; padding: .55rem 1.15rem;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  color: var(--accent); background: var(--surface);
  border: 2px solid var(--accent); border-radius: 999px;
}
.btn:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-block { width: 100%; }
.btn-large { font-size: 1.15rem; padding: .8rem 1.75rem; }

.notice {
  border: 1px solid var(--border); border-inline-start: 6px solid var(--accent);
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 1.5rem;
}
.notice h2 { margin-top: 0; }
.notice-error { border-color: var(--error); background: var(--error-soft); color: var(--error); font-weight: 600; }
.notice-success { border-color: var(--success); background: var(--success-soft); }

.tag {
  display: inline-block; padding: .05rem .6rem; font-size: .85rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: 999px; color: var(--text);
}
.tag-category { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------ форми */

.form > * + * { margin-top: 1.1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
label, legend { font-weight: 600; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"], select {
  width: 100%; min-height: 2.9rem; padding: .5rem .8rem;
  font: inherit; color: var(--text); background: var(--surface);
  border: 2px solid var(--border); border-radius: 10px;
}
input:hover, select:hover { border-color: var(--accent); }

fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; }
legend { padding: 0; margin-bottom: .5rem; font-size: 1.1rem; }

.check { display: flex; align-items: flex-start; gap: .7rem; padding: .45rem 0; }
.check input { flex: none; width: 1.5rem; height: 1.5rem; margin: .1rem 0 0; accent-color: var(--accent); }
.check label { font-weight: 400; }

/* ---------------------------------------------------------- каталог */

.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filters .field { flex: 1 1 12rem; }
.filters .field-grow { flex: 3 1 18rem; }

.search-hero h2 { margin-top: 0; }
.search-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.search-row .field { flex: 1 1 16rem; }

.stats { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem; }
.stats li { flex: 1 1 14rem; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 1rem 1.25rem; }
.stats strong { display: block; font-size: 1.6rem; line-height: 1.2; color: var(--accent); }

.letters { margin-bottom: 1.5rem; }
.letters summary {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 2.75rem; padding: .5rem 1rem;
  font-weight: 600; color: var(--accent); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.letters summary:hover { background: var(--accent-soft); }
.letters ul { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.letters a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.75rem; min-height: 2.75rem; padding: .25rem .6rem;
  font-weight: 700; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.letters a:hover { background: var(--accent-soft); }
.letters a[aria-current] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.results-heading { margin-top: 0; }

.book-list { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.book {
  display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: .75rem;
}
.book-main { flex: 1 1 18rem; min-width: 0; }
.book-title a { text-decoration: none; overflow-wrap: anywhere; }
.book-title a:hover { text-decoration: underline; }
.book-author { margin: .15rem 0 .35rem; font-weight: 600; }
.book-meta { margin: 0; color: var(--muted); font-size: .92rem; display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; }
.btn-download { flex: none; }

.pagination { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; padding-top: 1rem; border-top: 1px solid var(--hairline); }
.pagination p { margin: 0; font-weight: 600; }
.pagination ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.goto { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-inline-start: auto; }
.goto input { width: 6rem; }

/* ----------------------------------------------------------- детайли */

.details { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: .6rem 1.5rem; }
.details dt { font-weight: 600; color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }

.plain-list { list-style: none; padding: 0; }
.row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; margin-bottom: .75rem; }
.row form { margin: 0; }

/* --------------------------------------------------------- адаптация */

@media (max-width: 34rem) {
  h1 { font-size: 1.6rem; }
  .details { grid-template-columns: 1fr; gap: .1rem; }
  .details dd { margin-bottom: .6rem; }
  .btn-download { width: 100%; }
  .goto { margin-inline-start: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .letters a, input, select { transition: background-color .15s, border-color .15s, color .15s; }
}

@media (forced-colors: active) {
  .btn, .card, .book, .notice, .letters a { border: 1px solid CanvasText; }
  .site-nav a[aria-current="page"], .letters a[aria-current] { outline: 2px solid Highlight; }
}

@media print {
  .site-nav, .skip-link, .filters, .letters, .pagination, .btn, .footer-nav { display: none; }
}

.history li { padding: .6rem 0; border-bottom: 1px solid var(--hairline); }
.sub-heading { margin: 1.75rem 0 .75rem; }
.stats-line { font-size: 1.1rem; }
.stats-line strong { color: var(--accent); font-size: 1.4rem; }
.footer-account { margin: .5rem 0 0; color: var(--muted); }
.tag { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
.plain-list.tight { margin: 0; }
.plain-list.tight li + li { margin-top: .25rem; }
select { text-overflow: ellipsis; }
