/* ==========================================================================
   Achievement badges: on the dashboards (public/achievements.js) and on the
   pages that explain them. A round medal per badge, in its own colour;
   badges not yet earned are greyed, with progress where it helps.
   ========================================================================== */
.ach-bronze   { --m1: #e3b48c; --m2: #a86a3d; --m3: #5b3218; }
.ach-silver   { --m1: #eef1f5; --m2: #8a96a8; --m3: #334155; }
.ach-gold     { --m1: #f3dc8f; --m2: #b8912f; --m3: #6b4f10; }
.ach-platinum { --m1: #e2f0f7; --m2: #6f93aa; --m3: #0b2533; }
.ach-teal   { --m1: #99f6e4; --m2: #0d9488; --m3: #134e4a; }
.ach-violet { --m1: #ddd6fe; --m2: #7c3aed; --m3: #3b0764; }
.ach-rose   { --m1: #fecdd3; --m2: #e11d48; --m3: #881337; }
.ach-amber  { --m1: #fde68a; --m2: #d97706; --m3: #78350f; }
.ach-blue   { --m1: #bfdbfe; --m2: #2563eb; --m3: #1e3a8a; }
.ach-orange { --m1: #fed7aa; --m2: #ea580c; --m3: #7c2d12; }
.ach-sky    { --m1: #bae6fd; --m2: #0284c7; --m3: #0c4a6e; }
.ach-indigo { --m1: #c7d2fe; --m2: #4f46e5; --m3: #1e1b4b; }
.ach-green  { --m1: #bbf7d0; --m2: #16a34a; --m3: #14532d; }

.ach-group + .ach-group { margin-top: 24px; }
.ach-group-title { margin: 0 0 12px; font-size: 1rem; font-weight: 800; color: var(--ink); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 12px; }
.ach-badge {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 18px 14px 16px;
    background: var(--surface, #fff); border: 1px solid var(--line, #e2e8f0); border-radius: 18px; min-width: 0;
    transition: transform .2s, box-shadow .2s;
}
.ach-badge.is-earned { border-color: color-mix(in srgb, var(--m2) 45%, transparent); box-shadow: 0 10px 24px -16px var(--m2); }
.ach-badge.is-earned:hover { transform: translateY(-3px) rotate(-1deg); }
.ach-medal {
    position: relative; display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; margin-bottom: 4px;
    background: radial-gradient(circle at 35% 30%, var(--m1), var(--m2) 62%, var(--m3));
    box-shadow: inset 0 -6px 12px rgba(0, 0, 0, .18), inset 0 4px 8px rgba(255, 255, 255, .5), 0 0 0 4px color-mix(in srgb, var(--m1) 60%, #fff);
    color: #fff;
}
.ach-medal .material-symbols-outlined { font-size: 36px; text-shadow: 0 2px 4px rgba(0, 0, 0, .25); }
.ach-badge.is-cert .ach-medal { border-radius: 22px; }
.ach-badge:not(.is-earned) .ach-medal { filter: grayscale(1) opacity(.45); }
.ach-name { color: var(--ink, #0f172a); font-size: .98rem; line-height: 1.25; }
.ach-badge:not(.is-earned) .ach-name { color: var(--muted, #64748b); }
.ach-how { color: var(--muted, #64748b); font-size: .82rem; line-height: 1.45; }
.ach-progress { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ach-progress small { color: var(--muted, #64748b); font-weight: 700; font-size: .75rem; }
.ach-bar { flex: 1; height: 7px; border-radius: 999px; background: var(--canvas, #f1f5f9); overflow: hidden; }
.ach-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--m1), var(--m2)); }
.ach-tick { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; margin-top: 4px; font-size: .78rem; font-weight: 700; color: var(--m3); }
.ach-tick .material-symbols-outlined { font-size: 16px; color: var(--m2); }

/* The celebration */
.ach-pop {
    position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px;
    background: rgba(15, 23, 42, .55); animation: fadeIn .2s ease;
}
.ach-pop-card {
    display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; width: min(360px, 100%);
    padding: 28px 24px 24px; border-radius: 26px; background: var(--surface, #fff); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .45);
    animation: ach-pop .55s cubic-bezier(.2, 1.4, .4, 1);
}
.ach-pop-kicker { font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #b8912f; }
.ach-pop-badge { border: 0; background: none; padding: 6px 0 0; box-shadow: none; }
.ach-pop-badge .ach-medal { width: 112px; height: 112px; animation: ach-spin 1.1s cubic-bezier(.2, .8, .2, 1); }
.ach-pop-badge .ach-medal .material-symbols-outlined { font-size: 56px; }
.ach-pop-name { font-size: 1.35rem; color: var(--ink, #0f172a); }
.ach-pop-how { margin: 0 0 8px; color: var(--muted, #64748b); }
.ach-pop-btn { min-width: 140px; justify-content: center; }
@keyframes ach-pop { from { opacity: 0; transform: scale(.7) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes ach-spin { from { transform: rotateY(-540deg) scale(.4); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .ach-pop-card, .ach-pop-badge .ach-medal { animation: none; } }

/* ---------- the pages that explain achievements ---------- */
.ach-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ach-hero-medals { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 26px; }
.ach-hero-medals .ach-medal { width: 64px; height: 64px; animation: ach-float 4s ease-in-out infinite; }
.ach-hero-medals .ach-medal:nth-child(2n) { animation-delay: -1.3s; }
.ach-hero-medals .ach-medal:nth-child(3n) { animation-delay: -2.6s; }
.ach-hero-medals .ach-medal .material-symbols-outlined { font-size: 30px; }
.ach-hero-medals .ach-bronze, .ach-hero-medals .ach-silver, .ach-hero-medals .ach-gold, .ach-hero-medals .ach-platinum { border-radius: 20px; }
@keyframes ach-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(-4deg); } }
.ach-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 40px; align-items: center; margin-bottom: 36px; }
.ach-split-text { min-width: 0; }
.ach-certs { margin: 0; }
.ach-certs img { display: block; width: 100%; height: auto; filter: drop-shadow(0 18px 30px rgba(12, 26, 74, .18)); }
.ach-list { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.ach-list li { position: relative; padding-inline-start: 26px; line-height: 1.6; }
.ach-list li::before { content: ""; position: absolute; inset-inline-start: 4px; top: .55em; width: 10px; height: 10px; border-radius: 50%; background: #b8912f; }
.ach-levels { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; max-width: 980px; counter-reset: none; }
.ach-levels li {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 10px; text-align: center;
    background: var(--surface, #fff); border: 1px solid var(--line, #e2e8f0); border-radius: 18px;
}
.ach-level-num {
    display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; margin-bottom: 4px;
    background: linear-gradient(135deg, var(--brand-100, #dbe4fb), var(--brand, #2748b3)); color: #fff; font-weight: 800; font-size: 1.15rem;
}
.ach-levels li:nth-child(2) .ach-level-num { background: linear-gradient(135deg, #99f6e4, #0d9488); }
.ach-levels li:nth-child(3) .ach-level-num { background: linear-gradient(135deg, #ddd6fe, #7c3aed); }
.ach-levels li:nth-child(4) .ach-level-num { background: linear-gradient(135deg, #fecdd3, #e11d48); }
.ach-levels li:nth-child(5) .ach-level-num { background: linear-gradient(135deg, #f3dc8f, #b8912f); }
.ach-levels small { color: var(--muted, #64748b); font-size: .82rem; }
.ach-narrow { max-width: 760px; }
.ach-faq { display: grid; gap: 10px; }
.ach-faq details { background: var(--surface, #fff); border: 1px solid var(--line, #e2e8f0); border-radius: 14px; padding: 4px 18px; }
.ach-faq summary { cursor: pointer; padding: 12px 0; font-weight: 700; color: var(--ink, #0f172a); }
.ach-faq p { margin: 0 0 14px; color: var(--muted, #64748b); line-height: 1.65; }
@media (max-width: 860px) {
    .ach-split { grid-template-columns: minmax(0, 1fr); }
    .ach-levels { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .ach-hero-medals .ach-medal { animation: none; } }

/* Dashboards: five tabs fit on phones by scrolling sideways. */
@media (max-width: 480px) {
    .dash-tabs:has(.dash-tab:nth-child(5)) { display: flex; overflow-x: auto; scrollbar-width: none; }
    .dash-tabs:has(.dash-tab:nth-child(5)) .dash-tab { flex: 0 0 auto; padding: 9px 12px; }
}

/* ---------- the trophy shelf at the top of a dashboard ---------- */
.ach-level { --m1: #c7d2fe; --m2: #4f46e5; --m3: #1e1b4b; }
.ach-shelf {
    position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; margin: 0 0 20px; padding: 14px 18px;
    border-radius: 20px; overflow: hidden; border: 1px solid #ecdcae;
    background: linear-gradient(110deg, #fffaf0, #fff 45%, #f5f7ff);
    box-shadow: 0 10px 26px -18px rgba(184, 145, 47, .6);
}
.ach-shelf::after {                                  /* a slow shine across the shelf */
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .7) 50%, transparent 60%);
    transform: translateX(-100%); animation: ach-shine 7s ease-in-out 1.5s infinite;
}
@keyframes ach-shine { 0%, 70% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.ach-shelf-lead .ach-medal { width: 54px; height: 54px; margin: 0; animation: ach-bob 3.5s ease-in-out infinite; }
.ach-shelf-lead .ach-medal .material-symbols-outlined { font-size: 28px; }
.ach-shelf-lead .ach-medal strong { font-size: 1.4rem; color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, .25); }
@keyframes ach-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-3px) rotate(-6deg); } }
.ach-shelf-text { display: flex; flex-direction: column; gap: 3px; min-width: 180px; flex: 1 1 220px; }
.ach-shelf-text strong { color: var(--ink); font-size: 1rem; }
.ach-shelf-text small { color: var(--muted); font-size: .82rem; }
.ach-shelf-bar { display: block; height: 9px; margin-top: 4px; border-radius: 999px; background: #f1eadb; overflow: hidden; }
.ach-shelf-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #e3c06a, #b8912f); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.ach-shelf-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ach-shelf-medals { display: flex; align-items: center; }
.ach-mini { display: inline-flex; padding: 0; border: 0; background: none; box-shadow: none; }
.ach-mini + .ach-mini { margin-inline-start: -10px; }
.ach-mini .ach-medal { width: 38px; height: 38px; margin: 0; box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .18), 0 0 0 3px #fff; }
.ach-mini .ach-medal .material-symbols-outlined { font-size: 19px; }
.ach-mini:hover { transform: translateY(-3px); z-index: 1; }
.ach-shelf-empty { color: var(--muted); font-size: .82rem; font-weight: 600; }
.ach-shelf-count { color: var(--muted); font-size: .75rem; font-weight: 700; }
.ach-shelf-btn { position: relative; z-index: 1; }
@media (max-width: 560px) {
    .ach-shelf { padding: 12px 14px; }
    .ach-shelf-side { flex-direction: row; gap: 8px; }
    .ach-shelf-btn { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .ach-shelf::after, .ach-shelf-lead .ach-medal { animation: none; } }

/* ---------- tappable medals: the home page section and the achievement pages ---------- */
.ach-showcase { background: radial-gradient(900px 420px at 10% 0%, #fff6dd, transparent 60%), radial-gradient(800px 420px at 100% 100%, #eef2ff, transparent 60%), var(--surface, #fff); }
.ach-show-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.ach-secret {
    display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px 14px; border-radius: 16px;
    background: linear-gradient(110deg, #fff7e0, #fdf2ff); border: 1px dashed #e3c06a; color: #6b4f10; font-size: .9rem; line-height: 1.5;
}
.ach-secret .material-symbols-outlined { flex: none; font-size: 28px; color: #b8912f; animation: tassel-wiggle 2.4s ease-in-out 1s infinite; }
.ach-secret a { color: #7a5b12; font-weight: 800; }
.ach-show-card {
    display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 26px; border-radius: 26px;
    background: var(--surface, #fff); border: 1px solid var(--line, #e2e8f0); box-shadow: 0 24px 50px -36px rgba(12, 26, 74, .45);
}
.ach-show-card h3 { margin: 0; font-size: 1.35rem; }
.ach-show-card > p { margin: 0; color: var(--muted, #64748b); line-height: 1.6; }
.ach-show-chip {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
    font-size: .8rem; font-weight: 800; background: #eef2ff; color: #3730a3;
}
.is-mentors .ach-show-chip { background: #faf1d6; color: #7a5b12; }
.ach-show-chip .material-symbols-outlined { font-size: 18px; }
.ach-show-certs { display: block; width: 100%; height: auto; filter: drop-shadow(0 14px 22px rgba(12, 26, 74, .16)); }
.ach-tap-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ach-tap { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.ach-tap .ach-medal { width: 54px; height: 54px; margin: 0; transition: transform .2s; }
.ach-tap.is-cert .ach-medal { border-radius: 16px; }
.ach-tap .ach-medal .material-symbols-outlined { font-size: 26px; }
.ach-tap .ach-medal strong { color: #fff; font-size: 1.05rem; text-shadow: 0 2px 4px rgba(0, 0, 0, .25); }
.ach-tap:hover .ach-medal { transform: translateY(-4px) rotate(-8deg) scale(1.06); }
.ach-tap:focus-visible { outline: 3px solid var(--brand, #2748b3); outline-offset: 3px; }
.ach-tap.is-active .ach-medal { box-shadow: inset 0 -6px 12px rgba(0, 0, 0, .18), 0 0 0 4px #fff, 0 0 0 7px var(--m2); }
.is-spinning { animation: ach-flip .7s cubic-bezier(.2, .8, .2, 1); }
@keyframes ach-flip { from { transform: rotateY(-360deg) scale(.8); } to { transform: none; } }
.ach-tip {
    margin: 0; min-height: 3.2em; padding: 10px 14px; border-radius: 14px; background: var(--canvas, #f8fafc);
    color: var(--muted, #64748b); line-height: 1.5; font-size: .92rem;
}
.ach-tip strong { color: var(--ink, #0f172a); }
.ach-tip.is-new { animation: rise-in .3s ease; }
.ach-ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: .8rem; font-weight: 700; color: #4f46e5; }
.ach-ladder li { padding: 3px 10px; border-radius: 999px; background: #eef2ff; }
.ach-ladder li + li::before { content: "›"; margin-inline-end: 6px; color: #a5b4fc; }
[dir="rtl"] .ach-ladder li + li::before { content: "‹"; }
.ach-show-card .link-arrow { margin-top: auto; align-self: flex-start; }
.ach-grid .ach-badge { cursor: default; }
main:not(:has(#achList)) .ach-grid .ach-badge { cursor: pointer; }

/* "For students | For mentors" on the achievement pages */
.ach-switch { display: flex; width: max-content; max-width: 100%; gap: 4px; padding: 4px; margin-bottom: 18px; border-radius: 999px; background: var(--surface, #fff); border: 1px solid var(--line, #e2e8f0); }
.ach-switch a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: .9rem; color: var(--muted, #64748b); text-decoration: none; }
.ach-switch a .material-symbols-outlined { font-size: 18px; }
.ach-switch a.is-active { background: var(--brand, #2748b3); color: #fff; }
.ach-switch a:not(.is-active):hover { color: var(--brand, #2748b3); }
@media (max-width: 860px) { .ach-show-grid { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { .is-spinning { animation: none; } }

/* ---------- badges on a mentor's public page ---------- */
.mp-earned { display: grid; gap: 8px; }
.mp-earned-badge { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .9rem; color: var(--ink, #0f172a); }
.mp-earned-badge .ach-medal { width: 38px; height: 38px; margin: 0; flex: none; box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .18), 0 0 0 3px #fff; }
.mp-earned-badge .ach-medal .material-symbols-outlined { font-size: 20px; }
.mp-earned-all { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; font-weight: 700; font-size: .88rem; color: var(--theme, var(--brand)); text-decoration: none; }
.mp-earned-all .material-symbols-outlined { font-size: 18px; }

/* ---------- someone's badge page (/badges/...) ---------- */
.ach-brag h1 { unicode-bidi: plaintext; }
.ach-brag-feature {
    display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-top: 22px; padding: 18px 22px; max-width: 560px;
    border-radius: 22px; background: var(--surface, #fff); border: 1px solid #ecdcae; box-shadow: 0 18px 40px -26px rgba(184, 145, 47, .7);
}
.ach-brag-feature > div:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 200px; }
.ach-brag-feature strong { font-size: 1.3rem; color: var(--ink, #0f172a); }
.ach-brag-feature > div:last-child > span:not(.ach-pop-kicker) { color: var(--muted, #64748b); }
.ach-badge.is-featured { outline: 3px solid var(--m2); outline-offset: 2px; }
.ach-empty { text-align: center; color: var(--muted, #64748b); padding: 30px 0; }

/* ---------- sharing: show off your badges ---------- */
.ach-pop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ach-shelf-actions { display: flex; gap: 8px; position: relative; z-index: 1; }
.ach-share { position: relative; }
.ach-share-close { position: absolute; top: 12px; inset-inline-end: 12px; }
.ach-share-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.ach-share-btns .dash-btn { justify-content: center; text-decoration: none; }
.ach-share-wa { background: #25d366; color: #fff; border-color: #25d366; }
.ach-share-x { background: #0f1419; color: #fff; border-color: #0f1419; }
.ach-share-wa:hover, .ach-share-x:hover { filter: brightness(1.08); color: #fff; }
@media (max-width: 560px) { .ach-shelf-actions { flex: 1 1 100%; } .ach-shelf-actions .dash-btn { flex: 1; justify-content: center; } }

/* ---------- small medals next to a mentor's name (cards, page header) ---------- */
.dir-medals { display: inline-flex; align-items: center; vertical-align: middle; margin-inline-start: 6px; }
.dir-medal {
    display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none; color: #fff;
    background: radial-gradient(circle at 35% 30%, var(--m1), var(--m2) 62%, var(--m3));
    box-shadow: 0 0 0 2px var(--surface, #fff), 0 2px 4px rgba(0, 0, 0, .15);
}
.dir-medal + .dir-medal { margin-inline-start: -5px; }
.dir-medal .material-symbols-outlined { font-size: 14px; }
.dir-medal-more { margin-inline-start: 4px; font-size: .75rem; font-weight: 800; color: var(--muted, #64748b); }
.featured-card .dir-medals { margin-inline-start: 6px; }
.mp-badge.mp-medals { text-decoration: none; color: var(--text); padding-inline-start: 6px; }
.mp-badge.mp-medals:hover { border-color: var(--theme, var(--brand)); color: var(--theme-ink, var(--brand)); }
.mp-badge.mp-medals .dir-medal { width: 22px; height: 22px; }
.mp-badge.mp-medals .dir-medal .material-symbols-outlined { font-size: 13px; color: #fff; }
