/* Element Whispers — static styles
   No build, no framework. Custom properties + small set of utilities. */

:root {
  --earth:        #8B7355;
  --water:        #20B2AA;
  --air:          #B0C4DE;
  --fire:         #CD5C5C;
  --ether:        #FFD700;

  --parchment:    #F5F0E6;
  --parchment-soft: #FBF8F1;
  --ink-950:      #0E0C14;
  --ink-900:      #16131F;
  --ink-800:      #1F1B2C;

  --serif: 'Cormorant Garamond', 'Lora', Georgia, serif;
  --sans:  'Inter', system-ui, -apple-system, sans-serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--sans);
  color: var(--parchment);
  background:
    radial-gradient(ellipse at top, rgba(255, 215, 0, 0.06), transparent 55%),
    radial-gradient(ellipse at bottom, rgba(32, 178, 170, 0.05), transparent 55%),
    linear-gradient(180deg, var(--ink-950) 0%, var(--ink-900) 50%, var(--ink-950) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Faint starfield as a body backdrop */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 78% 32%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 34% 72%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 62% 88%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 91% 64%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 22% 52%, rgba(255,255,255,0.3), transparent);
  pointer-events: none;
  opacity: 0.6;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

h1, h2 {
  font-family: var(--serif);
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.01em;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ───── Screen transitions ─────────────────────────────────────────────── */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .55s ease, transform .55s ease;
}
.screen.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* ───── Welcome screen ─────────────────────────────────────────────────── */

.welcome-orbits {
  position: relative;
  width: min(72vmin, 320px);
  height: min(72vmin, 320px);
  margin-bottom: 2.5rem;
}
.welcome-orbits::before,
.welcome-orbits::after {
  content: '';
  position: absolute;
  inset: 1.5rem;
  border: 1px solid rgba(245, 240, 230, 0.10);
  border-radius: 50%;
}
.welcome-orbits::after { inset: 4rem; }

.orb {
  position: absolute;
  font-size: 1.9rem;
  transform: translate(-50%, -50%);
  color: var(--c);
  text-shadow: 0 0 18px var(--c);
  animation: orb-float 6s ease-in-out infinite;
}
/* Five orbiters — top, then clockwise at 72° intervals */
.orb[data-i="0"] { left: 50%;   top: 8%;  animation-delay: 0s; }
.orb[data-i="1"] { left: 90%;   top: 38%; animation-delay: .7s; }
.orb[data-i="2"] { left: 75%;   top: 84%; animation-delay: 1.4s; }
.orb[data-i="3"] { left: 25%;   top: 84%; animation-delay: 2.1s; }
.orb[data-i="4"] { left: 10%;   top: 38%; animation-delay: 2.8s; }

@keyframes orb-float {
  0%, 100% { transform: translate(-50%, -50%) translateY(0); }
  50%      { transform: translate(-50%, -50%) translateY(-6px); }
}

.orb-center {
  position: absolute;
  left: 50%; top: 50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(245, 240, 230, 0.85);
  box-shadow: 0 0 20px rgba(245, 240, 230, 0.8);
  transform: translate(-50%, -50%);
  animation: pulse 5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: .85; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.12); }
}

[data-screen="welcome"] h1 {
  font-size: clamp(2.4rem, 7vw, 4rem);
}
.subtitle {
  margin: .5rem 0 2.5rem;
  font-family: var(--serif);
  font-style: italic;
  color: rgba(245, 240, 230, 0.7);
  font-size: 1.25rem;
}
.footer-elements {
  position: absolute;
  bottom: 1.5rem;
  font-size: .65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(245, 240, 230, 0.4);
}

/* ───── Common typography helpers ──────────────────────────────────────── */

.eyebrow {
  font-size: .68rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(245, 240, 230, 0.45);
  margin: 0 0 .8rem;
}
.eyebrow.gold { color: rgba(255, 215, 0, 0.7); }
.lead {
  font-family: var(--serif);
  font-style: italic;
  color: rgba(245, 240, 230, 0.65);
  font-size: 1.1rem;
  max-width: 36rem;
  margin: 0 0 2rem;
}
.muted-italic {
  font-family: var(--serif);
  font-style: italic;
  font-size: .9rem;
  color: rgba(245, 240, 230, 0.4);
  margin: 0 0 1.5rem;
}
.quoted-italic {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: rgba(245, 240, 230, 0.8);
  margin: .5rem 0 1.5rem;
  max-width: 38rem;
}
.quoted-italic::before { content: '“'; }
.quoted-italic::after  { content: '”'; }

.balance { text-wrap: balance; }

h2.balance, [data-screen="question"] h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  max-width: 30rem;
  margin: 0 0 .7rem;
}

/* ───── Forms ──────────────────────────────────────────────────────────── */

form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
  width: 100%;
  max-width: 36rem;
}
textarea {
  width: 100%;
  background: rgba(22, 19, 31, 0.65);
  border: 1px solid rgba(245, 240, 230, 0.18);
  border-radius: 1.1rem;
  padding: 1.2rem 1.25rem;
  color: var(--parchment);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.5;
  resize: none;
  transition: border-color .4s, box-shadow .4s;
}
textarea::placeholder {
  color: rgba(245, 240, 230, 0.3);
  font-style: italic;
}
textarea:focus {
  outline: none;
  border-color: rgba(255, 215, 0, 0.55);
  box-shadow: 0 0 22px rgba(255, 215, 0, 0.15);
}

/* ───── Buttons ────────────────────────────────────────────────────────── */

.btn-ghost {
  background: transparent;
  color: var(--parchment);
  border: 1px solid rgba(245, 240, 230, 0.3);
  padding: .9rem 2.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: .78rem;
  transition: border-color .4s, color .4s, box-shadow .4s;
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--ether);
  color: var(--ether);
  box-shadow: 0 0 22px rgba(255, 215, 0, 0.25);
}
.btn-ghost:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.btn-ghost.small {
  padding: .55rem 1.5rem;
  font-size: .68rem;
}
.btn-ghost.gold {
  border-color: rgba(255, 215, 0, 0.6);
  color: var(--ether);
}
.btn-ghost.gold:hover {
  background: rgba(255, 215, 0, 0.08);
}

.link-ghost {
  background: transparent;
  border: none;
  color: rgba(245, 240, 230, 0.4);
  font-size: .65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: .25rem;
}
.link-ghost:hover { color: rgba(245, 240, 230, 0.75); }

.reset-link {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  background: transparent;
  border: none;
  color: rgba(245, 240, 230, 0.3);
  font-size: .6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.reset-link:hover { color: rgba(245, 240, 230, 0.7); }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* ───── Board ──────────────────────────────────────────────────────────── */

.board-wrap {
  position: relative;
  width: min(90vw, 480px);
  aspect-ratio: 1;
  margin: 1rem auto 2rem;
}
.board {
  width: 100%;
  height: 100%;
}
.board-center {
  position: absolute;
  inset: 30% 28%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  pointer-events: none;
}
.board-question {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--parchment);
}

.node-circle {
  transition: fill-opacity .5s, filter .5s, r .5s;
}
.node-circle.active {
  fill-opacity: 0.9;
}

/* ───── Dice ───────────────────────────────────────────────────────────── */

.dice-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  margin-top: .5rem;
}
.die {
  width: 110px;
  height: 110px;
  background: var(--parchment-soft);
  border-radius: 1.1rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5), inset 0 -4px 8px rgba(0,0,0,0.1);
  padding: 1rem;
  display: grid;
  place-items: center;
  transition: transform .5s ease;
}
.die.rolling { animation: dice-spin .6s linear infinite; }
@keyframes dice-spin {
  to { transform: rotate(360deg) scale(1.05); }
}
.die .pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  height: 100%;
}
.die .pips span {
  display: block;
  background: var(--ink-950);
  border-radius: 50%;
  align-self: center;
  justify-self: center;
  width: 14px;
  height: 14px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
}

#dice-status {
  font-family: var(--serif);
  font-style: italic;
  color: rgba(245, 240, 230, 0.55);
  min-height: 1.6em;
}
.element-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.element-reveal .name {
  font-family: var(--serif);
  font-size: 2rem;
  color: var(--c);
  text-shadow: 0 0 24px var(--c);
}
.element-reveal .essence {
  color: rgba(245, 240, 230, 0.6);
  font-family: var(--serif);
  font-style: italic;
  font-size: .95rem;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  max-width: 36rem;
  margin-top: .8rem;
}
.choice-row button {
  padding: .55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--c);
  color: var(--c);
  background: transparent;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: .7rem;
  transition: transform .2s, background .3s;
}
.choice-row button:hover { transform: scale(1.05); }

/* ───── Card ───────────────────────────────────────────────────────────── */

.card-stage {
  perspective: 1400px;
  width: min(85vw, 340px);
  aspect-ratio: 5 / 7;
  cursor: pointer;
  margin: 1rem 0 2rem;
}
.card-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(0.001deg);
  transition: transform .9s cubic-bezier(.22, 1, .36, 1);
}
.card-3d.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  border-radius: 1.2rem;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  overflow: hidden;
}
.card-front {
  /* background + shadow set via JS to match drawn card's element */
}
.card-back {
  background: linear-gradient(160deg, #FBF8F1 0%, #F5F0E6 100%);
  color: var(--ink-950);
  transform: rotateY(180deg);
}
.card-face::before {
  /* inner border */
  content: '';
  position: absolute;
  inset: .8rem;
  border: 1px solid currentColor;
  border-radius: 1rem;
  opacity: 0.18;
  pointer-events: none;
}

.card-element-symbol {
  font-size: 5rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.3));
  animation: float 8s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.card-element-name {
  font-family: var(--serif);
  font-size: 1.8rem;
  margin: 0;
  letter-spacing: 0.02em;
}
.card-whisper {
  margin: .75rem 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.85);
  max-width: 80%;
}
.card-prompt-bottom {
  position: absolute;
  bottom: 1.3rem;
  font-size: .58rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}
.card-prompt-bottom.dark { color: rgba(14, 12, 20, 0.4); }

.card-back-symbol {
  font-size: 2rem;
  margin-bottom: .6rem;
}
.card-element-tag {
  font-size: .6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin: 0 0 1.4rem;
}
.card-question {
  font-family: var(--serif);
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  line-height: 1.3;
  color: var(--ink-950);
  margin: 0;
}

/* show different eyebrow based on flip */
[data-screen="card"] .when-flipped { display: none; }
[data-screen="card"].is-flipped .when-flipped { display: inline; }
[data-screen="card"].is-flipped .when-not-flipped { display: none; }
[data-screen="card"] [data-action="begin-reflection"] { display: none; }
[data-screen="card"].is-flipped [data-action="begin-reflection"] {
  display: inline-block;
  animation: fade-in .8s ease-out .4s both;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ───── Timer ──────────────────────────────────────────────────────────── */

.timer-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  margin-bottom: 2rem;
}
.timer-svg {
  width: 100%;
  height: 100%;
}
#timer-progress {
  transition: stroke-dashoffset 1s linear, stroke .4s;
  filter: drop-shadow(0 0 12px currentColor);
}
.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.timer-seconds {
  font-family: var(--serif);
  font-size: 4rem;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.card-question-echo {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: rgba(245, 240, 230, 0.9);
  max-width: 32rem;
  margin: 0 0 .5rem;
}

.duration-picker {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}
.duration-picker button {
  background: transparent;
  border: 1px solid rgba(245, 240, 230, 0.15);
  color: rgba(245, 240, 230, 0.4);
  padding: .35rem .85rem;
  border-radius: 999px;
  font-size: .65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: border-color .3s, color .3s;
}
.duration-picker button.active {
  border-color: rgba(255, 215, 0, 0.7);
  color: var(--ether);
}

/* ───── Share / summary ───────────────────────────────────────────────── */

.element-pill {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--c);
  color: var(--c);
  text-transform: uppercase;
  font-size: .65rem;
  letter-spacing: 0.3em;
  margin: 1rem 0 1.25rem;
}
.element-pill .sym { font-size: 1.1rem; }

.reflection-card {
  background: rgba(22, 19, 31, 0.5);
  border: 1px solid rgba(245, 240, 230, 0.15);
  border-radius: 1.2rem;
  padding: 1.5rem 1.6rem;
  margin: 0 auto 2rem;
  max-width: 36rem;
  text-align: left;
}
.reflection-text {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(245, 240, 230, 0.88);
  white-space: pre-wrap;
  margin: .5rem 0 0;
}

.summary-list {
  width: 100%;
  max-width: 38rem;
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.summary-item {
  position: relative;
  background: rgba(22, 19, 31, 0.45);
  border: 1px solid rgba(245, 240, 230, 0.1);
  border-radius: 1.2rem;
  padding: 1.5rem 1.6rem;
  text-align: left;
  overflow: hidden;
}
.summary-item::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--c);
  box-shadow: 0 0 16px var(--c);
}
.summary-item .row-top {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .8rem;
}
.summary-item .row-top .sym { font-size: 1.4rem; color: var(--c); }
.summary-item .row-top .tag {
  font-size: .6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--c);
}
.summary-item .row-top .turn-num {
  margin-left: auto;
  color: rgba(245, 240, 230, 0.3);
  font-size: .7rem;
}
.summary-item .q {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  margin: 0 0 .75rem;
}
.summary-item .reflection-text {
  font-size: 1rem;
}
