/* Ronnie Mini App — «Награды»: the medal, the awards screen, the pills of the home screen that open it, and the
   full-screen «Новая награда!». Loaded after app.css; uses its tokens, cards, buttons and keyframes.
   The pictures (awards/<image>.webp) are square and transparent: a medal hanging on its ribbon. */

/* ---------- the pills of the home screen are buttons: both open «Награды» ---------- */
.chip--tap { position: relative; transition: transform 0.12s var(--ease); }
.chip--tap::after { content: ''; position: absolute; inset: -6px -2px; } /* 48 px touch target */
.chip--tap:active { transform: scale(0.95); }
.chip__go { margin: 0 -6px 0 -3px; color: var(--ink-3); }
/* «A1 · 20 | 🏅 6»: the medals the student has — a quiet hint of what is behind the pill */
.chip__medals { display: inline-flex; align-items: center; gap: 3px; margin-left: 2px; padding-left: 9px; border-left: 1.5px solid var(--line); color: var(--amber-ink); }

/* ---------- the medal ---------- */
/* the metals: m1 light → m3 dark (the body), m4 the paw; the same variables colour the small dots of the rank card */
.medal--bronze, .atier__dot--bronze { --m1: #F0C59A; --m2: #CE8E56; --m3: #9C6231; --m4: #7A4718; }
.medal--silver, .atier__dot--silver { --m1: #F4F5F7; --m2: #C9CCD3; --m3: #9094A0; --m4: #6A6E7A; }
.medal--gold, .atier__dot--gold { --m1: #FCE597; --m2: #EBB93E; --m3: #BC851C; --m4: #8A5A0B; }
.medal--diamond, .atier__dot--diamond { --m1: #E0F6FB; --m2: #93D3E8; --m3: #4F9FBD; --m4: #2B7391; }
.medal--first { --m1: #F9C3BA; --m2: #E46C5F; --m3: #B9453A; --m4: #8E2F26; }
.medal--secret { --m1: #D2C7EE; --m2: #9A86D0; --m3: #6853A6; --m4: #48377C; }
.medal--mystery { --m1: #E4E0D6; --m2: #BDB7AB; --m3: #928C80; --m4: #716B60; }

.medal { position: relative; display: block; width: 100%; aspect-ratio: 1 / 1; }
.medal__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  -webkit-user-drag: none;
}
.medal.is-ok .medal__img { opacity: 1; }
/* the picture is on its way: a quiet round place for it */
.medal.is-loading::before { content: ''; position: absolute; inset: 9%; border-radius: 50%; background: var(--bg-deep); }

/* no picture file: a round medal in the metal of its tier, with a paw */
.medal__drawn {
  position: absolute;
  inset: 6%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--m1) 0%, var(--m2) 52%, var(--m3) 100%);
  box-shadow: 0 2px 0 var(--m3), 0 5px 12px rgba(86, 66, 30, 0.16);
}
.medal__drawn::before {
  content: '';
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: linear-gradient(325deg, var(--m1), var(--m2));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.5), inset 0 2px 5px rgba(0, 0, 0, 0.14);
}
.medal__drawn::after { /* a soft gloss */
  content: '';
  position: absolute;
  left: 15%;
  top: 9%;
  width: 46%;
  height: 28%;
  border-radius: 50%;
  background: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
  transform: rotate(-24deg);
  pointer-events: none;
}
.medal__mark { position: relative; width: 44%; height: 44%; color: var(--m4); }

/* not earned yet: the same medal, pale — its metal and colours still show, so one sees what is ahead */
.medal.is-off .medal__img, .medal.is-off .medal__drawn { filter: grayscale(0.55) brightness(1.06); }
.medal.is-off.is-ok .medal__img, .medal.is-off .medal__drawn { opacity: 0.5; }
/* …a mystery medal is a secret, not a faded one */
.medal--mystery.is-off .medal__img, .medal--mystery.is-off .medal__drawn { filter: none; }
.medal--mystery.is-off.is-ok .medal__img, .medal--mystery.is-off .medal__drawn { opacity: 0.88; }

/* a slow shine that sweeps over the medal now and then («Новая награда!»): the picture itself is its mask, so the
   light never leaves the medal and its ribbon; the drawn medal is a circle */
.medal__shine {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.medal__shine--round { inset: 6%; border-radius: 50%; }
.medal__shine::before {
  content: '';
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -60%;
  width: 42%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0));
  transform: skewX(-18deg);
  animation: medal-shine 3.4s ease-in-out 1s infinite;
}

.medal__lock {
  position: absolute;
  right: 2%;
  bottom: 2%;
  width: 36%;
  min-width: 18px;
  max-width: 30px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: 0 1px 3px rgba(43, 41, 38, 0.24);
}
.medal__lock .ic { width: 58%; height: 58%; }

/* ---------- a progress bar ---------- */
.abar { display: block; height: 8px; border-radius: 4px; background: var(--grey-tint); overflow: hidden; }
.abar i { display: block; height: 100%; border-radius: inherit; background: var(--amber); transition: width 0.5s var(--ease); }
.abar--sm { height: 6px; }

/* ---------- the screen ---------- */
.awards__scroll { padding-bottom: var(--s8); }

/* the rank: a warm golden card — the title, the stars, the way to the next rank, the medals by metal */
.arank {
  position: relative;
  overflow: hidden;
  padding: var(--s5);
  border-radius: var(--r-xl);
  color: #4A3206;
  background: linear-gradient(135deg, #FCEBB6 0%, #F5CF78 55%, #EBBB55 100%);
  box-shadow: 0 3px 0 #D7A640, 0 14px 28px rgba(227, 165, 58, 0.26);
  animation: rise 0.42s var(--ease) both;
}
.arank__paw { position: absolute; color: #fff; opacity: 0.24; }
.arank__paw--1 { top: -18px; right: 92px; transform: rotate(20deg); }
.arank__paw--2 { top: 78px; right: -8px; transform: rotate(-24deg); }
.arank__top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.arank__titles { min-width: 0; }
.arank__eyebrow { font-size: 13.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--amber-ink); }
.arank__title { font-size: 28px; font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.arank__stars {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  background: rgba(255, 253, 247, 0.86);
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}
.abar--rank { position: relative; height: 10px; margin-top: var(--s4); border-radius: 5px; background: rgba(255, 253, 247, 0.62); }
.abar--rank i { background: var(--amber-ink); }
.arank__next { position: relative; margin-top: var(--s2); font-size: var(--fs-sm); font-weight: 700; }
.arank__tiers { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: var(--s4); }
.atier { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; padding: 10px 2px 8px; border-radius: var(--r-md); background: rgba(255, 253, 247, 0.74); text-align: center; }
.atier b { font-size: 20px; font-weight: 800; line-height: 1.1; }
.atier > span:last-child { max-width: 100%; font-size: 12.5px; font-weight: 700; color: #6B4A0E; overflow: hidden; text-overflow: ellipsis; }
.atier__dot {
  width: 18px;
  height: 18px;
  margin-bottom: 3px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--m1), var(--m2) 55%, var(--m3));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55), 0 1px 2px rgba(86, 66, 30, 0.28);
}

/* a section: «Первые шаги», «Линейки», «Секретные» */
.asec { margin: var(--s6) var(--s1) var(--s3); }
.asec__title { font-size: 20px; font-weight: 800; line-height: 1.2; }
.asec__text { margin-top: 2px; font-size: var(--fs-sm); line-height: 1.35; color: var(--ink-2); }

/* a grid of medals with their titles */
.agrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3) var(--s1); padding: var(--s4) var(--s2); }
.atile { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 4px 2px; border-radius: var(--r-md); transition: transform 0.12s var(--ease); }
.atile:active { transform: scale(0.95); }
.atile .medal { width: min(100%, 84px); }
.atile__title { max-width: 100%; font-size: 13.5px; font-weight: 700; line-height: 1.25; text-align: center; color: var(--ink-3); overflow-wrap: anywhere; }
.atile.is-earned .atile__title { color: var(--ink); }

/* a line: its title, what is counted, the student's number — and four medals, bronze → diamond */
.alines { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
.aline { padding: var(--s4) var(--s3) var(--s3); }
.aline__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); padding: 0 var(--s1); }
.aline__titles { min-width: 0; }
.aline__title { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.2; }
.aline__text { margin-top: 1px; font-size: var(--fs-sm); line-height: 1.3; color: var(--ink-2); }
.aline__value { flex: none; display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 15px; background: var(--amber-tint); color: var(--amber-ink); font-size: 14.5px; font-weight: 800; white-space: nowrap; }
.aline__lock { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--grey-tint); color: var(--grey-ink); }
.aline__row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s1); margin-top: var(--s3); }
.amedal { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; padding: 4px 2px 2px; border-radius: var(--r-md); transition: transform 0.12s var(--ease); }
.amedal:active { transform: scale(0.94); }
.amedal .medal { width: min(100%, 76px); }
.amedal .abar { width: 78%; }
.amedal__cap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.amedal.is-earned .amedal__cap { color: var(--green-ink); }
.amedal.is-next .amedal__cap { color: var(--ink); }

/* «Уровень 2»: seen from the first day, closed until a line's first level is complete */
.alevel {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: var(--s6) 0 var(--s3);
  padding: var(--s4);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, #45413C 0%, var(--ink) 100%);
  color: #fff;
  box-shadow: 0 3px 0 #1B1917, 0 12px 24px rgba(43, 41, 38, 0.2);
}
.alevel__icon { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: rgba(255, 255, 255, 0.12); color: #F6D58A; }
.alevel__body { min-width: 0; }
.alevel__title { font-size: 20px; font-weight: 800; line-height: 1.2; color: #F6D58A; }
.alevel__text { margin-top: 2px; font-size: var(--fs-sm); line-height: 1.4; color: rgba(255, 255, 255, 0.84); }
.aline--closed { background: rgba(255, 253, 247, 0.55); box-shadow: inset 0 0 0 1.5px var(--line); }
.aline--closed .aline__title { color: var(--ink-2); }
.aline--closed .amedal .medal { width: min(100%, 60px); }
.aline--closed .amedal__cap { display: none; }

/* ---------- the sheet of a medal ---------- */
.adetail { display: flex; flex-direction: column; align-items: center; text-align: center; }
.adetail__medal { width: min(52vw, 200px, 30vh); margin-bottom: var(--s3); animation: pop-in 0.45s var(--spring) both; }
.adetail__eyebrow { font-size: 13px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--amber-ink); }
.adetail__title { margin-top: 2px; font-size: 24px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.adetail__text { margin-top: var(--s2); max-width: 330px; font-size: var(--fs-md); line-height: 1.4; color: var(--ink-2); }
.adetail__earned {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  margin-top: var(--s4);
  padding: 6px 14px;
  border-radius: 18px;
  background: var(--green-tint);
  color: var(--green-ink);
  font-size: var(--fs-sm);
  font-weight: 800;
}
.adetail__progress { width: 100%; max-width: 300px; margin-top: var(--s4); }
.adetail__count { margin-top: var(--s2); font-size: var(--fs-sm); line-height: 1.35; color: var(--ink-2); }
.adetail__count b { font-size: 18px; font-weight: 800; color: var(--ink); }
.adetail__note {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  max-width: 340px;
  margin-top: var(--s4);
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: var(--fs-sm);
  line-height: 1.4;
  text-align: left;
  color: var(--ink-2);
}
.adetail__note .ic { flex: none; margin-top: 1px; color: var(--ink-3); }
.adetail__stars { margin-top: var(--s3); font-size: 14px; font-weight: 700; color: var(--amber-ink); }
.adetail__btn { margin-top: var(--s5); }

/* ---------- «Новая награда!» — over any tab ---------- */
.cele {
  position: absolute;
  inset: 0;
  z-index: 70; /* above the tab bar, the sheets (50) and the toast (60) */
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding: calc(var(--safe-top) + var(--s5)) var(--s6) calc(var(--safe-bottom) + var(--s5));
  text-align: center;
  background: radial-gradient(120% 78% at 50% 34%, #FFF7DC 0%, var(--bg) 64%);
  animation: cele-in 0.3s ease both;
}
.cele__body { position: relative; flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cele__stage { position: relative; width: min(62vw, 250px, 36vh); aspect-ratio: 1 / 1; margin-bottom: var(--s5); }
/* slow rays behind the medal (their centre is a little lower than the middle: the medal hangs on a ribbon) */
.cele__rays {
  position: absolute;
  inset: -40% -48% -56%;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(227, 165, 58, 0.24) 0deg 9deg, rgba(227, 165, 58, 0) 9deg 24deg);
  -webkit-mask-image: radial-gradient(circle closest-side, #000 34%, transparent 82%);
  mask-image: radial-gradient(circle closest-side, #000 34%, transparent 82%);
  animation: cele-rays 0.9s ease 0.15s both, cele-spin 28s linear infinite;
}
.cele__medal { position: relative; width: 100%; height: 100%; animation: cele-pop 0.75s var(--spring) 0.12s both; }
.cele__medal .medal { filter: drop-shadow(0 10px 18px rgba(86, 66, 30, 0.22)); }
.cele__eyebrow { font-size: 14px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); animation: rise 0.4s var(--ease) 0.45s both; }
.cele__title { margin-top: var(--s1); font-size: 28px; font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; overflow-wrap: anywhere; animation: rise 0.4s var(--ease) 0.52s both; }
.cele__text { margin-top: var(--s2); max-width: 320px; font-size: var(--fs-md); line-height: 1.4; color: var(--ink-2); animation: rise 0.4s var(--ease) 0.6s both; }
.cele__stars { display: inline-flex; align-items: center; height: 32px; margin-top: var(--s3); padding: 0 14px; border-radius: 16px; background: var(--amber-tint); color: var(--amber-ink); font-size: 14.5px; font-weight: 800; animation: pop-in 0.4s var(--spring) 0.75s both; }
.cele__foot { position: relative; flex: none; width: 100%; max-width: 340px; }
.cele__more { margin-bottom: var(--s3); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.cele__btn { animation: rise 0.4s var(--ease) 0.7s both; }

/* a few pieces of paper fall once */
.cele__confetti { position: absolute; inset: 0; pointer-events: none; }
.cele__confetti i {
  position: absolute;
  top: -5%;
  left: var(--x);
  width: 9px;
  height: 13px;
  border-radius: 2px;
  background: var(--c);
  opacity: 0;
  animation: cele-fall var(--t) cubic-bezier(0.3, 0.2, 0.6, 1) var(--d) both;
}
.cele__confetti i.is-round { width: 10px; height: 10px; border-radius: 50%; }

@keyframes cele-in { from { opacity: 0; } }
@keyframes cele-pop { 0% { opacity: 0; transform: scale(0.3) rotate(-14deg); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes cele-rays { from { opacity: 0; } to { opacity: 1; } }
@keyframes cele-spin { to { transform: rotate(360deg); } }
@keyframes medal-shine { 0% { transform: skewX(-18deg) translateX(0); } 42%, 100% { transform: skewX(-18deg) translateX(440%); } }
@keyframes cele-fall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--dx), 108vh, 0) rotate(var(--r)); }
}

/* calm: no rays turning, no shine, no paper (app.css already cuts every animation short) */
@media (prefers-reduced-motion: reduce) {
  .cele__confetti, .medal__shine { display: none; }
  .cele__rays { animation: none; }
}

@media (max-height: 640px) {
  .cele__stage { margin-bottom: var(--s3); }
  .cele__title { font-size: 24px; }
}
