/* Phone polish. Loaded last so it can override style.css and extras.css. */

html { -webkit-text-size-adjust: 100%; }
body { overflow-x: clip; }
button, a, .opt, .scale-btn { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* Sticky call-to-action bar on the landing pages (phones only) */
.mobile-cta { display: none; }
.egg-big { display: none; }
.nav .btn { white-space: nowrap; }

@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .screen { padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }
  .brand-inner { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .tabs a { padding: 8px 12px; }

  /* ---------- Landing ---------- */
  .hero { gap: 28px; padding: 12px 0 32px; }
  h1 { font-size: clamp(32px, 9.5vw, 40px); margin: 12px 0 14px; }
  .lede { font-size: 16.5px; margin-bottom: 20px; }
  .facts { gap: 0; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; margin-bottom: 20px; }
  .facts strong { font-size: 26px; }
  .hero-copy .btn.primary { width: 100%; }
  .hero-art { max-width: 300px; }
  .hero-art::before { inset: 0; }
  .sample { transform: none; padding: 16px; border-radius: 18px; }

  /* Skill areas become a swipeable row */
  .areas { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; margin: 0 -16px 36px; padding: 0 16px 6px; scrollbar-width: none; }
  .areas::-webkit-scrollbar { display: none; }
  .area { flex: 0 0 78%; scroll-snap-align: center; padding: 20px; }

  .steps { margin-bottom: 36px; }
  .steps ol { gap: 16px; }
  .start-panel { border-radius: 20px; }
  .start-rules, .start-box { padding: 22px 20px; }
  .price-big { font-size: 38px; }
  .foot { margin-top: 28px; }

  .mobile-cta {
    display: block; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    transform: translateY(110%); transition: transform .25s ease;
  }
  .mobile-cta.show { transform: none; }
  .mobile-cta .btn { width: 100%; }

  /* ---------- IQ test: fit a whole question on one screen ---------- */
  body[data-screen="test"] .brand,
  body[data-screen="p-test"] .brand { display: none; }
  body[data-screen="test"] .screen,
  body[data-screen="p-test"] .screen { padding-top: 0; }
  .test-head {
    position: sticky; top: 0; z-index: 5; margin: 0 -16px; padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px);
    gap: 14px;
  }
  .q-count { font-size: 15px; margin-bottom: 6px; }
  .ring { width: 52px; height: 52px; }
  .ring span { font-size: 13px; }

  .question { margin-top: 6px; padding: 14px; border-radius: 18px; }
  .q-type { font-size: 11px; padding: 3px 9px; }
  .prompt { font-size: 17px; margin: 8px 0 12px; }
  .matrix { width: min(100%, calc(100dvh - 430px), 340px); min-width: 210px; margin-bottom: 14px; border-radius: 10px; }
  .matrix .missing { font-size: 32px; }
  .series { font-size: clamp(24px, 8vw, 32px); padding: 22px 8px; margin-bottom: 14px; }
  .statement { font-size: 16.5px; padding: 14px 16px; margin-bottom: 14px; }

  .options { gap: 8px; }
  .opt { font-size: 16px; padding: 12px 14px; min-height: 52px; }
  .opt.figure { position: relative; padding: 5px; border-radius: 12px; }
  .opt.figure .letter { position: absolute; top: 5px; left: 5px; z-index: 1; width: 20px; height: 20px; font-size: 11px; border-radius: 6px; }
  .opt.figure .tile { max-width: none; border-radius: 8px; }
  .opt:hover { transform: none; }
  .opt:active { transform: scale(.97); }

  /* Fixed bottom bar for Back / Finish / Skip */
  #test .nav, #p-test .nav {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; margin: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  #test .nav .btn { padding: 12px 16px; min-width: 96px; }
  .dots { margin-top: 18px; gap: 5px; }
  .dots button { width: 28px; height: 28px; border-radius: 8px; }

  /* ---------- Personality test ---------- */
  #p-test:not([hidden]) { display: flex; flex-direction: column; min-height: 100dvh; }
  #p-test .egg-mini { display: none; }
  #p-test .test-head { grid-template-columns: 1fr; }
  .egg-big { display: block; width: min(150px, 22dvh); aspect-ratio: 1; margin: auto auto 0; }
  .egg-big svg { width: 100%; height: 100%; transform-origin: 50% 90%; }
  .egg-big.wobble svg { animation: wobble .6s ease; }
  .hatch-msg { margin: 6px 0 0; font-size: 14px; text-align: center; }
  .p-card { padding: 26px 14px 18px; margin: 14px 0 auto; }
  .p-statement { font-size: clamp(22px, 6.6vw, 28px); margin-bottom: 26px; min-height: 3.75em; }
  .scale { gap: 6px; }
  .scale-btn { padding: 12px 2px 10px; border-radius: 14px; font-size: 11px; line-height: 1.2; min-height: 82px; background: var(--bg); border-color: var(--line); }
  .scale-btn .emoji { font-size: 30px; }
  .scale-btn:hover .emoji { transform: none; }
  .scale-btn:active { transform: scale(.94); }
  #p-test .nav .muted { font-size: 12.5px; text-align: right; }

  /* ---------- Paywall ---------- */
  .paywall { padding: 28px 18px; margin-top: 8px; border-radius: 20px; }
  .paywall h1 { font-size: 30px; margin-top: 12px; }
  .teaser { padding: 18px 16px 10px; }
  .includes li { font-size: 15px; }

  /* ---------- Results ---------- */
  .result-hero { padding: 30px 16px 26px; margin-top: 8px; border-radius: 20px; }
  .card { padding: 18px; border-radius: 18px; margin: 14px 0; }
  #curve text { font-size: 22px; }
  .careers { grid-template-columns: 1fr; gap: 10px; }
  .careers-head .btn { width: 100%; }
  .cross-sell { padding: 22px 18px; gap: 12px; }
  .cross-sell .btn { width: 100%; }
  #restart, #p-restart { width: 100%; }

  /* ---------- Personality landing & results ---------- */
  .p-hero { gap: 16px; padding: 12px 0 28px; }
  .p-cta { align-items: stretch; }
  .p-cta .btn { width: 100%; }
  .p-price { text-align: center; }
  .p-hero-art { height: 250px; order: -1; }
  .species-row { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin: 14px -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .species-row::-webkit-scrollbar { display: none; }
  .species { flex: 0 0 auto; scroll-snap-align: start; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .g-card { padding: 10px 8px 12px; border-radius: 14px; }
  .g-card:hover, .g-card:focus { transform: none; box-shadow: none; }
  .g-tag { max-height: none; }

  .type-hero { padding: 22px 18px; gap: 4px; border-radius: 22px; margin-top: 8px; }
  .type-critter { max-width: 180px; }
  .type-tag { font-size: 16.5px; }
  .trait-head { font-size: 12.5px; }
  .buddy { flex-direction: column; text-align: center; gap: 8px; }
  .buddy-critter { width: 120px; }
}

/* Very short phones (e.g. iPhone SE): shrink the test chrome further */
@media (max-width: 640px) and (max-height: 700px) {
  .prompt { font-size: 16px; margin: 6px 0 10px; }
  .q-type { display: none; }
  .question { padding: 12px; }
  .matrix { width: min(100%, calc(100dvh - 420px), 280px); min-width: 170px; margin-bottom: 10px; }
  .opt.figure { padding: 3px; }
  .opt.figure .tile { max-width: 80px; margin: 0 auto; }
  .ring { width: 46px; height: 46px; }
}

/* Start panel sits right under the hero */
.start-panel { margin-bottom: 56px; }
@media (max-width: 640px) { .start-panel { margin-bottom: 36px; } }
