@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Work+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #0F1220;
  --panel: #171B2E;
  --panel-2: #1E2338;
  --panel-3: #262C46;
  --gold: #E8B95C;
  --gold-dim: #B8934A;
  --teal: #35C9C1;
  --text: #F1EEE6;
  --muted: #8B93AC;
  --danger: #E1685A;
  --border: rgba(241, 238, 230, 0.09);
  --radius: 14px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

img, video { max-width: 100%; display: block; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; color: var(--muted); }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Sprocket-hole divider: the signature motif, echoing a film reel ---------- */
.sprocket-divider {
  height: 22px;
  margin: 0;
  background-image: radial-gradient(circle, var(--ink) 5px, transparent 5.5px);
  background-size: 26px 22px;
  background-repeat: repeat-x;
  background-position: 13px center;
  background-color: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* ---------- Top navigation ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 18, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--gold);
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 0 0 3px var(--ink),
    0 0 0 4px rgba(232, 185, 92, 0.35);
}
.brand-mark::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle 2.6px at 50% 8%, var(--ink) 99%, transparent 100%),
    radial-gradient(circle 2.6px at 85% 28%, var(--ink) 99%, transparent 100%),
    radial-gradient(circle 2.6px at 85% 72%, var(--ink) 99%, transparent 100%),
    radial-gradient(circle 2.6px at 50% 92%, var(--ink) 99%, transparent 100%),
    radial-gradient(circle 2.6px at 15% 72%, var(--ink) 99%, transparent 100%),
    radial-gradient(circle 2.6px at 15% 28%, var(--ink) 99%, transparent 100%);
}
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav-links a, .nav-links button {
  font: inherit;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover, .nav-links button:hover { color: var(--text); background: var(--panel-2); }
.nav-links a.active { color: var(--ink); background: var(--gold); }

.wallet-chip {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--gold);
}
.wallet-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--gold); color: #1a1406; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--panel-3); }
.btn-teal { background: var(--teal); color: #05221f; }
.btn-teal:hover { filter: brightness(1.08); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(225, 104, 90, 0.4); }
.btn-danger:hover { background: rgba(225, 104, 90, 0.1); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 7px 14px; font-size: 0.83rem; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.video-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.video-card:hover { transform: translateY(-3px); border-color: rgba(232, 185, 92, 0.4); }
.video-thumb {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--panel-2), var(--panel-3));
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 2rem;
  position: relative;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.video-body h3 { margin: 0; font-size: 1.02rem; }
.video-meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; font-size: 0.82rem; }
.earn-badge {
  font-family: var(--font-mono);
  color: var(--gold);
  background: rgba(232, 185, 92, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
}
.duration-badge { color: var(--muted); font-family: var(--font-mono); }

/* ---------- Ticket-stub wallet card (signature element) ---------- */
.ticket {
  display: flex;
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ticket-main {
  flex: 1;
  padding: 26px 24px;
}
.ticket-eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}
.ticket-balance {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--gold);
  margin: 4px 0 0;
  line-height: 1;
}
.ticket-sub { color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.ticket-stub {
  width: 130px;
  flex-shrink: 0;
  border-left: 2px dashed var(--border);
  background: var(--panel-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  padding: 16px;
  position: relative;
}
.ticket-stub::before, .ticket-stub::after {
  content: '';
  position: absolute; left: -11px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--ink);
}
.ticket-stub::before { top: -11px; }
.ticket-stub::after { bottom: -11px; }
.ticket-stub-label { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: 0.08em; }
.ticket-stub-value { font-family: var(--font-mono); font-size: 1.1rem; color: var(--teal); font-weight: 600; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  font: inherit;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); }
.field textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 0.78rem; color: var(--muted); margin-top: 5px; }
.radio-group { display: flex; gap: 10px; }
.radio-group label {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-2); cursor: pointer; font-size: 0.88rem; color: var(--muted);
}
.radio-group input { width: auto; }
.radio-group input:checked + span { color: var(--gold); }

.auth-shell {
  max-width: 420px;
  margin: 64px auto;
  padding: 0 24px;
}

.banner {
  padding: 12px 16px;
  border-radius: 9px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.banner-error { background: rgba(225, 104, 90, 0.12); color: #ff9c90; border: 1px solid rgba(225,104,90,0.3); }
.banner-success { background: rgba(53, 201, 193, 0.12); color: var(--teal); border: 1px solid rgba(53,201,193,0.3); }

/* ---------- Status pills ---------- */
.status-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-block;
}
.status-ready { background: rgba(53, 201, 193, 0.15); color: var(--teal); }
.status-pending, .status-converting { background: rgba(232, 185, 92, 0.15); color: var(--gold); }
.status-failed { background: rgba(225, 104, 90, 0.15); color: var(--danger); }
.status-active { background: rgba(53, 201, 193, 0.15); color: var(--teal); }
.status-disabled { background: rgba(225, 104, 90, 0.15); color: var(--danger); }
.status-approved { background: rgba(53, 201, 193, 0.15); color: var(--teal); }
.status-rejected { background: rgba(225, 104, 90, 0.15); color: var(--danger); }

/* ---------- Watch page ---------- */
.player-wrap { background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.player-wrap video { width: 100%; display: block; max-height: 70vh; background: #000; }
.earn-tracker {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  margin-top: 18px;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.earn-tracker .item { display: flex; flex-direction: column; gap: 2px; }
.earn-tracker .item .label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--font-mono); }
.earn-tracker .item .value { font-family: var(--font-mono); font-size: 1.15rem; color: var(--gold); font-weight: 600; }
.earn-toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--gold); color: #1a1406;
  padding: 12px 20px; border-radius: 999px;
  font-family: var(--font-mono); font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  transform: translateY(20px); opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
  z-index: 50;
}
.earn-toast.show { transform: translateY(0); opacity: 1; }

/* ---------- Tables (admin) ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
td { vertical-align: middle; }
.table-wrap { overflow-x: auto; }
.mono { font-family: var(--font-mono); }

/* ---------- Admin layout ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.admin-sidebar a {
  display: block; padding: 10px 14px; border-radius: 9px;
  text-decoration: none; color: var(--muted); font-size: 0.92rem; font-weight: 500;
}
.admin-sidebar a:hover { background: var(--panel-2); color: var(--text); }
.admin-sidebar a.active { background: var(--gold); color: #1a1406; }
.admin-main { flex: 1; padding: 32px; max-width: 1100px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-card .label { font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-family: var(--font-display); font-size: 1.8rem; color: var(--gold); margin-top: 4px; }
.tabs { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab-btn {
  font: inherit; background: none; border: none; color: var(--muted);
  padding: 10px 4px; margin-right: 20px; cursor: pointer; font-size: 0.92rem; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }
.section { display: none; }
.section.active { display: block; }
.row-actions { display: flex; gap: 8px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .icon { font-size: 2.4rem; margin-bottom: 10px; }

/* ---------- Footer ---------- */
footer {
  margin-top: 60px;
  padding: 28px 0 60px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- Hero ---------- */
.hero {
  padding: 56px 0 40px;
  display: flex;
  gap: 40px;
  align-items: center;
  flex-wrap: wrap;
}
.hero-copy { flex: 1; min-width: 280px; }
.hero-copy .eyebrow {
  font-family: var(--font-mono); color: var(--teal); text-transform: uppercase;
  letter-spacing: 0.14em; font-size: 0.78rem; margin-bottom: 10px; display: block;
}
.hero-stats { display: flex; gap: 28px; margin-top: 24px; flex-wrap: wrap; }
.hero-stats .stat b { display: block; font-family: var(--font-display); font-size: 1.6rem; color: var(--gold); }
.hero-stats .stat span { font-size: 0.8rem; color: var(--muted); }

@media (max-width: 720px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; flex-direction: row; overflow-x: auto; }
  .admin-main { padding: 20px; }
  .ticket { flex-direction: column; }
  .ticket-stub { width: auto; border-left: none; border-top: 2px dashed var(--border); flex-direction: row; }
  .ticket-stub::before, .ticket-stub::after { left: auto; top: -11px; }
  .ticket-stub::before { left: -11px; }
  .ticket-stub::after { right: -11px; left: auto; }
}

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
