/* =================================================================
   PUZZLE PAGE STYLES
   ----------------------------------------------------------------- 
   The Wordle-style unscramble puzzle. Tile pile at the top, slots 
   below, drag/tap to place, colour-coded feedback after each check.
   ================================================================= */

/* ----- Intro section ----- */
.puzzle-intro {
  background: var(--slate);
  color: var(--parchment);
  padding: var(--space-lg) 0;
  text-align: center;
}

.puzzle-intro__eyebrow {
  display: inline-block;
  font-family: var(--font-typewriter);
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--sandstone-pale);
  margin-bottom: 0.6rem;
  padding: 4px 12px;
  border: 1px solid rgba(232, 212, 192, 0.4);
  border-radius: 2px;
}

.puzzle-intro__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-style: italic;
  color: var(--parchment);
  margin: 0 0 0.8rem;
  font-weight: 500;
}

.puzzle-intro__sub {
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1.5;
  color: rgba(247, 240, 227, 0.85);
  max-width: 580px;
  margin: 0 auto 1rem;
}

.puzzle-intro__credit {
  font-family: var(--font-hand);
  font-size: 1.1rem;
  color: var(--sandstone-pale);
  margin: 1rem 0 0;
}

/* ----- The puzzle itself ----- */
.puzzle {
  padding: var(--space-lg) 0;
  background: var(--parchment);
}

.puzzle__pile-wrap,
.puzzle__slots-wrap {
  margin-bottom: var(--space-md);
}

.puzzle__pile-label,
.puzzle__slots-label {
  font-family: var(--font-typewriter);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sandstone-deep);
  text-align: center;
  margin: 0 0 0.7rem;
}

/* The PILE: where unplaced tiles live */
.puzzle__pile {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem;
  background: var(--parchment-deep);
  border: 2px dashed rgba(184, 83, 42, 0.3);
  border-radius: 6px;
  min-height: 80px;
}

/* The SLOTS: 6 numbered boxes */
.puzzle__slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.4);
  border: 2px solid rgba(184, 83, 42, 0.3);
  border-radius: 6px;
  align-items: stretch;
}

@media (min-width: 700px) {
  .puzzle__slots {
    grid-template-columns: repeat(6, 1fr);
  }
}

.puzzle__slot {
  min-height: 64px;
  background: #fff;
  border: 1.5px dashed rgba(61, 74, 82, 0.3);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
  box-sizing: border-box;
  align-self: stretch;
}

.puzzle__slot::before {
  content: attr(data-slot-num);
  position: absolute;
  top: 4px;
  left: 6px;
  font-family: var(--font-typewriter);
  font-size: 0.65rem;
  color: var(--slate-soft);
  letter-spacing: 0.1em;
}

.puzzle__slot.is-drop-target {
  background: rgba(184, 83, 42, 0.08);
  border-color: var(--sandstone);
}

.puzzle__slot.is-filled {
  border-style: solid;
  border-color: rgba(61, 74, 82, 0.5);
}

.puzzle__slot.is-correct {
  border-color: #5A6B3A;
  background: rgba(90, 107, 58, 0.08);
}

.puzzle__slot.is-incorrect {
  border-color: #B8932B;
  background: rgba(184, 147, 43, 0.08);
}

.puzzle__slot.is-locked {
  /* hint-revealed: looks correct but with a small marker */
  border-color: #5A6B3A;
  background: rgba(90, 107, 58, 0.08);
}

.puzzle__slot.is-locked::after {
  content: 'hint';
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: var(--font-typewriter);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: #5A6B3A;
}

/* TILES — the actual words */
.puzzle__tile {
  background: var(--sandstone);
  color: var(--parchment);
  font-family: var(--font-stencil);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  padding: 0.7rem 1.1rem;
  border-radius: 4px;
  border: none;
  cursor: grab;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.puzzle__tile:hover {
  background: var(--sandstone-deep);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.puzzle__tile:active,
.puzzle__tile.is-dragging {
  cursor: grabbing;
  transform: rotate(-2deg) scale(1.05);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.puzzle__tile.is-selected {
  background: var(--sandstone-deep);
  outline: 3px solid var(--solway);
  outline-offset: 2px;
}

.puzzle__tile.is-placed {
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.5rem 0.7rem;
  width: 100%;
  text-align: center;
}

.puzzle__tile.is-correct {
  background: #5A6B3A;
  cursor: default;
}

.puzzle__tile.is-correct:hover {
  transform: none;
  background: #5A6B3A;
}

.puzzle__tile.is-shake {
  animation: tileShake 0.4s ease-in-out;
}

@keyframes tileShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px) rotate(-1deg); }
  40% { transform: translateX(4px) rotate(1deg); }
  60% { transform: translateX(-4px) rotate(-1deg); }
  80% { transform: translateX(4px) rotate(1deg); }
}

/* ----- Controls ----- */
.puzzle__controls {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

.puzzle__btn {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.8rem 1.6rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.puzzle__btn--check {
  background: var(--solway);
  color: var(--parchment);
}

.puzzle__btn--check:hover:not(:disabled) {
  background: #3D5868;
}

.puzzle__btn--check:disabled {
  background: var(--slate-soft);
  cursor: not-allowed;
  opacity: 0.6;
}

.puzzle__btn--reset {
  background: transparent;
  color: var(--slate);
  border: 1px solid var(--slate-soft);
}

.puzzle__btn--reset:hover {
  background: rgba(61, 74, 82, 0.05);
}

.puzzle__btn--hint {
  background: #B8932B;
  color: #fff;
}

.puzzle__btn--hint:hover {
  background: #9A7A24;
}

/* ----- Feedback ----- */
.puzzle__feedback {
  text-align: center;
  margin: var(--space-md) auto 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--slate);
  min-height: 1.8rem;
  max-width: 480px;
}

.puzzle__feedback.is-positive {
  color: #4A5A30;
}

.puzzle__feedback.is-encouraging {
  color: var(--sandstone-deep);
}

/* ----- Hint area ----- */
.puzzle__hint-wrap {
  text-align: center;
  margin-top: var(--space-md);
}

.puzzle__hint-text {
  margin-top: 0.6rem;
  font-family: var(--font-hand);
  font-size: 1.2rem;
  color: var(--sandstone-deep);
}

/* ----- Success state ----- */
.puzzle__success {
  text-align: center;
  margin-top: var(--space-lg);
  padding: var(--space-lg) var(--space-md);
  background: rgba(90, 107, 58, 0.06);
  border: 2px solid #5A6B3A;
  border-radius: 8px;
  animation: successFadeIn 0.6s ease-out;
}

@keyframes successFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.puzzle__success-stamp {
  display: inline-block;
  margin-bottom: 1rem;
  transform: rotate(-4deg);
  animation: stampLand 0.5s ease-out 0.2s both;
}

@keyframes stampLand {
  0% { opacity: 0; transform: rotate(-4deg) scale(2); }
  60% { opacity: 1; transform: rotate(-4deg) scale(0.9); }
  100% { opacity: 1; transform: rotate(-4deg) scale(1); }
}

.puzzle__success-stamp-inner {
  display: inline-block;
  font-family: var(--font-stencil);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5A6B3A;
  padding: 0.6rem 1.4rem;
  border: 3px double #5A6B3A;
  border-radius: 4px;
}

.puzzle__success-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-style: italic;
  color: var(--slate);
  margin: 0 0 0.6rem;
}

.puzzle__success-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1.55;
  color: var(--slate);
  max-width: 520px;
  margin: 0 auto 1.4rem;
}

.puzzle__success-link {
  display: inline-block;
  background: var(--sandstone);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.9rem 1.8rem;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.puzzle__success-link:hover {
  background: var(--sandstone-deep);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Narrow content wrapper helper (re-use across both pages) */
.wrap--narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}
