/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-headline);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
  color: var(--on-primary);
}
.btn--primary:hover {
  box-shadow: 0 0 16px rgba(199, 153, 255, 0.45);
}

.btn--secondary {
  background: var(--secondary);
  color: var(--on-secondary);
}
.btn--secondary:hover {
  box-shadow: 0 0 16px rgba(74, 248, 227, 0.4);
}

.btn--tertiary {
  background: transparent;
  color: var(--tertiary);
  padding: var(--space-2) 0;
  border-bottom: 2px solid var(--tertiary);
  border-radius: 0;
}
.btn--tertiary:hover { color: #ffb870; }

.btn--ghost {
  background: var(--surface-high);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface-highest); }

.btn--block { width: 100%; }
.btn--sm { padding: var(--space-2) var(--space-4); font-size: 0.75rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-low);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: relative;
}

.card--bright { background: var(--surface-bright); }
.card--mid { background: var(--surface-mid); }

.card__title {
  font-family: var(--font-headline);
  font-size: 1.125rem;
  margin-bottom: var(--space-2);
}

/* ---------- Product card (custom element) ---------- */
product-card {
  display: block;
  background: var(--surface-low);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  position: relative;
  transition: transform 0.2s ease;
}
product-card:hover { transform: translateY(-2px); }

.product-card__image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--surface-mid);
}
.product-card__platform {
  font-family: var(--font-headline);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: var(--space-4);
}
.product-card__title {
  font-family: var(--font-headline);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-top: var(--space-1);
}
.product-card__price {
  color: var(--tertiary);
  font-weight: 600;
  margin-top: var(--space-2);
  font-family: var(--font-headline);
}

/* ---------- Pixel accent ---------- */
.pixel-accent,
pixel-accent {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 8px;
  height: 8px;
  background: var(--tertiary);
  display: block;
}

/* ---------- Form field ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.field__label {
  font-family: var(--font-headline);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.field__input,
.field__select,
.field__textarea {
  background: var(--surface-highest);
  color: var(--text);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  outline: 1px solid transparent;
  transition: outline-color 0.15s ease;
}
.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  outline-color: var(--secondary);
}
.field__hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.field__error {
  font-size: 0.75rem;
  color: var(--error);
}

.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: 0.875rem;
}

/* ---------- Chip ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border-radius: var(--radius-full);
  font-family: var(--font-headline);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chip--warning { background: var(--tertiary); color: var(--on-tertiary); }
.chip--danger { background: var(--error-container); color: var(--on-error-container); }
.chip--muted { background: var(--surface-highest); color: var(--text-muted); }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.375rem;
  background: var(--tertiary);
  color: var(--on-tertiary);
  border-radius: var(--radius-full);
  font-family: var(--font-headline);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
}

/* ---------- Country picker ---------- */
country-picker {
  position: relative;
  display: block;
}

.country-picker__field {
  position: relative;
  display: flex;
  align-items: center;
}

.country-picker__display {
  width: 100%;
  background: var(--surface-highest);
  color: var(--text);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-8) var(--space-3) var(--space-4);
  outline: 1px solid transparent;
  cursor: pointer;
  transition: outline-color 0.15s ease;
}

country-picker.is-open .country-picker__display {
  outline-color: var(--secondary);
}

.country-picker__caret {
  position: absolute;
  right: var(--space-4);
  color: var(--text-muted);
  pointer-events: none;
  transition: transform 0.15s ease;
}

country-picker.is-open .country-picker__caret {
  transform: rotate(180deg);
}

.country-picker__popover[hidden] {
  display: none;
}

.country-picker__popover {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--surface-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow), 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 20rem;
}

.country-picker__search {
  background: var(--surface-highest);
  color: var(--text);
  border: none;
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

.country-picker__search:focus {
  box-shadow: inset 0 -2px 0 var(--secondary);
}

.country-picker__list {
  list-style: none;
  margin: 0;
  padding: var(--space-2) 0;
  overflow-y: auto;
}

.country-picker__region {
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-headline);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.country-picker__option {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  padding: var(--space-2) var(--space-4);
  font-size: 0.9375rem;
  cursor: pointer;
}

.country-picker__option:hover,
.country-picker__option:focus-visible {
  background: var(--surface-highest);
  color: var(--secondary);
  outline: none;
}

.country-picker__empty {
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}

/* ---------- Table ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-low);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table th,
.table td {
  text-align: left;
  padding: var(--space-4);
}
.table th {
  font-family: var(--font-headline);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--surface-mid);
}
.table tr + tr td { border-top: 1px solid rgba(72, 72, 71, 0.2); }
.table tbody tr:hover { background: var(--surface-mid); }

/* ---------- Site header (custom element) ---------- */
.site-nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  background: rgba(14, 14, 14, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 50;
}
.site-nav__logo {
  font-family: var(--font-headline);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--primary);
  text-transform: uppercase;
}
.site-nav__links {
  display: flex;
  gap: var(--space-8);
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-headline);
  font-size: 0.875rem;
}
.site-nav__links a {
  color: var(--text-muted);
  padding-bottom: 2px;
  transition: color 0.15s ease;
}
.site-nav__links a:hover { color: var(--secondary); }
.site-nav__links a.is-active {
  color: var(--primary);
  border-bottom: 2px solid var(--tertiary);
}
.site-nav__actions {
  display: flex;
  gap: var(--space-5);
  align-items: center;
}
.site-nav__action {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-family: var(--font-headline);
  font-size: 0.875rem;
}
.site-nav__action:hover { color: var(--secondary); }
.site-nav__action .badge {
  position: static;
  margin-left: var(--space-1);
}

@media (max-width: 768px) {
  .site-nav { padding: 0 var(--space-4); }
  .site-nav__links { display: none; }
}

/* ---------- Site footer ---------- */
.site-footer {
  background: var(--surface-low);
  padding: var(--space-16) var(--space-8) var(--space-10);
  margin-top: var(--space-24);
}
.site-footer__grid {
  max-width: var(--page-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: var(--space-10);
}
.site-footer__brand {
  font-family: var(--font-headline);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
}
.site-footer__tagline {
  color: var(--text-muted);
  margin-top: var(--space-3);
  max-width: 22rem;
}
.site-footer__col h4 {
  font-family: var(--font-headline);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}
.site-footer__col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.site-footer__col a { color: var(--text); font-size: 0.875rem; }
.site-footer__col a:hover { color: var(--secondary); }
.site-footer__bottom {
  max-width: var(--page-max);
  margin: var(--space-10) auto 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-headline);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@media (max-width: 768px) {
  .site-footer__grid { grid-template-columns: 1fr; gap: var(--space-6); }
}

/* ---------- Admin sidebar ---------- */
.admin-sidebar {
  background: var(--surface-low);
  padding: var(--space-6) var(--space-4);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}
.admin-sidebar__brand {
  font-family: var(--font-headline);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 var(--space-2);
}
.admin-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.admin-sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-headline);
  font-size: 0.875rem;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  transition: background 0.15s ease, color 0.15s ease;
}
.admin-sidebar__link:hover { background: var(--surface-mid); color: var(--text); }
.admin-sidebar__link.is-active {
  background: var(--surface-mid);
  color: var(--primary);
}

/* ---------- Admin topbar ---------- */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-low);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
}
.admin-topbar__search {
  flex: 1;
  max-width: 28rem;
}
.admin-topbar__search input {
  width: 100%;
  background: var(--surface-highest);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  color: var(--text);
}
.admin-topbar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-headline);
  font-size: 0.875rem;
}
.admin-topbar__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

/* ---------- Stat card ---------- */
.stat {
  background: var(--surface-low);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
}
.stat__label {
  font-family: var(--font-headline);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.stat__value {
  font-family: var(--font-headline);
  font-size: 2rem;
  font-weight: 700;
  margin-top: var(--space-2);
}
.stat__delta {
  font-size: 0.75rem;
  margin-top: var(--space-2);
  font-family: var(--font-headline);
  letter-spacing: 0.04em;
}
.stat__delta--up { color: var(--secondary); }
.stat__delta--down { color: var(--error); }

/* ---------- Field: error state + password toggle ---------- */
.field.has-error .field__input,
.field.has-error .field__select,
.field.has-error .field__textarea,
.field.has-error .country-picker__display {
  outline-color: var(--error);
}
.field.has-error .field__label {
  color: var(--error);
}

.field__input-wrap {
  position: relative;
  display: block;
}
.field__input--pw {
  padding-right: 2.75rem;
  width: 100%;
}
.field__pw-toggle {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  padding: var(--space-1);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}
.field__pw-toggle:hover { color: var(--text); background: var(--surface-high); }
.field__pw-toggle:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}

/* ---------- Password strength meter ---------- */
.pw-strength {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.pw-strength__bar {
  display: flex;
  gap: 4px;
}
.pw-strength__seg {
  flex: 1;
  height: 4px;
  background: var(--surface-high);
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}
.pw-strength[data-level="1"] .pw-strength__seg:nth-child(-n+1) { background: var(--error); }
.pw-strength[data-level="2"] .pw-strength__seg:nth-child(-n+2) { background: var(--tertiary); }
.pw-strength[data-level="3"] .pw-strength__seg:nth-child(-n+3) { background: var(--secondary); }
.pw-strength__label {
  font-family: var(--font-headline);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.pw-strength[data-level="1"] .pw-strength__label { color: var(--error); }
.pw-strength[data-level="2"] .pw-strength__label { color: var(--tertiary); }
.pw-strength[data-level="3"] .pw-strength__label { color: var(--secondary); }

/* ---------- Character counter ---------- */
.field__counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  font-family: var(--font-headline);
}
.field__counter.is-over { color: var(--error); }

/* ---------- Checkout card-fields hide ---------- */
.checkout__card-fields.is-hidden { display: none; }

/* ---------- Toast notifications ---------- */
.toast-stack {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: 9999;
  pointer-events: none;
  max-width: calc(100vw - var(--space-8));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 16rem;
  max-width: 22rem;
  background: var(--surface-highest);
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  border-left: 3px solid var(--primary);
  animation: toast-in 0.22s ease-out both;
}
.toast.is-leaving {
  animation: toast-out 0.22s ease-in both;
}
.toast__icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--primary);
}
.toast__body {
  flex: 1;
  min-width: 0;
}
.toast__title {
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0;
  line-height: 1.25;
}
.toast__message {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.35;
}
.toast__close {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  opacity: 0.6;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.toast__close:hover {
  opacity: 1;
  color: var(--text);
  background: var(--surface-bright);
}

.toast--success { border-left-color: var(--secondary); }
.toast--success .toast__icon { color: var(--secondary); }
.toast--error { border-left-color: var(--error); }
.toast--error .toast__icon { color: var(--error); }
.toast--warn { border-left-color: var(--tertiary); }
.toast--warn .toast__icon { color: var(--tertiary); }
.toast--info { border-left-color: var(--primary); }
.toast--info .toast__icon { color: var(--primary); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

@media (max-width: 560px) {
  .toast-stack {
    right: var(--space-3);
    left: var(--space-3);
    bottom: var(--space-3);
  }
  .toast { max-width: none; }
}

/* ==========================================================================
   Modal (window.modal)
   ========================================================================== */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  pointer-events: auto;
  animation: modal-fade 0.18s ease-out both;
}

.modal-overlay.is-leaving {
  animation: modal-fade-out 0.16s ease-in both;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal {
  position: relative;
  width: min(26rem, calc(100vw - 2 * var(--space-6)));
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  text-align: center;
  animation: modal-pop 0.2s ease-out both;
}

.modal__icon {
  align-self: center;
  width: 3rem;
  height: 3rem;
  font-size: 1.5rem;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-low);
  border-radius: var(--radius-full);
}

.modal--danger .modal__icon { color: var(--error); }
.modal--success .modal__icon { color: var(--secondary); }
.modal--warn .modal__icon { color: var(--tertiary); }
.modal--secondary .modal__icon { color: var(--secondary); }

.modal__title {
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--text);
}

.modal__message {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
  font-size: 0.9375rem;
}

.modal__body {
  color: var(--text-muted);
  line-height: 1.6;
  text-align: left;
  font-size: 0.9375rem;
}

.modal__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.modal__actions .btn {
  min-width: 6rem;
}

/* Definition list used inside modal view dialogs. */
.modal__info {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: var(--space-5);
  row-gap: var(--space-2);
  margin: 0;
  text-align: left;
}
.modal__info dt {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
}
.modal__info dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

/* Form embedded inside a modal. */
.modal__form {
  text-align: left;
  margin-top: var(--space-2);
}
.modal__form .field__label {
  font-size: 0.8125rem;
}

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 560px) {
  .modal {
    padding: var(--space-6);
  }
  .modal__actions .btn {
    flex: 1 1 auto;
  }
}
