/* =========================================================================
   ACCOUNT page (/account - account.html)
   Profile dashboard (identity + quota hero), the three plan cards, the library
   grid and the confirm dialog. Loaded after tokens.css + system.css.

   Everything reusable lives in system.css (.card, .badge, .btn), and so does
   .quota, although this page is its only consumer (see its header there); this
   file only holds the page's layout and the pieces unique to it.
   ========================================================================= */

.account-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.5rem var(--space-xl) 4rem;
}

.account-title {
  font-family: var(--heading);
  font-size: var(--text-4xl); font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--space-xl);
}


/* --------------------------------------------------------------------------
   PROFILE: identity row + quota hero
   Extends the shared .card with roomier padding (it is the page's hero).
   -------------------------------------------------------------------------- */

/* TWO GROUPS, SIDE BY SIDE: who you are, and what you have left.
   The balance leads — it is the question this page is opened to answer, and the only
   one on it that leads to an action. Identity supports it, so it takes the reading
   start (left) while the metric takes the emphasis (size).

   The balance column carries its own width (see `.quota`'s own min-width) rather than
   being sized by its content. Rendered evidence: with a plain `auto` track the column
   collapsed to its longest label, so the progress bar measured ~185px under
   `accCreditsRemaining` and half again as much under `accUsageRemaining` — the same
   meter changing shape with the language and with the billing mode, and its two end
   labels squeezed until they nearly touched. Given a width, the meter is the same object
   everywhere and the identity absorbs the slack, which is the right way round: an email
   is the unpredictable half.

   `align-items: start` keeps both blocks reading from the top edge rather than centring
   a two-line stack against a four-line one.

   The right column is `#quota-row`, hidden until `loadProfile` knows there is a number
   (admin and a dev run have none). With it display:none the grid quietly becomes one
   column, which is why the left side is not sized against it. */
.profile-card {
  padding: 1.8rem;
  margin-bottom: var(--space-xl);
  display: grid;
  /* `auto` plus a min-width on the balance itself, rather than a fixed second track.
     Both give the stable 250px meter; only this one still COLLAPSES when there is no
     balance to show (admin, or a run with quotas off, where `#quota-row` stays
     display:none) instead of reserving a quarter of the card for nothing. */
  /* `minmax(0, 1fr)`, not `1fr`: a bare `1fr` track has an automatic minimum of
     MIN-CONTENT, so a long unbreakable address could widen the track past the card
     rather than wrapping inside it. Defensive, not a fix for an observed break —
     measured at 485px of content the card does not overflow either way. It costs
     nothing and it is the form that stays correct when the content is not a
     well-behaved gmail address. */
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-2xl);
}

.profile-id { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-md); }

/* Avatar: the email's initial on a shortcrust disc (no upload, no external call) */
.avatar {
  width: 48px; height: 48px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--shortcrust);
  border-radius: 50%;
  font-family: var(--heading);
  font-size: var(--text-2xl); font-weight: 700;
  color: var(--cocoa-dk);
}
/* Badge, email, sign out — in that order, and NOT on one even gap. The badge and the
   email are one unit (a label and the thing it labels), so they sit tight; the button is
   a different kind of thing and gets air. An equal gap for all three made the button read
   as a third line of the identity. */
.profile-id-text {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: var(--space-xs);
  /* Keeps a long address from pushing the balance column narrower than its labels: the
     grid track is `1fr`, and without this a min-content floor of one unbroken email wins
     against it. Paired with `overflow-wrap` on .profile-email. */
  min-width: 0;
}
.profile-id-text #btn-logout { margin-top: var(--space-sm); }
.profile-email {
  font-family: var(--body); font-size: var(--text-lg); font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
}


/* --------------------------------------------------------------------------
   PLAN CARDS
   The card component itself now lives in system.css — /pricing is a second
   consumer, and the two screens must not drift into two different-looking price
   cards. Only what is specific to THIS page stays here.
   -------------------------------------------------------------------------- */

.plan-selector { margin-bottom: 3rem; }

.plan-pending-note {
  margin-top: var(--space-lg);
  font-family: var(--body); font-size: var(--text-sm);
  color: var(--ink-faded);
  text-align: center;
}


/* --------------------------------------------------------------------------
   LIBRARY
   -------------------------------------------------------------------------- */

/* One rule for both section headings on this page. The pack catalogue is a section
   like the library is, so it gets the library's heading rather than a second one
   tuned to look the same — that pair is exactly what drifts. The subtitle is the
   only addition: the packs need one sentence ("creations never expire") and the
   library needs none, so it carries a smaller margin than the bare heading. */
.account-library h2,
.plan-selector h2 {
  font-family: var(--heading);
  font-size: var(--text-2xl); font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--space-xl);
}

.plan-selector h2 + .plan-selector-sub {
  margin: calc(var(--space-xl) * -1 + var(--space-xs)) 0 var(--space-xl);
  font-family: var(--body); font-size: var(--text-base);
  color: var(--ink-soft);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-lg);
  align-items: start;
}

.library-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-faded);
  font-style: italic;
  font-size: var(--text-md);
  padding: 3rem var(--space-lg);
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

/* Card body: the shared .card (paper-2 + lift) plus this page's internals. */
.library-card { padding: var(--space-md); }
.library-card-thumb {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  aspect-ratio: 1;
  margin-bottom: var(--space-md);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.library-card-thumb img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: var(--space-sm);
}
.library-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: .15rem;
}
.library-card-prompt {
  font-family: var(--heading);
  font-size: var(--text-lg); font-weight: 600;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.library-card-head .badge { flex-shrink: 0; }
.library-card-meta {
  font-family: var(--body);
  font-size: var(--text-xs);
  color: var(--ink-faded);
}

/* Expandable params panel */
.lib-params-toggle {
  margin-top: var(--space-sm);
  font-family: var(--body);
  font-size: var(--text-2xs); font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft);
  background: none; border: none;
  cursor: pointer;
  padding: 0;
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
}
.lib-params-toggle svg { width: 14px; height: 14px; transition: transform var(--dur-base); }
.lib-params-toggle:hover { color: var(--ink); }
.lib-params {
  display: none;
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--line-soft);
}
.lib-params.open { display: block; }
.lib-params-toggle:has(+ .lib-params.open) svg { transform: rotate(180deg); }
.lib-param {
  display: flex; justify-content: space-between;
  font-family: var(--body);
  font-size: var(--text-xs);
  padding: .12rem 0;
}
.lib-param span:first-child { color: var(--ink-faded); }
.lib-param span:last-child { color: var(--ink); font-weight: 600; }

.library-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}
.library-card-actions .btn--primary { flex: 1; font-size: var(--text-sm); }
/* Icon-only actions: square-ish tap target, no text to pad around. */
.lib-icon-btn { padding: .32rem; border-radius: 50%; }
.lib-icon-btn svg { width: 16px; height: 16px; }


/* --------------------------------------------------------------------------
   DANGER ZONE (account deletion)
   -------------------------------------------------------------------------- */

/* Set apart rather than styled loudly: the burgundy hairline says "different
   kind of control" while the button keeps the shared .btn--danger grammar, so
   nothing here invents a second visual language for destructive actions. */
.danger-zone {
  margin-top: 3rem;
  border-color: rgb(var(--burgundy-rgb) / .35);
}
.danger-zone-title {
  margin: 0 0 .6rem;
  font-size: var(--text-lg); color: var(--burgundy);
}
.danger-zone-body { margin: 0 0 .5rem; color: var(--ink); line-height: 1.55; }
.danger-zone-alt {
  margin: 0 0 1.1rem;
  font-size: var(--text-sm); color: var(--ink-soft); line-height: 1.55;
}
/* Empty until something fails, so it takes no space when there is nothing to say. */
.danger-zone-error:not(:empty) {
  margin-bottom: .9rem;
  font-size: var(--text-sm); color: var(--burgundy);
}


/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */

@media (max-width: 820px) {
  .account-main { padding: var(--space-xl) var(--space-lg) 3rem; }
  .account-title { font-size: var(--text-3xl); }
  /* One column, and the balance keeps its DOM position — second, under the identity.
     No `order` swap to put the number first: that would make the visual order disagree
     with the DOM and focus order for the sake of a few hundred pixels, and the metric
     already leads by SIZE wherever it sits. It also stops right-aligning here, because
     a lone right-aligned block in a single column reads as a mistake rather than as a
     column edge; the bar's two labels keep their opposite ends. */
  .profile-card { grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); }
  /* Left-aligned, and with its own hairline. Side by side the gap and the column edge
     did the separating; stacked, neither exists — right-aligning a lone block in a
     single column reads as a mistake, and `--space-xl` alone lets the balance read as
     one more line of the identity block. This is the one place a rule earns itself,
     where proximity can no longer do the work. */
  .quota {
    text-align: left;
    border-top: 1px solid var(--line-soft);
    padding-top: var(--space-xl);
    /* Released once stacked: the meter already spans the column, and a 250px floor is
       what would push the card into a horizontal scroll on a 320px screen. */
    min-width: 0;
  }
  /* The plan-card steps moved to system.css WITH the component: /pricing uses it
     without loading this file, and a card that never collapsed on a phone was
     the exact bug the .doc-topbar move already taught us. */
}

@media (max-width: 480px) {
  .profile-card { padding: 1.2rem; }
  /* `minmax(0, 1fr)`, not `1fr`: a bare `1fr` track has a MIN-CONTENT floor, and the
     card title is one unwrappable line (nowrap + ellipsis), so a long prompt widened
     the track to its full length — measured 633px of card on a 375px screen, the
     badge and the actions off the edge. Above 480px the `minmax(220px, …)` floor
     is fixed, so the content never set it there. Pinned by e2e A3. */
  .library-grid { grid-template-columns: minmax(0, 1fr); }
}
