/*
Theme Name: TR Kitap
Description: Türkiye ders kitapları kataloğu (Maarif Modeli) — okulyk.kz yapısında.
Version: 1.0
Text Domain: trkitap
*/

:root {
  --paper: #f5f6f8;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #5d6874;
  --line: #dfe3e8;
  --accent: #c2132f;        /* MEB kırmızısı — yalnızca vurgu */
  --accent-ink: #ffffff;
  --accent-soft: #fbe7ea;
  --f-head: "Outfit", "Segoe UI", system-ui, sans-serif;
  --f-body: "Work Sans", "Segoe UI", system-ui, sans-serif;
  --radius: 10px;
  --wrap: 1180px;
  --t-hover: 180ms;
  --tap: 44px;              /* минимальная цель нажатия */
}

/* Доступность: скрытая подпись и ссылка «к содержимому» */
.visually-hidden { position: absolute; 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: 16px; top: -100px; z-index: 100; background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; }
main:focus { outline: none; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }  /* полноширинные ленты не дают горизонтальной прокрутки */
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.55 var(--f-body);
}
a { color: inherit; transition: color var(--t-hover) ease, border-color var(--t-hover) ease, background-color var(--t-hover) ease; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
h1, h2, h3 { font-family: var(--f-head); line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 17px; font-weight: 700; }

/* Шапка */
.site-header { background: var(--surface); border-top: 4px solid var(--accent); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; gap: 20px; min-height: 64px; flex-wrap: wrap; }
.logo { font: 700 22px/1 var(--f-head); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); }
.logo b { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 4px 7px; font-size: 16px; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.nav a { text-decoration: none; color: var(--muted); display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 10px; }
.nav a:hover { color: var(--ink); }
.search { margin-left: auto; display: flex; flex: 0 1 300px; }
.search input { flex: 1; min-width: 0; min-height: var(--tap); font: inherit; font-size: 16px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px 0 0 8px; background: var(--paper); }
.search button { font: 600 15px var(--f-body); border: 0; background: var(--ink); color: var(--surface); padding: 0 16px; min-height: var(--tap); border-radius: 0 8px 8px 0; cursor: pointer; transition: background-color var(--t-hover) ease; }
.search button:hover { background: #2c3a48; }
@media (max-width: 760px) {
  .site-header { position: static; }      /* на телефоне шапка не съедает экран при прокрутке */
  .site-header .wrap { gap: 4px 12px; }
  .search { flex-basis: 100%; margin: 0 0 10px; }
}

main { padding-block: 28px 56px; display: grid; gap: 36px; }
.breadcrumbs { font-size: 14px; color: var(--muted); line-height: 1.4; }
.breadcrumbs a { color: var(--muted); padding-block: 12px; }  /* inline: зона нажатия больше, а строку не раздувает */
.breadcrumbs a:hover { color: var(--ink); }
.lede { color: var(--muted); margin: 8px 0 0; max-width: 70ch; }

/* Главная: классы */
.grades { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grade {
  display: grid; gap: 4px; padding: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none;
}
.grade { transition: border-color var(--t-hover) ease, transform var(--t-hover) ease; }
.grade:hover { border-color: var(--accent); }
.grade:active { transform: scale(0.98); }
.grade .num { font: 800 30px/1 var(--f-head); }
.grade .meta { font-size: 14px; color: var(--muted); }
/* Лента заголовка: белая полоса на всю ширину поверх серой страницы; красный — только акцентами */
.band {
  margin-inline: calc(50% - 50vw); padding: 20px calc(50vw - 50%) 22px;
  background: var(--surface); border-bottom: 1px solid var(--line); display: grid; gap: 6px;
}
main > .band:first-child { margin-top: -28px; }
.band .lede { margin: 0; }
@media (max-width: 760px) { .band { padding-block: 14px 16px; gap: 4px; } }
.band .stages { margin-top: 18px; }
.band .grade-chip { color: var(--ink); background: var(--paper); border-color: var(--line); }
.band .grade-chip:hover { background: var(--surface); border-color: var(--ink); color: var(--ink); }

/* Главная: классы по ступеням — компактные кнопки */
.stages { display: flex; flex-wrap: wrap; gap: 16px 22px; }
.stage { display: grid; gap: 8px; align-content: start; }
.stage__name { font: 600 15px var(--f-body); color: var(--muted); }
.stage__grades { display: flex; flex-wrap: wrap; gap: 8px; }
.grade-chip {
  display: inline-flex; align-items: center; justify-content: center; min-width: 52px; min-height: 52px; padding: 0 14px;
  font: 700 22px/1 var(--f-head); text-decoration: none; white-space: nowrap; font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color var(--t-hover) ease, color var(--t-hover) ease, transform 120ms ease;
}
.grade-chip--wide { font-size: 17px; }
.grade-chip:hover { border-color: var(--ink); }
.grade-chip:active { transform: scale(0.96); }
@media (max-width: 760px) { .stages { gap: 14px 20px; } .grade-chip { min-width: 48px; min-height: 48px; font-size: 20px; } }
@media (min-width: 761px) {
  /* на компьютере кнопки классов крупнее */
  .stages { gap: 20px 40px; }
  .stage__name { font-size: 16px; }
  .stage__grades { gap: 10px; }
  .grade-chip { min-width: 64px; min-height: 64px; font-size: 28px; border-radius: 12px; padding: 0 18px; }
  .grade-chip--wide { font-size: 19px; }
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
/* Предметы — плашками, как классы, но в плотной сетке */
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.subjects a {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px;
  font-weight: 600; line-height: 1.25; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color var(--t-hover) ease, transform 120ms ease;
}
.subjects a:hover { border-color: var(--ink); }
.subjects a:active { transform: scale(0.98); }
.subjects a span { color: var(--muted); font-weight: 400; font-size: 14px; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .subjects { grid-template-columns: repeat(2, minmax(0, 1fr)); } .subjects a { min-height: 48px; padding: 8px 12px; font-size: 15px; } }
.subject-groups { display: grid; gap: 28px; }
.subject-groups h3 { margin-bottom: 6px; }
/* Предметы на главной: карточки с иконкой (как «Тренируйся по предметам» на entkz) */
.subject-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.subject-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 18px 12px; min-height: 120px; text-align: center; text-decoration: none;
  font-weight: 600; font-size: 16px; line-height: 1.25;
  background: var(--surface); border: 2px solid #e6e1d8; border-radius: 16px;
  transition: border-color var(--t-hover) ease;
}
.subject-card__icon { width: 46px; height: 46px; flex: none; transition: transform 200ms ease; }
.subject-card__icon svg { width: 100%; height: 100%; display: block; }
.subject-card:hover { border-color: var(--ink); }
.subject-card:hover .subject-card__icon { transform: scale(1.06); }
@media (max-width: 760px) {
  .subject-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .subject-card { min-height: 104px; padding: 14px 8px; font-size: 15px; }
  .subject-card__icon { width: 40px; height: 40px; }
}
.subject-group { display: grid; gap: 10px; }
.subject-group h3 { font: 600 18px var(--f-head); display: flex; align-items: baseline; gap: 8px; margin: 0; }
.subject-group h3 span { color: var(--muted); font: 400 15px var(--f-body); }

/* Карточки книг */
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; }
/* Карточка книги: белая скруглённая подложка — обложка и подпись одним блоком */
.book {
  display: grid; gap: 8px; align-content: start; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 14px;
  transition: border-color var(--t-hover) ease;
}
.book:hover { border-color: #c3cad3; }
.book .title, .book .sub { padding-inline: 4px; }
.book .cover { aspect-ratio: 3 / 4; background: var(--line); border-radius: 6px; overflow: hidden; }
.book .cover img { width: 100%; height: 100%; object-fit: cover; }
.book .title { font-weight: 600; line-height: 1.3; }
.book .sub { font-size: 14px; color: var(--muted); }
.book .title { transition: color var(--t-hover) ease; }
.book .cover img { transition: transform 300ms ease; }
.book:hover .title { color: var(--accent); }
.book:hover .cover img { transform: scale(1.02); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.group { display: grid; gap: 14px; scroll-margin-top: 90px; }
.jump { display: flex; flex-wrap: wrap; gap: 8px; }
.jump a { text-decoration: none; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.jump a:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 760px) {
  /* на телефоне облако компактнее: меньше шрифт и высота, промежутки сохраняют удобство нажатия */
  .jump { gap: 6px; }
  .jump a { font-size: 14px; min-height: 36px; padding: 0 12px; }
}

/* Страница книги */
.book-page { display: grid; grid-template-columns: 260px 1fr; gap: 32px; align-items: start; }
@media (max-width: 760px) { .book-page { grid-template-columns: 1fr; } .book-page .cover-big { max-width: 220px; } }
.cover-big { border-radius: 8px; overflow: hidden; box-shadow: 0 4px 18px rgba(0,0,0,.12); background: var(--line); }
.facts { border-collapse: collapse; width: 100%; margin-top: 18px; }
.facts th, .facts td { text-align: left; padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.facts td a { display: inline-block; padding-block: 12px; margin-block: -12px; }  /* цель нажатия 44px без сдвига строки */
.facts th { width: 170px; color: var(--muted); font-weight: 400; padding-right: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); font: 600 16px var(--f-head); text-decoration: none; padding: 12px 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, transform 120ms ease; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary:hover { background: #a50f27; border-color: #a50f27; }
.btn:active { transform: scale(0.98); }
.note { font-size: 14px; color: var(--muted); }

/* Плеер */
.reader { background: #2b3036; border-radius: var(--radius); overflow: hidden; }
.reader-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; background: #1f2328; color: #e9ecef; font-size: 14px; }
.reader-bar button { font: 600 15px var(--f-body); background: #3a4048; color: #fff; border: 0; border-radius: 6px; padding: 0 12px; cursor: pointer; min-width: var(--tap); min-height: var(--tap); transition: background-color var(--t-hover) ease; }
.reader-bar input { min-height: var(--tap); }
.reader-bar button:hover { background: #4a515a; }
.reader-bar .pos { font-variant-numeric: tabular-nums; }
.reader-bar input { width: 56px; font: inherit; padding: 4px 6px; border-radius: 6px; border: 0; text-align: center; }
.reader-bar .grow { flex: 1; }
.reader-pages { height: min(85vh, 1100px); overflow: auto; display: grid; justify-items: center; gap: 12px; padding: 16px; }
.reader-page { background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.35); position: relative; max-width: 100%; }
.reader-page canvas { display: block; width: 100%; height: auto; }
.reader-page .pnum { position: absolute; right: 8px; bottom: 6px; font-size: 12px; color: #888; }
.reader-status { color: #e9ecef; padding: 40px 16px; text-align: center; }
.reader iframe { width: 100%; height: min(85vh, 1100px); border: 0; display: block; background: #fff; }
.reader:fullscreen .reader-pages, .reader:fullscreen iframe { height: calc(100vh - 52px); }
.reader--flip iframe { height: min(88vh, 1100px); }

/* Кнопка «Online oku» и раздел плеера */
.btn-read { margin-top: 16px; font-size: 17px; padding-inline: 26px; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.reader-section { scroll-margin-top: 80px; }
.reader-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.reader-close { display: none; }
.book-about { display: grid; gap: 10px; }

/* Плеер на весь экран (телефон, после «Online oku») */
html.reader-lock, html.reader-lock body { overflow: hidden; }
.reader-section.is-full {
  position: fixed; inset: 0; z-index: 1000; margin: 0; background: #1f2328;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.reader-section.is-full .reader-section__head { margin: 0; padding: 8px 10px 8px 16px; }
.reader-section.is-full h2 { font-size: 16px; color: #fff; }
.reader-section.is-full .reader-close {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--accent); color: #fff; font: 400 30px/1 var(--f-body);
}
.reader-section.is-full .reader-close:active { transform: scale(0.94); }
.reader-section.is-full [data-act="full"] { display: none; }  /* уже на весь экран */
.reader-section.is-full .reader { flex: 1; min-height: 0; border-radius: 0; display: flex; flex-direction: column; }
.reader-section.is-full .reader-pages, .reader-section.is-full .reader iframe { flex: 1; height: auto; min-height: 0; }
/* Кнопка «Kitabı aç» — только там, где встроенный PDF не листается (телефоны, планшеты) */
.reader-open { display: none; align-items: center; gap: 16px; padding: 14px; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; text-decoration: none; }
.reader-open img { width: 84px; height: auto; border-radius: 6px; flex: none; }
.reader-open strong { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 18px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font: 600 17px var(--f-head); margin-bottom: 8px; }
.reader-open > span { display: grid; justify-items: start; color: var(--muted); font-size: 15px; }
@media (max-width: 900px), (pointer: coarse) {
  .reader--native { display: none; }
  .reader-open { display: flex; }
  .reader--flip iframe { height: 82vh; }
}

.site-footer { background: var(--ink); font-size: 14px; color: #c9d1d9; padding-block: 32px; }
.site-footer .wrap { display: grid; gap: 8px; }
.site-footer .logo { color: #fff; margin-bottom: 4px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 6px; }
.footer-links a { color: #e6eaee; text-decoration: none; padding-block: 6px; }
.footer-links a:hover { color: #fff; text-decoration: underline; }
/* Текстовые страницы (о нас, политика и т. п.) */
.page-content { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: clamp(20px, 4vw, 40px); max-width: 820px; }
.page-content h2 { margin: 28px 0 10px; }
.page-content p, .page-content li { max-width: 70ch; }
.book-intro { margin: 16px 0 0; max-width: 70ch; color: var(--ink); }
.site-footer a { color: #fff; }
.pagination { display: flex; gap: 6px; flex-wrap: wrap; }
.pagination .page-numbers { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: var(--surface); }
.pagination .current { background: var(--ink); color: var(--surface); }
