/*
 * The account page (Account.js) — what the bubble beside the bottom nav opens.
 *
 * The shell is the tool pages' (see odds-converter.css for the long form): a
 * fixed page at z-index 70 that fades while its sheet rises, with its own
 * scrolling body so the tab under it keeps its place. Restated here for the
 * reason those files give — a sixth copy now, and they all want one
 * `.tool-page`; this is another vote for folding them.
 *
 * Below the hero the page is the mock's: white cards on the off-white page,
 * a hairline between rows, the accent kept for the one CTA and the switch,
 * and gold — the tier's colour and nothing else's in tokens.css — on the
 * plan badge alone. Nothing casts a shadow but the photo's ring.
 */

/* --- Shell -------------------------------------------------------------------- */

.account {
  --enter-y: 12px;

  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  max-width: var(--app-max-width);
  margin-inline: auto;
  background: var(--bg);
  opacity: 0;
  transition: opacity var(--duration) var(--easing);
}

.account[hidden] {
  display: none;
}

.account [hidden] {
  display: none !important;
}

.account[data-open="true"] {
  --enter-y: 0px;

  opacity: 1;
}

.account__sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: var(--safe-top);
  transform: translateY(var(--enter-y));
  transition: transform var(--duration) var(--easing);
}

/* The page's own scroller, so the tab pane under it keeps its place. */
.account__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.account-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: 0 var(--space-4) calc(var(--space-8) + var(--safe-bottom));
}

/* The toasts sit at the foot of the page rather than above the nav's
   footprint (the slip's default) — there is no nav under this page. */
.account .slip-toasts {
  position: absolute;
  right: 0;
  bottom: calc(var(--space-4) + var(--safe-bottom));
  left: 0;
}

/* --- Top row -------------------------------------------------------------------- */

.account-top {
  display: flex;
  align-items: center;
  /* Pulls the button out to the page's edge, where every other page keeps it. */
  margin-inline: calc(var(--space-1) * -1);
  padding-top: var(--space-4);
}

/* --- Hero -------------------------------------------------------------------------- */

.account-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  text-align: center;
}

/*
 * The photo, ringed. The one shadow on the page: the ring lifts the face off
 * the page the way the mock's does off its gradient, and a photo with no edge
 * of its own (a dark portrait on the off-white) still ends somewhere.
 */
.account-hero__avatar {
  display: grid;
  place-items: center;
  margin-bottom: var(--space-3);
  padding: 4px;
  background: var(--surface);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-card);
}

/* The monogram at portrait size — the primitive's 12px is sized for a crest. */
.account-hero__avatar .logo--monogram {
  background: var(--accent-tint);
  color: var(--accent);
  font-size: var(--text-2xl);
  letter-spacing: 0;
}

.account-hero__name {
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.account-hero__handle {
  color: var(--text-muted);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
}

.account-hero__edit {
  margin-top: var(--space-3);
  padding-inline: var(--space-5);
  font-size: var(--text-sm);
}

/* --- Referral card ------------------------------------------------------------------- */

.account-referral {
  position: relative;
  display: flex;
  overflow: hidden;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

/* Leaves the art its corner: the text stops well short of the right edge. */
.account-referral__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  max-width: 72%;
}

.account-referral__title {
  color: var(--text);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  line-height: 1.3;
}

.account-referral__sub {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.35;
}

.account-referral__cta {
  margin-top: var(--space-2);
  padding-inline: var(--space-5);
  font-size: var(--text-sm);
}

/*
 * The stand-in for the mock's artwork: a trophy in the accent tint, bleeding
 * off the bottom-right corner the way the crowd's hands do. Replace the glyph
 * with the image and keep the box.
 */
.account-referral__art {
  position: absolute;
  right: -10px;
  bottom: -18px;
  display: grid;
  place-items: center;
  color: var(--accent);
  opacity: 0.16;
  transform: rotate(-12deg);
  pointer-events: none;
}

/* --- Sections and rows --------------------------------------------------------------- */

.account-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.account-section__label {
  padding-left: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.account-list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.account-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 60px;
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  text-align: left;
  /* Press scale comes from [data-pressable] in interactions.css. */
  transition:
    background-color var(--duration) var(--easing),
    transform var(--spring-duration) var(--spring);
}

.account-row + .account-row {
  border-top: 1px solid var(--border);
}

.account-row[data-pressed="true"] {
  background: var(--surface-sunken);
}

.account-row__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  color: var(--text);
}

.account-row__label {
  flex: 1;
  min-width: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.account-row__trailing {
  display: contents;
}

.account-row__chevron {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

/* Sign out: the error colour on the glyph and the label, so the row reads as
   leaving rather than as one more page. The chevron stays muted — it is the
   row's, not the action's. */
.account-row--danger .account-row__icon,
.account-row--danger .account-row__label {
  color: var(--error-strong);
}

/* No chevron: it leads nowhere, it leaves. */
.account-row--danger .account-row__chevron {
  display: none;
}

/* --- Plan --------------------------------------------------------------------------------- */

.account-plan {
  min-height: 84px;
}

/* Tier status, in the tier's colour: the one place on the page gold appears. */
.account-plan__badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: var(--gold-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--gold);
}

/* Off the tier, the crown goes quiet: the badge says what there is to have. */
.account-plan[data-plan="free"] .account-plan__badge {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.account-plan__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.account-plan__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: 1.2;
}

.account-plan__note {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.35;
}

/* --- Settings ------------------------------------------------------------------------------ */

/*
 * The filter sheet's switch on this page's row: its own sunken chrome comes
 * off so it sits in the card like the rows above it, and only the track and
 * knob remain of it. The text block takes the row's type so the label reads
 * at the same size as "My Slips" beside it.
 */
.account-row.filter-switch {
  padding: var(--space-3) var(--space-4);
  background: none;
  border-radius: 0;
}

.account-row.filter-switch[data-pressed="true"] {
  background: var(--surface-sunken);
}

.account-row.filter-switch .filter-switch__label {
  font-size: var(--text-md);
}

.account-row.filter-switch:disabled {
  cursor: default;
}

.account-row.filter-switch:disabled .filter-switch__track {
  opacity: 0.5;
}

/* While Telegram is being asked, the knob waits where it is and the row says so. */
.account-row.filter-switch[aria-busy="true"] .filter-switch__track {
  opacity: 0.6;
}

/* --- Reduced motion ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .account,
  .account__sheet,
  .account-row {
    transition: none;
  }
}
