/* ── Matcha Marikina ────────────────────────────────────────────────────────
   All presentation lives here. index.html holds only structure + logic.
   Sizes that must survive a 320px phone use clamp(min, vw, max).
   ------------------------------------------------------------------------ */

:root {
  --blue:        #1565B0;
  --green:       #A6BC33;
  --olive:       #77902F;
  --olive-dark:  #5F7A24;
  --leaf:        #8CA83F;
  --lime:        #DCE8AB;
  --lime-edge:   #C4D98A;
  --locked:      #A8B93C;
  --cream:       #FCF3D7;
  --cream-warm:  #FCF2D3;
  --cream-soft:  rgba(252, 242, 211, .85);
  --cell:        #FBF3DB;
  --pink:        #E4649A;
  --orange:      #F08A2B;
  --scan:        #C6E05A;
  --input-bg:    #F7F7F5;
  --ink:         #3A3A2A;
  --app-max:     430px;
  --tabbar:      calc(94px + env(safe-area-inset-bottom, 0px));
  --font:        'QTVagaRound', system-ui, sans-serif;
}

@font-face {
  font-family: 'QTVagaRound';
  src: url('./assets/QTVagaRound-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: #33455f;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;          /* kills the 300ms double-tap zoom delay */
  overscroll-behavior-y: contain;      /* no rubber-band bounce past the card */
}

input, button { font-family: var(--font); }
a { color: var(--blue); }
a:hover { color: #0f4a86; }

@keyframes pop {
  0%   { transform: scale(.6); opacity: 0; }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes scanline { 0% { top: 6%; } 100% { top: 92%; } }
@keyframes floatstar {
  0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); }
  50%      { transform: translateY(-6px) rotate(var(--r, 0deg)); }
}

@media (prefers-reduced-motion: reduce) {
  .star, .scanline { animation: none !important; }
  /* selection still reads, it just snaps instead of growing and wiggling */
  .cup__shadow, .cup__art { transition: none !important; animation: none !important; }
}

/* ── shell ───────────────────────────────────────────────────────────────── */

.app {
  width: 100%;
  max-width: var(--app-max);
  min-height: 100vh;
  min-height: 100dvh;                  /* mobile browser chrome doesn't clip it */
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
  background: #B9BDB0 url('./assets/bg.jpg') no-repeat center top / cover;
  font-family: var(--font);
}

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.star {
  position: absolute;
  color: currentColor;                 /* the SVG inherits this */
  animation: floatstar 7s ease-in-out infinite;
}
.star svg { display: block; width: 100%; height: 100%; }

.screen { position: relative; z-index: 2; }
.screen--form   { padding: 34px clamp(14px, 5vw, 20px) 46px; }
.screen--tabbed { padding: 24px clamp(12px, 4.5vw, 18px) calc(var(--tabbar) + 36px); }

/* ── masthead ────────────────────────────────────────────────────────────── */

.brand { text-align: center; }
.brand__logo {
  width: 88%;
  max-width: 340px;
  margin: 0 auto;
  aspect-ratio: 718 / 318;
  overflow: hidden;
  filter: drop-shadow(0 6px 12px rgba(30, 40, 15, .35));
}
.brand__logo img { display: block; width: 100%; }
.brand__date {
  margin-top: 8px;
  font-weight: 800;
  font-size: clamp(20px, 6.5vw, 26px);
  letter-spacing: .5px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(20, 30, 50, .45);
}

.hero-logo {
  display: block;
  width: 74%;
  max-width: 290px;
  margin: 0 auto;
  filter: drop-shadow(0 6px 12px rgba(30, 40, 15, .35));
}
.hero-logo--vote { width: 82%; max-width: 320px; }

/* ── form card ───────────────────────────────────────────────────────────── */

.card {
  margin-top: 22px;
  background: var(--cream-soft);
  border-radius: 34px;
  padding: 26px clamp(16px, 5.5vw, 22px) 24px;
  box-shadow: 0 18px 34px -18px rgba(45, 45, 20, .5);
}
.card__title {
  text-align: center;
  font-weight: 800;
  font-size: clamp(27px, 8.4vw, 36px);
  line-height: 1;
  color: var(--blue);
}
.card__title--accent {
  color: var(--green);
  line-height: 1.05;
  margin-bottom: 18px;
}

.field { margin-bottom: 14px; }
.field--last { margin-bottom: 18px; }
.field__label {
  display: block;
  font-weight: 800;
  font-size: clamp(16px, 5vw, 19px);
  color: var(--blue);
  margin-bottom: 6px;
}
.field__input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 14px;
  border: 2px solid var(--blue);
  background: var(--input-bg);
  font-size: 17px;                     /* >=16px or iOS zooms the page on focus */
  font-weight: 700;
  color: var(--ink);
  outline: none;
}
.field__input:focus { border-color: var(--pink); }

.gender { display: flex; gap: clamp(6px, 2.5vw, 10px); }
.gender__opt {
  flex: 1;
  min-width: 0;
  padding: 12px 4px;
  border-radius: 14px;
  border: 2px solid var(--blue);
  text-align: center;
  font-weight: 800;
  font-size: clamp(16px, 5vw, 20px);
  color: var(--blue);
  background: #F8F5E6;
  cursor: pointer;
  transition: background .15s;
}
.gender__opt--on { background: var(--lime); }

.consent {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 18px 0 16px;
  padding: 13px 14px;
  background: var(--cream-warm);
  border: 2px solid var(--blue);
  border-radius: 16px;
}
.consent__box {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--blue);
  cursor: pointer;
}
.consent__text {
  font-weight: 700;
  font-size: clamp(13px, 4vw, 15px);
  color: var(--blue);
  line-height: 1.3;
  cursor: pointer;
}

.altlink {
  margin-top: 14px;
  text-align: center;
  font-weight: 800;
  font-size: clamp(14px, 4.3vw, 16px);
  color: var(--olive);
  cursor: pointer;
}
.altlink em { color: var(--pink); text-decoration: underline; font-style: normal; }

/* ── buttons ─────────────────────────────────────────────────────────────── */

.btn {
  font-family: var(--font);
  font-weight: 800;
  cursor: pointer;
  border: none;
}
.btn--block {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 2px solid var(--blue);
  background: var(--lime);
  color: var(--blue);
  font-size: clamp(26px, 8vw, 34px);
}
.btn--vote { margin-top: 20px; font-size: clamp(21px, 6.4vw, 26px); }
.btn--pill {
  border-radius: 999px;
  padding: 12px 26px;
  color: #fff;
  background: var(--pink);
  font-size: clamp(14px, 4.4vw, 17px);
  white-space: nowrap;
}
.btn--ghost {
  border-radius: 999px;
  padding: 12px 20px;
  border: 2px solid var(--scan);
  background: transparent;
  color: var(--scan);
  font-size: 16px;
}
.btn--soft {
  border-radius: 999px;
  padding: 12px;
  border: 2px solid var(--lime-edge);
  background: var(--cream);
  color: var(--olive);
  font-size: 15px;
}
.btn--locked { background: var(--locked); cursor: default; }
.btn--done   { opacity: .85; cursor: default; }
.btn.is-off  { opacity: .55; }
.btn.is-dim  { opacity: .5; }

/* ── bingo ───────────────────────────────────────────────────────────────── */

.stats { display: flex; gap: 12px; margin: 22px 0 16px; }
.stat {
  flex: 1;
  background: var(--cream);
  border: 2px solid var(--blue);
  border-radius: 16px;
  padding: 12px 6px 10px;
  text-align: center;
}
.stat__num {
  font-weight: 800;
  font-size: clamp(23px, 7.2vw, 28px);
  color: var(--orange);
  line-height: 1;
}
.stat__label { font-weight: 800; font-size: clamp(13px, 4vw, 15px); color: var(--orange); }

.board {
  background: url('./assets/bingo-box-bg.png') center / 100% 100% no-repeat;
  border-radius: 24px;
  padding: clamp(9px, 3.4vw, 14px);
  box-shadow: 0 14px 30px -18px rgba(40, 45, 10, .6);
}
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(3px, 1.2vw, 5px);
}

.cell {
  aspect-ratio: 1 / 1;
  border-radius: 11px;
  background: var(--cell);
  border: 2px solid var(--leaf);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2px, 1vw, 4px) clamp(1px, .8vw, 3px);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition: background .18s, border-color .18s;
}
.cell--on { background: var(--olive-dark); border-color: var(--olive-dark); }
.cell__label {
  font-weight: 800;
  font-size: clamp(7px, 2.3vw, 9.5px);
  line-height: 1.12;
  color: var(--olive);
  overflow-wrap: anywhere;             /* long station names stay inside the box */
  hyphens: auto;
}
.cell--on .cell__label { color: #fff; }
.cell__icon { width: 86%; display: block; }

.claims { margin-top: 16px; display: flex; flex-direction: column; gap: 11px; }
.claim {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--cream);
  border: 2px solid var(--lime-edge);
  border-radius: 20px;
  padding: 12px 14px;
}
.claim__title { font-weight: 800; font-size: clamp(16px, 5vw, 19px); color: var(--olive); line-height: 1.1; }
.claim__sub   { font-weight: 700; font-size: clamp(12px, 3.7vw, 14px); color: var(--olive); }

/* ── best matcha ─────────────────────────────────────────────────────────── */

.brands {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px clamp(6px, 2.5vw, 10px);
  margin-top: 24px;
}
.brand-card {
  cursor: pointer;
  padding: 5px;
  border-radius: 20px;
  border: 4px solid transparent;
  transition: border-color .15s;
}
/* Selection is shown by the growing lime silhouette behind the cup, not a border.
   The transparent border above stays purely to reserve layout space. */

/* Cup art is 500x707 and already carries the vendor name — no text overlay. */
.cup { position: relative; width: 100%; aspect-ratio: 500 / 707; }
.cup img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* cup_shadow.png is the same 500x707 silhouette, so scaling it up behind the
   art reads as an even outline growing out from under the chosen cup. */
/* A background-image, not an <img> — see the note in renderVals(). */
.cup__art {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: center / contain no-repeat;
  transition: transform .3s cubic-bezier(.34, 1.46, .64, 1);
}
.cup__shadow {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transform: scale(.86);
  transform-origin: 50% 50%;
  pointer-events: none;
  transition: opacity .2s ease, transform .3s cubic-bezier(.34, 1.46, .64, 1);
}
/* translateY before scale, so the nudge stays exact on screen rather than
   being multiplied by the scale factor.
   scaleY is held below scaleX to squish the halo ~5px shorter than an even
   grow: exact at the 430px design width, proportionally less on narrow phones. */
/* Halo and cup each grow with their own wobble. The two keyframe sets run at
   different durations and rotate in opposite directions, so they never line up
   — the cup leans one way while the halo leans the other. Final frames match
   the static transforms below, so nothing jumps when the animation ends. */
@keyframes cup-halo-pop {
  0%   { transform: translateY(0) scale(.86, .86)       rotate(0deg); }
  35%  { transform: translateY(0) scale(1.175, 1.125)   rotate(-2.2deg); }
  62%  { transform: translateY(0) scale(1.122, 1.081)   rotate(1.4deg); }
  82%  { transform: translateY(0) scale(1.152, 1.104)   rotate(-.6deg); }
  100% { transform: translateY(0) scale(1.1402, 1.0965) rotate(0deg); }
}
@keyframes cup-art-pop {
  0%   { transform: scale(1)      rotate(0deg); }
  30%  { transform: scale(1.030)  rotate(1.5deg); }
  58%  { transform: scale(1.010)  rotate(-1deg); }
  80%  { transform: scale(1.023)  rotate(.45deg); }
  100% { transform: scale(1.0186) rotate(0deg); }
}

.brand-card--on .cup__shadow {
  opacity: 1;
  transform: translateY(0) scale(1.1402, 1.0965);
  animation: cup-halo-pop .5s cubic-bezier(.34, 1.46, .64, 1) both;
}

/* The chosen cup itself lifts a little too, so art and halo grow together. */
.brand-card--on .cup__art {
  transform: scale(1.0186);
  animation: cup-art-pop .62s cubic-bezier(.34, 1.46, .64, 1) .04s both;
}

.voted { text-align: center; margin-top: 22px; }
.voted__badge {
  display: inline-block;
  background: var(--lime);
  border: 2px solid var(--blue);
  border-radius: 14px;
  padding: 12px clamp(20px, 8vw, 34px);
  font-weight: 800;
  font-size: clamp(19px, 6vw, 24px);
  color: var(--blue);
}
.voted__cup { width: 66%; margin: 14px auto 0; position: relative; aspect-ratio: 500 / 707; }
.voted__art { position: absolute; inset: 0; background: center / contain no-repeat; }
.voted__name {
  margin-top: 10px;
  font-weight: 800;
  font-size: clamp(17px, 5.2vw, 21px);
  line-height: 1.15;
  color: var(--olive-dark);
  overflow-wrap: anywhere;
}

/* ── tab bar ─────────────────────────────────────────────────────────────── */

.tabs {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  z-index: 30;
  display: flex;
  background: var(--cream);
  padding: 14px 10px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 20px -14px rgba(0, 0, 0, .5);
}
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: .45;
  transition: opacity .15s;
}
.tab--on { opacity: 1; }
.tab img { display: block; height: clamp(46px, 14vw, 62px); width: auto; }

/* ── overlays ────────────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(35, 32, 12, .62);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay--black { background: rgba(0, 0, 0, .7); }

.scanbox {
  width: min(72vw, 260px);
  height: min(72vw, 260px);
  background: #0b0b0b;
  border: 4px solid var(--scan);
  border-radius: 22px;
  position: relative;
  margin: 0 auto;
  overflow: hidden;
}
.scanbox video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b0b0b;
}
.corner { position: absolute; width: 30px; height: 30px; border: 5px solid var(--scan); }
.corner--tl { top: 12px; left: 12px;  border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.corner--tr { top: 12px; right: 12px; border-left: 0;  border-bottom: 0; border-top-right-radius: 8px; }
.corner--bl { bottom: 12px; left: 12px;  border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.corner--br { bottom: 12px; right: 12px; border-left: 0;  border-top: 0; border-bottom-right-radius: 8px; }
.scanline {
  position: absolute;
  left: 8%;
  width: 84%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--scan), transparent);
  animation: scanline 1.1s ease-in-out infinite alternate;
}
.scan__status {
  font-weight: 800;
  font-size: clamp(18px, 5.6vw, 22px);
  color: #fff;
  margin-top: 18px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.scan__err {
  margin: 12px auto 0;
  max-width: 262px;
  background: var(--cream);
  border: 2px solid var(--pink);
  border-radius: 16px;
  padding: 11px 13px;
  font-weight: 700;
  font-size: 14px;
  color: var(--pink);
  line-height: 1.35;
}
.scan__actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.modal {
  width: 100%;
  max-width: 310px;
  text-align: center;
  animation: pop .25s ease-out both;
}
.modal--panel {
  background: var(--cream);
  border: 3px solid #A8C755;
  border-radius: 24px;
  padding: 24px;
}
.modal__title {
  font-weight: 800;
  font-size: clamp(34px, 11vw, 42px);
  color: var(--cream);
  margin-bottom: 14px;
  text-shadow: 0 3px 10px rgba(0, 0, 0, .4);
}
.modal__actions { display: flex; gap: 14px; margin-top: 16px; padding: 0 4px; }

.prize {
  background: var(--cream);
  border: 3px solid #A8C755;
  border-radius: 26px;
  padding: 18px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 34px -18px rgba(20, 25, 10, .7);
}
.prize img {
  display: block;
  width: 80%;
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
  margin-left: 6px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .35));
}
.prize__btn {
  flex: 1;
  padding: 14px;
  border-radius: 16px;
  border: none;
  font-size: clamp(16px, 5vw, 19px);
  cursor: pointer;
}
.prize__btn--later { background: var(--cream); color: var(--pink); }
.prize__btn--claim { flex: 1.6; background: var(--pink); color: #fff; }

.confirm__title { font-weight: 800; font-size: clamp(19px, 6vw, 22px); color: var(--blue); margin-bottom: 6px; }
.confirm__text  { font-weight: 700; font-size: clamp(14px, 4.2vw, 15px); color: var(--olive); margin-bottom: 18px; line-height: 1.35; }
.confirm__actions { display: flex; gap: 10px; }
.confirm__actions .btn:last-child { flex: 1.4; }
.confirm__actions .btn { flex: 1; }

.toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--blue);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  max-width: 88%;
  text-align: center;
  box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .6);
}
