/* Account pages: sign in, create account, forgotten password, and the portal.
 *
 * Built from the same tokens as ride.css (surface, line, accent, radius) so the portal does not
 * look like a different site bolted on. The only new idea here is the fact list: account values
 * are label-and-value pairs, not prose, and they need to stay aligned when the Chinese labels are
 * longer than the English ones.
 */

.account-shell { max-width: 62rem; }

/* Two pages, one shell: a menu on the left, the chosen page on the right.
 *
 * The menu is a column of buttons, not links, because switching must not reload: every value on
 * this page is fetched after load, and a reload would re-request the account the visitor is already
 * reading. On a narrow screen the column turns into a row above the page, which is the shape the
 * phone already uses for tabs everywhere else in the app.
 */
.account-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.account-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 24px;
}
.account-nav__item {
  appearance: none;
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  text-align: left;
  font: inherit;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.account-nav__item:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.account-nav__item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The selected page is marked by a bar and full-strength text rather than a filled pill: a filled
 * pill in this palette reads as a button that does something when pressed. */
.account-nav__item.is-on {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 2px 0 0 var(--accent);
}

.account-panel[hidden] { display: none; }
.account-panels { min-width: 0; }

.account-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.account-top h2 { margin-bottom: 0; }
.account-signout { flex: 0 0 auto; }

.account-loading { color: var(--muted); font-size: 15px; }
.account-alt { color: var(--muted); font-size: 15px; margin: 18px 0 0; }
.account-alt a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.account-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.account-footnote { margin-top: 30px; }

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.account-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 2.6vw, 30px);
  margin-bottom: 20px;
}
.account-grid .account-card { margin-bottom: 0; }
.account-card h3 {
  font-size: 17px;
  letter-spacing: 0.01em;
  margin: 0 0 16px;
}

.account-facts { margin: 0; display: grid; gap: 14px; }
.account-facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.account-facts > div:last-child { border-bottom: 0; padding-bottom: 0; }
.account-facts dt { color: var(--muted); font-size: 14px; }
.account-facts dd {
  margin: 0;
  text-align: right;
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Free and Pro need to be distinguishable at a glance; the word alone is easy to skim past. */
.plan-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0E1013;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.plan-badge--pro {
  border-color: rgba(255, 75, 31, 0.55);
  background: rgba(255, 75, 31, 0.14);
  color: #FFCDB5;
}

/* A form inside a card should not draw a second card around itself. */
.form-card--flat {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  max-width: 100%;
  margin-top: 18px;
}

.account-card--danger { border-color: rgba(255, 75, 31, 0.30); }
.account-danger { margin-top: 18px; }
.account-danger summary {
  cursor: pointer;
  display: inline-block;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 75, 31, 0.45);
  color: #FFCDB5;
  font-size: 15px;
  font-weight: 600;
}
.account-danger summary:hover { border-color: rgba(255, 75, 31, 0.8); }
.account-danger[open] summary { margin-bottom: 6px; }

.account-done {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 2.6vw, 30px);
  margin-top: 24px;
}
.account-done h3 { margin: 0 0 12px; font-size: 18px; }
.account-done .btn { margin-top: 8px; }

/* Fitness card: three figures over a two-line chart. The chart is an SVG with a fixed viewBox so
   it can stretch to the card's width without a redraw on resize. */
.fitness-figures {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 4px 0 14px;
}
.fitness-figures > div { display: flex; flex-direction: column; gap: 2px; }
.fitness-label { color: var(--muted); font-size: 12px; letter-spacing: .02em; text-transform: uppercase; }
.fitness-figures strong { font-size: clamp(22px, 2.4vw, 28px); font-variant-numeric: tabular-nums; }
/* Each figure in its series colour, so the number above the chart and the line inside it are
   obviously the same thing. */
.fit-fig--fitness { color: #3FA7F5; }
.fit-fig--fatigue { color: #8B5CF6; }
.fit-fig--form { color: #9AA3AD; }
.fitness-chart { width: 100%; height: auto; aspect-ratio: 600 / 180;
  display: block; margin: 0 0 10px; }
.fitness-chart[hidden] { display: none; }
/* The form pane carries its own axis, so it is a second chart rather than an extra plot line.
   150/600 keeps the same 10:2.5 proportions as the top pane without shrinking it to a strip. */
.fitness-chart--form { aspect-ratio: 600 / 150; margin: 14px 0 0; }

/* Chips and readout: the range is a view control, not a filter on what was fetched (one call
   covers six months), so switching is instant and costs no quota. */
.fitness-ranges { display: flex; gap: 8px; margin: 10px 0 2px; }
.fitness-ranges[hidden] { display: none; }
.fit-chip {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12px; cursor: pointer;
}
.fit-chip.is-on { background: rgba(255, 255, 255, 0.10); color: #fff; border-color: transparent; }
.fit-chip:focus-visible { outline: 2px solid var(--accent, #ff4b1f); outline-offset: 2px; }

/* Legend left, readout right, above the charts. The readout only exists while a pointer or a
   finger is on the chart, so it must not reserve space by itself - the row keeps its height from
   the legend, and the readout is right-aligned into it. */
.fitness-chart-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 10px 0 4px;
}
.fitness-chart-head[hidden] { display: none; }
.fitness-readout {
  display: flex; gap: 18px; font-variant-numeric: tabular-nums; text-align: right;
}
.fitness-readout[hidden] { display: none; }
.fit-cell { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.fit-cell:first-child { align-items: flex-start; }
.fit-k { font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.fit-v { font-size: 15px; color: #fff; }
.fit-v--fitness { color: #3FA7F5; }
.fit-v--fatigue { color: #8B5CF6; }
.fit-v--form { color: #9AA3AD; }

/* Narrow screens: the legend and a four-column table cannot share a line, so the table drops
   underneath and stays right-aligned. */
@media (max-width: 620px) {
  .fitness-chart-head { flex-direction: column; align-items: stretch; gap: 6px; }
  .fitness-readout { justify-content: flex-start; gap: 14px; }
  .fit-cell { align-items: flex-start; }
  .fit-cell:first-child { min-width: 44px; }
}

/* A finger dragging across the chart scrubs; a finger dragging down still scrolls the page. */
.fitness-panes { touch-action: pan-y; }

.fitness-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.fitness-legend[hidden] { display: none; }
.fitness-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fit-dot { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.fit-dot--fitness { background: #3FA7F5; }
.fit-dot--fatigue { background: #8B5CF6; }
.fit-dot--form { background: #9AA3AD; }

@media (max-width: 860px) {
  .account-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .account-nav {
    position: static;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .account-nav__item {
    flex: 0 0 auto;
    text-align: center;
    padding: 9px 16px;
    border: 1px solid var(--line);
  }
  .account-nav__item.is-on {
    box-shadow: none;
    border-color: var(--accent);
  }
}

@media (max-width: 760px) {
  .account-grid { grid-template-columns: minmax(0, 1fr); }
  .account-facts > div { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .account-danger summary { transition: none; }
}
