/* Copyright (C) 2023 Raymond Sun - All Rights Reserved
 * You may not use, distribute and modify this code without the author's written permission.
 */

/*
  The account surface: the sign-in card and the dashboard behind it.

  Laid out as a column of grouped cards in the manner of an iOS settings screen. The page
  it replaces used `.product`, a class no stylesheet in this repo defines, so every card
  rendered as bare text under a full-width teal bar.
*/

.acct-page{
  --acct-bg: #f2f2f7;
  --acct-card: #ffffff;
  --acct-sep: rgba(60, 60, 67, 0.13);
  --acct-label: #1c1c1e;
  --acct-label-2: #6e6e73;
  --acct-label-3: #8e8e93;
  --acct-brand: #0d9488;
  --acct-brand-dark: #0f766e;
  --acct-brand-soft: rgba(13, 148, 136, 0.1);
  --acct-red: #d70015;
  --acct-green: #248a3d;
  --acct-radius: 18px;
  /* Apple's standard interface curve. Motion starts fast and settles, which reads as
     responsive rather than animated. */
  --acct-ease: cubic-bezier(0.32, 0.72, 0, 1);

  box-sizing: border-box;
  min-height: 70vh;
  padding: 40px 16px 64px;
  background: var(--acct-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto,
               Helvetica, Arial, sans-serif;
  color: var(--acct-label);
  -webkit-font-smoothing: antialiased;
}

.acct-page *,
.acct-page *::before,
.acct-page *::after{ box-sizing: border-box; }

.acct-shell{
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- shared card ---------- */

.acct-card{
  background: var(--acct-card);
  border-radius: var(--acct-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.acct-card + .acct-card{ margin-top: 14px; }

.acct-section{ margin-bottom: 26px; }

.acct-section-title{
  margin: 0 0 8px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--acct-label-3);
}

.acct-pad{ padding: 16px 18px; }

/* ---------- identity header ---------- */

.acct-identity{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}

.acct-avatar{
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #14b8a6, #0d9488);
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  text-transform: uppercase;
}

.acct-identity-text{ min-width: 0; flex: 1 1 auto; }

.acct-identity-email{
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acct-identity-plan{
  margin-top: 3px;
  font-size: 13px;
  color: var(--acct-label-2);
}

/* ---------- buttons ---------- */

.acct-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  border: none;
  border-radius: 13px;
  background: var(--acct-brand);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s var(--acct-ease), background 0.18s var(--acct-ease),
              opacity 0.18s var(--acct-ease);
}

.acct-btn:hover{ background: var(--acct-brand-dark); color: #fff; text-decoration: none; }
/* The press, not the hover, is what makes a control feel physical on a touch screen. */
.acct-btn:active{ transform: scale(0.97); }
.acct-btn:focus-visible{ outline: 3px solid rgba(13, 148, 136, 0.4); outline-offset: 2px; }

.acct-btn-secondary{
  background: #fff;
  color: var(--acct-label);
  border: 1px solid var(--acct-sep);
}
.acct-btn-secondary:hover{ background: #f7f7f9; color: var(--acct-label); }

.acct-btn-tinted{
  background: var(--acct-brand-soft);
  color: var(--acct-brand-dark);
}
.acct-btn-tinted:hover{ background: rgba(13, 148, 136, 0.18); color: var(--acct-brand-dark); }

.acct-btn-destructive{ background: rgba(215, 0, 21, 0.09); color: var(--acct-red); }
.acct-btn-destructive:hover{ background: rgba(215, 0, 21, 0.16); color: var(--acct-red); }

.acct-btn-small{ min-height: 38px; font-size: 14px; width: auto; }

.acct-btn[disabled]{ opacity: 0.45; cursor: default; transform: none; }

.acct-btn-row{ display: flex; flex-wrap: wrap; gap: 8px; }
.acct-btn-row .acct-btn{ flex: 1 1 150px; }

/* ---------- sign in ---------- */

.acct-signin{ padding: 28px 22px 22px; text-align: center; }

.acct-mark{
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--acct-brand-soft);
  font-size: 26px;
}

.acct-signin h1{
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.acct-signin-sub{
  margin: 0 auto 22px;
  max-width: 340px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--acct-label-2);
}

.acct-divider{
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  font-size: 12px;
  color: var(--acct-label-3);
}
.acct-divider::before,
.acct-divider::after{ content: ''; flex: 1; height: 1px; background: var(--acct-sep); }

.acct-field{
  width: 100%;
  min-height: 46px;
  margin-bottom: 10px;
  padding: 0 15px;
  border: 1px solid var(--acct-sep);
  border-radius: 13px;
  background: #f7f7f9;
  font-family: inherit;
  font-size: 16px; /* below 16px iOS Safari zooms the whole page on focus */
  color: var(--acct-label);
  transition: border-color 0.18s var(--acct-ease), background 0.18s var(--acct-ease),
              box-shadow 0.18s var(--acct-ease);
}
.acct-field::placeholder{ color: var(--acct-label-3); }
.acct-field:focus{
  outline: none;
  background: #fff;
  border-color: var(--acct-brand);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.14);
}

.acct-signin-foot{
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--acct-label-3);
}

/* ---------- meter ---------- */

.acct-usage-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.acct-usage-figure{ font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.acct-usage-figure b{ font-weight: 700; }
.acct-usage-of{ font-size: 13px; color: var(--acct-label-2); }

.acct-meter{
  height: 8px;
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.1);
  overflow: hidden;
}

.acct-meter-fill{
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #14b8a6, #0d9488);
  transition: width 0.6s var(--acct-ease);
}

.acct-meter-fill.is-high{ background: linear-gradient(90deg, #f59e0b, #d97706); }
.acct-meter-fill.is-full{ background: linear-gradient(90deg, #ef4444, #d70015); }

.acct-note{
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--acct-label-3);
}

/* ---------- key card ---------- */

.acct-key-head{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--acct-sep);
}

.acct-key-title{ font-size: 16px; font-weight: 600; flex: 1 1 auto; }

.acct-status{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(36, 138, 61, 0.12);
  color: var(--acct-green);
}
.acct-status::before{
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.acct-status-off{ background: rgba(215, 0, 21, 0.1); color: var(--acct-red); }

.acct-key-value{
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 11px 12px;
  border-radius: 12px;
  background: #f7f7f9;
  border: 1px solid var(--acct-sep);
}

.acct-key-value code{
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--acct-label);
  background: none;
  padding: 0;
}

.acct-copy{
  flex: 0 0 auto;
  min-width: 68px;
  padding: 6px 12px;
  border: none;
  border-radius: 9px;
  background: var(--acct-brand-soft);
  color: var(--acct-brand-dark);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s var(--acct-ease), color 0.18s var(--acct-ease);
}
.acct-copy:hover{ background: rgba(13, 148, 136, 0.18); }
.acct-copy.is-done{ background: rgba(36, 138, 61, 0.14); color: var(--acct-green); }

/* Label left, value right, in the manner of a settings row. */
.acct-row{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  font-size: 14px;
  border-top: 1px solid var(--acct-sep);
}
.acct-row:first-of-type{ border-top: none; }
.acct-row dt{ color: var(--acct-label-2); font-weight: 400; }
.acct-row dd{ margin: 0; text-align: right; font-weight: 600; }

.acct-rows{ margin: 0 0 14px; }

/* ---------- disclosure ---------- */

.acct-disclose + .acct-disclose{ border-top: 1px solid var(--acct-sep); }

.acct-disclose-toggle{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 15px 18px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--acct-label);
  text-align: left;
  cursor: pointer;
}
.acct-disclose-toggle:hover{ color: var(--acct-brand-dark); }

.acct-chevron{
  margin-left: auto;
  font-size: 11px;
  color: var(--acct-label-3);
  transition: transform 0.3s var(--acct-ease);
}
.acct-disclose.is-open .acct-chevron{ transform: rotate(90deg); }

.acct-disclose-body{
  display: none;
  padding: 0 18px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--acct-label-2);
}
.acct-disclose.is-open .acct-disclose-body{ display: block; }
.acct-disclose-body p{ margin: 0 0 10px; }
.acct-disclose-body p:last-child{ margin-bottom: 0; }
.acct-disclose-body code{
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 1px 5px;
  border-radius: 5px;
  background: #f2f2f7;
  color: var(--acct-label);
}

/* ---------- skeleton ---------- */

.acct-skeleton{ padding: 18px; }

.acct-skeleton-line{
  height: 12px;
  margin-bottom: 11px;
  border-radius: 6px;
  background: linear-gradient(90deg, #ececed 25%, #f6f6f7 37%, #ececed 63%);
  background-size: 400% 100%;
  animation: acct-shimmer 1.4s ease infinite;
}
.acct-skeleton-line:last-child{ margin-bottom: 0; width: 55%; }

@keyframes acct-shimmer{
  from{ background-position: 100% 50%; }
  to{ background-position: 0 50%; }
}

/* ---------- toast ---------- */

.acct-toast{
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  /* Not a pill: an error long enough to wrap turns a 999px radius into a lozenge. */
  border-radius: 20px;
  background: rgba(28, 28, 30, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.26);
  transform: translate(-50%, 140%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.45s var(--acct-ease), opacity 0.3s var(--acct-ease);
}
.acct-toast.is-visible{ transform: translate(-50%, 0); opacity: 1; }
.acct-toast.is-error{ background: rgba(179, 0, 17, 0.94); }

.acct-spinner{
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
  border-radius: 50%;
  animation: acct-spin 0.7s linear infinite;
}

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

/* ---------- action sheet ---------- */

.acct-sheet-backdrop{
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  transition: opacity 0.28s var(--acct-ease);
}
.acct-sheet-backdrop.is-visible{ opacity: 1; }

.acct-sheet{
  width: 100%;
  max-width: 420px;
  padding: 22px 20px 20px;
  border-radius: 22px;
  background: var(--acct-card);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  transform: translateY(28px);
  transition: transform 0.36s var(--acct-ease);
}
.acct-sheet-backdrop.is-visible .acct-sheet{ transform: translateY(0); }

.acct-sheet h2{ margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.acct-sheet p{ margin: 0 0 18px; font-size: 14px; line-height: 1.55; color: var(--acct-label-2); }

@media (min-width: 600px){
  .acct-sheet-backdrop{ align-items: center; }
}

@media (prefers-reduced-motion: reduce){
  .acct-page *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
