/* Блок «Олимпиада — это не только баллы и грамоты» — «Тетрадь и маркер» (home/_learning_notebook.html.erb).
   Страница тетради в клетку: крупный журнальный заголовок с пометками маркером, лист с заданием,
   приклеенный скотчем, пометки ручкой на полях. Два «инструмента»: маркер (широкие цветные мазки)
   и фиолетовая ручка (тонкие линии — стрелки, галочка, звезда, курсивные подписи).
   Появление: reveal ставит секции is-seen — линии и мазки прочерчиваются. Нарисованное состояние —
   основное; «ненарисованное» включается только на компьютере, со скриптами и без reduced-motion. */

.l2{
  --l2-ink: #24243e;
  --l2-text: #4a4d66;
  --l2-vio: #6744d4;
  --l2-y: #fbd163;          /* маркеры — фирменные цвета, разбавленные бумагой */
  --l2-c: #94dcee;
  --l2-p: #f6b0d7;
  --l2-paper: #fbf8f0;
  --l2-fs: clamp(46px, 4.9vw, 70px);
  --l2-ease: cubic-bezier(.2, .75, .2, 1);
  position: relative; isolation: isolate; overflow: hidden;
  scroll-margin-top: 24px;
  padding: 82px 0 104px;
  color: var(--l2-ink);
  background: linear-gradient(#fff, var(--l2-paper) 120px, var(--l2-paper) calc(100% - 150px), #fdfcf8);
}
/* клетка */
.l2::before{
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(84, 70, 160, .075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 70, 160, .075) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: calc(50% - 8px) 18px;
  -webkit-mask-image: linear-gradient(transparent, #000 140px, #000 calc(100% - 170px), transparent);
          mask-image: linear-gradient(transparent, #000 140px, #000 calc(100% - 170px), transparent);
}
/* красная линия полей */
.l2::after{
  content: ""; position: absolute; top: 0; bottom: 0; z-index: -1; pointer-events: none;
  left: calc(50% - 560px - 56px); width: 2px;
  background: rgba(232, 111, 181, .42);
  -webkit-mask-image: linear-gradient(transparent, #000 140px, #000 calc(100% - 170px), transparent);
          mask-image: linear-gradient(transparent, #000 140px, #000 calc(100% - 170px), transparent);
}
.l2-in{ position: relative; }

/* ───────── верх: заголовок, лист, кнопка ───────── */
.l2-top{
  display: grid; align-items: start;
  grid-template-columns: minmax(0, 46fr) minmax(0, 58fr);
}

.l2-title{
  grid-column: 1 / -1; grid-row: 1;
  position: relative; z-index: 1;
  font-size: var(--l2-fs); line-height: .98; font-weight: 800; letter-spacing: -.038em;
  color: var(--l2-ink);
}
.l2 .l2-br-m{ display: none; }

/* «не только» — закрашено фиолетовым маркером */
.l2-not{
  position: relative; z-index: 0; display: inline-block;
  margin: .05em 0 .07em -.15em; padding: .02em .17em .1em;
  color: #fff; white-space: nowrap;
  rotate: -1.6deg;
}
.l2-not::before{
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--l2-vio);
  clip-path: polygon(0 7%, 28% 3%, 61% 5%, 100% 0, 99.2% 93%, 72% 97%, 36% 95%, .8% 100%);
}

/* «баллы», «грамоты» — мазок по базовой линии, как в полосе фактов */
.l2-hl{ position: relative; z-index: 0; white-space: nowrap; }
.l2-hl::before{
  content: ""; position: absolute; z-index: -1;
  left: -.1em; right: -.12em; bottom: .07em; height: .4em;
  border-radius: .05em .16em .07em .18em / .12em .07em .15em .06em;
  background: var(--l2-y);
  rotate: -1.1deg;
  transform-origin: 0 60%;
  transition: transform .62s var(--l2-ease) .2s;
}
.l2-hl-b::before{ background: var(--l2-p); rotate: .8deg; transition-delay: .42s; }

/* ручка */
.l2-pen{
  fill: none; stroke: var(--l2-vio); stroke-width: 3;
  stroke-linecap: round; stroke-linejoin: round; overflow: visible;
}
.l2-pen path{
  stroke-dasharray: 1; stroke-dashoffset: 0;
  transition: stroke-dashoffset .5s cubic-bezier(.5, 0, .2, 1) var(--l2-d, .5s), opacity .01s linear var(--l2-d, .5s);
}
.l2-pen .l2-pen-2{ transition-duration: .22s, .01s; transition-delay: calc(var(--l2-d, .5s) + .46s); }
.l2-tick{ --l2-d: .55s; width: .5em; height: .455em; margin-left: .1em; vertical-align: .44em; stroke-width: 5; }
.l2-star{ --l2-d: .75s; width: .5em; height: .5em; margin-left: .12em; vertical-align: .4em; stroke-width: 4.2; rotate: 9deg; }
.l2-star path{ transition-duration: .7s, .01s; }

/* лист с заданием */
.l2-sheet{
  grid-column: 2; grid-row: 1 / span 2;
  position: relative; z-index: 2;
  margin: calc(var(--l2-fs) * 1.42) 12px 0 0;   /* 12px: повёрнутый лист и листы под ним не выходят за правую линию колонки */
  rotate: 1.5deg;
  transition: rotate .6s var(--l2-ease), translate .6s var(--l2-ease);
}
/* листы под ним */
.l2-sheet::before, .l2-sheet::after{
  content: ""; position: absolute; inset: 0; border-radius: 3px;
  background: #fffdf7;
  box-shadow: 0 1px 2px rgba(36, 36, 62, .14), 0 14px 22px -16px rgba(36, 36, 62, .3);
  transition: rotate .6s var(--l2-ease), translate .6s var(--l2-ease);
}
.l2-sheet::before{
  rotate: -4.2deg; translate: -14px 4px;
  background:
    linear-gradient(rgba(84, 70, 160, .1) 1px, transparent 1px) 0 12px / 20px 20px,
    linear-gradient(90deg, rgba(84, 70, 160, .1) 1px, transparent 1px) 12px 0 / 20px 20px,
    #fffdf7;
}
.l2-sheet::after{ rotate: -1.9deg; translate: 7px 5px; }
.l2-paper{
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  padding: 34px 40px 0;             /* поля листа вокруг кадра */
  border-radius: 3px;
  background: #fdfbff;             /* цвет поля в записи задания: условие «напечатано» на листе */
  box-shadow: 0 1px 1px rgba(36, 36, 62, .1), 0 3px 6px rgba(36, 36, 62, .05), 0 30px 46px -24px rgba(36, 36, 62, .42);
}
.l2-tape{
  position: absolute; z-index: 2; top: -16px; left: 50%;
  width: 124px; height: 32px; margin-left: -62px;
  rotate: -3.2deg;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .22) 0 1px, transparent 1px 6px),
    rgba(247, 185, 40, .66);
  clip-path: polygon(0 0, 3.5% 17%, 0 33%, 3.5% 50%, 0 67%, 3.5% 83%, 0 100%, 100% 100%, 96.5% 83%, 100% 67%, 96.5% 50%, 100% 33%, 96.5% 17%, 100% 0);
}
.l2-film{ order: 1; overflow: hidden; }
.l2-film[hidden]{ display: none; }
.l2-film video{
  display: block; width: 100%; height: auto; aspect-ratio: 1200 / 684;
  margin-bottom: -1.6%;            /* серая кромка внизу записи — под обрез */
  background: #fdfbff;
  pointer-events: none;
}

/* вкладки — подписи под кадром; выбранная закрашена маркером */
.l2-tabs{
  order: 2;
  display: flex; justify-content: space-between; gap: 4px;
  margin-top: 14px; padding: 7px 0 11px;
  border-top: 1.5px dashed #d9d5e8;
}
.l2-tab{
  --l2-k: var(--l2-y);
  display: flex; align-items: center; gap: 9px;
  min-height: 50px; padding: 0 12px 0 6px; margin: 0;
  border: 0; border-radius: 8px; background: none;
  font-size: 16px; line-height: 1.1; font-weight: 700; letter-spacing: -.01em;
  color: #6a6c85; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .2s;
}
.l2-tab-2{ --l2-k: var(--l2-c); }
.l2-tab-3{ --l2-k: var(--l2-p); }
.l2-tab-n{
  flex: none; display: grid; place-items: center;
  width: 25px; height: 25px;
  border: 1.5px solid currentColor;
  border-radius: 52% 48% 50% 50% / 48% 54% 46% 52%;
  font-size: 13px; line-height: 1; font-weight: 700; font-variant-numeric: lining-nums;
  transition: background-color .2s, border-color .2s, color .2s;
}
.l2-tab-t{ position: relative; z-index: 0; white-space: nowrap; }
.l2-tab-t::before{
  content: ""; position: absolute; z-index: -1;
  inset: -.34em -.46em -.3em -.4em;
  border-radius: .2em .5em .26em .56em / .5em .26em .56em .2em;
  background: var(--l2-k);
  rotate: -1.2deg;
  transform: scaleX(0); transform-origin: 0 50%;
  transition: transform .2s ease-in;
}
.l2-tab[aria-selected="true"]{ color: var(--l2-ink); cursor: default; }
.l2-tab[aria-selected="true"] .l2-tab-n{ background: var(--l2-ink); border-color: var(--l2-ink); color: #fff; }
.l2-tab[aria-selected="true"] .l2-tab-t::before{ transform: none; transition: transform .46s var(--l2-ease); }
.l2-tab:focus-visible{ outline: 2.5px solid var(--l2-vio); outline-offset: 1px; }

/* подпись на полях: «Примеры заданий» со стрелкой к листу */
.l2-note{
  position: absolute; z-index: 3; right: 9%; bottom: 100%;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 4px;
  color: var(--l2-vio);
  rotate: -6deg; transform-origin: 100% 100%;
}
.l2-note-t{ font-size: 23px; line-height: 1.1; font-weight: 600; font-style: italic; letter-spacing: -.012em; white-space: nowrap; }
.l2-note-arrow{ --l2-d: .9s; flex: none; width: 62px; height: 55px; margin-top: 9px; }

/* кнопка и пометка «бесплатно» */
.l2-go{
  grid-column: 1; grid-row: 2;
  display: flex; flex-direction: column; align-items: flex-start; gap: 18px;
  margin-top: 48px;
}
.l2-cta{
  position: relative; isolation: isolate; flex: none; display: inline-block;
  border-radius: 17px 20px 18px 21px / 20px 17px 21px 18px;
  font-size: 21px; line-height: 1.1; font-weight: 800; letter-spacing: -.012em;
  color: #fff; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.l2-cta::before{
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; background: var(--l2-ink);
  translate: 6px 7px;
  transition: translate .18s var(--l2-ease);
}
.l2-cta-face{
  display: flex; align-items: center; justify-content: center; gap: 16px;
  min-height: 70px; padding: 0 28px 0 32px;
  border-radius: inherit;
  background: var(--l2-vio);
  transition: translate .18s var(--l2-ease), background-color .18s;
}
.l2-cta-arrow{
  flex: none; width: 30px; height: 24px;
  fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
  transition: translate .22s var(--l2-ease);
}
.l2-cta:focus-visible{ outline: 3px solid var(--l2-ink); outline-offset: 5px; }
.l2-cta:active .l2-cta-face{ translate: 5px 6px; background: #5a39c2; }
.l2-cta:active::before{ translate: 6px 7px; }

.l2-free{
  display: grid; grid-template-columns: auto auto; align-items: start; column-gap: 6px;
  margin: 0 0 0 44px;
  color: var(--l2-vio); font-style: italic;
  rotate: -3.5deg;
}
.l2-free-arrow{ --l2-d: 1.15s; grid-row: 1 / span 2; width: 60px; height: 40px; margin-top: -6px; scale: 1 -1; }
.l2-free-a{ position: relative; justify-self: start; margin-top: 12px; font-size: 23px; line-height: 1.1; font-weight: 700; letter-spacing: -.012em; }
.l2-free-a::after{
  content: ""; position: absolute; left: -2px; right: -5px; bottom: -4px; height: 2.5px;
  border-radius: 2px; background: currentColor;
  rotate: -.8deg; transform-origin: 0 50%;
  transition: transform .4s var(--l2-ease) 1.6s;
}
.l2-free-b{ margin-top: 9px; font-size: 15px; line-height: 1.2; font-weight: 500; color: #5b4ea8; white-space: nowrap; }

/* ───────── три пункта ───────── */
.l2-points{
  list-style: none; margin: 92px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 56px;
}
.l2-pt{ --l2-k: var(--l2-y); --l2-pd: .15s; position: relative; padding-top: 24px; }
.l2-pt-2{ --l2-k: var(--l2-c); --l2-pd: .3s; }
.l2-pt-3{ --l2-k: var(--l2-p); --l2-pd: .45s; }
.l2-pt::before{
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--l2-ink);
  transform-origin: 0 50%;
  transition: transform .7s var(--l2-ease) var(--l2-pd);
}
.l2-num{
  display: block;
  font-size: 76px; line-height: .9; font-weight: 800; letter-spacing: -.045em;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--l2-ink);
}
@supports (-webkit-text-stroke: 2px #000){
  .l2-num{ color: transparent; -webkit-text-stroke: 2px var(--l2-ink); text-shadow: .07em .06em 0 var(--l2-k); }
}
.l2-pt-t{ margin-top: 18px; font-size: 24px; line-height: 1.26; font-weight: 800; letter-spacing: -.016em; color: var(--l2-ink); }
.l2-mk{
  margin: 0 -.14em; padding: 0 .14em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  background: linear-gradient(var(--l2-k), var(--l2-k)) no-repeat 0 84% / 100% .46em;
  transition: background-size .7s var(--l2-ease) calc(var(--l2-pd) + .25s);
}
.l2-pt-p{ margin-top: 13px; max-width: 34em; font-size: 16.5px; line-height: 1.56; color: var(--l2-text); }

/* ───────── наведение ───────── */
@media (hover: hover){
  .l2-sheet:hover{ rotate: .5deg; translate: 0 -4px; }
  .l2-sheet:hover::before{ rotate: -5.4deg; translate: -19px 7px; }
  .l2-sheet:hover::after{ rotate: -2.6deg; translate: 10px 8px; }
  .l2-tab[aria-selected="false"]:hover{ color: var(--l2-ink); }
  .l2-tab[aria-selected="false"]:hover .l2-tab-t::before{ transform: scaleX(1); opacity: .42; transition: transform .3s var(--l2-ease); }
  .l2-cta:hover .l2-cta-face{ translate: -2px -3px; background: #7150de; }
  .l2-cta:hover::before{ translate: 8px 9px; }
  .l2-cta:hover .l2-cta-arrow{ translate: 5px 0; }
  .l2-cta:active .l2-cta-face{ translate: 5px 6px; background: #5a39c2; }
  .l2-cta:active::before{ translate: 6px 7px; }
}

/* ───────── «ненарисованное» состояние до появления ───────── */
@media (min-width: 901px) and (prefers-reduced-motion: no-preference) and (scripting: enabled){
  .l2:not(.is-seen) .l2-pen path{ stroke-dashoffset: 1; opacity: 0; }
  .l2:not(.is-seen) .l2-hl::before,
  .l2:not(.is-seen) .l2-free-a::after,
  .l2:not(.is-seen) .l2-pt::before{ transform: scaleX(0); }
  .l2:not(.is-seen) .l2-mk{ background-size: 0 .46em; }
}

/* ───────── размеры ───────── */
@media (max-width: 1180px){
  .l2-top{ grid-template-columns: minmax(0, 45fr) minmax(0, 55fr); }
  .l2-paper{ padding: 26px 28px 0; }
  .l2-points{ column-gap: 40px; margin-top: 80px; }
  .l2-tab{ font-size: 15px; padding-right: 8px; gap: 7px; }
  .l2-cta{ font-size: 20px; }
  .l2-cta-face{ min-height: 66px; padding: 0 24px 0 28px; }
  .l2-free-a, .l2-note-t{ font-size: 21px; }
  .l2-num{ font-size: 68px; }
  .l2-pt-t{ font-size: 22px; }
  .l2-pt-p{ font-size: 16px; }
}

/* одна колонка */
@media (max-width: 900px){
  .l2{ --l2-fs: clamp(31px, 9vw, 56px); padding: 54px 0 68px; }
  .l2::after{ content: none; }
  .l2::before{ background-size: 26px 26px; }
  .l2-top{ display: flex; flex-direction: column; align-items: stretch; }
  .l2-sheet{ margin: 78px 0 0; rotate: -.7deg; }
  .l2-paper{ padding: 30px 34px 0; }
  .l2-sheet::before{ rotate: 2.4deg; translate: 6px 5px; }
  .l2-sheet::after{ rotate: 1.1deg; translate: -3px 6px; }
  .l2-note{ right: 12%; }
  .l2-go{ margin-top: 46px; }
  .l2-points{ grid-template-columns: minmax(0, 1fr); row-gap: 40px; margin-top: 64px; }
  .l2-pt{ display: grid; grid-template-columns: 132px minmax(0, 1fr); column-gap: 12px; padding-top: 22px; }
  .l2-num{ grid-row: 1 / span 2; }
  .l2-pt-t{ margin-top: 2px; }
  .l2-pt-p{ max-width: none; margin-top: 10px; }
}
@media (max-width: 900px) and (hover: hover){
  .l2-sheet:hover{ rotate: -.7deg; translate: none; }
  .l2-sheet:hover::before{ rotate: 2.4deg; translate: 6px 5px; }
  .l2-sheet:hover::after{ rotate: 1.1deg; translate: -3px 6px; }
}

/* телефон */
@media (max-width: 600px){
  .l2{ padding: 44px 0 60px; }
  .l2 .l2-br-m{ display: inline; }
  .l2 .l2-br-d{ display: none; }
  .l2-not{ margin-left: .04em; }
  .l2-sheet{ margin-top: 70px; }
  .l2-paper{ padding: 22px 18px 0; }
  .l2-tabs{ margin-left: -8px; margin-right: -8px; }
  .l2-tape{ width: 92px; height: 25px; margin-left: -46px; top: -15px; }
  .l2-tabs{ margin-top: 4px; padding: 3px 0 5px; gap: 0; }
  .l2-tabs{ justify-content: space-around; }
  .l2-tab{ min-height: 48px; padding: 0 6px; font-size: 14.5px; letter-spacing: -.015em; }
  .l2-tab-n{ display: none; }
  .l2-tab-t::before{ inset: -.4em -.5em -.36em -.46em; }
  .l2-tab-t::after{ content: ""; position: absolute; left: 0; right: 0; bottom: -.3em; border-top: 1.5px dashed #b9b5d0; }
  .l2-tab[aria-selected="true"] .l2-tab-t::after{ content: none; }
  .l2-note{ right: 9%; margin-bottom: 2px; }
  .l2-note-t{ font-size: 20px; }
  .l2-note-arrow{ width: 52px; height: 46px; }
  .l2-go{ flex-direction: column; align-items: stretch; gap: 0; margin-top: 40px; }
  .l2-cta{ display: block; margin-right: 6px; font-size: 20px; }
  .l2-cta-face{ min-height: 62px; }
  .l2-free{ align-self: flex-start; margin: 16px 0 0 34px; rotate: -3deg; }
  .l2-free-arrow{ width: 52px; height: 35px; margin-top: -4px; }
  .l2-free-a{ font-size: 21px; }
  .l2-free-b{ margin-top: 8px; }
  .l2-points{ margin-top: 52px; row-gap: 34px; }
  .l2-pt{ display: block; padding-top: 18px; }
  .l2-num{ font-size: 54px; }
  .l2-pt-t{ margin-top: 12px; font-size: 22px; }
  .l2-pt-p{ font-size: 16px; }
}
@supports (-webkit-text-stroke: 2px #000){
  @media (max-width: 600px){ .l2-num{ -webkit-text-stroke-width: 1.6px; } }
}
@media (max-width: 374px){
  .l2-tab{ font-size: 13.5px; padding: 0 4px; }
  .l2-tab-t::before{ inset: -.4em -.36em -.36em -.34em; }
}

@media (prefers-reduced-motion: reduce){
  .l2 *, .l2 *::before, .l2 *::after{ transition: none; animation: none; }
}
