/*
  Shared product chrome: topbar, footer, buttons, form controls, cards,
  badges, flashes. Recipes are documented in
  docs/superpowers/specs/2026-08-30-web-ui-design.md §6 and
  docs/superpowers/specs/2026-08-31-web-ui-polish.md.
*/

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--color-topbar-bg);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: var(--border-hairline-width) solid var(--color-border-hairline);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-primary);
  min-width: 0;
}

.brand:hover {
  color: var(--color-text-primary);
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: var(--fs-heading-lg);
  font-weight: 800;
  line-height: var(--lh-heading-lg);
  letter-spacing: var(--ls-heading-lg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

/* Text links only. Avatar and Discord keep their own square sizing. */
.topbar-nav a:not(.topbar-avatar):not(.icon-link) {
  display: inline-flex;
  align-items: center;
  height: var(--control-height-sm);
  color: var(--color-text-secondary);
  font-size: var(--fs-body-md);
  font-weight: 500;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.topbar-nav a:not(.topbar-avatar):not(.icon-link):hover {
  color: var(--color-text-primary);
  background: var(--color-surface-hover);
}

.topbar-nav a.is-active {
  color: var(--color-text-primary);
  background: var(--color-brand-orange-soft);
}

.topbar-nav .topbar-avatar,
.topbar-nav .icon-link {
  width: 32px;
  height: 32px;
  padding: 0;
  margin-left: var(--space-2);
  justify-content: center;
}

.topbar-nav .topbar-avatar {
  border-radius: var(--radius-full);
}

.icon-link {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  font-size: var(--fs-heading-md);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.icon-link:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-hover);
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-brand-orange-soft);
  color: var(--color-brand-orange);
  display: grid;
  place-items: center;
  font-size: var(--fs-body-sm);
  font-weight: 600;
  line-height: 1;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px var(--color-border-strong);
  transition: box-shadow var(--transition-fast);
}

.topbar-avatar:hover {
  box-shadow: inset 0 0 0 1px var(--color-brand-orange);
}

.topbar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  flex-shrink: 0;
  margin-top: var(--space-8);
  border-top: var(--border-hairline-width) solid var(--color-border-hairline);
  color: var(--color-text-secondary);
  font-size: var(--fs-body-sm);
  padding: var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-height);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: var(--border-hairline-width) solid transparent;
  font: inherit;
  font-size: var(--fs-body-md);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  text-transform: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast);
}

.btn i {
  font-size: 1em;
  line-height: 1;
}

.btn-lg {
  height: var(--control-height-lg);
  padding: 0 var(--space-5);
  font-size: var(--fs-body-lg);
}

.btn-sm {
  height: var(--control-height-sm);
  padding: 0 var(--space-3);
  font-size: var(--fs-body-sm);
}

.btn-primary {
  background: var(--color-brand-orange);
  color: var(--color-text-on-accent);
}

.btn-primary:hover {
  background: var(--color-brand-orange-hover);
  color: var(--color-text-on-accent);
}

.btn-secondary {
  background: transparent;
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-strong);
  color: var(--color-text-primary);
}

/* Low-emphasis action that lives next to a primary one — no border until hover. */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
}

.btn-block {
  width: 100%;
}

.btn-google {
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}

.btn-google:hover {
  background: var(--color-surface-overlay);
  color: var(--color-text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

/* Square icon-only button; keep an aria-label on it. */
.btn-icon {
  width: var(--control-height);
  padding: 0;
  flex-shrink: 0;
}

.btn-icon.btn-sm {
  width: var(--control-height-sm);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* A row of buttons, or a button next to a link. */
.actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================================
   Divider
   ============================================================ */

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-caption);
  text-transform: uppercase;
  margin: var(--space-5) 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border-hairline);
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  display: block;
  background: var(--color-surface-raised);
  border: var(--border-hairline-width) solid var(--color-border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.card + .card {
  margin-top: var(--space-4);
}

.card > h2:first-child,
.card > .card-head:first-child {
  margin-top: 0;
}

.card h2 {
  font-size: var(--fs-heading-md);
  margin-bottom: var(--space-3);
}

/* Title on the left, action on the right. */
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.card-head h2 {
  margin-bottom: 0;
}

.card-head .btn {
  flex-shrink: 0;
}

/* Label / value rows for read-only facts — replaces stacks of bare <p>. */
.meta-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}

.meta-list > div {
  display: grid;
  grid-template-columns: minmax(7rem, 12rem) 1fr;
  gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-2) 0;
  border-bottom: var(--border-hairline-width) solid var(--color-border-hairline);
}

.meta-list > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.meta-list dt,
.meta-list .meta-key {
  color: var(--color-text-secondary);
  font-size: var(--fs-body-md);
}

.meta-list dd,
.meta-list .meta-value {
  margin: 0;
  color: var(--color-text-primary);
  font-size: var(--fs-body-md);
  word-break: break-word;
}

@media (max-width: 640px) {
  .meta-list > div {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
}

/* Empty state: icon, one line of what is missing, one action. */
.empty-state {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  color: var(--color-text-secondary);
}

.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-surface-overlay);
  color: var(--color-text-secondary);
  font-size: var(--fs-display-sm);
}

.empty-state p {
  max-width: 42ch;
}

.empty-state .empty-title {
  color: var(--color-text-primary);
  font-weight: 600;
}

.empty-state .empty-icon.is-spinning {
  animation: rlt-spin 1.2s linear infinite;
}

@keyframes rlt-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   Form controls
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

/* Both markup shapes are in use: <div class="field"><label>…  and
   <label class="field"><span>… — they must look identical. */
.field > label,
.field > span {
  font-size: var(--fs-body-md);
  font-weight: 500;
  line-height: var(--lh-body-md);
  color: var(--color-text-secondary);
}

/* The control recipe is bound to the elements, not to .field, so a control
   placed outside a field (a value cell in a table, for example) can never fall
   back to the native light-on-white rendering. */
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea,
.form-control {
  height: var(--control-height);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: var(--border-hairline-width) solid var(--color-border-strong);
  background: var(--color-surface-canvas);
  color: var(--color-text-primary);
  font: inherit;
  font-size: var(--fs-body-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
    background-color var(--transition-fast);
}

textarea,
textarea.form-control {
  height: auto;
  min-height: calc(var(--control-height) * 2);
  padding: var(--space-3);
  line-height: var(--lh-body-md);
  resize: vertical;
}

select,
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-6);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

select option {
  background: var(--color-surface-overlay);
  color: var(--color-text-primary);
}

/* Width belongs to the layout context, not to the control itself, so a control
   in a table cell can still size itself. */
.field input,
.field select,
.field textarea,
.form-control {
  width: 100%;
}

/* Controls carry their own focus treatment (orange border + soft ring), so the
   global focus outline would double up on them. */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.form-control:focus-visible {
  outline: none;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--color-brand-orange);
  outline-offset: 2px;
}

input::placeholder,
textarea::placeholder,
.form-control::placeholder {
  color: var(--color-text-placeholder);
}

input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover,
.form-control:hover {
  border-color: var(--color-text-faint);
}

input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus,
.form-control:focus {
  outline: none;
  border-color: var(--color-brand-orange);
  box-shadow: 0 0 0 var(--focus-ring-width) var(--color-brand-orange-soft);
}

/* Read-only values are still selectable, but must not read as editable. */
input[readonly],
textarea[readonly],
.form-control[readonly] {
  color: var(--color-text-secondary);
  background: var(--color-surface-sunken);
  border-color: var(--color-border-hairline);
  cursor: default;
}

input[readonly]:hover,
.form-control[readonly]:hover {
  border-color: var(--color-border-hairline);
}

input:disabled,
select:disabled,
textarea:disabled,
.form-control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Hide the number spinners: prices are typed, not nudged. */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--color-brand-orange);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Helper text under a control. */
.field .hint {
  margin-top: calc(var(--space-1) * -1);
}

/* ============================================================
   Lists
   ============================================================ */

.list {
  margin: 0;
  padding-left: var(--space-4);
  color: var(--color-text-secondary);
}

.list li + li {
  margin-top: var(--space-2);
}

/* ============================================================
   Flash / alert
   ============================================================ */

.flash,
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: var(--border-hairline-width) solid transparent;
  margin-bottom: var(--space-4);
  font-size: var(--fs-body-md);
  line-height: var(--lh-body-md);
}

.flash-ok,
.alert-success {
  background: var(--color-brand-green-soft);
  border-color: rgba(46, 212, 122, 0.32);
  color: var(--color-text-primary);
}

.flash-error,
.alert-error {
  background: var(--color-danger-soft);
  border-color: rgba(229, 72, 77, 0.36);
  color: var(--color-danger);
}

/* Consent / opt-in checkbox with a full sentence next to it. Lives here rather
   than in account.css because the public buy flow needs it too. */
.checkbox-field {
  display: flex;
  flex-direction: row;
  gap: var(--space-3);
  align-items: flex-start;
  margin-bottom: 0;
}

.checkbox-field > span {
  color: var(--color-text-primary);
  font-weight: 400;
  font-size: var(--fs-body-md);
  line-height: var(--lh-body-md);
}

.checkbox-field input {
  margin-top: 0.2em;
}

/* ============================================================
   Notice
   ============================================================ */

/* A standing callout that is part of the page, not feedback about an action.
   .alert is the flash-derived one and reads as transient; this one does not. */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: var(--border-hairline-width) solid var(--color-border-hairline);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font-size: var(--fs-body-md);
  line-height: var(--lh-body-md);
}

.notice > i {
  flex-shrink: 0;
  font-size: var(--fs-heading-md);
  line-height: var(--lh-body-md);
  color: var(--color-text-secondary);
}

.notice-title {
  color: var(--color-text-primary);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

/* A short rule list inside a notice: scannable points instead of one dense paragraph. */
.notice-list {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding-left: var(--space-5);
}

.notice-warn {
  border-color: rgba(242, 118, 46, 0.32);
  background: var(--color-brand-orange-soft);
}

.notice-warn > i {
  color: var(--color-brand-orange);
}

/* ============================================================
   Display numerals (exchange codes, order codes)
   ============================================================ */

.code-block {
  font-size: var(--fs-display-sm);
  line-height: var(--lh-display-sm);
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  word-break: break-all;
}

/* ============================================================
   Auth card
   ============================================================ */

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-6);
}

.auth-card h1 {
  font-size: var(--fs-display-sm);
  line-height: var(--lh-display-sm);
  letter-spacing: var(--ls-display-sm);
  margin-bottom: var(--space-2);
}

.auth-lede {
  margin-bottom: var(--space-5);
}

.auth-card .field:last-of-type {
  margin-bottom: var(--space-5);
}

.auth-card .btn-block + .btn-block {
  margin-top: var(--space-3);
}

/* ============================================================
   Narrow viewports
   ============================================================ */

@media (max-width: 640px) {
  .topbar {
    padding: 0 var(--space-4);
    gap: var(--space-2);
  }

  .brand-name {
    font-size: var(--fs-heading-md);
    max-width: 150px;
  }

  .topbar-nav a:not(.topbar-avatar):not(.icon-link) {
    padding: 0 var(--space-2);
  }

  .card {
    padding: var(--space-4);
  }

  .auth-card {
    padding: var(--space-5);
  }

  .site-footer {
    padding: var(--space-4);
    font-size: var(--fs-caption);
    line-height: var(--lh-body-sm);
  }
}

/* Below this width the wordmark would truncate mid-letter; the circular mark
   carries the brand on its own. */
@media (max-width: 430px) {
  .topbar .brand-name {
    display: none;
  }
}
