/* Learner profile ("Meu perfil"): hero, next step, journey map, milestones and certificates.
   Tokens come from web/css/tokens.css + brand.css; the track colours (--track, --track-tint)
   from assets/course.css by data-track. */
@layer components {
.profile {
  --track: var(--color-action); --track-tint: var(--color-action-tint);
  display: grid; gap: var(--space-6);
  animation: course-fade-up var(--duration-slow) var(--ease-out);
  & ol { padding: 0; list-style: none; }
}

.profile__card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: var(--space-6); }
.profile__eyebrow { font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); }
.profile__h2 { font-size: var(--text-lg); font-weight: 700; line-height: 1.2; }
.profile__muted { font-size: var(--text-sm); color: var(--color-text-muted); }

/* Hero: photo inside a ring that fills with the overall progress. */
.profile__hero { display: grid; grid-template-columns: auto 1fr; gap: var(--space-4) var(--space-6); align-items: center; }
.profile__avatar { position: relative; width: 6.5rem; height: 6.5rem; display: grid; place-items: center; }
.profile__ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.profile__ring-track { fill: none; stroke: var(--color-surface-sunken); stroke-width: 6; }
.profile__ring-fill { fill: none; stroke: var(--color-action); stroke-width: 6; stroke-linecap: round; }
.profile__photo, .profile__initials { width: 5.5rem; height: 5.5rem; border-radius: var(--radius-full); }
.profile__photo { object-fit: cover; background: var(--color-surface-sunken); }
/* "Trocar foto": a real file input kept in the tab order, visually behind its label. */
.profile__photo-change {
  position: absolute; inset-block-end: calc(-1 * var(--space-6)); inset-inline: 0; margin-inline: auto; width: max-content;
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); background: var(--color-surface);
  border: 1px solid var(--color-border-strong); font-size: var(--text-xs); font-weight: 500; color: var(--color-action); cursor: pointer;
  &:hover { background: var(--color-action-tint); }
  &:focus-within { outline: 2px solid var(--color-action); outline-offset: 2px; }
  &:has(:disabled) { cursor: progress; color: var(--color-text-muted); }
}
.profile__photo-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.profile__initials { display: grid; place-items: center; background: var(--color-nav); color: var(--color-on-nav); font-size: var(--text-xl); font-weight: 700; }
.profile__name { font-size: var(--text-2xl); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.profile__meta { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--color-text-muted); overflow-wrap: anywhere; }
.profile__stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.profile__stat { display: flex; flex-direction: column-reverse; gap: var(--space-1); }
.profile__stat dt { font-size: var(--text-xs); color: var(--color-text-muted); }
.profile__stat dd { font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.profile__stat-of { font-size: var(--text-sm); font-weight: 400; color: var(--color-text-muted); }

/* Next step: the one thing to do now. */
.next { display: grid; gap: var(--space-4); background: var(--color-nav); color: var(--color-on-nav); border-radius: var(--radius-lg); padding: var(--space-6); }
.next__eyebrow { font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }
.next__title { font-size: var(--text-xl); font-weight: 700; line-height: 1.2; margin-top: var(--space-1); }
.next__meta { font-size: var(--text-sm); margin-top: var(--space-1); }
.next__go {
  justify-self: start; display: inline-flex; align-items: center; gap: var(--space-2); min-height: 2.75rem; padding: 0 var(--space-6);
  border: 0; border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-nav);
  font: inherit; font-size: var(--text-sm); font-weight: 700; cursor: pointer;
  &:hover { background: var(--color-action-tint); }
  &:focus-visible { outline-color: var(--color-on-nav); }
}

/* Journey map: one line per track, a station per level, a tick per lesson. */
.journey { display: grid; gap: var(--space-6); }
.journey__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.journey__track { display: grid; gap: var(--space-4); padding-top: var(--space-6); border-top: 1px solid var(--color-border); }
.journey__track-head { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-base); font-weight: 700; }
.journey__icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: var(--radius-md); background: var(--track-tint); color: var(--track); }
.journey__pct { margin-left: auto; font-size: var(--text-sm); color: var(--track); font-variant-numeric: tabular-nums; }
.journey__level {
  position: relative; display: grid; grid-template-columns: 2.75rem 1fr; grid-template-areas: "station info" ". ticks";
  column-gap: var(--space-4); row-gap: var(--space-2); padding-bottom: var(--space-6);
  &::before { content: ""; position: absolute; left: calc(1.375rem - 1px); top: 2.75rem; bottom: 0; width: 2px; background: var(--color-border); }
  &:last-child { padding-bottom: 0; }
  &:last-child::before { display: none; }
}
.journey__level--done::before { background: var(--track); }
.journey__station {
  grid-area: station; position: relative; z-index: 1; display: grid; place-items: center; width: 2.75rem; height: 2.75rem;
  border-radius: var(--radius-full); border: 2px solid var(--track); background: var(--color-surface); color: var(--track);
  font: inherit; font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; cursor: pointer;
  &:hover { background: var(--track-tint); }
}
.journey__level--done .journey__station { background: var(--track); color: var(--color-surface); }
.journey__level--locked .journey__station { border: 2px dashed var(--color-border-strong); background: var(--color-surface-sunken); color: var(--color-text-muted); }
.journey__level[aria-current="step"] .journey__station { box-shadow: 0 0 0 0.375rem var(--track-tint); }
.journey__info { grid-area: info; align-self: center; min-width: 0; }
.journey__name { font-size: var(--text-sm); font-weight: 700; }
.journey__status { font-size: var(--text-xs); color: var(--color-text-muted); }
.journey__here { display: inline-block; margin-bottom: var(--space-1); padding: 0 var(--space-2); border-radius: var(--radius-full); background: var(--color-text); color: var(--color-surface); font-size: var(--text-xs); font-weight: 500; }
.journey__cert { display: inline-flex; align-items: center; gap: var(--space-1); margin-top: var(--space-1); font-size: var(--text-xs); font-weight: 500; color: var(--color-action); }
.journey__cert:hover { color: var(--color-action-hover); text-decoration: underline; }
/* A sub-track of the level (Android Standard...): optional lessons, with their own count. */
.journey__sub { display: inline-flex; align-items: center; gap: var(--space-1); margin-top: var(--space-1); padding: 0; border: 0; background: none; font: inherit; font-size: var(--text-xs); color: var(--color-text-muted); cursor: pointer; }
.journey__sub:hover { color: var(--color-action); text-decoration: underline; }
.journey__ticks { grid-area: ticks; display: flex; flex-wrap: wrap; gap: var(--space-1); }
.journey__tick { width: 0.5rem; height: 0.5rem; border-radius: var(--radius-full); border: 1px solid var(--color-border-strong); background: var(--color-surface); }
.journey__tick--done { border-color: var(--track); background: var(--track); }
.journey__legend { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: var(--text-xs); color: var(--color-text-muted); }
.journey__key { display: inline-flex; align-items: center; gap: var(--space-1); }
.journey__key::before { content: ""; width: 0.75rem; height: 0.75rem; border-radius: var(--radius-full); border: 2px solid var(--color-action); background: var(--color-surface); }
.journey__key--done::before { background: var(--color-action); }
.journey__key--here::before { box-shadow: 0 0 0 0.1875rem var(--color-action-tint); }
.journey__key--locked::before { border: 2px dashed var(--color-border-strong); background: var(--color-surface-sunken); }

/* Milestones: a dated log, newest first. */
.profile__lower { display: grid; gap: var(--space-6); align-items: start; }
.milestones { display: grid; gap: var(--space-4); }
.milestone {
  position: relative; display: grid; grid-template-columns: 2rem 1fr; column-gap: var(--space-3); padding-bottom: var(--space-4);
  &::before { content: ""; position: absolute; left: calc(1rem - 1px); top: 2rem; bottom: 0; width: 2px; background: var(--color-border); }
  &:last-child::before { display: none; }
}
.milestone__icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: var(--radius-full); background: var(--track-tint); color: var(--track); }
.milestone--cert .milestone__icon { background: var(--track); color: var(--color-surface); }
.milestone--start .milestone__icon { background: var(--color-surface-sunken); color: var(--color-text-muted); }
.milestones__more > summary { cursor: pointer; font-size: var(--text-sm); font-weight: 500; color: var(--color-action); }
.milestones__more > summary:hover { color: var(--color-action-hover); }
.milestones__more[open] > summary { margin-bottom: var(--space-4); }
.milestone__title { font-size: var(--text-sm); font-weight: 500; }
.milestone__detail, .milestone__date { font-size: var(--text-xs); color: var(--color-text-muted); }
.certs { display: grid; gap: var(--space-3); }
.cert-item {
  display: grid; grid-template-columns: 2.5rem 1fr auto; align-items: center; gap: var(--space-3); padding: var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text);
  &:hover { border-color: var(--track); background: var(--track-tint); color: var(--color-text); }
}
.cert-item__seal { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-full); background: var(--track); color: var(--color-surface); }
.cert-item__title { font-size: var(--text-sm); font-weight: 500; overflow-wrap: anywhere; }
.cert-entry { display: grid; gap: var(--space-2); }
.cert-entry__renew {
  justify-self: start; min-height: 2.75rem; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-md);
  background: var(--color-action); color: var(--color-surface); font: inherit; font-size: var(--text-sm); font-weight: 500; cursor: pointer;
  &:hover { background: var(--color-action-hover); }
}
.cert-item__revoked { color: var(--color-danger-strong); background: var(--color-danger-tint); border-radius: var(--radius-sm); padding: 0 var(--space-1); }

@media (min-width: 37.5em) {
  .profile__stats { grid-template-columns: repeat(4, 1fr); }
  .next { grid-template-columns: 1fr auto; align-items: center; }
}
@media (min-width: 56.25em) {
  /* The map turns sideways: the line runs left to right through the stations. */
  .journey__levels { display: flex; }
  .journey__level {
    flex: 1; min-width: 0; grid-template-columns: 1fr 2.75rem; grid-template-areas: "ticks station" "info info"; padding: 0;
    &::before, &:last-child::before { display: block; left: 0; right: 2.75rem; top: calc(1.375rem - 1px); bottom: auto; width: auto; height: 2px; }
  }
  .journey__ticks { align-self: center; justify-content: space-evenly; flex-wrap: nowrap; padding: 0 var(--space-2); position: relative; }
  .journey__info { text-align: right; padding-left: var(--space-4); }
  .profile__lower { grid-template-columns: 3fr 2fr; }
}
@media (min-width: 75em) {
  /* Only with room to spare do the figures sit beside the name. */
  .profile__hero { grid-template-columns: auto 1fr auto; }
  .profile__stats { grid-column: auto; padding: 0 0 0 var(--space-6); border-top: 0; border-left: 1px solid var(--color-border); gap: var(--space-6); }
}
}
