/* Bio Lore button components.
   This file owns the live DOM reconstruction for actionable buttons that used
   to be baked into full-page art references. */

body[data-view="start"] .start-action,
body[data-view="mode"] .mode-start-action,
body[data-view="result"] #copyButton,
body[data-view="share"] #saveAvatarButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2.5%;
  min-height: 0;
  margin: 0;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--purple);
  color: #fff;
  font-size: clamp(1.1rem, 5.1vw, 1.35rem);
  font-weight: 900;
  line-height: 1;
  opacity: 1;
  pointer-events: auto;
  box-shadow: none;
}

body[data-view="quiz"] .quiz-actions #quizBackButton,
body[data-view="share"] #saveResultCardButton,
body[data-view="share"] #shareCopyButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2.5%;
  min-height: 0;
  margin: 0;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--ink);
  font-size: clamp(0.82rem, 3.65vw, 1rem);
  font-weight: 900;
  line-height: 1;
  opacity: 1;
  pointer-events: auto;
  box-shadow: none;
}

body[data-view="start"] .start-action {
  left: 6.7%;
  top: 85.9%;
  z-index: 20;
  width: 86.7%;
  height: 8.2%;
}

body[data-view="mode"] .plain-nav,
body[data-view="mode"] .mode-card,
body[data-view="mode"] .mode-start-action {
  opacity: 1;
  pointer-events: auto;
}

body[data-view="mode"] .mode-card {
  display: grid;
  grid-template-columns: 54% minmax(0, 1fr);
  grid-template-rows: 1fr auto auto auto 1fr;
  align-items: center;
  padding: 4.8% 6%;
  border: 3px solid var(--line);
  border-radius: 13px;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: none;
}

body[data-view="mode"] #freeTestButton,
body[data-view="mode"] #fullTestButton {
  left: 6.2%;
  width: 87.6%;
}

body[data-view="mode"] #freeTestButton {
  top: 16.4%;
  height: 35.2%;
}

body[data-view="mode"] #fullTestButton {
  top: 52.1%;
  height: 32.4%;
}

body[data-view="mode"] .mode-start-action {
  top: 88.2%;
  left: 6.9%;
  z-index: 20;
  width: 86.2%;
  height: 7.1%;
}

body[data-view="mode"] .mode-radio {
  position: absolute;
  top: 6.4%;
  left: 4.4%;
  width: 8.2%;
  height: 8.2%;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fffdf8 none;
  overflow: visible;
}

body[data-view="mode"] .mode-check {
  position: absolute;
  top: 48%;
  left: 54%;
  display: none;
  width: 68%;
  height: 36%;
  border-right: 5px solid var(--purple);
  border-bottom: 5px solid var(--purple);
  border-radius: 1px;
  transform: translate(-50%, -56%) rotate(45deg);
  transform-origin: center;
}

body[data-view="mode"] .mode-card.selected .mode-radio {
  background: #fffdf8 none;
}

body[data-view="mode"] .mode-card.selected .mode-check {
  display: block;
}

body[data-view="mode"] .test-panel::before,
body[data-view="mode"] .test-panel::after {
  position: absolute;
  right: auto;
  bottom: auto;
  left: 8.65%;
  z-index: 60;
  display: block;
  width: 9%;
  height: 4.65%;
  content: "";
  border: 0;
  --mode-checkmark-art: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 30' fill='none'%3E%3Cpath d='M7 16.2c3.5 1.7 6.7 4.7 9.1 7.1C21.6 15.4 28.2 8.5 36 4.7' stroke='%236d5bd7' stroke-width='5.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M8.8 15.1c3 2 5.8 4.4 8.1 6.5C22.4 14.3 28.4 8.2 34.6 5.8' stroke='%238375e8' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round' opacity='.7'/%3E%3C/svg%3E");
  background: transparent var(--mode-checkmark-art) center / contain no-repeat;
  color: transparent;
  opacity: 0;
  pointer-events: none;
  transform: rotate(-7deg);
  transform-origin: center;
}

body[data-view="mode"] .test-panel::before {
  top: 18.1%;
}

body[data-view="mode"] .test-panel::after {
  top: 53.58%;
}

body[data-view="mode"][data-selected-plan="free"] .test-panel::before,
body[data-view="mode"][data-selected-plan="full"] .test-panel::after {
  right: auto;
  bottom: auto;
  background: transparent var(--mode-checkmark-art) center / contain no-repeat;
  opacity: 1;
}

body[data-view="mode"] .mode-card.selected .mode-radio::after {
  content: none;
}

body[data-view="quiz"] .answer-button {
  border: 3px solid var(--line);
  border-radius: 13px;
  background: #fffdf8;
  opacity: 1;
  pointer-events: auto;
}

body[data-view="quiz"] .answer-button:hover,
body[data-view="quiz"] .answer-button:focus-visible,
body[data-view="quiz"] .answer-button.selected {
  border-color: var(--purple);
  outline: 0;
  box-shadow: inset 0 0 0 1px var(--purple);
}

body[data-view="quiz"] .answer-marker {
  border: 3px solid var(--line);
  background: var(--lavender);
}

body[data-view="quiz"] .answer-button.selected::after {
  background: url("../../assets/art/icons/icon-check.png") center / contain no-repeat;
}

body[data-view="quiz"] .quiz-actions #quizBackButton {
  top: 89.2%;
  width: 34%;
  height: 5.1%;
}

body[data-view="quiz"] .quiz-actions #quizBackButton {
  left: 5.6%;
}

body[data-view="result"] .actions {
  position: static;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding-bottom: 0;
  opacity: 1;
  pointer-events: auto;
}

body[data-view="result"] #copyButton {
  width: 100%;
  height: auto;
  min-height: 48px;
}

/* Standard mobile web UI button reset. */
body[data-view="start"] .start-action,
body[data-view="mode"] .mode-start-action {
  position: static;
  display: inline-flex;
  width: 100%;
  height: auto;
  min-height: 52px;
  margin: 0;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--purple);
  opacity: 1;
  pointer-events: auto;
}

body[data-view="mode"] .plain-nav,
body[data-view="mode"] .mode-card {
  opacity: 1;
  pointer-events: auto;
}

body[data-view="mode"] .plain-nav {
  position: static;
}

body[data-view="mode"] .mode-card {
  position: relative;
  left: auto;
  top: auto;
  width: auto;
  height: auto;
}

body[data-view="mode"] #freeTestButton,
body[data-view="mode"] #fullTestButton {
  left: auto;
  top: auto;
  width: auto;
}

body[data-view="mode"] .mode-start-action {
  left: auto;
  top: auto;
}

body[data-view="quiz"] .answer-button {
  position: static;
  left: auto;
  top: auto;
  width: auto;
  height: auto;
  min-height: 76px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fffdf8;
  opacity: 1;
  pointer-events: auto;
}

body[data-view="quiz"] .answer-button:nth-child(1),
body[data-view="quiz"] .answer-button:nth-child(2),
body[data-view="quiz"] .answer-button:nth-child(3) {
  top: auto;
}

body[data-view="quiz"] .quiz-actions #quizBackButton {
  position: static;
  width: 100%;
  height: auto;
  min-height: 46px;
  border: 3px solid var(--line);
  opacity: 1;
  pointer-events: auto;
}

body[data-view="quiz"] .quiz-actions #quizBackButton {
  left: auto;
}

body[data-view="share"] .share-actions {
  right: 7.1%;
  bottom: 13.7%;
  left: 7.1%;
  z-index: 10;
  display: grid;
  gap: 7px;
  height: auto;
  margin: 0;
}

body[data-view="share"] .share-actions button {
  width: 100%;
  height: 44px;
  min-height: 0;
  border-width: 3px;
  opacity: 1;
  pointer-events: auto;
}

body[data-view="share"] #shareCopyButton {
  display: none;
}

/* Proportion blueprint button/card positions. Kept here because this file loads after styles.css. */
body[data-view="start"] .start-action {
  position: absolute;
  right: 7%;
  bottom: 6.9%;
  left: 7%;
  width: auto;
  height: 8%;
  min-height: 0;
  margin: 0;
  font-size: clamp(1.55rem, calc(var(--artboard-width, 390px) * 0.068), 2.5rem);
}

body[data-view="mode"] .plain-nav {
  position: absolute;
  top: 6.1%;
  left: 6.2%;
  z-index: 5;
}

body[data-view="mode"] .mode-head h1 {
  top: var(--mode-title-top, 4.9%);
  right: var(--mode-title-right, 12%);
  left: var(--mode-title-left, 22%);
  font-size: var(--mode-title-font-size, clamp(2.25rem, calc(var(--artboard-width, 390px) * 0.1), 4rem));
  line-height: 1;
}

body[data-view="mode"] .mode-card {
  position: absolute;
  left: 6.4%;
  width: 87.2%;
  height: 31.8%;
  min-height: 0;
  opacity: 1;
  pointer-events: auto;
}

body[data-view="mode"] #freeTestButton {
  left: 6.4%;
  top: 16.5%;
  width: 87.2%;
  height: 31.8%;
}

body[data-view="mode"] #fullTestButton {
  left: 6.4%;
  top: 50.8%;
  width: 87.2%;
  height: 31.8%;
}

body[data-view="mode"] .mode-start-action {
  position: absolute;
  right: 6.8%;
  bottom: 3.2%;
  left: 6.8%;
  width: auto;
  height: 7%;
  min-height: 0;
  margin: 0;
  font-size: clamp(1.7rem, calc(var(--artboard-width, 390px) * 0.075), 2.7rem);
}

body[data-view="quiz"] .answer-button {
  position: static;
  width: auto;
  height: auto;
  min-height: 10.6dvh;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 20px;
  border-radius: 20px;
}

body[data-view="quiz"] .quiz-actions #quizBackButton {
  position: static;
  width: 100%;
  height: auto;
  min-height: 58px;
  font-size: clamp(1.18rem, 5.2vw, 1.8rem);
}

body[data-view="share"] .share-actions {
  position: absolute;
  right: 7%;
  bottom: 16%;
  left: 7%;
  gap: 2dvh;
}

body[data-view="share"] .share-actions button {
  height: auto;
  min-height: 7dvh;
  font-size: clamp(1.35rem, 6vw, 2.1rem);
}

/* Art proportion corrections for mode and quiz controls. */
body[data-view="mode"] .test-panel::before,
body[data-view="mode"] .test-panel::after,
body[data-view="mode"][data-selected-plan="free"] .test-panel::before,
body[data-view="mode"][data-selected-plan="full"] .test-panel::after {
  content: none;
  display: none;
}

body[data-view="mode"] .mode-radio {
  top: 7.8%;
  left: 4.1%;
  width: 9.15%;
  height: auto;
  aspect-ratio: 1;
  background: #fffdf8;
}

body[data-view="mode"] .mode-check,
body[data-view="mode"] .mode-card.selected .mode-check {
  display: none;
}

body[data-view="mode"] .mode-card.selected .mode-radio::after {
  position: absolute;
  inset: 22%;
  display: block;
  content: "";
  border-radius: 999px;
  background: var(--purple);
}

body[data-view="quiz"] .answer-button {
  min-height: 12.2dvh;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 18px;
  padding: 14px 22px;
}

body[data-view="quiz"] .quiz-actions #quizBackButton {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 34%;
  min-height: 58px;
}

body[data-view="quiz"] .answer-button,
body[data-view="quiz"] .answer-button:nth-child(1),
body[data-view="quiz"] .answer-button:nth-child(2),
body[data-view="quiz"] .answer-button:nth-child(3) {
  min-height: calc(var(--artboard-height, 844px) * 0.088);
  padding: 8px 20px;
}

body[data-view="share"] .share-actions #saveAvatarButton,
body[data-view="share"] .share-actions #saveResultCardButton {
  height: 48px;
  min-height: 48px;
  border-width: 4px;
}

body[data-view="share"] .share-actions #saveAvatarButton {
  font-size: clamp(1.34rem, 6.1vw, 2rem);
}

body[data-view="share"] .share-actions #saveResultCardButton {
  font-size: clamp(1.02rem, 4.6vw, 1.45rem);
}

body[data-view="share"] .share-actions #saveResultCardButton span {
  width: 38px;
  height: 38px;
  background-size: 175% 175%;
}

body[data-view="share"] .share-actions #saveAvatarButton span {
  width: 35px;
  height: 35px;
  background-size: 165% 165%;
}

body[data-view="mode"] #freeTestButton .mode-doodle {
  position: absolute;
  top: 11.1%;
  left: -1.1%;
  width: 66.8%;
  height: 96.5%;
  background-size: contain;
}

body[data-view="mode"] #fullTestButton .mode-doodle {
  position: absolute;
  top: 16.3%;
  left: 3.4%;
  width: 58%;
  height: 83.5%;
  background-size: contain;
}

/* Goal: final clickable-art control layer. */
body[data-view="start"] .start-action {
  position: absolute;
  top: var(--home-cta-top, 89.75%);
  right: auto;
  bottom: auto;
  left: var(--home-cta-left, 6.68%);
  z-index: 40;
  width: var(--home-cta-width, 86.75%);
  height: var(--home-cta-height, 7.86%);
  min-height: 0;
  font-size: var(--home-cta-font-size, clamp(1.48rem, calc(var(--artboard-width, 390px) * 0.068), 2.4rem));
}

body[data-view="mode"] .mode-card {
  position: absolute;
  display: grid;
  grid-template-columns: 54% minmax(0, 1fr);
  grid-template-rows: 14% auto auto auto 1fr;
  align-items: start;
  padding: 4.8% 6%;
  border: 3px solid var(--line);
  border-radius: 22px;
  background: #fffdf8;
  box-shadow: none;
}

body[data-view="mode"] #freeTestButton {
  top: var(--mode-free-top, 16.59%);
  left: 6.1%;
  width: 87.69%;
  height: var(--mode-free-height, 33.62%);
}

body[data-view="mode"] #fullTestButton {
  top: var(--mode-full-top, 52.39%);
  left: 6.1%;
  width: 87.69%;
  height: var(--mode-full-height, 30.37%);
}

body[data-view="mode"] .mode-radio {
  position: absolute;
  top: 3.2%;
  left: 0.6%;
  width: 14.7%;
  height: auto;
  aspect-ratio: 1;
  border: 0;
  background: url("../../assets/art/icons/icon-radio-empty.png") center / contain no-repeat !important;
}

body[data-view="mode"] .mode-card.selected .mode-radio {
  top: 0.9%;
  left: -1%;
  width: 19.9%;
  background: url("../../assets/art/icons/icon-radio-selected.png") center / contain no-repeat !important;
}

body[data-view="mode"] .mode-card.selected .mode-radio::after,
body[data-view="mode"] .mode-check {
  content: none;
  display: none;
}

body[data-view="mode"] #freeTestButton .mode-doodle {
  position: absolute;
  top: var(--mode-free-doodle-top, 10.2%);
  left: var(--mode-free-doodle-left, -0.8%);
  width: var(--mode-free-doodle-width, 66.4%);
  height: var(--mode-free-doodle-height, 91.3%);
  min-height: 0;
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: contain;
}

body[data-view="mode"] #fullTestButton .mode-doodle {
  position: absolute;
  top: var(--mode-full-doodle-top, 11.9%);
  left: var(--mode-full-doodle-left, 3.7%);
  width: var(--mode-full-doodle-width, 57.7%);
  height: var(--mode-full-doodle-height, 87.4%);
  min-height: 0;
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: contain;
}

body[data-view="mode"] .mode-card strong {
  grid-column: 2;
  grid-row: 2;
  font-size: var(--mode-card-title-font, clamp(2.2rem, calc(var(--artboard-width, 390px) * 0.106), 3.9rem));
  line-height: 0.92;
}

body[data-view="mode"] .mode-card em {
  grid-column: 2;
  grid-row: 3;
  font-size: var(--mode-card-count-font, clamp(4.45rem, calc(var(--artboard-width, 390px) * 0.2), 7.4rem));
  line-height: 0.88;
}

body[data-view="mode"] .mode-card span:not(.mode-radio):not(.mode-doodle) {
  grid-column: 2;
  grid-row: 4;
  font-size: var(--mode-card-unit-font, clamp(1.28rem, calc(var(--artboard-width, 390px) * 0.059), 2.15rem));
  line-height: 1;
}

body[data-view="mode"] .mode-card small {
  grid-column: 2;
  grid-row: 5;
  max-width: 12em;
  font-size: var(--mode-card-small-font, clamp(0.72rem, calc(var(--artboard-width, 390px) * 0.0325), 1.08rem));
  line-height: 1.12;
}

body[data-view="mode"] #freeTestButton small {
  margin-top: 0;
}

body[data-view="mode"] #fullTestButton {
  grid-template-rows: 10% auto auto auto auto 1fr;
}

body[data-view="mode"] #fullTestButton strong {
  font-size: var(--mode-full-title-font, clamp(2.05rem, calc(var(--artboard-width, 390px) * 0.0925), 3.55rem));
  line-height: 0.94;
}

body[data-view="mode"] #fullTestButton em {
  font-size: var(--mode-full-count-font, clamp(3.9rem, calc(var(--artboard-width, 390px) * 0.171), 6.2rem));
  line-height: 0.84;
}

body[data-view="mode"] #fullTestButton span:not(.mode-radio):not(.mode-doodle) {
  font-size: var(--mode-full-unit-font, clamp(1.22rem, calc(var(--artboard-width, 390px) * 0.0535), 1.95rem));
  line-height: 0.92;
}

body[data-view="mode"] #fullTestButton small {
  font-size: var(--mode-full-small-font, clamp(0.64rem, calc(var(--artboard-width, 390px) * 0.0285), 0.95rem));
  line-height: 1.25;
}

body[data-view="mode"] #fullTestButton small {
  margin-top: 8px;
}

body[data-view="mode"] .mode-start-action {
  position: absolute;
  top: auto;
  right: auto;
  bottom: var(--mode-cta-bottom, 2%);
  left: 6.21%;
  z-index: 40;
  width: 87.69%;
  height: var(--mode-cta-height, 6.78%);
  min-height: 0;
  font-size: clamp(1.55rem, calc(var(--artboard-width, 390px) * 0.07), 2.5rem);
}

@media (max-width: 340px) {
  body[data-view="mode"] #fullTestButton small {
    margin-top: 2px;
  }
}

body[data-view="quiz"] .answer-button {
  height: calc(var(--artboard-height, 844px) * 0.088);
  min-height: calc(var(--artboard-height, 844px) * 0.088);
  max-height: calc(var(--artboard-height, 844px) * 0.088);
  grid-template-columns: clamp(48px, calc(var(--artboard-width, 390px) * 0.152), 60px) minmax(0, 1fr);
  gap: clamp(10px, calc(var(--artboard-width, 390px) * 0.036), 16px);
  padding: clamp(7px, calc(var(--artboard-width, 390px) * 0.023), 10px) clamp(14px, calc(var(--artboard-width, 390px) * 0.046), 20px);
  border-radius: 20px;
  overflow: hidden;
}

body[data-view="quiz"] .answer-marker {
  width: clamp(42px, calc(var(--artboard-width, 390px) * 0.128), 50px);
  height: clamp(42px, calc(var(--artboard-width, 390px) * 0.128), 50px);
  font-size: clamp(1.25rem, calc(var(--artboard-width, 390px) * 0.062), 1.55rem);
}

body[data-view="quiz"] .answer-copy,
body[data-view="quiz"] .quiz-view[data-question-length="long"] .answer-copy {
  font-size: clamp(0.8rem, calc(var(--artboard-width, 390px) * 0.0398), 0.97rem);
  line-height: 1.08;
}

body[data-view="quiz"] .quiz-actions #quizBackButton {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: none;
  min-height: 0;
  height: 100%;
  font-size: clamp(1rem, 4.8vw, 1.7rem);
}

@supports (-webkit-touch-callout: none) {
  @media (hover: none) and (pointer: coarse) {
    body[data-view="start"] .start-action {
      position: fixed;
      top: auto;
      right: auto;
      bottom: 36px;
      left: calc((100vw - var(--artboard-width, 390px)) / 2 + var(--artboard-width, 390px) * 0.0668);
      z-index: 80;
      display: inline-flex;
      visibility: visible;
      width: calc(var(--artboard-width, 390px) * 0.8675);
      height: 58px;
      opacity: 1;
    }

    body[data-view="mode"] .mode-start-action {
      position: fixed;
      top: auto;
      right: auto;
      bottom: 36px;
      left: calc((100vw - var(--artboard-width, 390px)) / 2 + var(--artboard-width, 390px) * 0.0621);
      z-index: 80;
      display: inline-flex;
      visibility: visible;
      width: calc(var(--artboard-width, 390px) * 0.8769);
      height: 58px;
      opacity: 1;
    }
  }
}
