/* ============================================================
   profile.css — profile photo, first-run wizard, public profile
   ------------------------------------------------------------
   Builds on account.css tokens (.acct scope). The public profile is a
   lighter sibling of the learner card: the same teal band and concentric
   rings, with the photo sitting on the band's edge like an ID badge.
   Logical properties only (RTL needs no overrides).
   ============================================================ */

/* ── Avatar ───────────────────────────────────────────────── */
.pf-avatar {
  display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  background: var(--surface-sunken, #eef2f2);
}
.pf-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pf-avatar--mark { background: transparent; overflow: visible; }

/* Header chip photo */
.shell-account.has-photo .shell-account__initials { display: block; padding: 0; overflow: hidden; }
.shell-account__initials img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* Hero: the photo is a button (change photo) */
.acct-hero__photo {
  position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 50%;
  background: none; color: inherit; cursor: pointer;
  box-shadow: 0 0 0 3px rgba(255,255,255,.75), 0 0 0 9px rgba(255,255,255,.08);
  transition: transform .25s var(--acct-ease), box-shadow .2s ease;
}
.acct-hero__photo:hover { transform: scale(1.03); }
.acct-hero__photo:active { transform: scale(.98); }
.acct-hero__photo:focus-visible { outline: 3px solid var(--acct-amber); outline-offset: 6px; }
.acct-hero__photo .pf-avatar--mark { box-shadow: none; }
.acct-hero__photo:has(.pf-avatar--mark) { box-shadow: none; }
.acct-hero__photo-badge {
  position: absolute; inset-inline-end: 2%; bottom: 2%; width: 32%; max-width: 36px; aspect-ratio: 1;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--acct-amber); color: #2b2007; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.acct-hero__photo-badge svg { width: 58%; height: 58%; }

/* ── Leaderboard: names link to profiles ──────────────────── */
.lb-row__link { color: inherit; text-decoration: none; min-width: 0; display: inline-flex; }
.lb-row__link:hover bdi { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.lb-row__link:focus-visible { outline: 2px solid var(--acct-teal); outline-offset: 3px; border-radius: 4px; }

/* ── Public profile card ──────────────────────────────────── */
.pf-page { max-width: 760px; margin-inline: auto; display: grid; gap: 18px; }
.pf-page__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.pf-page__actions a.acct-btn svg:first-child { transform: scaleX(-1); }       /* chevron points "back" */
html[dir="rtl"] .pf-page__actions a.acct-btn svg:first-child { transform: none; }

.pf-card {
  container-type: inline-size;
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; gap: 18px;
  padding: 0 clamp(20px, 4vw, 40px) clamp(22px, 3.4vw, 36px);
  background: var(--surface); border: 1px solid var(--acct-line); border-radius: 24px;
  box-shadow: var(--acct-shadow);
}
.pf-card__band {
  height: clamp(96px, 16vw, 132px); margin-inline: calc(-1 * clamp(20px, 4vw, 40px));
  background:
    repeating-radial-gradient(circle at 88% -40%, transparent 0 30px, rgba(255,255,255,.08) 30px 31px),
    linear-gradient(135deg, var(--mark-disc) 0%, var(--acct-teal) 62%, #24595a 100%);
  position: relative;
}
.pf-card__band::after {
  content: ""; position: absolute; inset-inline-end: 12%; top: 28%; width: 9px; height: 9px; border-radius: 50%;
  background: var(--acct-amber); box-shadow: 0 0 22px 6px color-mix(in srgb, var(--acct-amber) 45%, transparent);
}
.pf-card__head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 22px; align-items: end; }
.pf-card__avatar {
  width: clamp(104px, 17vw, 144px); aspect-ratio: 1; border-radius: 50%; padding: 5px;
  background: var(--surface); box-shadow: 0 10px 30px -12px hsl(var(--shadow-color, 180 30% 15%) / .45);
  position: relative; z-index: 1;
  margin-top: calc(-1 * clamp(52px, 9vw, 72px));   /* only the photo overlaps the band */
}
.pf-card__avatar .acct-iris__initials { font-size: 30px; }
.pf-card__id { min-width: 0; padding-bottom: 4px; }
.pf-card__id .acct-kicker { margin-bottom: 6px; }
.pf-card__name {
  margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
  font-family: var(--acct-display); font-weight: 600; font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem);
  line-height: 1.1; letter-spacing: -.015em; overflow-wrap: anywhere;
}
html[dir="rtl"] .pf-card__name { letter-spacing: 0; line-height: 1.3; }
.pf-card .acct-hero__tags { margin-top: 10px; }
.pf-card .acct-tag { background: var(--acct-tint); border-color: color-mix(in srgb, var(--acct-teal) 22%, transparent); color: var(--acct-teal-deep); }
.pf-card__bio { margin: 0; font-size: 1.02rem; line-height: 1.65; color: var(--acct-ink-soft); max-width: 60ch; white-space: pre-line; }
.pf-card__since { margin: 0; font-size: .8rem; color: var(--acct-ink-faint); }

.pf-study {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px;
  border: 1px solid var(--acct-line); border-radius: 16px; background: var(--acct-paper);
}
.pf-study__icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--acct-tint); color: var(--acct-teal-deep); }
.pf-study__icon svg { width: 22px; height: 22px; }
.pf-study__text { display: grid; gap: 2px; min-width: 0; font-size: .9rem; color: var(--acct-ink-soft); }
.pf-study__text strong { color: var(--acct-ink); font-size: 1rem; overflow-wrap: anywhere; }
.pf-study__label { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--acct-teal); }
html[dir="rtl"] .pf-study__label { letter-spacing: 0; font-size: .8rem; }
.pf-study__when { font-weight: 600; color: var(--acct-teal-deep); }

.pf-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); border: 1px solid var(--acct-line); border-radius: 16px; overflow: hidden; }
.pf-stat { display: grid; gap: 2px; padding: 14px 16px; border-inline-start: 1px solid var(--acct-line); margin-inline-start: -1px; }
.pf-stat__v { font-family: var(--acct-display); font-size: 1.6rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--acct-ink); }
.pf-stat__k { font-size: .76rem; color: var(--acct-ink-faint); }

.pf-card--preview { box-shadow: none; border-radius: 20px; }
.pf-card--preview .pf-card__name { font-size: 1.45rem; }
.pf-card--preview .pf-card__avatar { width: 96px; margin-top: -48px; }
.pf-card--preview .pf-card__band { height: 84px; }
.pf-card--preview .pf-stat__v { font-size: 1.2rem; }

@container (max-width: 440px) {
  .pf-card__head { grid-template-columns: minmax(0, 1fr); }
  .pf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ── First-run wizard ─────────────────────────────────────── */
.pf-ob { max-width: 760px; margin-inline: auto; display: grid; gap: 18px; }
.pf-ob__head { display: grid; gap: 14px; justify-items: center; text-align: center; }
.pf-ob__head .acct-kicker { margin: 0; }
.pf-ob__steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.pf-ob__dot { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; color: var(--acct-ink-faint); font-size: .82rem; font-weight: 600; transition: background .3s ease, color .3s ease; }
html[dir="rtl"] .pf-ob__dot { padding: 6px 6px 6px 12px; }
.pf-ob__dot + .pf-ob__dot::before { content: ""; width: 18px; height: 1.5px; background: var(--acct-line-strong); margin-inline-end: 6px; }
.pf-ob__num {
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--acct-line-strong); font-family: var(--acct-mono); font-size: .76rem;
}
.pf-ob__num svg { width: 15px; height: 15px; }
.pf-ob__dot.is-current { color: var(--acct-teal-deep); background: var(--acct-tint); }
.pf-ob__dot.is-current .pf-ob__num { border-color: var(--acct-teal); background: var(--acct-teal); color: var(--on-accent, #fff); }
.pf-ob__dot.is-done { color: var(--acct-teal-deep); }
.pf-ob__dot.is-done .pf-ob__num { border-color: var(--acct-teal); color: var(--acct-teal); }
@media (max-width: 560px) {
  .pf-ob__dot:not(.is-current) .pf-ob__name { display: none; }
  .pf-ob__dot { padding-inline-end: 6px; }
  .pf-ob__dot + .pf-ob__dot::before { width: 10px; }
}

.pf-ob__card { display: grid; gap: 20px; animation: pf-step-in .45s var(--acct-ease); }
@keyframes pf-step-in { from { opacity: 0; transform: translateY(8px); } }
.pf-ob__title { font-size: clamp(1.7rem, 1.1rem + 2.2vw, 2.5rem); }
.pf-ob__card .acct-lede { margin-top: -8px; }

.pf-ob__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pf-chip { position: relative; cursor: pointer; }
.pf-chip input { position: absolute; opacity: 0; pointer-events: none; }
.pf-chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--acct-line-strong); background: var(--surface); font-size: .9rem; font-weight: 600;
  color: var(--acct-ink-soft); transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.pf-chip:hover span { border-color: var(--acct-teal); }
.pf-chip input:checked + span { background: var(--acct-teal); border-color: var(--acct-teal); color: var(--on-accent, #fff); }
.pf-chip input:focus-visible + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--acct-teal) 22%, transparent); }
.pf-chip:active span { transform: scale(.97); }

.pf-ob__photo { display: flex; flex-wrap: wrap; align-items: center; gap: 22px 28px; }
.pf-ob__avatar {
  position: relative; width: 148px; aspect-ratio: 1; flex: none; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer;
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px color-mix(in srgb, var(--acct-teal) 35%, transparent), 0 18px 40px -18px rgba(0,0,0,.35);
  transition: transform .25s var(--acct-ease);
}
.pf-ob__avatar:hover { transform: scale(1.03); }
.pf-ob__avatar:focus-visible { outline: 3px solid var(--acct-teal); outline-offset: 8px; }
.pf-ob__avatar .acct-iris__ring { stroke: var(--mark-ring); }
.pf-ob__avatar-badge {
  position: absolute; inset-inline-end: 4px; bottom: 4px; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; background: var(--acct-teal); color: #fff; box-shadow: 0 0 0 3px var(--surface);
}
.pf-ob__avatar-badge svg { width: 20px; height: 20px; }
.pf-ob__photo-actions { display: grid; gap: 10px; flex: 1; min-width: min(100%, 220px); }
.pf-ob__photo-actions .acct-btn { width: 100%; }

.pf-ob__study .acct-card { box-shadow: none; padding: 0; border: 0; }

.pf-ob__privacy { display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .pf-ob__privacy { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.pf-ob__privacy-controls { display: grid; gap: 18px; min-width: 0; }
.pf-ob__privacy .acct-vis__row { grid-template-columns: 1fr; }
.pf-ob__preview { position: sticky; top: 90px; display: grid; gap: 10px; min-width: 0; }
.acct-toggles.is-muted { opacity: .5; }

.pf-ob__foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pf-ob__foot-end { display: flex; gap: 10px; align-items: center; margin-inline-start: auto; }
.pf-ob__foot .acct-btn--primary { min-width: 150px; }
.pf-ob__skip { width: auto; border-color: transparent; }

.pf-bio { min-height: 70px; resize: vertical; line-height: 1.5; }
.pf-bio__count { text-align: end; font-family: var(--acct-mono); font-size: .72rem; }

/* ── Public profile settings card ─────────────────────────── */
.pf-settings__photo { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.pf-settings__avatar { width: 96px; }
.pf-settings__photo-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pf-settings__foot { display: flex; justify-content: flex-end; }
.pf-settings__share { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 16px; border-top: 1px solid var(--acct-line); }
.pf-settings__copy { width: auto; }
.acct-hub__col-main > [data-public] + [data-form] { margin-top: 20px; }

/* ── Cropper dialog ───────────────────────────────────────── */
.pf-crop { width: min(400px, calc(100vw - 24px)); margin: auto; max-height: calc(100dvh - 24px); overflow: auto; }
.pf-crop__body { justify-items: center; }
.pf-crop__body > * { width: 100%; }
.pf-crop__stage {
  position: relative; width: min(288px, 100%); aspect-ratio: 1; justify-self: center;
  border-radius: 18px; overflow: hidden; background: #0e1f1f; cursor: grab; touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.pf-crop__stage:active { cursor: grabbing; }
.pf-crop__stage:focus-visible { outline: 3px solid var(--acct-teal); outline-offset: 3px; }
.pf-crop__canvas { display: block; width: 100%; height: 100%; }
.pf-crop__ring {                              /* dims everything outside the circle */
  position: absolute; inset: 0; pointer-events: none; border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(8, 20, 20, .55), inset 0 0 0 2px rgba(255,255,255,.85);
}
.pf-crop__loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; }
.pf-crop__loading[hidden] { display: none; }
.pf-crop__loading svg { width: 28px; height: 28px; animation: acct-spin 1.2s linear infinite; }
.pf-crop__hint { text-align: center; }
.pf-crop__tools { display: flex; align-items: end; gap: 12px; }
.pf-crop__zoom { flex: 1; display: grid; gap: 2px; }
.pf-crop__zoom input { width: 100%; accent-color: var(--acct-teal); }
.pf-crop__rotate { min-height: 40px; padding-inline: 12px; }
.pf-crop__actions { display: flex; justify-content: flex-end; gap: 10px; }
.pf-crop .acct-status { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .pf-ob__card, .acct-hero__photo, .pf-ob__avatar { animation: none; transition: none; }
}
