/* CodeArt: печатные коллажи и учебные материалы */
.reading, .reading-card {
  --text: #221e2a;
  --muted: #625b6a;
  --rule: #d9d5d2;
  --accent: #d6f869;
  --wash: #eff7ce;
}
.reading.history, .reading-card.history { --accent: #ffc84e; --wash: #fff0c7; }
.reading.social, .reading-card.social { --accent: #caa5fe; --wash: #f1e6ff; }
.reading.code, .reading-card.code { --accent: #c8ef63; --wash: #edf6d3; }
.reading { color: var(--text); background: #faf8f4; }
.reading [hidden] { display: none !important; }
.reading :focus-visible, .reading-card:focus-visible { outline: 3px solid #7952d4; outline-offset: 4px; }
.reading-head, .reading-head nav, .reading-foot { display: flex; align-items: center; justify-content: space-between; gap: clamp(12px,3vw,36px); }
.reading-head { padding-block: 13px; border-bottom: 1px solid var(--rule); }
.reading-head img { display: block; width: 105px; height: auto; }
.reading-head nav { font-size: .9rem; font-weight: 500; }
.reading-head nav a, .reading-foot a, .reading-crumb a { text-decoration: none; }
.reading-head nav a:last-child { border: 1px solid #a9a2aa; padding: 7px 13px; border-radius: 20px; }
.reading-head nav a:hover, .reading-foot a:hover, .reading-crumb a:hover { text-decoration: underline; text-underline-offset: .25em; }
.reading-crumb { display: flex; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); margin: 17px 2px; }
.reading-foot { flex-wrap: wrap; padding-block: 24px; margin-top: 44px; border-top: 1px solid var(--rule); font-size: .87rem; }
.reading-hero {
  position: relative; isolation: isolate; overflow: hidden; border-radius: 24px;
  display: grid; grid-template-columns: minmax(0,1.08fr) minmax(0,.92fr); align-items: center;
  padding: clamp(30px,4.2vw,60px); gap: clamp(14px,2.5vw,36px);
  color: #fffaf1; background-color: #282333;
  background-image: radial-gradient(ellipse at 93% 24%,#69508475,transparent 58%), radial-gradient(#ffffff1f .8px,transparent 1px);
  background-size: auto, 8px 8px;
}
.reading-hero .hero-copy { position: relative; z-index: 2; min-width: 0; }
.reading-hero .hero-copy small { display: inline-flex; align-items: center; gap: 10px; color: #fff9ed; font-size: .75rem; font-weight: 700; letter-spacing: .04em; }
.reading-hero .hero-copy small::before { content: ''; width: 25px; height: 3px; background: var(--accent); }
.reading-hero h1 { margin: 15px 0; letter-spacing: -.055em; font-size: clamp(1.85rem,3.25vw,3rem); line-height: 1.13; hyphens: auto; }
.catalog .reading-hero h1 { font-size: clamp(2.65rem,5.2vw,4.85rem); line-height: 1.02; }
.reading-hero h1 em { color: var(--accent); font-style: normal; }
.reading-hero .hero-copy p { max-width: 51ch; color: #ebe3ef; font-size: clamp(.96rem,1.36vw,1.1rem); line-height: 1.53; }
.cover-action, .quiz-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 20px; min-height: 45px;
  padding: 10px 18px; border: 1px solid transparent; border-radius: 9px; font-size: .92rem;
  font-weight: 700; line-height: 1.3; text-decoration: none; cursor: pointer;
}
.cover-action { margin-top: 23px; background: var(--accent); color: #221e2a; }
.cover-action span { font-size: 1.15rem; line-height: 1; }
.cover-action:hover { background: #fffaf1; }
.cover-stack, .story-cover { position: relative; isolation: isolate; width: 100%; }
.cover-stack { aspect-ratio: 1.65; }
.cover-stack::before, .story-cover::before {
  content: ''; position: absolute; z-index: -1; inset: -8% -10%;
  border: 1px dashed #e4cbff77; border-radius: 50%; transform: rotate(-17deg);
}
.cover-stack::after {
  content: ''; position: absolute; top: -2%; right: 2%; width: 14%; aspect-ratio: 1; background: #c9a7f8;
  clip-path: polygon(50% 0,58% 29%,80% 7%,74% 37%,100% 32%,80% 51%,100% 66%,72% 64%,78% 94%,55% 74%,46% 100%,40% 73%,14% 93%,25% 65%,0 67%,18% 49%,0 31%,29% 37%,20% 9%,42% 28%);
}
.print, .story-cover img { background: #fffaf3; padding: 5px; box-shadow: 2px 9px 15px #16111d60; }
.print { position: absolute; width: 46%; border-radius: 2px; }
.print img { width: 100%; display: block; }
.print-0 { top: 7%; left: 0; transform: rotate(-15deg); }
.print-1 { top: 22%; left: 24%; transform: rotate(3deg); }
.print-2 { top: 9%; right: 0; transform: rotate(14deg); }
.story-cover { justify-self: center; width: min(72%,255px); aspect-ratio: 1; margin: 8px 0; }
.story-cover img { width: 100%; transform: rotate(5deg); }
.story-cover::before { inset: 7% -23%; transform: rotate(-35deg); }
.story-cover::after { content: ''; position: absolute; top: -3%; left: 34%; width: 34%; height: 8%; transform: rotate(-5deg); background: #f6dfadcf; clip-path: polygon(2% 4%,99% 0,96% 30%,100% 53%,96% 78%,98% 99%,0 96%,3% 74%,0 58%,3% 34%); }
.library { margin: clamp(38px,5vw,70px) 0; }
.library-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; border-bottom: 1px solid var(--rule); padding-bottom: 16px; }
.library h2 { font-size: clamp(1.55rem,3vw,2.45rem); letter-spacing: -.045em; }
.topic-filter, .trace-controls { display: flex; flex-wrap: wrap; gap: 7px; }
.topic-filter button, .trace-controls button {
  min-height: 40px; padding: 6px 14px; border: 1px solid #c8c2c8; border-radius: 999px;
  color: #352f3d; background: transparent; cursor: pointer; font-size: .87rem; font-weight: 500;
}
.topic-filter button[aria-pressed="true"], .trace-controls button[aria-pressed="true"] { background: var(--text); color: white; border-color: var(--text); }
.topic-filter button:hover, .trace-controls button:hover { border-color: var(--text); }
.reading-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: clamp(14px,2vw,24px); margin: 23px 0 32px; }
.reading-card { display: flex; flex-direction: column; overflow: hidden; border-radius: 15px; border: 1px solid var(--rule); background: #fffdfa; color: var(--text); text-decoration: none; transition: transform .2s ease,box-shadow .2s ease; }
.card-art { position: relative; overflow: hidden; aspect-ratio: 1.94; background: var(--wash); }
.card-art img { width: 100%; height: 100%; object-fit: cover; object-position: center 42%; transition: transform .35s ease; }
.card-art small { position: absolute; bottom: 12px; left: 14px; background: #fffaf1; padding: 3px 10px; border: 1px solid #221e2a; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.card-copy { display: flex; flex-direction: column; flex: 1; padding: clamp(17px,1.8vw,24px); }
.card-kind { color: var(--muted); font-size: .76rem; font-weight: 500; }
.reading-card h3 { margin: 7px 0 10px; font-size: clamp(1.05rem,1.55vw,1.34rem); letter-spacing: -.033em; line-height: 1.25; text-wrap: pretty; hyphens: auto; }
.card-copy p { margin: 0 0 21px; font-size: .94rem; line-height: 1.5; color: #544c59; }
.card-copy b { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 11px; border-top: 1px solid var(--rule); font-size: .85rem; }
.card-copy i { display: grid; place-items: center; width: 29px; height: 29px; background: var(--wash); border-radius: 50%; font: normal 1.06rem/1 system-ui; }
@media (hover: hover) {
  .reading-card:hover { transform: translateY(-4px); box-shadow: 0 9px 24px #28173510; border-color: #ada4b1; }
  .reading-card:hover img { transform: scale(1.035); }
  .reading-card:hover i { background: var(--accent); }
}

.reading-layout { display: grid; grid-template-columns: minmax(0,70ch) minmax(160px,25%); justify-content: space-between; gap: clamp(30px,5vw,80px); max-width: 1060px; margin: clamp(32px,4vw,58px) auto; }
.reading-body { min-width: 0; font-size: clamp(1rem,1.4vw,1.1rem); line-height: 1.72; }
.reading-body h2 { font-size: clamp(1.28rem,2.15vw,1.8rem); line-height: 1.25; letter-spacing: -.035em; margin: 1.75em 0 .5em; }
.reading-body > h2:first-child { margin-top: 0; }
.reading-body h3 { font-size: 1.1rem; margin: 1.4em 0 .5em; }
.reading-body p { margin: 10px 0; }
.reading-body ol, .reading-body ul { padding-left: 1.4em; list-style: revert; }
.reading-body li + li { margin-top: .3em; }
.reading-body a:not(.btn), .reading-layout aside a:hover { color: #603395; text-decoration: underline; text-underline-offset: .17em; }
.reading-body blockquote { margin: 20px 0; padding: 12px 22px; border-left: 4px solid var(--accent); background: var(--wash); }
.reading-body details:not(.story-contents) { margin: 16px 0; padding: 13px 16px; background: white; border: 1px solid var(--rule); border-radius: 10px; }
.reading summary { cursor: pointer; font-weight: 700; }
.reading-body pre { margin: 18px 0; border-radius: 13px; padding: clamp(14px,2vw,24px); overflow: auto; color: #f5f1ff; background: #292433; font: .91rem/1.6 ui-monospace,monospace; tab-size: 4; }
.reading-body :not(pre) > code { background: #e9e4eb; padding: .1em .28em; border-radius: 4px; overflow-wrap: anywhere; }
.reading-layout aside { align-self: start; position: sticky; top: 28px; padding: 17px; border: 1px solid var(--rule); border-top: 4px solid var(--accent); border-radius: 10px; background: #fffdfa; font-size: .9rem; line-height: 1.52; }
.reading-layout aside hr { height: 1px; margin: 18px 0 14px; border: 0; background: var(--rule); }
.reading-layout aside nav { display: grid; gap: 9px; margin-top: 11px; }
.reading-layout aside a { display: block; color: #524759; text-decoration: none; }
.reading-layout aside > a { margin-top: 7px; }

.lesson-figure, .lesson-table { padding: clamp(16px,2.4vw,26px); border: 1px solid #d5cec9; border-radius: 16px; margin: 24px 0; background: #fffefa; }
.lesson-figure figcaption, .lesson-table caption { text-align: left; color: #282231; font-family: var(--font-display); font-size: clamp(.99rem,1.6vw,1.18rem); letter-spacing: -.025em; line-height: 1.4; }
.reading-body .lesson-figure p { font-size: .91rem; line-height: 1.52; }
.reading-body .lesson-flow { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 17px; padding: 0; margin: 18px 0 0; list-style: none; }
.reading-body .lesson-flow li { position: relative; padding: 13px; margin: 0; border: 1px solid #d2cbc8; border-radius: 9px; background: #f7f3ee; line-height: 1.46; }
.reading-body .lesson-flow li:last-child { background: var(--wash); }
.lesson-flow li:not(:last-child)::after { content: '→'; position: absolute; right: -18px; width: 18px; top: 50%; transform: translateY(-50%); text-align: center; color: #53425b; }
.lesson-flow b, .lesson-flow span { display: block; }
.lesson-flow b { margin-bottom: 5px; font-size: .88rem; }
.lesson-flow span { font-size: .88rem; overflow-wrap: anywhere; }
.lesson-table table { width: 100%; border-collapse: collapse; font-size: .9rem; text-align: left; line-height: 1.48; table-layout: fixed; }
.lesson-table caption { padding-bottom: 13px; }
.lesson-table th, .lesson-table td { padding: 10px 8px; vertical-align: top; overflow-wrap: anywhere; hyphens: auto; }
.lesson-table thead { background: var(--wash); }
.lesson-table th:first-child { width: 28%; }
.lesson-table tbody tr + tr { border-top: 1px solid var(--rule); }
.chart-row { display: grid; grid-template-columns: minmax(74px,auto) 1fr 38px; gap: 10px; align-items: center; margin-top: 13px; font-size: .85rem; }
.bar-track { height: 19px; overflow: hidden; border-radius: 4px; background: repeating-linear-gradient(to right,#eee8f3 0 calc(25% - 1px),#cfc5da calc(25% - 1px) 25%); }
.bar-track i { display: block; height: 100%; background: #796098; }
.chart-row + .chart-row .bar-track i { background: #9f60ab; }
.reading-body .chart-note { margin: 18px 0 0; padding-top: 10px; border-top: 1px solid var(--rule); }
.trace-controls { margin: 15px 0 0; }
.trace-controls button { font-size: .83rem; }

.reading-quiz, .reading-cta { margin: 38px 0 0; border-radius: 18px; padding: clamp(18px,3vw,34px); }
.reading-quiz { background: #eee6fc; border: 1px solid #cfbfdf; }
.reading-body .reading-quiz h2, .reading-body .reading-cta h2 { margin: 0 0 12px; }
.quiz-meter { display: flex; align-items: center; gap: 13px; margin: 16px 0 19px; }
.quiz-count { flex: none; color: #59496d; font-size: .82rem; font-weight: 700; }
.quiz-meter progress { flex: 1; width: 100%; height: 7px; border: 0; border-radius: 99px; overflow: hidden; background: #d8cce7; color: #7952b9; appearance: none; }
.quiz-meter progress::-webkit-progress-bar { background: #d8cce7; }
.quiz-meter progress::-webkit-progress-value { background: #7952b9; border-radius: 99px; transition: width .35s ease; }
.quiz-meter progress::-moz-progress-bar { background: #7952b9; border-radius: 99px; }
.reading-quiz fieldset { border: 0; padding: 0; margin: 0; min-width: 0; animation: quiz-enter .28s ease-out; }
.reading-quiz legend { padding: 0; margin: 0 0 12px; font-weight: 700; line-height: 1.45; }
.quiz-choice { position: relative; display: flex; align-items: flex-start; gap: 11px; margin: 8px 0; padding: 10px 13px; min-height: 45px; border: 1px solid #cbc1d5; border-radius: 9px; background: #fffdfa; line-height: 1.48; font-size: .97rem; cursor: pointer; }
.quiz-choice input { flex: none; width: 17px; height: 17px; margin: .2em 0 0; accent-color: #68479c; }
.quiz-choice:has(:checked) { background: #f7f2ff; border-color: #7451a9; box-shadow: inset 0 0 0 1px #7451a9; }
.quiz-choice:has(:focus-visible) { outline: 3px solid #7952d4; outline-offset: 2px; }
.quiz-choice:has(:disabled) { cursor: default; }
.quiz-choice.correct, .quiz-choice.incorrect { padding-right: 36px; box-shadow: none; }
.quiz-choice.correct { border-color: #58804b; background: #e7f4df; animation: quiz-confirm .42s ease-out; }
.quiz-choice.incorrect { border-color: #b95651; background: #fff0ed; animation: quiz-nudge .25s ease-in-out; }
.quiz-choice.correct::after, .quiz-choice.incorrect::after { position: absolute; right: 13px; font-weight: 700; }
.quiz-choice.correct::after { content: '✓'; color: #316331; }
.quiz-choice.incorrect::after { content: '×'; color: #973a36; }
.feedback { margin: 13px 0 3px; padding: 10px 13px; background: #fffaf6; border-left: 3px solid #966242; font-size: .94rem; animation: quiz-enter .26s ease-out; }
.feedback.is-right { border-color: #4f7b45; }
.quiz-action { margin-top: 12px; background: #302637; color: white; }
.quiz-action:not(:disabled):hover { background: #563878; }
.quiz-action:disabled { background: #d4c9df; color: #544d5c; cursor: default; }
.quiz-result { padding: 16px 0; animation: quiz-enter .36s ease-out; }
.result-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: #d2ee82; border: 1px solid #544a67; font: bold 1.55rem/1 system-ui; animation: result-pop .45s ease-out; }
.reading-body .quiz-result h3 { margin: 12px 0 6px; font-size: 1.55rem; }
.quiz-review { font-size: .93rem; }
.quiz-review p, .quiz-review strong { font-weight: 700; }
.reading-cta { color: #fffaf1; background: #302939; }
.reading-body .reading-cta p { color: #e9e0f0; }
.reading-cta a.btn { margin: 9px 6px 0 0; background: var(--accent); color: #282231; min-height: 45px; padding: 10px 15px; line-height: 1.35; text-align: center; }
@keyframes quiz-enter { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes quiz-confirm { from { box-shadow: 0 0 0 3px #7aa86e66; } to { box-shadow: 0 0 0 8px transparent; } }
@keyframes quiz-nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes result-pop { from { transform: scale(.7) rotate(-12deg); } 70% { transform: scale(1.08) rotate(3deg); } to { transform: scale(1); } }

@media (max-width: 950px) {
  .reading-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 800px) {
  .reading-layout { display: flex; flex-direction: column; gap: 22px; }
  .reading-layout aside { order: -1; position: static; width: 100%; padding: 11px 15px; }
  .reading-layout aside hr, .reading-layout aside > b, .reading-layout aside > a { display: none; }
}
@media (max-width: 680px) {
  .reading-hero { grid-template-columns: minmax(0,1fr); gap: 15px; padding: 24px; }
  .cover-stack { width: min(90%,340px); aspect-ratio: 2.05; justify-self: center; margin: 0 0 15px; }
  .cover-stack::before { inset: 2% -8%; }
  .catalog .reading-hero .hero-copy p { max-width: 40ch; }
  .story-cover { width: min(63%,190px); margin: 8px 0; }
  .library { margin-top: 32px; }
  .reading-crumb { margin-block: 12px; }
  .reading-head nav { font-size: .78rem; gap: 12px; }
  .reading-head img { width: 79px; }
  .reading-head nav a:last-child { padding: 5px 8px; }
  .reading-grid { gap: 14px; }
}
@media (max-width: 520px) {
  .reading-grid { grid-template-columns: 1fr; }
  .topic-filter { gap: 6px; }
  .topic-filter button { padding-inline: 10px; font-size: .78rem; }
  .reading-body .lesson-flow { grid-template-columns: 1fr; gap: 18px; }
  .lesson-flow li:not(:last-child)::after { content: '↓'; inset: auto auto -20px 17px; transform: none; }
  .lesson-table { padding: 13px 9px; }
  .lesson-table th, .lesson-table td { font-size: .81rem; padding-inline: 5px; }
}
@media (max-width: 355px) {
  .reading-head nav { gap: 8px; font-size: .72rem; }
  .reading-head img { width: 65px; }
  .reading-hero { padding-inline: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  html:has(.reading) { scroll-behavior: auto; }
  .reading *, .reading *::before, .reading *::after, .reading-card, .reading-card img { transition: none !important; animation: none !important; }
}
