/* =========================================================
   Сайт книги Maximov Alexander
   «Как стать носителем иностранных языков за 4 месяца»
   Стиль: строго чёрно-белый. Светлая и тёмная темы.
   ========================================================= */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #111111;
  --muted: #5c5c5c;
  --line: #111111;
  --line-soft: #d9d9d9;
  --mark-bg: #ececec;
  --header-bg: rgba(255, 255, 255, 0.92);
  --header-offset: 70px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --fg: #f2f2f2;
  --muted: #a5a5a5;
  --line: #f2f2f2;
  --line-soft: #2c2c2c;
  --mark-bg: #242424;
  --header-bg: rgba(13, 13, 13, 0.92);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

img {
  max-width: 100%;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

.container {
  width: min(1180px, 100% - 40px);
  margin-inline: auto;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
}

.skip-link:focus {
  left: 10px;
  top: 10px;
}

/* ---------- Шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.header-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 22px;
  padding: 12px 0;
}

.brand {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
}

.brand:hover {
  opacity: 0.7;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-left: auto;
}

.site-nav a {
  font-size: 0.95rem;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}

.site-nav a:hover {
  border-color: currentColor;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-select {
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  padding: 7px 9px;
  border-radius: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
}

.theme-toggle:hover {
  background: var(--fg);
  color: var(--bg);
}

.theme-toggle svg {
  display: block;
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ---------- Language suggestion banner ---------- */

.lang-banner {
  padding: 10px 0;
  background: var(--mark-bg);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.92rem;
}

.lang-banner-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.lang-banner[hidden] {
  display: none;
}

.lang-banner-text {
  flex: 1 1 240px;
  margin: 0;
}

.lang-banner .btn--small {
  padding: 6px 12px;
}

.lang-banner-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  border: 1px solid var(--line);
  font-size: 1.1rem;
  line-height: 1;
}

.lang-banner-close:hover {
  background: var(--fg);
  color: var(--bg);
}

/* ---------- Первый экран ---------- */

.hero {
  padding: clamp(44px, 8vw, 96px) 0 clamp(34px, 6vw, 64px);
  border-bottom: 1px solid var(--line-soft);
}

.hero-author {
  margin: 0 0 18px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-title {
  margin: 0 0 18px;
  max-width: 24ch;
  font-size: clamp(1.9rem, 5vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.hero-lead {
  margin: 0 0 14px;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 600;
}

.hero-text {
  margin: 0 0 26px;
  max-width: 66ch;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: var(--fg);
  color: var(--bg);
}

.btn--primary {
  background: var(--fg);
  color: var(--bg);
}

.btn--primary:hover {
  background: transparent;
  color: var(--fg);
}

.btn--small {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn--disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- Секции ---------- */

.section {
  padding: clamp(40px, 6vw, 76px) 0;
  border-bottom: 1px solid var(--line-soft);
  scroll-margin-top: calc(var(--header-offset, 70px) + 16px);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 28px;
  margin-bottom: 28px;
}

.section-head-text {
  flex: 1 1 320px;
}

.section-head .section-title {
  margin-bottom: 8px;
}

.section-head .section-lead {
  margin-bottom: 0;
}

.book-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.section-lead {
  margin: 0 0 28px;
  max-width: 70ch;
  color: var(--muted);
}

/* ---------- Плитки глав ---------- */

.chapters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  column-gap: 16px;
  row-gap: 0;
  grid-auto-rows: 2px;
  align-items: start;
}

.tile {
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--line);
  background: var(--bg);
  scroll-margin-top: calc(var(--header-offset, 70px) + 16px);
}

.tile-heading {
  display: flex;
  flex: 1 1 auto;
  margin: 0;
}

.tile-heading .tile-toggle {
  flex: 1 1 auto;
}

.tile-toggle {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  padding: 18px 18px 16px;
  text-align: left;
}

.tile-toggle:hover {
  background: var(--fg);
  color: var(--bg);
}

.tile-toggle:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: -5px;
}

.tile-toggle:hover:focus-visible {
  outline-color: var(--bg);
}

.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.tile-number {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tile-toggle:hover .tile-number {
  color: inherit;
  opacity: 0.75;
}

.tile-marker {
  flex: none;
  font-size: 1.45rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.tile.is-open .tile-marker {
  transform: rotate(45deg);
}

.tile-title {
  display: block;
  font-size: clamp(1.05rem, 1.8vw, 1.28rem);
  font-weight: 800;
  line-height: 1.28;
}

.tile-preview {
  display: block;
  margin-top: 14px;
}

.tile-preview-item {
  display: block;
  margin-top: 8px;
  padding-left: 14px;
  text-indent: -14px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.tile-preview-item::before {
  content: '•';
  display: inline-block;
  width: 14px;
  text-indent: 0;
}

.tile-toggle:hover .tile-preview-item {
  color: inherit;
  opacity: 0.85;
}

.tile-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s ease;
}

.tile.is-open .tile-body {
  grid-template-rows: 1fr;
}

.tile-body-inner {
  overflow: hidden;
  min-height: 0;
}

.tile-content {
  border-top: 1px solid var(--line);
  padding: 18px 18px 22px;
}

.tile-content p {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

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

.tile-content mark {
  background: var(--mark-bg);
  color: inherit;
  padding: 0 0.08em;
}

.tile-content .tile-list {
  margin: 0 0 12px;
  padding-left: 1.6em;
  font-size: 0.98rem;
}

.tile-content .tile-list:last-child {
  margin-bottom: 0;
}

.tile-content li {
  margin: 0;
}

.tile-content li + li {
  margin-top: 4px;
}

.tile-content ol.tile-list > li::marker {
  font-weight: 700;
}

.tile-content figure {
  margin: 18px 0 0;
}

.tile-content figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line-soft);
  background: #ffffff;
  /* Для строго чёрно-белого графика раскомментируйте: filter: grayscale(1); */
}

.table-scroll {
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
}

.tile-content table {
  width: 100%;
  min-width: 460px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.tile-content th,
.tile-content td {
  border: 1px solid var(--line-soft);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  white-space: pre-line;
}

.tile-content thead th {
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
}

/* ---------- Карточки приложений и поддержки ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  border: 1.5px solid var(--line);
}

.card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.card-text {
  margin: 0;
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 0.95rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag {
  align-self: flex-start;
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid var(--line);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.note {
  margin: 18px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ---------- Подвал ---------- */

.site-footer {
  padding: 44px 0 28px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 28px;
}

.footer-title {
  margin: 0 0 12px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer-author {
  margin: 0 0 6px;
  font-weight: 800;
}

.footer-book {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.footer-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}

.footer-list a {
  text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
}

.footer-list a:hover {
  border-color: currentColor;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- Адаптив ---------- */

@media (max-width: 720px) {
  .header-inner {
    gap: 10px 14px;
  }

  .site-nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    gap: 14px;
  }

  .header-controls {
    margin-left: auto;
  }

  .tile-toggle {
    padding: 16px 15px 14px;
  }

  .tile-content {
    padding: 16px 15px 20px;
  }
}

/* ---------- Печать и PDF ---------- */

@media print {
  @page {
    margin: 16mm;
  }

  html {
    scroll-behavior: auto;
  }

  body {
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
  }

  .site-header,
  .skip-link,
  .lang-banner,
  .book-toolbar,
  .hero-actions,
  #apps,
  #support,
  .site-footer,
  .tile-marker,
  noscript {
    display: none !important;
  }

  .hero {
    padding: 0 0 18px;
    border-bottom: 1px solid #000000;
  }

  .hero-title {
    max-width: none;
    font-size: 24pt;
  }

  .hero-lead,
  .hero-text {
    color: #000000;
  }

  .section {
    padding: 0;
    border: 0;
  }

  .section-head {
    display: block;
    margin-bottom: 14px;
  }

  .chapters {
    display: block;
  }

  .tile {
    margin: 0 0 14px;
    border: 0;
    border-top: 1px solid #000000;
  }

  .tile-heading {
    display: block;
  }

  .tile-toggle {
    padding: 8px 0;
  }

  .tile-toggle:hover {
    background: transparent;
    color: inherit;
  }

  .tile-head {
    margin-bottom: 4px;
  }

  .tile-number {
    color: #000000;
  }

  .tile-title {
    font-size: 14pt;
  }

  .tile-preview {
    display: none;
  }

  .tile-body {
    display: block !important;
    grid-template-rows: 1fr !important;
  }

  .tile-body-inner {
    overflow: visible;
  }

  .tile-content {
    padding: 0 0 10px;
    border-top: 0;
  }

  .tile-content p {
    font-size: 11pt;
  }

  .tile-content .tile-list {
    font-size: 11pt;
  }

  .tile-content mark {
    background: #eeeeee;
  }

  .tile-content figure img {
    border: 1px solid #999999;
  }

  .table-scroll {
    overflow: visible;
    border: 1px solid #000000;
  }

  .tile-content table {
    min-width: 0;
    font-size: 9pt;
  }

  .tile-content th,
  .tile-content td {
    border-color: #999999;
  }

  .tile-content thead th {
    background: #000000;
    color: #ffffff;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}