/* ============================================
   Sentence Unscrambler - Te Reo Māori
   Warm clay & off-white palette
   ============================================ */

:root {
  --color-bg: #ffffff;
  --color-surface: #f5f3f0;
  --color-clay: #b85c4a;
  --color-clay-dark: #9a4a3a;
  --color-warm-tan: #e8ddd5;
  --color-warm-sand: #ddd0c4;
  --color-terracotta: #c47050;
  --color-warm-cream: #f2ebe4;
  --color-success: #8b9f7a;
  --color-progress-fill: #9db79f;
  --color-progress-track: #e6efe7;
  --color-error: #c97d7d;
  --color-text: #3d3832;
  --color-text-muted: #6b6560;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --shadow-sm: 0 2px 8px rgba(61, 56, 50, 0.06);
  --shadow-md: 0 4px 16px rgba(61, 56, 50, 0.08);
  --font-heading: 'Roboto Slab', Georgia, serif;
  --font-body: 'Hanken Grotesk', -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  line-height: 1.5;
}

body.is-embedded {
  min-height: auto;
  padding: 1rem;
}

.welcome-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.welcome-overlay.is-hidden {
  display: none;
}

.welcome-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(250, 249, 247, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.welcome-modal {
  position: relative;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.welcome-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-clay);
  margin: 0 0 0.5rem;
}

.welcome-intro {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.6;
}

.welcome-content p {
  font-family: var(--font-body);
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

.btn-start {
  margin-top: 1.5rem;
  width: 100%;
  padding: 0.8rem 1.5rem;
  background: var(--color-clay);
  color: #fff;
}

.praise-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1.5rem 2.25rem;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 1500;
  pointer-events: none;
  animation: praiseFadeIn 0.25s ease;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.praise-popup[hidden] {
  display: none !important;
}

.praise-heading {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-clay);
  margin: 0 0 0.75rem;
}

.praise-sentence {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text);
  margin: 0 0 0.25rem;
}

.praise-meaning {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin: 0;
  font-style: italic;
}

.praise-note {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-clay-dark);
  margin: 0.6rem 0 0;
}

.praise-continue {
  margin: 0.7rem 0 0;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

@keyframes praiseFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.app {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  transition: filter 0.2s ease;
}

body.has-praise-popup .app {
  filter: blur(4px);
}

body.is-embedded .app {
  min-height: auto;
  padding: 1rem;
}

/* Header */
.header {
  text-align: center;
}

.title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-clay);
  margin: 0 0 0.25rem;
}

.subtitle {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* Main */
.main {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

/* Progress */
.progress-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.progress-track {
  width: min(560px, 90%);
  height: 14px;
  border-radius: 999px;
  background: var(--color-progress-track);
  box-shadow: inset 0 0 0 1px rgba(61, 56, 50, 0.08);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--color-progress-fill);
  border-radius: inherit;
  transition: width 0.35s ease;
}

.progress-label {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

/* Tense badge */
.tense-label {
  display: flex;
  justify-content: center;
}

.tense-badge {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-xl);
  background: var(--color-warm-tan);
  color: var(--color-clay-dark);
}

/* Word bank */
.word-bank {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  min-height: 175px;
  display: flex;
  flex-direction: column;
}

.section-hint {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
  margin: 0 0 0.6rem;
}

.word-bank-inner {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 110px;
  align-items: center;
}

.question-box {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--color-warm-cream);
  border: 2px solid var(--color-warm-sand);
  min-height: 110px;
}

.question-box.incorrect {
  animation: shake 0.4s ease;
  border-color: var(--color-error);
  background: #f4dfdf;
}

.question-box.is-complete {
  border-color: var(--color-success);
}

.question-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  align-items: center;
}

.question-token {
  font-family: var(--font-heading);
  font-size: 1.32rem;
  font-weight: 600;
  color: var(--color-text);
}

.gap-input {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 500;
  width: 130px;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-md);
  border: 2px dashed var(--color-text-muted);
  background: #fff;
  color: var(--color-text);
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gap-input:focus {
  outline: none;
  border-color: var(--color-clay);
  box-shadow: 0 0 0 3px rgba(184, 92, 74, 0.15);
}

.word-chip {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  background: var(--color-warm-sand);
  color: var(--color-text);
  cursor: grab;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  touch-action: none;
  border: 2px solid transparent;
}

.word-chip:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.word-chip:active {
  cursor: grabbing;
}

.word-chip.is-selected {
  border-color: var(--color-text-muted);
  box-shadow: 0 0 0 3px rgba(107, 101, 96, 0.2);
}

.word-chip.is-dragging {
  opacity: 0.85;
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.word-chip.placed {
  display: none;
}

/* Slots */
.slots-section {
  display: flex;
  align-items: center;
  justify-content: center;
}

.slots-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: stretch;
}

.slot {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 500;
  min-width: 5rem;
  min-height: 3rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  background: var(--color-warm-cream);
  border: 2px dashed var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  position: relative;
}

.slot[role="listitem"] {
  list-style: none;
}

.slot.drag-over {
  background: var(--color-warm-tan);
  border-color: var(--color-success);
}

.slot.correct {
  background: var(--color-warm-tan);
  border: 2px solid var(--color-success);
  border-style: solid;
}

.slot.incorrect {
  animation: shake 0.4s ease;
  background: var(--color-terracotta);
  border-color: var(--color-error);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.slot-placeholder {
  color: var(--color-text-muted);
  font-weight: 400;
}

.slot-word {
  color: var(--color-text);
}

.slot-gap .slot-placeholder {
  letter-spacing: 0.08em;
}

/* Translation */
.translation {
  text-align: center;
  padding: 0.35rem 0 0;
  margin-top: -1.2rem;
}

.translation-label {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-clay-dark);
  margin: 0 0 0.4rem;
}

.translation-text {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--color-text);
  margin: 0;
  font-style: normal;
}

/* Controls */
.controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.btn-shuffle {
  background: var(--color-warm-tan);
  color: var(--color-clay-dark);
}

.btn-reset {
  background: var(--color-clay-dark);
  color: #fff;
}

.btn-help {
  background: var(--color-warm-sand);
  color: var(--color-text);
}

.btn-check {
  background: var(--color-clay);
  color: #fff;
}

.btn-check-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.btn-close {
  background: var(--color-text);
  color: white;
  margin-top: 1rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 38, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.modal-content p {
  font-family: var(--font-body);
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}

/* Embedded mode */
body.is-embedded .header {
  margin-bottom: 1rem;
}

body.is-embedded .main {
  gap: 1rem;
}

