/* ============================================================
   BioStack account pages: /account and /credits
   Loaded after styles.css and reuses its tokens (:root) and its
   .btn / .btn-primary / .btn-outline buttons. Everything else here is
   prefixed (acct-, buy-) so landing-page style changes can't break it.
   ============================================================ */

/* The pages are dark only: native controls (scrollbars, form fields, the
   date/number pickers, autofill) draw in their dark style too. The pages
   also say so in <meta name="color-scheme">, before this file loads. */
:root { color-scheme: dark; }

.acct-page {
  /* White on the green buttons: #238636 is 4.63:1, the darker hover #1a7f37
     5.08:1 (WCAG AA 4.5:1 for button text; #2ea043 / #3fb950 were 3.37 and
     2.54). Same values as styles.css --green-btn / --green-btn-hover. */
  --acct-green: #238636;
  --acct-green-hover: #1a7f37;
  --acct-body: #c9d1d9;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
html.acct-html { scroll-padding-top: calc(var(--nav-h) + 16px); }

/* Buttons on these pages wrap instead of overflowing narrow screens. (Not the
   header's: it is the landing page's, styled by styles.css alone.) */
.acct-main .btn,
.acct-overlay .btn {
  min-height: 44px;
  padding: 10px 22px;
  white-space: normal;
  text-align: center;
  line-height: 1.3;
  border: 1px solid transparent;
}
.acct-main .btn-outline,
.acct-overlay .btn-outline { border-color: var(--accent); color: #c9c4ff; }
/* Keyboard focus: styles.css draws it for links and buttons; inputs here
   drop the default outline for a border colour, so draw it back. */
.acct-page input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Headings, notes and results the page moves focus to (tabindex="-1") get no
   ring: the player didn't tab there, the page put them there. */
.acct-page [tabindex="-1"]:focus { outline: none; }
.acct-btn-ghost {
  background: transparent;
  color: var(--acct-body);
  border-color: var(--border) !important;
}
.acct-btn-ghost:hover { border-color: var(--text-secondary) !important; color: #fff; }
.acct-btn-play { background: var(--acct-green); color: #fff; }
.acct-btn-play:hover { background: var(--acct-green-hover); color: #fff; box-shadow: 0 0 22px rgba(63, 185, 80, 0.3); }
.acct-btn-danger { background: rgba(248, 81, 73, 0.14); color: #ffb3ad; border-color: rgba(248, 81, 73, 0.55) !important; }
.acct-btn-danger:hover { background: rgba(248, 81, 73, 0.24); color: #fff; }
.acct-linkbtn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.acct-linkbtn:hover:not(:disabled) { color: var(--accent-hover); }
.acct-linkbtn:disabled { color: var(--text-secondary); text-decoration: none; cursor: not-allowed; opacity: 0.7; }

[hidden] { display: none !important; }

.acct-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   HEADER: the landing page's own .nav (styles.css), same markup, so the
   two always match (links in a drawer below 1240px; on phones up to 480px
   the credit pill moves into the avatar menu and Sign In into the drawer).
   The only rule styles.css keys to the landing's own id (#authBtn) is
   repeated for this page's Sign In in RESPONSIVE below.
   ============================================================ */

/* ============================================================
   PAGE SHELL
   ============================================================ */

.acct-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 36px) 24px 56px;
}
.acct-head { margin-bottom: 22px; }
.acct-head h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.acct-head p { color: var(--text-secondary); margin-top: 4px; overflow-wrap: anywhere; }

.acct-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.acct-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
/* Credits switched off hide the whole right column (share, credit history):
   the left one takes the full width instead of leaving half the page empty. */
.acct-grid:not(:has(> .acct-col + .acct-col > .acct-panel:not([hidden]))) { grid-template-columns: minmax(0, 1fr); }

.acct-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 30px;
  min-width: 0;
}
.acct-panel h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.acct-panel h3 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 22px 0 6px;
}
.acct-small { font-size: 0.85rem; color: var(--text-secondary); }
.acct-body { color: var(--acct-body); }
.acct-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.acct-note,
.acct-ok,
.acct-err,
.acct-warn {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.92rem;
  color: var(--acct-body);
  line-height: 1.55;
}
.acct-note { background: rgba(128, 117, 255, 0.10); border: 1px solid rgba(128, 117, 255, 0.4); }
.acct-ok { background: rgba(63, 185, 80, 0.12); border: 1px solid rgba(63, 185, 80, 0.5); color: var(--text-primary); }
.acct-err { background: rgba(248, 81, 73, 0.10); border: 1px solid rgba(248, 81, 73, 0.5); color: var(--text-primary); }
.acct-warn { background: rgba(210, 153, 34, 0.12); border: 1px solid rgba(210, 153, 34, 0.5); color: var(--text-primary); }
.acct-note strong, .acct-ok strong, .acct-err strong, .acct-warn strong { color: var(--text-primary); }
/* The accent purple is 3.7:1 on the amber notice (press@intactis.bio in the
   payments-paused notes): links there use the text colour, underlined. */
.acct-warn a,
.acct-warn a:hover { color: var(--text-primary); text-decoration: underline; text-underline-offset: 2px; }
.acct-banner { margin-bottom: 18px; }
.acct-banner .acct-actions { margin-top: 10px; }

/* Loading skeleton (no words: it is gone in well under a second). */
.acct-loading { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.acct-skel {
  height: 180px;
  border-radius: var(--radius-xl);
  background: linear-gradient(90deg, #161b22 0%, #1c2128 50%, #161b22 100%);
  background-size: 200% 100%;
  animation: acctShimmer 1.4s ease-in-out infinite;
}
@keyframes acctShimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .acct-skel { animation: none; } }

/* ============================================================
   BALANCE
   ============================================================ */

.acct-balance-label { font-size: 0.9rem; color: var(--text-secondary); }
.acct-balance-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin: 2px 0 8px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   RESERVATIONS
   ============================================================ */

.acct-res-list { display: flex; flex-direction: column; }
.acct-res {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border-light);
}
.acct-res:first-child { border-top: none; padding-top: 4px; }
.acct-res-main { flex: 1 1 260px; min-width: 0; }
.acct-res-when { font-weight: 700; color: var(--text-primary); }
.acct-res-meta { font-size: 0.88rem; color: var(--text-secondary); margin-top: 2px; }
.acct-res-sent { font-size: 0.88rem; color: var(--acct-body); margin-top: 6px; }
.acct-res-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.acct-res-past .acct-res-when { font-weight: 600; color: var(--acct-body); }
.acct-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.acct-badge-live { color: var(--success); border-color: rgba(63, 185, 80, 0.6); background: rgba(63, 185, 80, 0.12); }
.acct-past-state { font-size: 0.88rem; color: var(--text-secondary); margin-top: 2px; }
.acct-empty { color: var(--acct-body); }
.acct-empty .btn { margin-top: 12px; }

/* ============================================================
   PAYMENT METHOD
   ============================================================ */

.acct-card-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 16px;
}
.acct-card-value { font-weight: 700; font-size: 1.05rem; }

/* ============================================================
   SHARE
   ============================================================ */

.acct-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 18px;
  counter-reset: step;
  color: var(--acct-body);
}
.acct-steps li { position: relative; padding-left: 26px; }
.acct-steps li::before {
  counter-increment: step;
  content: counter(step) ".";
  position: absolute;
  left: 0;
  font-weight: 700;
  color: var(--accent);
}
.acct-field { display: flex; flex-direction: column; gap: 6px; }
.acct-field label { font-size: 0.85rem; color: var(--text-secondary); }
.acct-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font: 0.95rem var(--font);
}
.acct-input:focus { border-color: var(--accent); outline: none; }
.acct-input[aria-invalid="true"] { border-color: var(--danger); }
.acct-form { display: flex; flex-direction: column; gap: 14px; }
.acct-form .btn { width: 100%; }
.acct-form-error { color: #ff9b94; font-size: 0.88rem; min-height: 0; }
/* A good outcome under a form (confirmation email sent): same tone as the
   landing's .modal-ok-text, never the error red. */
.acct-form-ok { color: var(--success); font-size: 0.88rem; }
.acct-form-ok:empty { display: none; }
/* The line under a Resend Confirmation Email button (the /account banner and
   Play Now dialog, /credits' unconfirmed view): sent in the ok green, refused
   in the error red, as on the sign-in form (over .acct-small and .acct-dialog p). */
.acct-msg-ok, .acct-dialog .acct-msg-ok { color: var(--success); }
.acct-msg-err, .acct-dialog .acct-msg-err { color: #ff9b94; }
.acct-fine { font-size: 0.82rem; color: var(--text-secondary); text-align: center; }
.acct-share-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-bottom: 8px;
}
.acct-share-link { font-size: 0.88rem; overflow-wrap: anywhere; }
/* A staff decline reason can hold a URL or a long unbroken word: wrap it
   inside the card instead of widening the page. */
#shareStatus { overflow-wrap: anywhere; min-width: 0; }
.acct-status-label { font-weight: 700; }
.acct-status-pending { color: var(--warning); }
.acct-status-approved { color: var(--success); }
.acct-status-rejected { color: #ff9b94; }

/* ============================================================
   CREDIT HISTORY
   ============================================================ */

.acct-ledger-wrap {
  max-height: 560px;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px;
  border-radius: 6px;
}
/* account.js makes the box focusable when it scrolls (keyboard scrolling). */
.acct-ledger-wrap:focus { outline: none; }
.acct-ledger-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.acct-ledger { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.acct-ledger th,
.acct-ledger td {
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  vertical-align: top;
}
.acct-ledger thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  z-index: 1;
}
.acct-ledger .col-date { width: 112px; padding-right: 12px; }
.acct-ledger td.col-date { color: var(--text-secondary); font-size: 0.85rem; white-space: nowrap; }
.acct-ledger td.col-date span { display: block; font-size: 0.78rem; color: var(--text-muted); }
.acct-ledger .col-act { padding-right: 12px; overflow-wrap: anywhere; }
.acct-ledger .col-cr { width: 70px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.acct-ledger .pos { color: var(--success); }
.acct-ledger .neg { color: var(--text-primary); }
.acct-ledger tfoot td,
.acct-ledger tfoot th { border-bottom: none; padding-top: 12px; font-weight: 700; }
/* The Balance row stays in view at the foot of a long, scrolling history
   (its top line and shadow also show there is more above). */
.acct-ledger tfoot th,
.acct-ledger tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  box-shadow: inset 0 1px 0 var(--border), 0 -10px 12px -10px rgba(0, 0, 0, 0.7);
  z-index: 1;
}
.acct-ledger-empty { color: var(--acct-body); padding: 6px 0 4px; }
.acct-foot-line { margin-top: 14px; }

/* ============================================================
   SIGN IN (signed-out state on both pages)
   ============================================================ */

.acct-signin {
  max-width: 480px;
  margin: 0 auto;
}
.acct-signin .acct-head { text-align: center; }
.acct-signin-alt { text-align: center; margin-top: 18px; color: var(--acct-body); font-size: 0.92rem; }
.acct-signin-alt p + p { margin-top: 4px; }
.acct-forgot { text-align: right; font-size: 0.88rem; margin-top: -6px; }
.acct-signin-notice { margin-bottom: 16px; }

/* ============================================================
   DIALOGS
   ============================================================ */

.acct-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.acct-dialog {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.acct-dialog h2 { font-size: 1.35rem; color: var(--accent); margin: 0 36px 10px 0; line-height: 1.3; }
.acct-dialog p { color: var(--acct-body); }
.acct-dialog p + p { margin-top: 10px; }
.acct-dialog .acct-actions { margin-top: 20px; }
.acct-dialog .acct-actions .btn { flex: 1 1 160px; }
.acct-x {
  position: absolute;
  top: 14px; right: 14px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.acct-x:hover { border-color: var(--accent); }
.acct-dialog-when { font-weight: 700; color: var(--text-primary) !important; }
.acct-check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 0.92rem; color: var(--acct-body); }
.acct-check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; }
.acct-welcome-num { font-size: 2.8rem; font-weight: 800; color: var(--accent); line-height: 1; text-align: center; }
.acct-welcome-sub { text-align: center; margin-bottom: 14px; }
/* Welcome (COPY_DECK 2.1): centered, buttons stacked, as the landing's. */
.acct-welcome { text-align: center; }
.acct-welcome h2 { margin: 0 36px 8px; color: var(--text-primary); }
.acct-dialog .acct-stack { flex-direction: column; gap: 10px; }
.acct-dialog .acct-stack .btn { flex: 0 0 auto; width: 100%; }

/* ============================================================
   BUY CREDITS (/credits)
   ============================================================ */

.buy-main { padding-top: calc(var(--nav-h) + 40px); }
.buy-card {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 30px;
}
.buy-card h1 { font-size: 1.65rem; line-height: 1.25; font-weight: 700; color: var(--text-primary); }
.buy-price { margin: 6px 0 20px; font-size: 1rem; font-weight: 600; }
.buy-signin-line { margin: 6px 0 20px; color: var(--acct-body); }
.buy-label { margin: 0 0 8px; font-size: 0.85rem; color: var(--text-secondary); }
.buy-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.buy-chip {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-body);
  color: var(--text-primary);
  font: 700 1.15rem var(--font);
  cursor: pointer;
}
.buy-chip:hover:not(:disabled) { border-color: var(--text-secondary); }
.buy-chip[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: rgba(128, 117, 255, 0.16);
  color: #fff;
}
.buy-chip:disabled { opacity: 0.55; cursor: not-allowed; }
/* Forced colors (Windows High Contrast) drop the background, shadow and
   accent border above, which left the chosen amount looking like the rest:
   there it is filled with the system highlight and a thicker border. */
@media (forced-colors: active) {
  .buy-chip[aria-pressed="true"] {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
    border: 3px solid HighlightText;
    outline: 2px solid Highlight;
  }
  .buy-chip[aria-pressed="true"]:disabled {
    background: GrayText;
    color: Canvas;
    outline-color: GrayText;
    opacity: 1;
  }
}
.buy-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}
.buy-total { font-size: 1.12rem; font-weight: 700; }
.buy-paywith-val { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-weight: 600; }
.buy-paywith-val .acct-linkbtn { font-size: 0.85rem; font-weight: 400; }
.buy-notice {
  margin: 4px 0 18px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #161b22;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.buy-notice strong { color: var(--text-primary); }
.buy-nocard { margin: 4px 0 16px; }
.buy-nocard .btn { margin-top: 10px; }
.buy-pay {
  width: 100%;
  min-height: 50px !important;
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  border-radius: 10px !important;
}
/* Busy (Processing payment..., the bank's prompt): still focusable, no hover glow. */
.buy-pay[aria-disabled="true"]:hover { background: var(--accent); box-shadow: none; }
.buy-status { margin-top: 16px; }
.buy-result-icon { display: block; margin-bottom: 14px; }
.buy-result h1 { margin-bottom: 4px; }
.buy-result p { margin-top: 10px; color: var(--acct-body); line-height: 1.55; }
.buy-result .buy-strong { font-weight: 700; color: var(--text-primary); }
.buy-decline-detail { font-size: 0.88rem; color: var(--text-secondary); }

/* ============================================================
   FOOTER (same links as the landing page)
   ============================================================ */

.acct-page .footer { flex-shrink: 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 960px) {
  .acct-grid { grid-template-columns: minmax(0, 1fr); }
  .acct-loading { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .acct-main { padding: calc(var(--nav-h) + 22px) 16px 40px; }
  .buy-main { padding-top: calc(var(--nav-h) + 22px); }
  .acct-head h1 { font-size: 1.6rem; }
  .acct-panel { padding: 22px 18px; border-radius: var(--radius-lg); }
  .acct-balance-value { font-size: 2.4rem; }
  .acct-res-btns { width: 100%; }
  .acct-res-btns .btn { flex: 1 1 auto; }
  .acct-actions .btn { flex: 1 1 auto; }
  .acct-card-row .btn { width: 100%; }
  .acct-dialog { padding: 24px 18px; }
  .buy-card { padding: 22px 18px; }
  .buy-card h1 { font-size: 1.4rem; }
  .acct-ledger .col-date { width: 100px; padding-right: 10px; }
  .acct-ledger td.col-date { font-size: 0.8rem; }
  .acct-ledger .col-cr { width: 48px; }
  .acct-ledger { font-size: 0.88rem; }
  /* Phones: the whole history in the page's own scroll, no box inside it. */
  .acct-ledger-wrap { max-height: none; overflow: visible; }
  .acct-ledger thead th,
  .acct-ledger tfoot th,
  .acct-ledger tfoot td { position: static; box-shadow: inset 0 1px 0 var(--border); }
  .acct-page .footer-links { justify-content: center; gap: 12px 20px; }
}

/* styles.css hides the landing's header Sign In (#authBtn) here and shows the
   one in the drawer; the same for this page's. */
@media (max-width: 480px) {
  .nav-actions #navSignIn { display: none; }
}
