/* =========================================================================
   PrizeMall — Design System v1.0 (vanilla CSS port)
   Ported from the same tokens used in the Next.js build's tailwind.config.ts
   + globals.css, so visuals match exactly. No build step, no CDN dependency
   — this is the whole design system in one plain stylesheet.
   ========================================================================= */

:root {
  /* §1 Colours — synced 1:1 to PrizeMall-Prototype-Source-v155/app/globals.css */
  --navy: #0B1F3A;
  --navy-2: #153D8A;
  --navy-3: #1B4CA6;
  --ink: #132238;
  --gold: #D4AF37;
  --gold-light: #FFF4C7;
  --gold-mist: #FFFBEC;
  --gold-dark: #B45309; /* darker gold used for eyebrow labels / small text on white */
  --white: #FFFFFF;
  --muted: #64748B;
  --neutral: #687280;
  --line: #E5EAF1;
  --soft: #F5F7FB;
  --success: #149F69;      /* prototype's --green */
  --success-soft: #EAFAF3; /* prototype's --green-soft */
  --info: #174992;
  --info-soft: #EDF4FF;    /* prototype's --blue-soft */
  --warning: #F59E08;
  --error: #EF4444;
  --primary: #7C3AED;      /* matches prototype's --purple exactly */
  --primary-soft: #F4EFFF; /* prototype's --purple-soft */
  --coral-soft: #FFF0EB;

  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* §2 Typography */
  --font-brand: 'Inter', system-ui, -apple-system, sans-serif;

  /* §14 Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;

  /* §15 Shadows — synced to prototype's --shadow / --shadow-small */
  --shadow-sm: 0 8px 28px rgba(11, 31, 58, 0.08);
  --shadow-md: 0 18px 55px rgba(11, 31, 58, 0.1);
  --shadow-lg: 0 18px 55px rgba(11, 31, 58, 0.1);

  /* §13 Spacing (8pt grid) is just used directly as px values below —
     4/8/12/16/24/32/40/48/64 — no token needed since CSS has no calc-free
     shorthand worth aliasing here. */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  font-family: var(--font-brand);
  color: var(--gray-900);
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Typography scale (§2) ───────────────────────────────────────────── */
.text-h1 { font-size: 2rem; line-height: 2.5rem; font-weight: 700; }
.text-h2 { font-size: 1.5rem; line-height: 2rem; font-weight: 700; }
.text-h3 { font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; }
.text-h4 { font-size: 1.125rem; line-height: 1.5rem; font-weight: 600; }
.text-body1 { font-size: 1rem; line-height: 1.5rem; }
.text-body2 { font-size: 0.875rem; line-height: 1.25rem; }
.text-caption { font-size: 0.75rem; line-height: 1rem; }

/* ── App shell: mobile-first, scales to a centered phone-width card on
   larger viewports (matches the Next.js build's ConditionalWrapper) ──── */
.app-shell {
  min-height: 100vh;
  background: var(--white);
  position: relative;
}
/* Bottom-nav clearance lives on .site-footer (see below), not here — every
   page that has the fixed bottom nav also renders the full site footer
   right above it, so padding this whole shell just left a slab of blank
   white space after the footer's last row. Pages with no footer at all
   (rare) still get clearance via .app-shell.no-footer-nav-pad below. */
.app-shell.no-bottom-nav { padding-bottom: 0; }
@media (min-width: 640px) {
  body:not(.full-bleed) { background: var(--gray-100); }
  .app-shell:not(.full-bleed-shell) {
    max-width: 448px;
    margin: 0 auto;
    min-height: 100vh;
    box-shadow: var(--shadow-lg);
  }
}

.container { padding-left: 16px; padding-right: 16px; }

/* ── Buttons (§4) ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 1px solid transparent; border-radius: 13px;
  font-weight: 780; font-size: 0.9375rem;
  padding: 14px 20px; width: 100%;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.15s, background 0.15s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: 0.58; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: var(--navy); box-shadow: 0 10px 25px rgba(212,175,55,.25); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 30px rgba(212,175,55,.35); }
.btn-primary:active:not(:disabled) { filter: brightness(0.96); }
.btn-secondary { background: var(--soft); color: var(--navy); border: 1px solid var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--gray-300); }
.btn-dark { background: var(--navy); color: var(--white); }
.btn-purple { background: var(--primary); color: var(--white); }
.btn-sm { width: auto; padding: 7px 12px; font-size: 0.75rem; gap: 5px; white-space: nowrap; }

/* ── Inputs (§6) ──────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--gray-800); margin-bottom: 6px; }
.input-wrap { position: relative; }
.input-wrap .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); width: 18px; height: 18px; }
.input {
  width: 100%; height: 52px; border-radius: var(--radius-xl);
  border: 1.5px solid var(--gray-200); background: var(--white);
  padding: 0 16px; font-size: 0.9375rem; color: var(--gray-900);
  outline: none; transition: border-color 0.15s;
}
.input-wrap .input.has-icon { padding-left: 44px; }
.input:focus { border-color: var(--primary); }
.input.error { border-color: var(--error); }
.input::placeholder { color: var(--gray-400); }
.field-error { color: var(--error); font-size: 0.75rem; margin-top: 4px; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 36px; }

/* ── Badges / Status (§5) ─────────────────────────────────────────────── */
.tile-icon { width: 32px; height: 32px; border-radius: 12px; background: var(--gold-mist); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 5px 10px; font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap; }
.badge-active { background: var(--success-soft); color: #08754B; }
.badge-sold-out { background: var(--gray-100); color: var(--gray-600); }
.badge-winner { background: var(--gold-light); color: #775C00; }
.badge-processing { background: var(--info-soft); color: var(--navy-2); }
.badge-verified { background: var(--success-soft); color: #08754B; }
.badge-pending { background: var(--gold-light); color: #775C00; }

.trust-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #DCFCE7; color: #16A34A; border-radius: 999px;
  padding: 6px 12px; font-size: 0.75rem; font-weight: 700;
}

/* ── Cards (§7) ───────────────────────────────────────────────────────── */
.card { background: var(--white); border-radius: 18px; box-shadow: var(--shadow-sm); border: 1px solid rgba(11,31,58,.1); }
.card-pad { padding: 16px; }
.competition-card { border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid rgba(11,31,58,.1); background: var(--white); }
.competition-card .thumb { position: relative; aspect-ratio: 4/3; max-height: 220px; background: var(--soft); overflow: hidden; }
.competition-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.competition-card .body { padding: 12px 14px 16px; }

/* ── Tabs (§8) ────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gray-100); }
.tab { padding: 10px 14px; font-size: 0.875rem; font-weight: 600; color: var(--gray-400); border-bottom: 2px solid transparent; background: none; border-top: none; border-left: none; border-right: none; }
.tab.active { color: var(--gray-900); border-color: var(--gold); }

/* ── Alerts (§9) ──────────────────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 10px; border-radius: var(--radius-lg); padding: 12px 14px; font-size: 0.875rem; }
.alert-success { background: #F0FDF4; color: #15803D; }
.alert-info { background: #EFF6FF; color: #1D4ED8; }
.alert-warning { background: #FFFBEB; color: #B45309; }
.alert-error { background: #FEF2F2; color: #B91C1C; }

/* ── Bottom nav (§10) ─────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center;
  background: var(--white); border-top: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 12px);
}
@media (min-width: 640px) {
  .bottom-nav { max-width: 448px; left: 50%; transform: translateX(-50%); right: auto; }
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0; color: var(--gray-400); }
.bottom-nav a.active { color: var(--gold); }
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a span { font-size: 0.625rem; font-weight: 600; }
.bottom-nav a .dot { width: 20px; height: 2px; border-radius: 999px; background: var(--gold); margin-top: 2px; }

/* ── Progress bar (§11) ───────────────────────────────────────────────── */
.progress { height: 6px; border-radius: 999px; background: var(--gray-200); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--gold); }
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }
.progress.danger > span { background: var(--error); }

/* ── Loading (§12) ────────────────────────────────────────────────────── */
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--gray-200); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: var(--gray-200); border-radius: var(--radius-md); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Empty states (§16) ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-400); }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: 0.5; }

/* ── Layout helpers ───────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }

.shop-pagination { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; margin-top: 20px; }
.shop-page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 6px; border-radius: var(--radius-md);
  font-size: 0.8125rem; font-weight: 700; color: var(--gray-600); background: var(--white);
  border: 1.5px solid var(--gray-200);
}
.shop-page-btn:hover { border-color: var(--gray-300); }
.shop-page-btn.active { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.shop-page-btn.disabled { opacity: 0.35; pointer-events: none; }
.shop-page-ellipsis { color: var(--gray-400); padding: 0 2px; font-weight: 700; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mt-5{margin-top:20px}.mt-6{margin-top:24px}.mt-8{margin-top:32px}
.my-4{margin-top:16px;margin-bottom:16px}
.pb-3{padding-bottom:12px}
.px-3{padding-left:12px;padding-right:12px}
.mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}
.p-3{padding:12px}.p-4{padding:16px}.px-4{padding-left:16px;padding-right:16px}.py-3{padding-top:12px;padding-bottom:12px}
.text-center { text-align: center; }
.text-white { color: var(--white); }
.text-gray-300 { color: var(--gray-300); }
.text-gray-400 { color: var(--gray-400); }
.text-gray-500 { color: var(--gray-500); }
.text-gray-600 { color: var(--gray-600); }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-gold { color: var(--gold); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-info { color: var(--info); }
.font-bold { font-weight: 700; }
.font-black { font-weight: 800; }
.w-full { width: 100%; }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.bg-navy { background: var(--navy); }
.bg-gold-mist { background: var(--gold-mist); }
.hidden { display: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 380px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Site-wide footer — mirrors prototype's <footer> (neutral bg) pattern,
   shared across every logged-in page via includes/foot.php. Matches the
   same design already used standalone on the landing page (index.php). */
.site-footer { background: var(--neutral); color: #d7e1ed; padding: 40px 16px 0; margin-top: 8px; }
.site-footer-inner { max-width: 1200px; margin: 0 auto; }
.site-footer-grid { display: grid; grid-template-columns: 1fr; gap: 32px; }
@media (min-width: 900px) { .site-footer-grid { grid-template-columns: 1.3fr 1fr 1fr; gap: 48px; } }
.site-footer-brand { display: block; font-size: 1.15rem; font-weight: 800; color: #fff; margin: 0 0 24px; text-decoration: none; }
.site-footer-brand span { color: var(--gold); }
.site-footer-brand-img { height: 28px; width: auto; max-width: 180px; object-fit: contain; display: block; }
.site-footer h2 { color: #fff; font-size: .8rem; font-weight: 800; margin: 18px 0 10px; }
.site-footer p { font-size: .74rem; line-height: 1.6; margin: 0 0 3px; color: #e1e8f1; }
.site-footer p.dim { color: #c1d0e1; }
.site-footer-license { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: .76rem; color: #e1e8f1; }
.site-footer-license-icon { color: var(--gold); flex-shrink: 0; }
.site-footer-contact { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: rgba(11,31,58,.18); margin-bottom: 8px; text-decoration: none; color: #fff; }
.site-footer-contact:hover { border-color: rgba(212,175,55,.65); background: rgba(11,31,58,.3); }
.site-footer-contact-icon { width: 32px; height: 32px; border-radius: 10px; background: rgba(212,175,55,.16); color: var(--gold); display: grid; place-items: center; flex-shrink: 0; }
.site-footer-contact small { display: block; color: #c7d4e3; font-size: .58rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.site-footer-contact strong { display: block; font-size: .76rem; font-weight: 780; color: #fff; }
.site-footer-contact-arrow { margin-left: auto; color: #b8c5d6; flex-shrink: 0; }
.site-footer-social { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.site-footer-social a { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,.28); display: grid; place-items: center; color: #fff; }
.site-footer-social a:hover { background: rgba(255,255,255,.12); border-color: #fff; }
/* Bottom row clears the fixed bottom nav itself — this is the only
   bottom-nav clearance in the whole app now (see .app-shell above), so
   there's no leftover blank slab after the footer on inner pages. Pages
   without the bottom nav (landing page uses its own footer markup, not
   this one) are unaffected since this class only appears where foot.php
   is actually included alongside bottom-nav.php. */
.site-footer-bottom { border-top: 1px solid rgba(255,255,255,.18); margin-top: 32px; padding: 16px 0 calc(env(safe-area-inset-bottom, 0px) + 84px); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; }
.site-footer-links { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 0; padding-top: 0; border-top: none; }
.site-footer-links a { color: #d9e3ef; font-size: .72rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.site-footer-links a:hover { color: #fff; }
.site-footer-copy { font-size: .64rem; color: #c1d0e1; margin: 0; }

/* Right-side slide-over drawer (pm-drawer.js) — used by competitions.php
   and shop.php so clicking a card opens its detail view without leaving
   the page. */
html.pm-drawer-lock, html.pm-drawer-lock body { overflow: hidden; }
.pm-drawer { position: fixed; inset: 0; z-index: 1000; visibility: hidden; }
.pm-drawer.open { visibility: visible; }
.pm-drawer-overlay { position: absolute; inset: 0; background: rgba(11,31,58,.55); opacity: 0; transition: opacity .25s ease; }
.pm-drawer.open .pm-drawer-overlay { opacity: 1; }
.pm-drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: 100%; max-width: 480px; background: #fff; box-shadow: -12px 0 40px rgba(11,31,58,.25); transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; }
.pm-drawer.open .pm-drawer-panel { transform: translateX(0); }
.pm-drawer-topbar { flex-shrink: 0; padding: 14px 16px; border-bottom: 1px solid var(--line, #eceff3); }
.pm-drawer-back { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line, #eceff3); color: var(--navy); font-weight: 700; font-size: .82rem; padding: 9px 14px; border-radius: 999px; box-shadow: 0 4px 10px rgba(11,31,58,.08); }
.pm-drawer-back:hover { background: var(--soft, #f5f6f8); }
/* NOTE: pm-drawer.js injects content.innerHTML (not the #pm-detail-content /
   .container element itself) into .pm-drawer-body, so the element carrying
   those selectors never actually exists inside the drawer — the padding has
   to live on .pm-drawer-body directly instead. */
.pm-drawer-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px 18px 40px; max-width: none; }
.pm-drawer-loading { padding: 60px 16px; text-align: center; color: var(--muted, #7b879b); font-size: .85rem; }
.pm-drawer-body .pm-detail-backlink { display: none; }

/* Tidy up typography/spacing for content that lands inside the narrower
   drawer panel — titles, descriptions and card rows all need slightly
   tighter rhythm than they get in the full-width page. */
.pm-drawer-body .text-h3 { font-size: 1.15rem; line-height: 1.55rem; color: var(--navy); }
.pm-drawer-body .text-h4 { font-size: 1.02rem; line-height: 1.4rem; color: var(--navy); }
.pm-drawer-body p.text-body2 { line-height: 1.5rem; }
.pm-drawer-body .grid-2 { gap: 10px; }
.pm-drawer-body .card { overflow: hidden; }
.pm-drawer-body img { max-width: 100%; }

@media (max-width: 480px) { .pm-drawer-panel { max-width: 100%; } }

/* Whole-card click targets (competitions.php, shop.php) — the buttons/forms
   inside stay independently clickable via data-pm-no-drawer. */
.cp-card-clickable, .sp-card-clickable { cursor: pointer; }
