/* Trade Loop website. Minimal hand-drawn: ink outlines, flat marker fills, off-white paper. */
:root {
  --red: #ff5a3c;
  --blue: #2f6df6;
  --green: #19b37d;
  --yellow: #ffc233;
  --ink: #1d1d1f;
  --white: #ffffff;
  --paper: #f7f5f0;
  --muted: #5d5d63;
  --hand: 'Patrick Hand', 'Comic Sans MS', cursive;
  --sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper) url('assets/paper.png') repeat;
  background-size: 384px auto;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}

a { color: var(--ink); text-decoration-color: var(--blue); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--red); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 6px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- buttons: hand-drawn pill frame over a flat fill with a hard ink shadow ---------- */
.btn {
  position: relative;
  z-index: 0;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  background: none;
  color: var(--ink);
  font: 700 1rem/1 var(--sans);
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn::before {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  border-radius: 999px;
  background: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
}
.btn::after {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  border-style: solid; border-color: transparent;
  border-width: 17px 18px;
  border-image: url('assets/frames/pill-a-ink.png') 52 54 / 17px 18px / 4px stretch;
  pointer-events: none;
}
.btn-b::after { border-image-source: url('assets/frames/pill-b-ink.png'); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); }
.btn:active:not(:disabled)::before { box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { cursor: default; opacity: 0.38; }
.btn:disabled::before { box-shadow: none; }
.btn.nudge::before { background: var(--yellow); }
.btn-small { min-height: 40px; padding: 0 16px; font-size: 0.9rem; }

/* ---------- landing: one screen, no scrolling ---------- */
.home { overflow: hidden; }
.hero {
  height: 100vh;
  height: 100dvh;
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: 'intro' 'play' 'store' 'foot';
  row-gap: clamp(6px, 1.6dvh, 16px);
  padding:
    max(env(safe-area-inset-top), clamp(10px, 2.4dvh, 28px))
    max(env(safe-area-inset-right), clamp(14px, 4vw, 44px))
    max(env(safe-area-inset-bottom), clamp(8px, 1.6dvh, 18px))
    max(env(safe-area-inset-left), clamp(14px, 4vw, 44px));
}

.intro { grid-area: intro; }
.brand {
  display: flex; align-items: center; gap: 10px;
  margin: 0;
}
.brand img { width: clamp(36px, 6dvh, 56px); height: auto; }
.brand-name { font: 400 clamp(1.6rem, 4.2dvh, 2.2rem)/1 var(--hand); }
.intro h1 span { display: block; }
.intro h1 {
  margin: clamp(4px, 1dvh, 12px) 0 0;
  font: 700 clamp(1.45rem, min(6.6vw, 4.6dvh), 2.4rem)/1.05 var(--sans);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.play {
  grid-area: play;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px;
}
.step {
  margin: 0;
  font: 400 clamp(1.05rem, 2.6dvh, 1.3rem)/1.1 var(--hand);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 479px) { .step-place { display: none; } }
.tools { display: flex; gap: 12px; flex: none; padding-right: 4px; }
.play:not(.js) .toolbar, .play:not(.js) .coach { display: none; }
.play.ended .tools { visibility: hidden; }

.coach {
  margin: 2px 0 0;
  height: 2.7em;
  overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  color: var(--muted);
  font-size: clamp(0.85rem, 2dvh, 1rem);
  line-height: 1.35;
}

.board {
  position: relative;
  min-height: 0;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.board-svg { position: absolute; inset: 0; display: block; overflow: visible; }
.board-svg image { pointer-events: none; }
.stall { cursor: pointer; outline: none; }
.stall[aria-disabled='true'] { cursor: default; }
.stall .focus-ring { fill: none; stroke: var(--blue); stroke-width: 3; stroke-dasharray: 6 5; opacity: 0; }
.stall:focus-visible .focus-ring { opacity: 1; }
.or { font-family: var(--sans); font-weight: 700; fill: var(--muted); letter-spacing: 0.04em; }

.nojs {
  max-width: 34rem;
  padding: 18px 20px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 4px 4px 0 var(--ink);
}
.nojs p { margin: 0 0 10px; }
.nojs p:last-child { margin: 0; color: var(--muted); }

.banner {
  position: absolute; top: 6px; left: 50%; z-index: 2;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 22px 9px;
  white-space: nowrap;
  max-width: calc(100% - 16px);
  font: 400 clamp(1.3rem, 3.4dvh, 1.7rem)/1.1 var(--hand);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  pointer-events: none;
}

.end {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center;
  padding: 8px;
}
.end[hidden] { display: none; }
.end-card {
  max-width: 26rem;
  padding: clamp(16px, 3dvh, 28px) clamp(18px, 3vw, 30px);
  text-align: center;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 20px 16px 22px 14px;
  box-shadow: 5px 5px 0 var(--ink);
}
.end-card h2 { margin: 0 0 6px; font: 400 clamp(1.7rem, 4.4dvh, 2.3rem)/1.05 var(--hand); }
.end-card h2:focus { outline: none; }
.end-card p { margin: 0 0 8px; }
.end-soon { font-weight: 700; }
.end-card .btn { margin-top: 8px; }

/* the store badge: clearly not live, so it is not a link */
.store { grid-area: store; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.badge {
  position: relative;
  display: inline-flex; flex-direction: column; justify-content: center;
  margin: 0;
  min-height: 54px;
  padding: 7px 20px 8px;
  color: var(--white);
  background: var(--ink);
  border-radius: 14px;
  box-shadow: 3px 3px 0 var(--red);
}
.badge::after {
  content: '';
  position: absolute; inset: 0;
  border-style: solid; border-color: transparent; border-width: 20px;
  border-image: url('assets/frames/m-a-ink.png') 60 / 20px / 4px stretch;
  pointer-events: none;
}
.badge-soon { color: var(--yellow); font: 700 0.72rem/1.2 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; }
.badge-to { font: 700 1.15rem/1.15 var(--sans); }
.store-note { margin: 0; color: var(--muted); font-size: 0.9rem; }

.foot {
  grid-area: foot;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 18px;
  font-size: 0.85rem;
  color: var(--muted);
}
.foot a { color: var(--muted); }
.foot a:hover { color: var(--ink); }

/* wide screens: words on the left, the market on the right */
@media (min-width: 640px) and (min-aspect-ratio: 5/4), (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .hero {
    grid-template-columns: minmax(300px, 1fr) minmax(0, 1.15fr);
    grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1fr) auto;
    grid-template-areas: '. play' 'intro play' 'store play' '. play' 'foot play';
    column-gap: clamp(28px, 5vw, 80px);
    row-gap: 0;
  }
  .brand img { width: clamp(48px, 7dvh, 72px); }
  .brand-name { font-size: clamp(1.9rem, 4.6dvh, 2.6rem); }
  .intro h1 { margin-top: clamp(10px, 2dvh, 22px); font-size: clamp(1.9rem, min(3.9vw, 7.5dvh), 3.9rem); line-height: 1.02; }
  .store { margin-top: clamp(18px, 4dvh, 40px); flex-direction: row; flex-wrap: wrap; gap: 14px; text-align: left; }
  .foot { align-self: end; justify-content: flex-start; }
}

@media (max-width: 899px) and (max-height: 720px) { .store-note { display: none; } }

/* very short screens (landscape phones): tighten everything */
@media (max-height: 520px) {
  .hero { row-gap: 4px; }
  .brand img { width: 32px; }
  .brand-name { font-size: 1.4rem; }
  .intro h1 { font-size: 1.4rem; }
  .badge { min-height: 44px; padding: 4px 14px; }
  .badge-to { font-size: 1rem; }
  .store-note { display: none; }
  .coach { height: 1.4em; -webkit-line-clamp: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled) { transform: none; }
}

/* ---------- legal pages: a readable column that scrolls ---------- */
.doc { min-height: 100vh; }
.doc-wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 28px) 22px max(env(safe-area-inset-bottom), 32px);
}
.doc-head { margin-bottom: 28px; }
.doc-head a { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.doc-head img { width: 44px; height: auto; }
.doc-head span { font: 400 1.7rem/1 var(--hand); }
.doc article {
  padding: clamp(20px, 4vw, 40px);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 20px 16px 22px 14px;
  box-shadow: 5px 5px 0 var(--ink);
}
.doc h1 { margin: 0 0 4px; font: 700 clamp(2rem, 6vw, 2.8rem)/1.05 var(--sans); letter-spacing: -0.02em; }
.doc .meta { margin: 0 0 24px; color: var(--muted); }
.doc h2 { margin: 30px 0 8px; font: 700 1.2rem/1.25 var(--sans); }
.doc p, .doc li { font-size: 1.02rem; line-height: 1.65; }
.doc ul { padding-left: 1.25rem; }
.doc li { margin-bottom: 6px; }
.doc .lead { font-size: 1.15rem; }
.doc .foot { margin-top: 28px; }
