/* Tool: option cards, kit, coin, result. */

/* Kit */
.kit { width: 100%; height: auto; overflow: visible; }
.kit-body { fill: var(--kit-body); }
.kit-sleeve { fill: var(--kit-sleeves); }
.kit-stripes { fill: var(--kit-stripe); }
.kit[data-pattern="solid"] .kit-stripes { display: none; }
.kit-body, .kit-sleeve, .kit-outline {
  stroke: var(--kit-outline);
  stroke-width: 1;
  stroke-linejoin: round;
}
.kit-outline { fill: none; }
.kit-collar, .kit-cuff {
  fill: none;
  stroke: var(--kit-trim);
  stroke-width: 3;
  stroke-linecap: round;
}
.kit--engraved { --kit-outline: var(--shrine-amber); }
.kit--engraved .kit-body,
.kit--engraved .kit-sleeve,
.kit--engraved .kit-outline { stroke-width: 2.5; }

/* Stage: card, coin, card */
.tool-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "a b"
    "coin coin";
  gap: var(--space-4);
  align-items: center;
  margin-top: var(--space-6);
}
.tool-stage > .option { align-self: stretch; } /* both cards share a height */
.tool-stage > .option--a { grid-area: a; }
.tool-stage > .option--b { grid-area: b; }
.tool-stage > .coin-slot { grid-area: coin; justify-self: center; }

@media (min-width: 768px) {
  .tool-stage {
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "a coin b";
    gap: var(--space-6);
  }
}

/* Option card (white in the altar, both themes) */
.option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-5) var(--space-3) var(--space-4);
  background: var(--surface);
  color: var(--text-primary);
  border: 3px solid transparent;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  text-align: center;
  transition: opacity 0.4s ease, border-color 0.3s ease, box-shadow 0.4s ease;
}
.option .kit { max-width: 140px; }
.option-name {
  font-weight: 800;
  font-stretch: 112%;
  font-size: var(--step-1);
  line-height: 1.15;
}
.option-meta { color: var(--text-muted); font-size: var(--step--1); }
.option-tag {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
  font-size: var(--step--1);
}
.option--a .option-tag { background: var(--shrine-option-a); color: var(--shrine-on-accent); }
.option--b .option-tag { background: var(--shrine-option-b); color: var(--shrine-on-accent); }

.option.is-winner {
  border-color: var(--shrine-winner);
  box-shadow:
    0 0 0 4px var(--winner-halo-ring),
    0 0 28px 2px var(--winner-halo-glow);
}
.option.is-loser { opacity: 0.45; }

/* Coin */
.option { z-index: 1; }
.coin-slot { position: relative; z-index: 0; }
.coin-slot:has(.is-tossing) { z-index: 2; } /* the coin rises over the cards on phones */
.coin-stage {
  position: relative;
  width: var(--coin-size);
  height: var(--coin-size);
  perspective: 900px;
}
.coin-glow {
  position: absolute;
  inset: -70%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--altar-glow) 0%, transparent 62%);
  pointer-events: none;
}
.coin-shadow {
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -14%;
  height: 10%;
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--shadow-coin), transparent 70%);
}
.coin-float, .coin-tosser, .coin-spinner { position: absolute; inset: 0; transform-style: preserve-3d; }
.coin-float { animation: coin-float 4s ease-in-out infinite; }
.coin-stage.is-tossing .coin-float { animation-play-state: paused; }

@keyframes coin-float {
  50% { transform: translateY(-6px); }
}

.coin-edge {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--shrine-amber) 0 3deg, var(--coin-gold) 3deg 6deg);
  transform: translateZ(var(--z));
}
.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* milled rim */
  background: repeating-conic-gradient(var(--shrine-amber) 0 2deg, var(--coin-gold) 2deg 4deg);
  transform: translateZ(4px);
}
.coin-face--b { transform: rotateX(180deg) translateZ(4px); }
.coin-face::before {
  /* the metal disc inside the rim */
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--coin-gold-light), var(--coin-gold) 55%, var(--shrine-amber));
  box-shadow:
    inset 0 0 0 1px var(--shrine-amber),
    inset 0 3px 4px color-mix(in srgb, var(--coin-gold-light) 80%, transparent),
    inset 0 -4px 8px color-mix(in srgb, var(--shrine-amber) 70%, transparent);
}
.coin-inscription {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.coin-inscription text {
  fill: var(--shrine-amber);
  font-family: var(--font-engraved);
  font-weight: 700;
  font-size: 13px;
}
.coin-ring { fill: none; stroke: var(--shrine-amber); stroke-width: 1.2; opacity: 0.7; }
.coin-inscription,
.coin-emblem-art,
.coin-emblem .kit {
  /* engraved: a light lip under every cut */
  filter: drop-shadow(0 1px 0 color-mix(in srgb, var(--coin-gold-light) 85%, transparent));
}
.coin-emblem {
  position: absolute;
  inset: 20% 27% 32%; /* sits high to leave room for the A/B letter */
  display: grid;
  place-items: center;
}
.coin-emblem-art { width: 100%; height: 100%; color: var(--shrine-amber); }
.shrine-arch, .shrine-altar {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.shrine-arch--inner { stroke-width: 2.5; opacity: 0.75; }
.shrine-ball { fill: var(--coin-gold-light); stroke: currentColor; stroke-width: 3; }
.shrine-ball-panel { fill: currentColor; }
.coin-fifty {
  fill: currentColor;
  font-family: var(--font-engraved);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: -0.02em;
}
.coin-face.has-option .coin-emblem { inset: 22% 24% 28%; }
.coin-letter {
  position: absolute;
  left: 50%;
  bottom: 17%;
  translate: -50% 0;
  color: var(--shrine-amber);
  font-family: var(--font-engraved);
  font-weight: 800;
  font-size: calc(var(--coin-size) * 0.09);
  line-height: 1;
  text-shadow: 0 1px 0 var(--coin-gold-light);
}

@media (prefers-reduced-motion: reduce) {
  .coin-float { animation: none; }
  .option { transition: none; }
}

/* Flip controls and result */
.tool-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-7);
}
.flip-status { min-height: 1.6em; color: var(--altar-muted); font-style: italic; }
.tool-note { color: var(--altar-muted); font-size: var(--step--1); text-align: center; margin-top: var(--space-5); }

.result {
  margin: var(--space-6) auto 0;
  max-width: 560px;
  text-align: center;
  animation: result-in 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.result[hidden] { display: none; }
.result-label {
  font-family: var(--font-engraved);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--shrine-winner);
  font-size: var(--step--1);
}
.result-headline { font-size: var(--step-3); margin-block: var(--space-2); }
.result-headline:focus { outline: none; }
.result-headline:focus-visible { outline: 3px solid var(--shrine-action); }
.result-sub { color: var(--altar-muted); }
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(12px); }
}
@media (prefers-reduced-motion: reduce) {
  .result { animation-duration: 0.3s; animation-name: fade-in; }
  @keyframes fade-in { from { opacity: 0; } }
}

/* Hero */
.hero { max-width: 760px; }
.hero h1 { margin-top: var(--space-3); }
.hero-intro { margin-top: var(--space-4); color: var(--altar-muted); font-size: var(--step-1); max-width: 60ch; }
/* Mode tabs */
.tool { margin-top: var(--space-6); }
.tabs-label { font-weight: 600; color: var(--altar-muted); font-size: var(--step--1); margin-bottom: var(--space-2); }
.mode-tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--shrine-altar-deep) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--altar-muted) 25%, transparent);
}
.mode-tab {
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--altar-text);
  font-weight: 700;
  white-space: nowrap;
}
.mode-tab[aria-selected="true"] { background: var(--altar-text); color: var(--shrine-altar); }
.mode-tab:disabled { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 599px) {
  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; padding-inline: var(--space-2); font-size: var(--step--1); }
}

.tool-error {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
}

/* Option card contents */
.option { justify-content: flex-start; }
.option-kit { width: 100%; display: grid; place-items: center; }
.option-info { min-height: 3.1em; display: grid; align-content: center; gap: 2px; }
.option-name { overflow-wrap: anywhere; }
.option-meta:empty, .option-name:empty { display: none; }
.kit--empty .kit-body, .kit--empty .kit-sleeve, .kit--empty .kit-outline {
  stroke: var(--border);
  stroke-dasharray: 4 3;
}
.kit--empty .kit-collar, .kit--empty .kit-cuff { stroke-width: 1.5; }

/* Combobox */
.combobox { position: relative; width: 100%; margin-top: var(--space-2); text-align: left; }
.option-label { display: block; font-weight: 700; font-size: var(--step--1); margin-bottom: var(--space-1); }
.combobox-input {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 1rem; /* 16px stops iOS zooming in */
  text-overflow: ellipsis;
}
.combobox-input::placeholder { color: var(--text-muted); }
.combobox-input:focus-visible { outline: 3px solid var(--shrine-altar); outline-offset: 1px; }
.combobox-input:disabled { background: var(--page-background); }
.combobox-list {
  position: absolute;
  z-index: 5;
  /* no top: sits at its static position, straight under the input */
  left: 0;
  width: max(100%, 260px);
  max-height: 320px;
  overflow-y: auto;
  margin: 4px 0 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
}
.option--b .combobox-list { left: auto; right: 0; }
.combobox-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.3;
}
.combobox-option:hover { background: var(--page-background); }
.combobox-option[aria-selected="true"] { background: var(--shrine-altar); color: var(--surface); }
.combobox-name { font-weight: 700; }
.combobox-meta { margin-left: auto; font-size: var(--step--1); color: var(--text-muted); white-space: nowrap; }
.combobox-option[aria-selected="true"] .combobox-meta { color: inherit; }
.flag-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--shrine-amber);
  box-shadow: 0 0 0 2px var(--surface);
}
.field-msg { min-height: 1.4em; margin-top: var(--space-1); font-size: var(--step--2); line-height: 1.35; color: var(--shrine-error); }

/* Swap */
.coin-slot { display: grid; justify-items: center; gap: var(--space-5); }
.swap {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--altar-muted) 50%, transparent);
  background: transparent;
  color: var(--altar-text);
}
.swap:hover { background: color-mix(in srgb, var(--altar-text) 12%, transparent); }
.swap:disabled { opacity: 0.4; cursor: not-allowed; }
.swap svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 767px) {
  .coin-slot { grid-template-columns: 1fr auto 1fr; align-items: center; width: 100%; }
  .coin-slot > #coin { grid-column: 2; }
  .coin-slot > .swap { grid-column: 3; justify-self: start; margin-left: var(--space-4); }
}

/* The call */
.call-choice { border: 0; padding: 0; margin: var(--space-6) auto 0; text-align: center; }
.call-choice legend { margin-inline: auto; font-weight: 600; color: var(--altar-muted); font-size: var(--step--1); margin-bottom: var(--space-2); }
.pills { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--altar-muted) 50%, transparent);
  border-radius: var(--radius-pill);
  font-weight: 600;
  cursor: pointer;
}
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pill:has(input:checked) { background: var(--shrine-option-a); border-color: var(--shrine-option-a); color: var(--shrine-on-accent); }
.pill:has(input:focus-visible) { outline: 3px solid var(--shrine-action); outline-offset: 3px; }
.pill:has(input:disabled) { opacity: 0.6; cursor: not-allowed; }

.tool-actions { margin-top: var(--space-5); }
.flip-help { color: var(--altar-muted); font-size: var(--step--1); }
.result-nudge { margin-top: var(--space-3); font-style: italic; color: var(--altar-text); }

/* Reserve space for parts JS builds after load, so nothing below them jumps */
.coin-slot > #coin { width: var(--coin-size); height: var(--coin-size); }
.option-visual { min-height: 140px; }
.pills { min-height: 40px; }

/* Phones: options, coin and Flip button above the fold. The intro moves below the tool. */
@media (max-width: 599px) {
  .altar { padding-top: var(--space-4); padding-bottom: var(--space-6); }
  .altar > .wrap { display: flex; flex-direction: column; }
  .hero { display: contents; }
  .hero .eyebrow { font-size: var(--step--2); letter-spacing: 0.1em; }
  .hero h1 { font-size: 1.75rem; margin-top: var(--space-1); }
  .hero-intro { order: 2; font-size: var(--step-0); margin-top: var(--space-5); }
  .tool { margin-top: var(--space-4); }
  .tabs-label, .call-choice legend {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .tool-stage { margin-top: var(--space-4); gap: var(--space-3); }
  .option { padding: var(--space-4) var(--space-2) var(--space-2); gap: var(--space-1); }
  .option .kit { max-width: 72px; }
  .option-info { min-height: 0; }
  .option-name { font-size: var(--step-0); }
  .option-label { font-size: var(--step--2); }
  .option-tag { width: 24px; height: 24px; font-size: var(--step--2); }
  .field-msg { min-height: 0; }
  .coin-slot { gap: 0; margin-top: var(--space-2); }
  .call-choice { margin-top: var(--space-4); }
  .pills { gap: var(--space-1); flex-wrap: nowrap; }
  .pill { min-height: 36px; padding: var(--space-1) var(--space-3); font-size: var(--step--1); }
  .tool-actions { margin-top: var(--space-4); gap: var(--space-2); }
}

/* Medallions: chips and transfer options */
.medallion {
  display: grid;
  place-items: center;
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--medallion, var(--shrine-altar));
  color: var(--surface);
}
.medallion svg {
  width: 50%;
  height: 50%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.medallion--outline {
  background: transparent;
  border: 2px solid var(--medallion);
  color: var(--text-muted);
}
.medallion--empty {
  background: var(--page-background);
  border: 2px dashed var(--border);
}
.medallion--sm { width: 34px; height: 34px; }
.medallion--sm svg { width: 64%; height: 64%; }
.medallion--sm.medallion--outline, .medallion--sm.medallion--empty { border-width: 1.5px; }
.option-visual { width: 100%; min-height: 72px; display: grid; place-items: center; }
.option .medallion:not(.medallion--sm) { margin-block: var(--space-4); }

/* Chip picker */
.chip-picker { border: 0; padding: 0; margin: var(--space-2) 0 0; min-width: 0; width: 100%; text-align: left; }
.chip-tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-1); }
.chip-tile {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: var(--space-2) 2px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}
.chip-tile input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip-tile:hover { background: var(--page-background); }
.chip-tile:has(input:checked) { border-color: var(--shrine-altar); background: var(--page-background); }
.chip-tile:has(input:focus-visible) { outline: 3px solid var(--shrine-altar); outline-offset: 1px; }
.chip-tile:has(input:disabled) { opacity: 0.3; cursor: not-allowed; }
.chip-tile:has(input:disabled) input { cursor: not-allowed; }
.chip-short { font-size: var(--step--2); font-weight: 700; color: var(--text-muted); line-height: 1; }
@media (max-width: 599px) {
  .chip-tiles { grid-template-columns: repeat(3, 1fr); }
}

/* Drafts rename */
.option-control { width: 100%; margin-top: var(--space-2); text-align: left; }
.text-input {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 1rem;
}
.text-input::placeholder { color: var(--text-muted); }
.text-input:focus-visible { outline: 3px solid var(--shrine-altar); outline-offset: 1px; }
.option-hint { font-weight: 400; color: var(--text-muted); }

/* Shared verdict and sharing */
.result-shared {
  display: inline-block;
  margin-bottom: var(--space-3);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--shrine-option-a);
  color: var(--shrine-on-accent);
  font-weight: 700;
  font-size: var(--step--1);
}
.share-status { margin-top: var(--space-3); min-height: 1.6em; color: var(--altar-muted); font-size: var(--step--1); overflow-wrap: anywhere; }

@media (max-width: 599px) {
  .option .medallion:not(.medallion--sm) { width: 56px; height: 56px; margin-block: var(--space-2); }
  .option-visual { min-height: 56px; }
  .chip-tile { padding: var(--space-1) 0; }
  .chip-tiles { row-gap: 0; }
  .medallion--sm { width: 30px; height: 30px; }
}

@media (max-width: 599px) {
  .option-visual { min-height: 72px; }
  .pills { min-height: 36px; }
}
