/* ============ Design tokens ============ */
:root {
  --bg-light: #FAFAF7;
  --bg-dark: #0D0D0D;
  --ink: #171717;
  --ink-soft: #6B6B6B;

  --pink: #EC1E68;
  --yellow: #F4E409;
  --purple: #6C3CE0;
  --blue: #2F5CF6;
  --green: #8CE81C;

  --status-red: #E8412C;
  --status-yellow: #F4C90D;
  --status-green: #33C46B;

  --font-display: 'Archivo Black', sans-serif;
  --font-body: 'Inter', sans-serif;

  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg-light);
  overflow-x: hidden;
}

button { font-family: inherit; }

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============ Screen 1: Situation select ============ */
.screen-select {
  min-height: 100vh;
  background: var(--bg-dark);
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: grid-drift 13s linear infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
}

@keyframes grid-drift {
  from { background-position: 0 0; }
  to { background-position: -400px 0; }
}

.select-inner {
  max-width: 880px;
  width: 100%;
  text-align: center;
}

.eyebrow {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--yellow);
  margin: 0 0 18px;
}

.select-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  line-height: 1.08;
  color: #fff;
  margin: 0 0 20px;
}

.select-subtitle {
  font-size: 1.05rem;
  line-height: 1.55;
  color: #B8B8B8;
  max-width: 520px;
  margin: 0 auto 32px;
}

.difficulty-switcher {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  margin: 0 auto 48px;
}

.difficulty-option {
  border: none;
  background: transparent;
  color: #B8B8B8;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}

.difficulty-option:hover {
  color: #fff;
}

.difficulty-option.active {
  background: var(--yellow);
  color: #171717;
}

.situation-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.situation-card {
  --card-color: #EC1E68;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 16px;
  background: #FAFAF7;
  border: 2px solid var(--card-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease;
}

.situation-card:nth-child(4),
.situation-card:nth-child(5) {
  grid-column: span 1;
}

.situation-icon {
  width: 40px;
  height: 40px;
  color: var(--card-color);
  transition: color 180ms ease;
}

.situation-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--card-color);
  transition: color 180ms ease;
}

.situation-card:hover,
.situation-card:focus-visible {
  background: var(--card-color);
  transform: translateY(-3px);
}

.situation-card:hover .situation-icon,
.situation-card:focus-visible .situation-icon,
.situation-card:hover .situation-name,
.situation-card:focus-visible .situation-name {
  color: #fff;
}

.situation-card:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .situation-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Keep two columns even on narrow phones (rather than collapsing to one
   big column per situation) — just shrink the cards themselves so two
   fit comfortably side by side. */
@media (max-width: 460px) {
  .situation-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .situation-card {
    padding: 20px 10px;
    gap: 8px;
  }
  .situation-icon {
    width: 30px;
    height: 30px;
  }
  .situation-name {
    font-size: 0.9rem;
  }

  /* The difficulty switcher (Basic/Intermediate/Advanced) was overflowing
     past the edge of narrow screens instead of staying centered — shrink
     it to fit instead. */
  .difficulty-switcher {
    max-width: 100%;
  }
  .difficulty-option {
    padding: 7px 10px;
    font-size: 0.72rem;
  }
}

/* ============ Screen 2: Practice ============ */
.screen-practice {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
}

.practice-topbar {
  padding: 24px clamp(20px, 5vw, 64px) 0;
}

.text-btn {
  background: none;
  border: none;
  color: #A0A0A0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0 18px;
}
.text-btn:hover { color: #fff; }

.progress-bar {
  display: flex;
  gap: 6px;
}

.progress-segment {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}

.progress-segment .fill {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 320ms cubic-bezier(.34,1.56,.64,1);
}

.progress-segment.filled .fill {
  transform: scaleX(1);
}

.progress-segment.status-green .fill { background: var(--status-green); }
.progress-segment.status-yellow .fill { background: var(--status-yellow); }
.progress-segment.status-red .fill { background: var(--status-red); }

.practice-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  position: relative;
}

.card-track {
  width: 100%;
  max-width: 620px;
}

/* Glass card that holds the sentence, input, and action buttons */
.sentence-card {
  text-align: center;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 24px;
  padding: 48px clamp(24px, 6vw, 48px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.sentence-card.enter {
  animation: slide-in-right 320ms ease-out both;
}

.sentence-card.exit {
  animation: slide-out-left 300ms ease-in both;
}

@keyframes slide-in-right {
  from { transform: translateX(60px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-out-left {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-60px); opacity: 0; }
}

.question-count {
  font-weight: 600;
  font-size: 0.85rem;
  color: #A0A0A0;
  margin: 0 0 14px;
}

.english-sentence {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.3rem);
  line-height: 1.25;
  color: #fff;
  margin: 0 0 36px;
}

.input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-bottom: 2px solid rgba(255,255,255,0.25);
  transition: border-color 150ms ease;
}
.input-row:focus-within {
  border-bottom-color: var(--yellow);
}

.answer-input {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-body);
  font-size: 1.3rem;
  padding: 10px 4px;
  color: #fff;
}
.answer-input:focus {
  outline: none;
}
.answer-input::placeholder { color: rgba(255,255,255,0.4); }

/* Read-only highlighted answer, shown in place of the input after grading */
.answer-display {
  font-family: var(--font-body);
  font-size: 1.3rem;
  line-height: 1.4;
  padding: 10px 4px;
  border-bottom: 2px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.92);
}
.answer-display.whole {
  border-radius: 10px;
  padding: 10px 14px;
  border-bottom: none;
}
.answer-display.whole.status-green {
  background: rgba(51,196,107,0.18);
  color: var(--status-green);
}
.answer-display.whole.status-yellow {
  background: rgba(244,201,13,0.18);
  color: var(--status-yellow);
}
.answer-display.whole.status-red {
  background: rgba(232,65,44,0.18);
  color: var(--status-red);
}
.answer-display mark {
  background: none;
  padding: 0 3px;
  border-radius: 4px;
}
.answer-display mark.hl-yellow {
  background: rgba(244,201,13,0.22);
  color: var(--status-yellow);
}
.answer-display mark.hl-red {
  background: rgba(232,65,44,0.25);
  color: var(--status-red);
}

.mic-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.mic-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.14);
  color: #D8D6CC;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.mic-btn svg {
  width: 20px;
  height: 20px;
}
.mic-btn:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.6);
  color: #fff;
}
.mic-btn.recording {
  background: var(--status-red);
  border-color: var(--status-red);
  color: #fff;
  animation: mic-pulse 1.1s ease-in-out infinite;
}
.mic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mic-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #9A9A9A;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,65,44,0.45); }
  50% { box-shadow: 0 0 0 8px rgba(232,65,44,0); }
}

.action-row {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.primary-btn {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--purple);
  border: none;
  border-radius: 999px;
  padding: 16px 40px;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease;
}
.primary-btn:hover { transform: translateY(-2px); }
.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.skip-btn {
  background: none;
  border: none;
  color: #A0A0A0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}
.skip-btn:hover { color: var(--status-red); }
.skip-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.feedback {
  margin-top: 28px;
  padding: 18px 22px;
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 0.98rem;
  line-height: 1.5;
  animation: pop-in 220ms ease-out both;
}

@keyframes pop-in {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.feedback-label {
  display: block;
  font-weight: 700;
  margin-bottom: 10px;
}

.feedback-list {
  margin: 0;
  padding-left: 20px;
}

.feedback-list li {
  margin-bottom: 6px;
}

.feedback-list li:last-child {
  margin-bottom: 0;
}

.feedback-subhead {
  font-weight: 700;
  font-size: 0.9rem;
  margin: 16px 0 8px;
  opacity: 0.85;
}

.feedback-alt li {
  font-style: italic;
}

.feedback.status-green {
  background: #EAFBF1;
  color: #1E7B47;
}
.feedback.status-yellow {
  background: #FEF8E4;
  color: #8A6D00;
}
.feedback.status-red {
  background: #FDECE9;
  color: #A6291A;
}

/* ---------- Skeleton loader (shown while fetching sentences) ---------- */
.sentence-skeleton {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 24px;
  padding: 48px clamp(24px, 6vw, 48px);
}

.skeleton-line {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.08) 25%,
    rgba(255,255,255,0.18) 50%,
    rgba(255,255,255,0.08) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  margin: 0 auto 14px;
}
.skeleton-line:last-child { margin-bottom: 0; }

.skeleton-line.count { width: 40%; height: 12px; }
.skeleton-line.title-1 { width: 90%; height: 30px; margin-top: 10px; }
.skeleton-line.title-2 { width: 65%; height: 30px; }
.skeleton-line.input { width: 100%; height: 44px; margin-top: 26px; }
.skeleton-line.button { width: 160px; height: 50px; border-radius: 999px; margin-top: 32px; }

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============ Screen 3: Summary ============ */
.screen-summary {
  min-height: 100vh;
  padding: 48px 24px;
  background: var(--bg-dark);
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
}

.summary-wrap {
  max-width: 960px;
  margin: 0 auto;
}

.summary-header {
  text-align: center;
  margin-bottom: 32px;
  animation: pop-in 400ms ease-out both;
}

.screen-summary .eyebrow { color: var(--yellow); }

.summary-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  color: #fff;
  margin: 0;
}

.summary-body {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 760px) {
  .summary-body {
    grid-template-columns: 1fr;
  }
}

/* --- Review list (left/main column) --- */
.summary-review {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.review-item {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-md);
  overflow: hidden;
  opacity: 0;
  animation: stat-in 420ms ease-out forwards;
}

.review-item-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.review-status-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.review-item.status-green .review-status-dot { background: var(--status-green); }
.review-item.status-yellow .review-status-dot { background: var(--status-yellow); }
.review-item.status-red .review-status-dot { background: var(--status-red); }

.review-texts {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.review-en {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}

.review-pt {
  font-size: 0.88rem;
  color: #A0A0A0;
}

.review-chevron {
  flex-shrink: 0;
  color: #A0A0A0;
  font-size: 0.8rem;
  transition: transform 180ms ease;
}
.review-item.expanded .review-chevron {
  transform: rotate(180deg);
}

.review-detail {
  padding: 0 16px 16px 38px;
  text-align: left;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
  margin-top: 2px;
}

.review-detail .feedback-list {
  font-size: 0.9rem;
  color: #E4E4E4;
}

.review-detail .feedback-subhead {
  color: #fff;
}

/* --- Sidebar (right column: stats + restart) --- */
.summary-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 24px;
}

.stat {
  padding: 20px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.14);
  opacity: 0;
  animation: stat-in 420ms ease-out forwards;
}
.stat-green { background: rgba(51,196,107,0.12); }
.stat-yellow { background: rgba(244,201,13,0.12); }
.stat-red { background: rgba(232,65,44,0.12); }

.stat:nth-child(1) { animation-delay: 80ms; }
.stat:nth-child(2) { animation-delay: 200ms; }
.stat:nth-child(3) { animation-delay: 320ms; }

@keyframes stat-in {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: 2.2rem;
  margin-bottom: 2px;
}
.stat-green .stat-number { color: var(--status-green); }
.stat-yellow .stat-number { color: var(--status-yellow); }
.stat-red .stat-number { color: var(--status-red); }

.stat-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #C0C0C0;
}

.summary-sidebar .primary-btn {
  width: 100%;
  margin-top: 8px;
}
