/* ============================================
   DECISIONS DECISIONS — Styles
   ============================================ */

/* === CUSTOM PROPERTIES === */
:root {
  --color-primary: #6C5CE7;
  --color-primary-light: #A29BFE;
  --color-action: #00B894;
  --color-action-hover: #00A381;
  --color-danger: #E17055;
  --color-bg: #F8F9FA;
  --color-surface: #FFFFFF;
  --color-text: #2D3436;
  --color-text-muted: #636E72;
  --color-border: #DFE6E9;
  --color-chip-bg: #E8E5FF;
  --color-chip-text: #5A4BD4;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

:root[data-theme="dark"] {
  --color-bg: #1A1A2E;
  --color-surface: #16213E;
  --color-text: #E8E8E8;
  --color-text-muted: #A0A0B0;
  --color-border: #2A2A4A;
  --color-chip-bg: #2D2B55;
  --color-chip-text: #A29BFE;
}

/* === RESET & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

/* === SCREEN READER ONLY === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === PAGE WRAPPER === */
.page-wrapper {
  display: flex;
  justify-content: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* === APP CONTAINER === */
.app-container {
  max-width: 600px;
  width: 100%;
  padding: 0.75rem 0;
}

/* === HEADER === */
.app-header {
  position: relative;
  text-align: center;
  padding: 0.75rem 0 0.5rem;
}

.app-header__title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.app-header__tagline {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 0.1rem;
}

/* === THEME TOGGLE === */
.theme-toggle {
  position: absolute;
  top: 0.75rem;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0.4rem;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.theme-toggle:hover {
  color: var(--color-primary);
  border-color: var(--color-primary-light);
}

/* Show sun in dark mode, moon in light mode */
.theme-toggle__icon--sun { display: none; }
.theme-toggle__icon--moon { display: block; }
:root[data-theme="dark"] .theme-toggle__icon--sun { display: block; }
:root[data-theme="dark"] .theme-toggle__icon--moon { display: none; }

/* === APP LAYOUT === */
.app-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

/* === STAGE === */
.stage-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 800px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stage:active {
  transform: scale(0.93);
  opacity: 0.85;
}

/* === TAP HINT === */
.tap-hint {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  text-align: center;
  animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* === MODULE VISIBILITY === */
.module {
  display: flex;
  align-items: center;
  justify-content: center;
}

.module[hidden] {
  display: none;
}

/* === COIN === */
.coin {
  width: 160px;
  height: 160px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.1s;
}

.coin__face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  backface-visibility: hidden;
  text-align: center;
  padding: 1.25rem;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.2;
}

/* When showing text options instead of SVG graphics */
.coin__face--text-mode {
  font-size: 1.4rem;
  font-weight: 700;
}

.coin__graphic {
  width: 55%;
  height: 55%;
  display: block;
}

.coin__label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  margin-top: 2px;
}

.coin__face--front {
  background:
    radial-gradient(circle at 35% 35%, rgba(255,255,255,0.4) 0%, transparent 50%),
    radial-gradient(circle at 65% 65%, rgba(0,0,0,0.15) 0%, transparent 50%),
    linear-gradient(145deg, #FFD700 0%, #DAA520 30%, #B8860B 60%, #DAA520 80%, #FFD700 100%);
  color: #6B4E00;
  border: 5px solid #B8860B;
  box-shadow:
    inset 0 0 0 3px rgba(255, 215, 0, 0.5),
    inset 0 0 15px rgba(0, 0, 0, 0.15),
    inset 0 2px 4px rgba(255, 255, 255, 0.3),
    0 6px 20px rgba(184, 134, 11, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 1px rgba(255, 215, 0, 0.6);
}

/* Metallic sheen overlay */
.coin__face--front::before,
.coin__face--back::before {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

/* Inner ring detail */
.coin__face--front::after,
.coin__face--back::after {
  content: '';
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

.coin__face--back {
  background:
    radial-gradient(circle at 35% 35%, rgba(255,255,255,0.35) 0%, transparent 50%),
    radial-gradient(circle at 65% 65%, rgba(0,0,0,0.15) 0%, transparent 50%),
    linear-gradient(145deg, #D4D4D4 0%, #A9A9A9 30%, #808080 60%, #A9A9A9 80%, #C0C0C0 100%);
  color: #333;
  border: 5px solid #808080;
  box-shadow:
    inset 0 0 0 3px rgba(192, 192, 192, 0.5),
    inset 0 0 15px rgba(0, 0, 0, 0.15),
    inset 0 2px 4px rgba(255, 255, 255, 0.25),
    0 6px 20px rgba(100, 100, 100, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 1px rgba(192, 192, 192, 0.5);
  transform: rotateY(180deg);
}

/* Coin flip animation */
@keyframes coinFlip {
  0% { transform: rotateY(0deg) translateY(0); }
  15% { transform: rotateY(540deg) translateY(-60px); }
  30% { transform: rotateY(1080deg) translateY(-80px); }
  50% { transform: rotateY(1440deg) translateY(-50px); }
  70% { transform: rotateY(1620deg) translateY(-15px); }
  85% { transform: rotateY(1710deg) translateY(0); }
  100% { transform: rotateY(var(--final-rotation)) translateY(0); }
}

.coin--flipping {
  animation: coinFlip 1.2s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

/* === DICE === */
.module--dice {
  /* Fixed dimensions for 3D perspective to work */
  width: 140px;
  height: 140px;
}

.dice {
  width: 100px;
  height: 100px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(30deg);
  transition: transform 0.1s;
}

.dice__face {
  position: absolute;
  width: 100px;
  height: 100px;
  background: var(--color-surface);
  border: 3px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 0.4rem;
  word-break: break-word;
  line-height: 1.2;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

/* Dice face positions */
.dice__face--1 { transform: rotateY(0deg) translateZ(50px); }
.dice__face--2 { transform: rotateY(180deg) translateZ(50px); }
.dice__face--3 { transform: rotateY(90deg) translateZ(50px); }
.dice__face--4 { transform: rotateY(-90deg) translateZ(50px); }
.dice__face--5 { transform: rotateX(90deg) translateZ(50px); }
.dice__face--6 { transform: rotateX(-90deg) translateZ(50px); }

/* Dice face with user text gets highlighted */
.dice__face--option {
  background: var(--color-chip-bg);
  border-color: var(--color-primary-light);
  color: var(--color-primary);
}

/* Decorative dot styling for unused faces */
.dice__face--decorative {
  color: var(--color-text-muted);
  font-size: 2rem;
}

/* Dice roll animation */
@keyframes diceRoll {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  20% { transform: rotateX(400deg) rotateY(200deg) rotateZ(100deg); }
  40% { transform: rotateX(600deg) rotateY(500deg) rotateZ(200deg); }
  60% { transform: rotateX(800deg) rotateY(700deg) rotateZ(300deg); }
  80% { transform: rotateX(900deg) rotateY(850deg) rotateZ(350deg); }
  100% { transform: rotateX(var(--dice-rx)) rotateY(var(--dice-ry)) rotateZ(0deg); }
}

.dice--rolling {
  animation: diceRoll 1.5s cubic-bezier(0.25, 0.8, 0.25, 1.1) forwards;
}

/* === WHEEL === */
.wheel-container {
  position: relative;
  width: 200px;
  height: 200px;
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 20px solid var(--color-primary);
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

#wheel-canvas {
  width: 200px;
  height: 200px;
  display: block;
}

/* === RESULT DISPLAY === */
.result-display {
  margin-top: 0.5rem;
  min-height: 2rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-primary);
}

@keyframes resultReveal {
  0% { opacity: 0; transform: scale(0) rotate(-10deg); }
  50% { transform: scale(1.2) rotate(3deg); }
  70% { transform: scale(0.95) rotate(-1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* Glowing shimmer on result text */
.result-display--show {
  text-shadow:
    0 0 10px rgba(108, 92, 231, 0.4),
    0 0 30px rgba(108, 92, 231, 0.2),
    0 0 60px rgba(108, 92, 231, 0.1);
  animation: resultReveal 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55),
             resultGlow 2s ease-in-out 0.6s infinite alternate;
}

@keyframes resultGlow {
  0% {
    text-shadow:
      0 0 10px rgba(108, 92, 231, 0.4),
      0 0 30px rgba(108, 92, 231, 0.2);
  }
  100% {
    text-shadow:
      0 0 15px rgba(108, 92, 231, 0.6),
      0 0 40px rgba(108, 92, 231, 0.3),
      0 0 80px rgba(108, 92, 231, 0.15);
  }
}

/* === ERROR RESULT === */
.result-display--error {
  color: var(--color-danger);
  animation: resultReveal 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  text-shadow: none;
}

/* === DARK MODE TEXT CONTRAST === */
:root[data-theme="dark"] .app-header__title,
:root[data-theme="dark"] .result-display,
:root[data-theme="dark"] .site-footer__link,
:root[data-theme="dark"] .site-footer__nav a:hover,
:root[data-theme="dark"] .dice__face--option {
  color: #A29BFE;
}

:root[data-theme="dark"] .result-display--show {
  text-shadow:
    0 0 10px rgba(162, 155, 254, 0.5),
    0 0 30px rgba(162, 155, 254, 0.25),
    0 0 60px rgba(162, 155, 254, 0.12);
}

/* === CELEBRATION EFFECTS === */

/* Background flash on result */
.celebrate-flash {
  animation: bgFlash 0.6s ease-out;
}

@keyframes bgFlash {
  0% { background-color: var(--color-bg); }
  15% { background-color: #F0EDFF; }
  40% { background-color: #E8FFE8; }
  100% { background-color: var(--color-bg); }
}

:root[data-theme="dark"] .celebrate-flash {
  animation: bgFlashDark 0.6s ease-out;
}

@keyframes bgFlashDark {
  0% { background-color: var(--color-bg); }
  15% { background-color: #1F1F3A; }
  40% { background-color: #1A2A2A; }
  100% { background-color: var(--color-bg); }
}

/* Stage victory bounce */
.stage--celebrate {
  animation: victoryBounce 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes victoryBounce {
  0% { transform: scale(1); }
  15% { transform: scale(1.08); }
  30% { transform: scale(0.95); }
  45% { transform: scale(1.04); }
  60% { transform: scale(0.98); }
  75% { transform: scale(1.01); }
  100% { transform: scale(1); }
}

/* === OPTIONS PANEL === */
.options-panel {
  width: 100%;
  max-width: 500px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.options-panel__hint {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.options-panel__input-row {
  display: flex;
  gap: 0.5rem;
}

.options-panel__input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
}

.options-panel__input:focus {
  border-color: var(--color-primary);
}

.options-panel__add-btn {
  padding: 0.6rem 1.1rem;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.options-panel__add-btn:hover {
  background: var(--color-primary-light);
}

.options-panel__add-btn:active {
  transform: scale(0.96);
}

.options-panel__add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === OPTION CHIPS === */
.options-panel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
  min-height: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem 0.3rem 0.75rem;
  background: var(--color-chip-bg);
  color: var(--color-chip-text);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  animation: chipIn 0.2s ease;
}

.chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 10px;
  margin: -10px;
  margin-left: -5px;
  box-sizing: content-box;
  border: none;
  background: transparent;
  color: var(--color-chip-text);
  cursor: pointer;
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
  transition: background var(--transition-fast);
}

.chip__remove:hover {
  background: rgba(108, 92, 231, 0.2);
}

.chip__remove:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* === CLEAR ALL === */
.options-panel__clear {
  margin-top: 0.4rem;
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem 0;
  transition: opacity var(--transition-fast);
}

.options-panel__clear:hover {
  opacity: 0.7;
}

.options-panel__clear:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === HOW IT WORKS === */
.how-it-works {
  width: 100%;
  max-width: 500px;
  margin-top: 0.25rem;
}

.how-it-works__summary {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
  padding: 0.4rem;
  list-style: none;
}

.how-it-works__summary::-webkit-details-marker {
  display: none;
}

.how-it-works__summary::after {
  content: " ▸";
  font-size: 0.7rem;
}

.how-it-works[open] .how-it-works__summary::after {
  content: " ▾";
}

.how-it-works__body {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-top: 0.4rem;
  box-shadow: var(--shadow-sm);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-text);
}

.how-it-works__body p {
  margin-bottom: 0.6rem;
}

.how-it-works__body p:last-child {
  margin-bottom: 0;
}

.how-it-works__body ul {
  margin: 0.4rem 0 0.6rem 1.2rem;
}

.how-it-works__body li {
  margin-bottom: 0.3rem;
}

/* === AD SLOTS === */
/* Hidden until AdSense is approved. Remove "display: none" to show ads. */
.ad-slot {
  display: none;
}

/* Ad layout rules (only visible when "display: none" is removed from .ad-slot) */
.ad-slot--bottom {
  min-height: 100px;
  max-width: 728px;
  margin: 1rem auto 0;
}

/* === FOOTER === */
.site-footer {
  margin-top: 2rem;
  padding: 1.5rem 1rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.site-footer__inner {
  max-width: 700px;
  margin: 0 auto;
}

.site-footer__nav {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.site-footer__nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color var(--transition-fast);
}

.site-footer__nav a:hover {
  color: var(--color-primary);
}

/* Dot separators between ecosystem links */
.site-footer__nav a + a::before {
  content: "·";
  margin-right: 0.4rem;
  color: var(--color-text-muted);
  opacity: 0.5;
  pointer-events: none;
}

.site-footer__copy {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  opacity: 0.7;
  margin-top: 0.6rem;
}

.site-footer__link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.site-footer__link:hover {
  text-decoration: underline;
}

/* === CONFETTI CANVAS === */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* === RESPONSIVE: DESKTOP (≥768px) === */
@media (min-width: 768px) {
  .app-header__title {
    font-size: 2.25rem;
  }

  .app-container {
    padding: 1rem 1rem 1rem 0;
  }

  /* Ad slots: both hidden until AdSense approved.
     When ready, remove "display: none" from .ad-slot base rule,
     then these layout rules will take effect. */
  .ad-slot--sidebar {
    width: 300px;
    min-width: 300px;
    min-height: 250px;
    margin-left: 1.5rem;
    align-self: flex-start;
    position: sticky;
    top: 1rem;
    border-radius: var(--radius-md);
  }

  .ad-slot--bottom {
    display: none;
  }

  .coin {
    width: 200px;
    height: 200px;
  }

  .coin__label {
    font-size: 0.75rem;
  }

  .dice {
    width: 120px;
    height: 120px;
  }

  .dice__face {
    width: 120px;
    height: 120px;
    font-size: 1rem;
  }

  .dice__face--1 { transform: rotateY(0deg) translateZ(60px); }
  .dice__face--2 { transform: rotateY(180deg) translateZ(60px); }
  .dice__face--3 { transform: rotateY(90deg) translateZ(60px); }
  .dice__face--4 { transform: rotateY(-90deg) translateZ(60px); }
  .dice__face--5 { transform: rotateX(90deg) translateZ(60px); }
  .dice__face--6 { transform: rotateX(-90deg) translateZ(60px); }

  #wheel-canvas {
    width: 260px;
    height: 260px;
  }

  .wheel-container {
    width: 260px;
    height: 260px;
  }

  .result-display {
    font-size: 1.6rem;
  }
}

/* === RESPONSIVE: SMALL MOBILE (≤380px) === */
@media (max-width: 380px) {
  .app-header {
    padding-right: 2.5rem;
  }

  .app-header__title {
    font-size: 1.4rem;
  }

  .app-header__tagline {
    font-size: 0.8rem;
  }

  .coin {
    width: 140px;
    height: 140px;
  }

  .result-display {
    font-size: 1.15rem;
  }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .module[hidden] {
    transition: none;
  }

  .coin--flipping {
    animation: none !important;
  }

  .dice--rolling {
    animation: none !important;
  }

  .result-display--show {
    animation: none !important;
  }

  .tap-hint {
    animation: none !important;
    opacity: 0.7;
  }
}
