/**
 * Subscription-management website presentation.
 *
 * The static billing website intentionally mirrors Repetitia's compact dark
 * surfaces and rounded action controls. Layout rules remain independent from
 * management state: JavaScript adds only the details and actions authorized by
 * the backend, while this file keeps all resulting states visually consistent.
 */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

/* -------------------------------------------------------------------------- */
/* Global theme and sizing                                                     */
/* -------------------------------------------------------------------------- */

:root {
  color-scheme: dark;
  font-family: Roboto, Arial, sans-serif;
  background: #111318;
  color: #e3e2e9;
}

* {
  box-sizing: border-box;
}

/**
 * Preserve the native hidden-state contract for dynamically rendered billing
 * details. JavaScript uses the hidden property while loading or clearing state.
 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #111318;
}

/* -------------------------------------------------------------------------- */
/* Responsive page shell and shared cards                                      */
/* -------------------------------------------------------------------------- */

.page-shell {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 16px 36px;
}

.account-panel,
.details-panel {
  background: #1b1b1f;
  border: 1px solid #45464f;
  border-radius: 16px;
}

.account-panel {
  padding: 20px 18px 18px;
}

.brand-logo {
  display: block;
  width: min(188px, 58%);
  height: auto;
  margin: 0 auto 20px;
}

.panel-header {
  margin-bottom: 16px;
}

/* -------------------------------------------------------------------------- */
/* Typography and live request status                                          */
/* -------------------------------------------------------------------------- */

.section-label {
  margin: 0 0 6px;
  color: #a9c7ff;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.3;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  color: #f7f7ff;
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.25;
}

h2 {
  margin-bottom: 4px;
  color: #f7f7ff;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
}

.summary-text {
  margin-bottom: 0;
  color: #c7c6d0;
  font-size: 0.92rem;
  line-height: 1.45;
}

/* The role=status element announces loading, success, and error messages. */
.status-message {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #202126;
  color: #c7c6d0;
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.4;
}

.status-message.error {
  color: #ffb4ab;
}

.loading-spinner {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  margin-right: 0.55rem;
  border: 2px solid #a9c7ff66;
  border-top-color: #a9c7ff;
  border-radius: 50%;
  vertical-align: -0.12rem;
  animation: billing-status-spin 0.8s linear infinite;
}

@keyframes billing-status-spin {
  to {
    transform: rotate(360deg);
  }
}

.recovery-card {
  margin-top: 8px;
  padding: 18px;
  border: 1px solid #f5a524;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b2b16, #2a2119);
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
}

.recovery-card h2 {
  margin-bottom: 8px;
  color: #ffd180;
}

.recovery-card p {
  margin: 0;
  color: #ffe0b2;
  font-size: 0.92rem;
  line-height: 1.5;
}

/* -------------------------------------------------------------------------- */
/* Backend-authorized billing actions                                          */
/* -------------------------------------------------------------------------- */

.plan-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  padding: 14px;
  border: 1px solid #45464f;
  border-radius: 14px;
  background: #202126;
}

.cadence {
  margin-bottom: 0;
  color: #c7c6d0;
  font-size: 0.9rem;
  line-height: 1.35;
}

/* Checkout and portal actions share one prominent, keyboard-visible control. */
.primary-button {
  min-width: 112px;
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  border-radius: 999px;
  background: #2d86f3;
  color: #ffffff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
}

.primary-button:hover:not(:disabled) {
  background: #5aa1ff;
}

.primary-button:focus-visible {
  outline: 3px solid #a9c7ff;
  outline-offset: 3px;
}

/* Disabled styling communicates that a one-time token handoff is in progress. */
.primary-button:disabled {
  background: #45464f;
  color: #c7c6d0;
  cursor: not-allowed;
}

/* -------------------------------------------------------------------------- */
/* Current account and entitlement details                                     */
/* -------------------------------------------------------------------------- */

/*
 * Non-complimentary states retain the compact definition-list layout because
 * those states may legitimately expose multiple short billing facts, such as
 * the current interval, next renewal date, or scheduled account action.
 */
.account-details {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid #45464f;
  border-radius: 14px;
  background: #202126;
}

.account-details div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.account-details dt {
  color: #c7c6d0;
}

.account-details dd {
  margin: 0;
  color: #f7f7ff;
  font-weight: 500;
  text-align: right;
}

/*
 * Every state presents the current plan as the first entitlement card. Paid
 * subscriptions place the renewal or scheduled access-end date directly under
 * the plan name. Complimentary access uses the same location for its access-
 * through date, keeping the lifecycle boundary visible and unambiguous.
 *
 * The :has() selector removes the outer definition-list chrome whenever the
 * current-plan card is present; any secondary facts remain below the card.
 */
.account-details:has(.entitlement-card) {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

.entitlement-card {
  margin: 0 0 18px;
  padding: 20px;
  border: 1px solid #565867;
  border-radius: 16px;
  background: linear-gradient(145deg, #262833, #202126);
  box-shadow: 0 12px 30px rgb(0 0 0 / 18%);
}

/* Uppercase eyebrow label establishes context without competing with the plan. */
.entitlement-label {
  margin: 0 0 6px;
  color: #b9b8c4;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Scholar remains the dominant visual element because it is the active access. */
.entitlement-card h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.55rem;
}

/* The expiration sentence is intentionally plain language rather than a label. */
.entitlement-expiration {
  margin: 8px 0 0;
  color: #e5e4ec;
  font-size: 1rem;
  line-height: 1.5;
}

.details-panel {
  padding: 18px;
}

.scholar-includes {
  margin: 0 0 14px;
}

.details-panel h2 {
  margin-bottom: 10px;
}

.details-panel ul {
  margin: 0;
  padding-left: 18px;
  color: #e3e2e9;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* -------------------------------------------------------------------------- */
/* Narrow-screen layout                                                        */
/* -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .page-shell {
    padding: 16px 12px 28px;
  }

  .account-panel,
  .details-panel {
    border-radius: 14px;
  }

  .plan-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }
}
