/* ============================================================
   Berlin Treasures — design tokens (mirror of design-system.md)
   ============================================================ */
:root {
  /* colour: deeper, less neon — a printed-poster green rather than a candy green */
  --bg-center: #bfdf70;
  --bg-mid:    #5c8c34;
  --bg-edge:   #16300f;

  --gold-shine: #fff4b8;
  --gold:       #ffd23f;
  --gold-deep:  #f0a017;
  --gold-dark:  #c47f00;

  --can-light: #cdd2d7;
  --can:       #aab0b6;
  --can-dark:  #7f878e;

  --outline:     #243528;   /* deep ink, used sparingly for borders/text on paper */
  --riso-shadow: #0f2b19;   /* duotone offset behind the title, like mis-registered print */
  --text-cream:  #fff7e2;
  --paper:       #f3e6c8;   /* kraft-tag / quote-card paper */
  --paper-edge:  #d9c194;

  /* type */
  --font-display: "Cal Sans", "Arial Black", "Trebuchet MS", sans-serif;
  --font-body:    "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --font-label:   "Courier Prime", ui-monospace, "SFMono-Regular", monospace;

  /* spacing & effects */
  --hero-max: 760px;
  --stack-gap: clamp(0.7rem, 2.2vh, 1.4rem);
  --radius: 999px;
  --radius-card: 14px;
  --shadow-soft: 0 16px 28px rgba(6, 18, 9, 0.38);
  --shadow-card: 0 10px 18px rgba(6, 18, 9, 0.3);

  /* golden pressable button */
  --tg-tilt: -2deg;
  --tg-edge: 7px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  min-height: 100vh;
  background:
    radial-gradient(120% 70% at 50% 108%, rgba(0, 0, 0, 0.4), transparent 62%),
    radial-gradient(circle at 50% 18%, var(--bg-center) 0%, var(--bg-mid) 42%, var(--bg-edge) 100%);
  background-attachment: fixed;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text-cream);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle print-grain, unifies the flat gradient + sprites into one "poster" surface */
.grain {
  position: fixed;
  inset: 0;
  z-index: 6;               /* above the canvas, below the Telegram button */
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- physics layer -------------------------------------------------- */
#playground {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;              /* above the hero text, below the button */
  display: block;
  touch-action: none;      /* let Matter.js own drag gestures on touch */
}

/* ---- hero (content column) ----------------------------------------- */
/* #spinZone (sized/positioned by spinner.js around the can) is the only thing
   that intercepts swipe-to-spin now — everywhere else in/around the hero
   column falls through to #playground so the falling cans stay draggable */
.spin-zone {
  position: fixed;
  z-index: 7;                /* above #playground (5) + .grain (6), below .hero-can/.telegram (10) */
  pointer-events: auto;
  border-radius: 50%;
  touch-action: none;        /* we own this swipe gesture, don't let the page scroll/zoom */
}

.hero {
  position: relative;
  z-index: 9;               /* above #playground (5) so its own children (can, Telegram) sit on top */
  pointer-events: none;     /* only children with their own pointer-events:auto are interactive; empty space falls through to the canvas */
  touch-action: pan-y;      /* allow vertical scrolling; the can itself (below) still owns its own drag/swipe */
  user-select: none;
  max-width: var(--hero-max);
  margin: 0 auto;
  min-height: 100vh;
  padding: clamp(1.2rem, 4vh, 2.6rem) 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--stack-gap);
  text-align: center;
}
/* text/quote content stays purely visual — clicks/swipes fall through to .hero's
   own spin handler (or, outside the hero column entirely, to the canvas) */
.hero > *:not(.hero-can):not(.tg-wrap) { pointer-events: none; }

.hero-can {
  position: relative;
  z-index: 10;              /* above #playground (5) so it can catch the grab */
  width: clamp(160px, 26vh, 248px);
  pointer-events: auto;     /* grab + drag it directly to lift it; swipe around it (on .hero) to spin it */
  touch-action: none;       /* we own the drag gesture, don't let the page scroll/zoom */
  cursor: grab;
  filter: drop-shadow(0 14px 12px rgba(0, 0, 0, 0.32));
  transition: filter 0.25s ease;
  animation: canBob 4s ease-in-out infinite;
}
/* lifted while being grabbed/dragged: bigger, softer shadow + a touch of scale;
   bob is suspended so it doesn't fight the drag translate, and it eases back
   to (0,0) via an inline transition set in JS on release */
.hero-can.lifted {
  z-index: 11;
  cursor: grabbing;
  animation: none;
  filter: drop-shadow(0 30px 24px rgba(0, 0, 0, 0.48));
}
.hero-can img {
  width: 100%;
  height: auto;
  display: block;
  will-change: transform;
  -webkit-user-drag: none;
  user-select: none;
  touch-action: none;        /* iOS honors touch-action on the actual touch target, and the touch often lands on the img itself */
}
@keyframes canBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* a little swing-tag, like something plucked off a flea-market find */
.found-tag {
  position: absolute;
  top: 6%;
  right: -22%;
  transform: rotate(9deg);
  background: var(--paper);
  color: var(--outline);
  font-family: var(--font-label);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.45em 0.7em 0.45em 1.1em;
  border-radius: 3px;
  box-shadow: var(--shadow-card);
}
.found-tag::before {
  content: "";
  position: absolute;
  top: 50%; left: 0.45em;
  width: 5px; height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: var(--bg-edge);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.4);
}

/* Duotone offset print, like a slightly mis-registered screen print, instead of a
   thick cartoon outline — a hard flat shadow (no blur) reads as crafted, not clip-art.
   Forced two lines (one word each via child spans) on every viewport, mobile included. */
.title {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.5px;
  font-size: clamp(2.8rem, 12vw, 6rem);
  color: var(--gold);                           /* fallback fill */
  -webkit-text-stroke: 1.5px var(--riso-shadow); /* thin edge — legible even on the bright center */
  paint-order: stroke fill;
  text-shadow: 5px 6px 0 var(--riso-shadow);     /* hard, unblurred duotone offset */
  margin-top: 0.1em;
}
.title span {
  display: block;
  line-height: 0.98;
}
.title span + span { margin-top: 0.05em; }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .title span {
    background: linear-gradient(180deg,
                var(--gold) 0%, var(--gold) 45%, var(--gold-deep) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

/* a little sticky-note torn off a market stall, not text floating on the gradient */
.quote {
  position: relative;
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 600;
  color: var(--outline);
  background: var(--paper);
  font-size: clamp(0.95rem, 2.6vw, 1.35rem);
  max-width: 26ch;
  padding: 0.8em 1.3em 0.8em 1.9em;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transform: rotate(-1.6deg);
}
.quote::before {
  content: "\201C";
  position: absolute;
  left: 0.22em;
  top: 0.02em;
  font-family: Georgia, "Times New Roman", serif;
  font-style: normal;
  font-size: 1.6em;
  color: var(--gold-dark);
  opacity: 0.8;
}

.welcome {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.subtext {
  font-family: var(--font-body);
  font-weight: 500;
  opacity: 0.92;
  font-size: clamp(0.95rem, 2.3vw, 1.2rem);
  max-width: 36ch;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* golden pressable button: a face (.telegram) that drops onto a milled step (.tg-edge) */
.tg-wrap {
  pointer-events: auto;                 /* clickable above the canvas */
  position: relative;
  z-index: 10;
  display: inline-block;
  margin-top: 0.35em;
  transform: rotate(0deg) translateY(0);   /* straight at rest */
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.tg-edge {
  position: absolute; inset: 0; z-index: 0;
  pointer-events: none;
  border-radius: var(--radius-card);
  transform: translateY(var(--tg-edge));
  background:
    repeating-linear-gradient(90deg,
      rgba(90, 60, 0, 0.11) 0px, rgba(90, 60, 0, 0.11) 1px,
      rgba(255, 255, 255, 0.04) 1px, rgba(255, 255, 255, 0.04) 2px,
      rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0) 5px),
    var(--gold-deep);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.telegram {
  position: relative; z-index: 1;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: clamp(1rem, 2.6vw, 1.3rem);
  letter-spacing: 0.04em;
  color: #6e4a00;
  text-decoration: none;
  background: var(--gold);
  padding: 0.75em 1.5em;
  border: none;
  border-radius: var(--radius-card);
  transform: translateY(0);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), background 0.15s ease;
}

.tg-shine {
  position: absolute; top: -30%; left: 44%; width: 16%; height: 160%;
  z-index: 2;                           /* reflection sits over the label */
  background: rgba(255, 255, 255, 0.38);
  transform: rotate(20deg) skewX(-6deg);
  pointer-events: none;
  transition: left 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.tg-label {
  position: relative; z-index: 1;
  /* engraved / carved-in text */
  text-shadow:
    0 1px 0 rgba(255, 246, 214, 0.55),
    0 -1px 0 rgba(70, 46, 0, 0.28);
}

.tg-icon { flex: 0 0 auto; position: relative; z-index: 1; color: #6e4a00; }

/* hover — slight lift + tilt */
.tg-wrap:hover { transform: rotate(var(--tg-tilt)) translateY(-6px); }
.tg-wrap:hover .telegram { background: var(--gold-shine); }
.tg-wrap:hover .tg-shine { left: 56%; }

.telegram:focus-visible { outline: 3px solid var(--gold-dark); outline-offset: 4px; }

/* click — face drops onto the step */
.tg-wrap:active { transform: rotate(var(--tg-tilt)) translateY(0); }
.tg-wrap:active .telegram {
  transform: translateY(var(--tg-edge));
  background: var(--gold-deep);
  transition: transform 0.06s ease-out, background 0.06s ease-out;
}
.tg-wrap:active .tg-shine { left: 52%; transition: left 0.06s ease-out; }

/* ---- interaction hint ---------------------------------------------- */
.hint {
  position: fixed;
  left: 0; right: 0; bottom: 16px;
  z-index: 8;
  pointer-events: none;
  text-align: center;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-cream);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  animation: hintPulse 2.4s ease-in-out infinite;
  transition: opacity 0.6s ease;
}
.hint.hide { opacity: 0; }
@keyframes hintPulse {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-can, .hint { animation: none; }
  .tg-wrap, .tg-edge, .telegram, .tg-shine { transition: none; }
}
