/* $PIG - flat cartoon Sherwood-folklore theme. Solid lime page, parchment "scroll" cards with thick
   dark outlines + hard-edged shadows. NO gradients, NO emojis. Mobile-first, responsive, 60fps-friendly
   (animate transform/opacity only). One self-hosted display font (placeholder woff2 + chunky fallbacks). */

/* Cartoon display face: self-hosted Luckiest Guy (OFL), vendored by build.js -> fonts/pig-display.woff2.
   No runtime CDN, no 404. Headings use it; body text stays the readable system stack. */
@font-face {
  font-family: "pig-display";
  src: url("../fonts/pig-display.woff2") format("woff2");
  font-display: swap;
}

:root {
  --lime: #c8fc57;
  --parchment: #f6ecd2;
  --parchment-2: #efe2bf;
  --ink: #241a17;
  --ink-soft: #5b4a40;
  --pink: #ff4f9b;
  --pink-ink: #7a1642;
  --green: #1f7a44;
  --green-ink: #0d3a20;
  --up: #16d670;
  --down: #ef4444;
  --outline: 3px;
  --radius: 12px;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --maxw: 1200px;
  --head: "pig-display", "Arial Black", "Segoe UI Black", "Helvetica Neue", Impact, Arial, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; } /* X7: the page must never swipe left/right */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background: var(--lime);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* --- artist background: a FIXED full-viewport layer BEHIND all content. position:fixed + z-index:-1
   (NOT background-attachment:fixed, which is janky/broken on mobile). The lime stays as the layer's
   background-color so nothing flashes while the image loads. WebP primary, optimized PNG fallback via
   image-set; desktop art (16:9) by default, mobile art (9:16) on small/portrait screens. Content sits
   on opaque parchment cards, so readability is unchanged. --- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--lime);
  background-image: url("../assets/bg-desktop.png");
  background-image: image-set(url("../assets/bg-desktop.webp") type("image/webp"), url("../assets/bg-desktop.png") type("image/png"));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
@media (max-width: 768px), (orientation: portrait) {
  body::before {
    background-image: url("../assets/bg-mobile.png");
    background-image: image-set(url("../assets/bg-mobile.webp") type("image/webp"), url("../assets/bg-mobile.png") type("image/png"));
  }
}
img, svg, canvas, video { max-width: 100%; display: block; }
/* nothing may exceed the viewport width */
.card, .stat, table, pre, code { max-width: 100%; }
h1, h2, h3 { overflow-wrap: anywhere; }
a { color: var(--pink-ink); text-decoration-thickness: 2px; text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); letter-spacing: 0.5px; margin: 0 0 0.4em; line-height: 1.05; }

/* --- reusable card (parchment scroll) --- */
.card {
  background: var(--parchment);
  border: var(--outline) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* --- buttons --- */
.btn {
  font-family: var(--head);
  font-size: 1rem;
  cursor: pointer;
  border: var(--outline) solid var(--ink);
  border-radius: 10px;
  background: var(--parchment);
  color: var(--ink);
  padding: 10px 18px;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.btn--pink { background: var(--pink); color: #fff; }
.btn--green { background: var(--green); color: #fff; }
.btn--lg { font-size: 1.15rem; padding: 14px 26px; }
.btn--sm { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }
.btn--block { width: 100%; }

/* --- mascot: real art, borderless (NO border, NO box-shadow, NO background) --- */
.mascot { display: block; border: 0; box-shadow: none; background: none; object-fit: contain; max-width: 100%; height: auto; }
.mascot--nav { width: 44px; height: 44px; }
.mascot--hero { width: 100%; max-width: 260px; }

/* --- layout helpers --- */
main { display: block; }
section { max-width: var(--maxw); margin: 0 auto; padding: 40px 20px; }
.section__title { font-size: clamp(1.6rem, 4vw, 2.4rem); text-align: center; margin-bottom: 24px; }

/* --- 1. nav --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--lime);
  border-bottom: var(--outline) solid var(--ink);
}
.nav__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.nav__wordmark { font-family: var(--head); font-size: 1.5rem; }
.nav__links { display: flex; align-items: center; gap: 18px; }
.nav__links a { color: var(--ink); text-decoration: none; font-weight: 700; }
.nav__links a:hover { color: var(--pink-ink); }
.nav__connect { margin-left: 6px; }
.nav__burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 46px;
  height: 44px;
  padding: 10px;
  background: var(--parchment);
  border: var(--outline) solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
}
.nav__burger span { display: block; height: 3px; background: var(--ink); border-radius: 2px; }

/* --- 2. hero (Y4: compact, hugs content - no large empty area) --- */
.hero {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr); /* copy fills; the tight max-width keeps it hugging */
  gap: 26px;
  align-items: center;
  padding: 24px 28px;
  max-width: 880px;            /* compact card, not a full-width band */
  margin: 20px auto;           /* definite max-width + auto margins => reliably CENTERED (unlike fit-content) */
}
.hero__art { display: flex; justify-content: center; align-items: center; }
.hero__title { font-size: clamp(2.8rem, 8vw, 4.5rem); margin: 0; }
.hero__rule { height: 5px; width: 110px; background: var(--pink); border-radius: 3px; margin: 4px 0 12px; }
.hero__fullform { font-family: var(--head); font-size: clamp(1.05rem, 2.6vw, 1.5rem); color: var(--green-ink); margin: 0 0 10px; }
.hero__lore { font-size: 1.02rem; max-width: 52ch; margin: 0 0 18px; }

/* --- 3. stats band --- */
.stats__grid, .learn__tokenomics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.stat { padding: 16px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.stat__label { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-soft); font-weight: 700; }
.stat__value { font-family: var(--head); font-size: clamp(1.2rem, 3vw, 1.7rem); }
.stat__sub { font-size: 0.8rem; color: var(--ink-soft); }

/* --- 4. swap --- */
.swap__card { max-width: 460px; margin: 0 auto; padding: 22px; }
.swap__tabs { display: flex; gap: 10px; margin-bottom: 14px; }
.swap__tab {
  flex: 1; min-height: 44px; font-family: var(--head); font-size: 1.05rem; cursor: pointer;
  border: var(--outline) solid var(--ink); border-radius: 10px; background: var(--parchment-2); color: var(--ink);
}
.swap__tab.is-active { background: var(--green); color: #fff; }
.swap__balances { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 12px; }
.swap__field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin-bottom: 14px; }
.swap__inputrow { position: relative; }
.swap__field input {
  font-size: 1.4rem; font-family: var(--head); padding: 12px 68px 12px 14px; min-height: 52px;
  border: var(--outline) solid var(--ink); border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
.swap__field input:focus-visible { outline: 3px solid var(--pink); outline-offset: 1px; }
.swap__max {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  min-height: 34px; padding: 5px 12px; cursor: pointer; font-family: var(--head); font-size: 0.85rem;
  border: 2px solid var(--ink); border-radius: 8px; background: var(--pink); color: #fff;
}
.swap__max:hover:not(:disabled) { filter: brightness(1.05); }
.swap__max:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.swap__max:disabled { opacity: 0.45; cursor: not-allowed; }
.swap__slippage { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.swap__presets, .markets__intervals { display: flex; gap: 6px; }
.chip {
  min-height: 36px; padding: 6px 12px; cursor: pointer; font-weight: 700;
  border: 2px solid var(--ink); border-radius: 8px; background: var(--parchment-2); color: var(--ink);
}
.chip.is-active { background: var(--pink); color: #fff; }
.chip:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.swap__quote { margin: 0 0 16px; display: grid; gap: 6px; }
.swap__quote div { display: flex; justify-content: space-between; font-size: 0.95rem; }
.swap__quote dt { color: var(--ink-soft); margin: 0; }
.swap__quote dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.swap__cap { font-size: 0.85rem; font-weight: 700; color: var(--down); margin: 0 0 10px; padding: 8px 10px; border: 2px solid var(--down); border-radius: 8px; background: rgba(239,68,68,0.08); }
.swap__cap[hidden] { display: none; }
.swap__taxnote { font-size: 0.8rem; color: var(--ink-soft); margin: 0 0 12px; text-align: center; }
.swap__hint { min-height: 1.2em; font-size: 0.9rem; margin: 12px 0 0; color: var(--pink-ink); }

/* --- 5. markets (chart + trades) --- */
.markets__grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
/* min-width:0 is THE fix: grid/flex children default to min-width:auto and won't shrink below their
   intrinsic content (the chart canvas / the trades table), which overflows the viewport on mobile. */
.markets__chart, .markets__trades { padding: 16px; min-width: 0; max-width: 100%; box-sizing: border-box; }
.markets__charthead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.markets__phase { font-family: var(--head); font-size: 0.95rem; padding: 4px 10px; border: 2px solid var(--ink); border-radius: 8px; background: var(--parchment-2); }
.markets__canvas { width: 100%; min-width: 0; max-width: 100%; height: 420px; }
.markets__subtitle { font-size: 1.1rem; margin-bottom: 10px; }
/* table scrolls INSIDE the card; FIX B: hide the scrollbars visually but keep wheel/touch/drag scrolling */
.markets__tablewrap { max-width: 100%; max-height: 420px; overflow-y: auto; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.markets__tablewrap::-webkit-scrollbar { width: 0; height: 0; display: none; }
.trades { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.trades th, .trades td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(36,26,23,0.15); white-space: nowrap; font-variant-numeric: tabular-nums; }
.trades th { position: sticky; top: 0; background: var(--parchment); font-family: var(--head); }
.trades a { color: var(--ink); text-decoration: none; }
.trades a:hover { text-decoration: underline; }
.trades .buy { color: var(--green); font-weight: 800; }
.trades .sell { color: var(--down); font-weight: 800; }

/* --- 6. learn / tokenomics --- */
.learn__grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.learn__prose { padding: 22px; }
.learn__prose ul, .learn__prose ol { padding-left: 1.2em; }
.learn__prose li { margin-bottom: 8px; }
.learn__tokenomics { grid-template-columns: repeat(2, 1fr); }

/* --- 7. faq --- */
.faq__list { display: grid; gap: 12px; max-width: 820px; margin: 0 auto; }
.faq__item { padding: 0; overflow: hidden; }
.faq__q {
  width: 100%; text-align: left; cursor: pointer; font-family: var(--head); font-size: 1.05rem;
  padding: 16px 18px; min-height: 44px; background: var(--parchment); color: var(--ink); border: 0; border-radius: var(--radius);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.faq__q::after { content: "+"; font-size: 1.4rem; color: var(--pink-ink); }
.faq__q[aria-expanded="true"]::after { content: "\2212"; }
.faq__q:focus-visible { outline: 3px solid var(--pink); outline-offset: -3px; }
.faq__a { padding: 0 18px; max-height: 0; overflow: hidden; transition: max-height 0.2s ease, padding 0.2s ease; }
.faq__a.is-open { max-height: 600px; padding: 0 18px 18px; }
.faq__net { display: grid; gap: 4px; margin: 10px 0; }
.faq__net div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed rgba(36,26,23,0.25); padding-bottom: 3px; }
.faq__net dt { color: var(--ink-soft); margin: 0; }
.faq__net dd { margin: 0; font-weight: 700; word-break: break-all; text-align: right; }
.faq__ca { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.faq__ca code { background: var(--parchment-2); border: 2px solid var(--ink); border-radius: 8px; padding: 6px 10px; word-break: break-all; font-size: 0.85rem; }

/* --- 8. footer --- */
.footer { max-width: var(--maxw); margin: 20px auto 0; padding: 28px 20px 60px; border-top: var(--outline) solid var(--ink); text-align: center; }
.footer__socials { display: flex; gap: 20px; justify-content: center; margin-bottom: 12px; }
.footer__socials a { font-family: var(--head); color: var(--ink); text-decoration: none; }
.footer__disclaimer { font-size: 0.85rem; color: var(--ink-soft); max-width: 60ch; margin: 0 auto; }

/* --- modal --- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(36, 26, 23, 0.5); }
.modal[hidden] { display: none; }
.modal__box { max-width: 420px; width: 100%; padding: 24px; }
.modal__title { color: var(--pink-ink); font-size: 1.3rem; }
.modal__body { margin: 0 0 18px; }

/* --- wallet chooser (Y1) --- */
.wallets { display: grid; gap: 10px; margin: 4px 0 16px; }
.wallets__row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; cursor: pointer; text-align: left;
  padding: 10px 14px; border: var(--outline) solid var(--ink); border-radius: 10px; background: var(--parchment-2); color: var(--ink);
  font-family: var(--head); font-size: 1.05rem; box-shadow: var(--shadow-sm); transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.wallets__row:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.wallets__row:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
.wallets__icon { width: 28px; height: 28px; border-radius: 6px; flex: 0 0 auto; }
.wallets__name { flex: 1; }
.wallets__empty { margin: 4px 0 16px; color: var(--ink-soft); }

/* --- toasts --- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 10px; max-width: min(360px, 90vw); }
.toast {
  background: var(--parchment); border: var(--outline) solid var(--ink); border-radius: 10px; box-shadow: var(--shadow-sm);
  padding: 12px 14px; font-size: 0.9rem; opacity: 0; transform: translateY(8px); transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast--ok { border-left: 8px solid var(--green); }
.toast--err { border-left: 8px solid var(--down); }
.toast--info { border-left: 8px solid var(--pink); }

/* ============================== responsive ============================== */
@media (max-width: 1024px) {
  .learn__grid { grid-template-columns: 1fr; }
}
/* markets: single column (chart above trades) below 900px so neither card is squeezed/clipped */
@media (max-width: 900px) {
  .markets__grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .nav__burger { display: flex; }
  .nav__links {
    position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0;
    background: var(--lime); border-bottom: var(--outline) solid var(--ink); padding: 8px 20px 16px; display: none;
  }
  .nav__links.is-open { display: flex; }
  .nav__links a { padding: 12px 4px; border-bottom: 1px dashed rgba(36,26,23,0.25); }
  .nav__connect { margin: 10px 0 0; }
  .hero { grid-template-columns: 1fr; width: auto; text-align: center; } /* full-width stacked on mobile */
  .hero__art { order: -1; }
  .hero__rule { margin-left: auto; margin-right: auto; }
  .hero__lore { margin-left: auto; margin-right: auto; }
  .learn__tokenomics { grid-template-columns: repeat(2, 1fr); }
}
/* phones (iPhone 14 / Pro Max ~ 390-430px and down) */
@media (max-width: 480px) {
  section { padding: 26px 14px; }
  .hero { padding: 20px; gap: 18px; }
  .hero__title { font-size: clamp(2.6rem, 16vw, 3.6rem); }
  .hero__fullform { font-size: 1.15rem; }
  .hero__lore { font-size: 1rem; }
  .mascot--hero { max-width: 220px; margin: 0 auto; }
  .stats__grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat { padding: 12px; }
  .stat__value { font-size: 1.15rem; }
  .swap__card { padding: 16px; }
  .section__title { font-size: clamp(1.5rem, 7vw, 2rem); }
  .markets__canvas { height: 320px; }               /* Y5: sensible mobile chart height */
  .markets__tablewrap { max-height: 320px; }        /* trades card its own height + internal scroll */
  .btn--lg { font-size: 1.05rem; padding: 12px 20px; }
  .nav { padding: 8px 14px; }
}
@media (max-width: 360px) {
  .stats__grid { grid-template-columns: 1fr; }
  .swap__slippage { flex-direction: column; align-items: flex-start; }
}

/* --- FIX 2: WalletConnect panel (deep-link on mobile / QR on desktop) --- */
.wc { margin: 10px 0; text-align: center; }
.wc__qr { max-width: 240px; margin: 0 auto 10px; background: #fff; padding: 8px; border: var(--outline) solid var(--ink); border-radius: var(--radius); }
.wc__qr svg { width: 100%; height: auto; display: block; }
.wc__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 6px; }
.wc__hint { font-size: 0.85rem; opacity: 0.85; margin: 4px 0 0; }
