/* ---------- Fonts (self-hosted — no external font CDN dependency) ---------- */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/space-grotesk-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/space-grotesk-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/space-grotesk-latin.woff2') format('woff2');
}

/* ---------- Design tokens ---------- */
:root {
  --ink: #14161a;
  --bg: #faf9f6;
  --surface: #ffffff;
  --border: #e5e3dd;
  --accent: #ff7a1a;
  --accent-hover: #e8690a;
  --muted: #8a8d94;
  --muted-2: #55585f;
  --body-text: #3a3c41;
  --danger-bg: #2a1215;
  --danger-text: #ff8a80;
  --danger-border: #5c2b2e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
input::placeholder, textarea::placeholder { color: #9a9da3; }

button { font-family: inherit; }

/* ---------- Layout shell ---------- */
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--ink);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.header .wordmark {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 22px; color: #fff;
  cursor: pointer; letter-spacing: 0.4px; white-space: nowrap;
}
.header .search-wrap { flex: 1; min-width: 240px; }
.header .search-wrap input {
  width: 100%; box-sizing: border-box; padding: 12px 16px;
  border-radius: 10px; border: none; font-size: 15px; font-family: inherit; outline: none;
}
.header .actions { display: flex; align-items: center; gap: 22px; }
.header .add-product {
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.header .wallet {
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.header .wallet .balance { color: var(--accent); }
.header .cart-icon { position: relative; cursor: pointer; color: #fff; display: flex; align-items: center; }
.header .cart-badge {
  position: absolute; top: -8px; right: -10px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.header .auth-link { color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.header .user-name { color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; opacity: 0.9; }

.discord-btn { background: #5865F2; display: flex; align-items: center; justify-content: center; }
.discord-btn:hover { background: #4752c4; }

/* ---------- Category bar ---------- */
.category-bar {
  display: flex; gap: 10px; padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.pill {
  font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 999px;
  cursor: pointer; white-space: nowrap; border: 1px solid var(--border); color: var(--ink);
}
.pill.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill.films { color: var(--accent); border-color: var(--accent); }
.pill.films.active { background: var(--accent); color: #fff; }

/* ---------- Main ---------- */
.main {
  flex: 1; padding: 32px 28px 64px 28px; max-width: 1400px;
  width: 100%; box-sizing: border-box; margin: 0 auto;
}
.section-title {
  font-family: 'Space Grotesk', sans-serif; font-size: 24px; margin: 0 0 16px 0;
  border-bottom: 3px solid var(--ink); display: inline-block; padding-bottom: 4px;
}
.section-title.spaced { margin-top: 40px; }
.row-scroll { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; }
.row-scroll > * { flex: 0 0 220px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.empty-note { color: var(--muted); font-size: 15px; }

/* ---------- Product card ---------- */
.product-card {
  cursor: pointer; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.product-card:hover { box-shadow: 0 8px 20px rgba(20,22,26,0.10); transform: translateY(-2px); }
.product-card .thumb {
  width: 100%; height: 150px; background: var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; text-align: center; padding: 8px;
}
.product-card .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.product-card .category {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent);
}
.product-card .name {
  font-family: 'Space Grotesk', sans-serif; font-size: 15px; font-weight: 600; color: var(--ink); line-height: 1.25;
}
.product-card .price-row {
  display: flex; justify-content: space-between; align-items: center; margin-top: 6px;
}
.product-card .price { font-size: 15px; font-weight: 700; color: var(--ink); }
.product-card .stock { font-size: 12px; color: var(--muted); }

/* ---------- Film card ---------- */
.film-card {
  cursor: pointer; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
}
.film-card .poster {
  width: 100%; height: 160px; background: var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; text-align: center; padding: 8px;
}
.film-card .body { padding: 12px 14px; }
.film-card .title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; }
.film-card .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Detail pages ---------- */
.back-link { color: var(--muted); font-size: 14px; cursor: pointer; margin-bottom: 20px; display: inline-block; }
.detail-grid { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 40px; }
.detail-image {
  width: 100%; height: 380px; background: var(--border); border-radius: 16px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 16px;
}
.detail-category { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.detail-title { font-family: 'Space Grotesk', sans-serif; font-size: 32px; margin: 8px 0 12px 0; }
.detail-price { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.detail-stock { font-size: 14px; color: var(--muted); margin-bottom: 20px; }
.detail-description { font-size: 15px; line-height: 1.6; color: var(--body-text); margin-bottom: 28px; max-width: 520px; }

.btn {
  display: inline-block; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px;
  padding: 13px 28px; border-radius: 10px; cursor: pointer; border: none; font-family: inherit;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: var(--muted); cursor: not-allowed; }
.btn.secondary { background: var(--ink); }
.btn.small { padding: 8px 16px; font-size: 13px; }
.btn.full-width { width: 100%; text-align: center; }

/* ---------- Cart ---------- */
.cart-item {
  display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border);
}
.cart-item .thumb { width: 64px; height: 64px; border-radius: 10px; background: var(--border); flex-shrink: 0; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .name { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; }
.cart-item .unit-price { font-size: 13px; color: var(--muted); margin-top: 2px; }
.qty-control { display: flex; align-items: center; gap: 10px; }
.qty-control button {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: 15px; line-height: 1;
}
.qty-control .qty { font-weight: 600; min-width: 20px; text-align: center; }
.cart-item .remove { color: var(--muted); font-size: 13px; cursor: pointer; }
.cart-summary {
  display: flex; justify-content: space-between; align-items: center; padding: 20px 0; font-size: 18px; font-weight: 700;
}

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 13px 14px; border-radius: 10px; border: 1px solid var(--border); font-size: 15px; font-family: inherit; width: 100%;
}
.form-grid .span-2 { grid-column: 1 / 3; }

/* ---------- Wallet panel ---------- */
.wallet-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; max-width: 480px;
}
.wallet-balance { font-family: 'Space Grotesk', sans-serif; font-size: 36px; font-weight: 700; margin: 8px 0 20px 0; }
.wallet-history { margin-top: 24px; }
.wallet-tx {
  display: flex; justify-content: space-between; font-size: 14px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.wallet-tx .amount.positive { color: #1a7a3c; font-weight: 600; }
.wallet-tx .amount.negative { color: var(--ink); font-weight: 600; }
.wallet-note {
  font-size: 13px; color: var(--muted); background: var(--bg); border: 1px dashed var(--border);
  border-radius: 10px; padding: 12px 14px; margin: 16px 0;
}

/* ---------- Auth modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,22,26,0.5); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 16px; padding: 32px; width: 100%; max-width: 380px;
}
.modal h2 { font-family: 'Space Grotesk', sans-serif; font-size: 22px; margin-bottom: 20px; }
.modal input {
  width: 100%; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 15px; font-family: inherit; margin-bottom: 12px;
}
.modal .switch-mode { font-size: 13px; color: var(--muted); margin-top: 14px; text-align: center; }
.modal .switch-mode span { color: var(--accent); cursor: pointer; font-weight: 600; }
.modal .close-x { float: right; cursor: pointer; color: var(--muted); font-size: 20px; }

/* ---------- Toasts / messages ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 14px; font-weight: 600; z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.error-text { color: #c23b2c; font-size: 14px; margin-top: 8px; }
.config-banner {
  background: var(--danger-bg); color: var(--danger-text); border-bottom: 1px solid var(--danger-border);
  font-size: 13px; padding: 10px 20px; text-align: center;
}

/* ---------- Watch page ---------- */
.watch-video { width: 100%; max-width: 800px; border-radius: 14px; background: #000; }
.watch-placeholder {
  width: 100%; max-width: 800px; aspect-ratio: 16/9; background: var(--ink); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 15px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: 1; }
  .header { padding: 12px 16px; }
  .main { padding: 24px 16px 48px 16px; }
  .category-bar { padding: 12px 16px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .product-card { transition: none; }
  .product-card:hover { transform: none; }
}

/* ---------- Focus visibility ---------- */
a:focus-visible, .pill:focus-visible, .btn:focus-visible, .product-card:focus-visible,
.film-card:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
