@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

/* EssentiallyABA Fluency V2 â€” consolidated stylesheet */
:root {
  --purple: #8173e8;
  --purple-dark: #6e5ed7;
  --purple-light: #f2efff;
  --purple-border: #e5defa;
  --ink: #302d45;
  --muted: #817c94;
  --white: #fff;
  --shadow: 0 18px 42px rgba(65, 51, 122, .11);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: #fff;
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 4px;
}
[hidden] { display: none !important; }

/* Layout and branding */
.app {
  min-height: 100vh;
  padding: clamp(20px, 4vh, 42px) 18px 48px;
  background: radial-gradient(ellipse 34% 35% at 50% 55%, rgba(222,214,255,.34), transparent 95%), #fff;
}
.app-header {
  text-align: center;
  margin-bottom: clamp(20px, 3vh, 30px);
}
.brand-logo {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 22px;
  object-fit: contain;
}
.app-header h1 {
  margin: 0 0 7px;
  font-size: clamp(22px, 2.5vw, 29px);
  font-weight: 700;
  letter-spacing: -1px;
}
.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Clickable logo returns to Study Space */
.brand-home-link {
  display: inline-block;
  text-decoration: none;
  border-radius: 8px;
}
.brand-home-link:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 5px;
}

/* Three-mode practice navigation */
.practice-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  max-width: max-content;
  padding: 7px;
  border: 1px solid #e9e2ff;
  border-radius: 999px;
  background: #f7f4ff;
  box-shadow: 0 8px 24px rgba(91, 72, 166, .07);
  margin: 0 auto clamp(22px, 3vh, 34px);
}
.practice-controls button, .practice-controls select {
  min-height: 41px;
  padding: 10px 17px;
  background: #fff;
  border: 1px solid #e8e5f2;
  border-radius: 999px;
  color: #6d6684;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 7px rgba(60,50,105,.035);
  transition: background .18s, border-color .18s;
}
.practice-controls button:hover, .practice-controls select:hover {
  background-color: var(--purple-light);
  border-color: var(--purple-border);
}
.practice-controls select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 35px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238173e8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
#mode-select { min-width: 155px; }
#selection-select {
  min-width: 190px;
  max-width: min(300px, 100%);
  text-overflow: ellipsis;
}

#shuffle-btn {
  background: #ece6ff;
  border-color: #e2d8ff;
  color: #6e5ed7;
  font-weight: 800;
}
#shuffle-btn:hover {
  background: #e4dcff;
  border-color: #d6c9ff;
}

/* Practice stage */
.practice-area {
  width: min(100%, 490px);
  margin-inline: auto;
}
.card-progress {
  margin-bottom: 15px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.card-stage {
  position: relative;
  width: 100%;
  min-height: 0;
  height: clamp(320px, 52vh, 420px);
  perspective: 1200px;
}
.flashcard-frame {
  position: absolute;
  inset: 0;
  padding: 7px;
  border-radius: 29px;
  background: linear-gradient(145deg, #e7e0ff, #f7f5ff 45%, #dcd2ff);
  box-shadow: 0 23px 40px rgba(67,52,125,.12), 0 6px 12px rgba(67,52,125,.05);
}
.flashcard {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 23px;
  background: transparent;
  text-align: center;
  perspective: 1200px;
  -webkit-tap-highlight-color: transparent;
}
.flashcard-inner {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 280ms cubic-bezier(.2,.7,.25,1);
}
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(18px, 3vw, 28px);
  border-radius: 23px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: auto;
}
/* White faces; identify each side with one quiet text label. */
.flashcard-front { background: #fff; }
.flashcard-back {
  transform: rotateY(180deg);
  background: #fff;
}

/* Keep metadata nodes for app.js, but display a single useful cue. */
.card-top {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 18px;
  color: #9185bb;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
}
.card-top > span { display: none; }
.flashcard-front .card-top::before { content: "PROMPT"; }
.flashcard-back .card-top::before {
  content: "ANSWER";
  color: #7060bd;
}
.card-bottom > span:first-child { display: none; }
.card-bottom {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: auto;
}

/* A richer border only after flipping; no purple card fill. */
.flashcard-frame:has(.flashcard.is-flipped) {
  background: linear-gradient(115deg,
    #b7a5fa 0%, #eee9ff 28%, #8974e6 52%,
    #e9e1ff 76%, #b6a0f6 100%);
  background-size: 250% 250%;
  animation: answer-border-shimmer 9s ease-in-out infinite alternate;
  box-shadow:
    0 18px 43px rgba(106, 82, 187, .16),
    0 0 27px rgba(156, 131, 239, .19),
    0 5px 12px rgba(67, 52, 125, .06);
}
@keyframes answer-border-shimmer {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

.card-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 12px 4px;
}
.card-text {
  display: block;
  width: 100%;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.flashcard-front .card-text {
  font-size: clamp(19px, 2.5vw, 26px);
  line-height: 1.5;
  font-weight: 600;
  color: #302d45;
}
.flashcard-back .card-text {
  font-size: clamp(18px, 2.4vw, 24px);
  line-height: 1.5;
  font-weight: 700;
  color: #514182;
}
.flip-hint {
  color: #a197c5;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* Response buttons â€” soft dimension, restrained interaction */
.response-buttons {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}
.response-buttons button {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 800;
  transition: transform 180ms ease, background-color 180ms ease,
              box-shadow 180ms ease, border-color 180ms ease;
}
#got-it-btn {
  background: var(--purple);
  border: 1px solid var(--purple);
  color: #fff;
  box-shadow: 0 5px 13px rgba(110, 94, 215, .17);
}

#got-it-btn:hover {
  background: var(--purple-dark);
  box-shadow: 0 8px 18px rgba(110, 94, 215, .23);
  transform: translateY(-2px);
}
#not-yet-btn {
  background: #f6f3ff;
  border: 1px solid #e2dafa;
  color: #766b9e;
  box-shadow: 0 3px 10px rgba(90, 75, 160, .05);
}

#not-yet-btn:hover {
  background: #eee9ff;
  border-color: #d3c7fb;
  box-shadow: 0 7px 16px rgba(90, 75, 160, .10);
  transform: translateY(-2px);
}
.response-buttons button:active { transform: translateY(0) scale(.98); }
.response-buttons button:disabled {
  cursor: not-allowed;
  opacity: .5;
  box-shadow: none;
  transform: none;
}

/* Results occupy the same position as the card */
.session-results {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: clamp(18px, 4vw, 32px);
  text-align: center;
  background: #fff;
  border: 1px solid var(--purple-border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow: auto;
}
.results-icon {
  display: grid;
  place-items: center;
  width: 49px;
  height: 49px;
  border-radius: 50%;
  background: #f0ebff;
  color: var(--purple);
  font-size: 27px;
}
.session-results h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 26px);
  letter-spacing: -.6px;
}
#session-score {
  margin: 0;
  color: var(--purple-dark);
  font-size: 20px;
  font-weight: 700;
}
.results-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 300px);
  margin-top: 10px;
}
.results-actions button {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--purple-border);
  border-radius: 12px;
  background: var(--purple-light);
  color: var(--purple-dark);
  font-size: 12px;
  font-weight: 700;
}
.results-actions button:hover { background: #e9e3ff; }
#restart-btn { background: #fff; }

/* Smaller screens */
@media (max-width: 600px) {
  .app { padding: 22px 14px 36px; }
  .brand-logo { margin-bottom: 15px; }
  .practice-controls { gap: 7px; max-width: 100%; border-radius: 22px; }
  .practice-controls button, .practice-controls select {
    font-size: 11px;
    padding: 9px 12px;
    min-height: 38px;
  }
  .practice-controls select {
    padding-right: 28px;
    background-position: right 9px center;
  }
  #mode-select, #selection-select {
    min-width: 0;
    max-width: 100%;
  }
  #selection-select { flex: 1 1 150px; }
  .card-stage { height: clamp(300px, 48vh, 400px); }
  .flashcard-frame { padding: 6px; }
  .flashcard-face { padding: 18px; }
  .response-buttons { margin-top: 16px; }
}

/* Compact desktop: keep card and response buttons in view */
@media (min-width: 601px) {
  .app { padding-top: 16px; padding-bottom: 24px; }
  .app-header { margin-bottom: 18px; }
  .brand-logo { width: 170px; margin-bottom: 12px; }
  .app-header h1 { margin-bottom: 4px; font-size: 25px; }
  .practice-controls { margin-bottom: 16px; }
  .card-progress { margin-bottom: 10px; }
  .card-stage { height: clamp(280px, 44vh, 390px); }
  .response-buttons { margin-top: 14px; }
}
@media (min-width: 601px) and (max-height: 750px) {
  .app { padding-top: 10px; }
  .brand-logo { width: 150px; margin-bottom: 8px; }
  .app-header { margin-bottom: 12px; }
  .practice-controls { margin-bottom: 12px; }
  .card-stage { height: clamp(260px, 40vh, 340px); }
}
@media (prefers-reduced-motion: reduce) {
  .flashcard-inner, .response-buttons button { transition: none; }
  .response-buttons button:hover { transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .flashcard-frame:has(.flashcard.is-flipped) { animation: none; }
}