/*
  css/josephs-workshop.css
  Scoped to St. Joseph's Workshop game.
  Mobile-first: 375 px primary, 1024 px secondary.
  Warm carpenter palette: cream, wood brown, soft gold.
  No SVG art. No canvas. All visuals are sprite images + CSS transforms.
*/

/* ---------------------------------------------------------------------------
   Variables
--------------------------------------------------------------------------- */
:root {
  --jw-cream: #f9f2e4;
  --jw-parchment: #ede0c4;
  --jw-wood: #7b4f2e;
  --jw-wood-dark: #4e2e10;
  --jw-wood-light: #b88254;
  --jw-gold: #d4a84b;
  --jw-gold-glow: #f1d080;
  --jw-ink: #2a1a0a;
  --jw-ink-soft: #5c3a1e;
  --jw-shadow: 0 8px 32px rgba(42, 26, 10, 0.22);
  --jw-radius: 12px;
  --jw-shelf-gap: 8px;
  --jw-tool-size: 64px;
}

/* ---------------------------------------------------------------------------
   Page shell
--------------------------------------------------------------------------- */
.workshop-page {
  background: linear-gradient(
    180deg,
    #3d2008 0%,
    #7b4f2e 30%,
    var(--jw-cream) 100%
  );
  color: var(--jw-ink);
  min-height: 100dvh;
  margin: 0;
  font-family: "Sentient", "Newsreader", Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------------------
   Header + navigation
--------------------------------------------------------------------------- */
.workshop-header {
  padding: 0 0 24px;
}

.workshop-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(42, 26, 10, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--jw-gold);
  text-decoration: none;
  font-family: "Newsreader", Georgia, serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--jw-gold);
  flex-shrink: 0;
}

.topbar-links {
  display: flex;
  gap: 20px;
}

.topbar-links a {
  color: var(--jw-parchment);
  text-decoration: none;
  font-size: 0.85rem;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.topbar-links a:hover,
.topbar-links a:focus {
  opacity: 1;
  text-decoration: underline;
}

.workshop-hero {
  text-align: center;
  padding: 24px 20px 8px;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  color: var(--jw-gold);
  margin: 0 0 6px;
  font-family:
    "Inter",
    -apple-system,
    sans-serif;
}

h1#page-title {
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(1.8rem, 6vw, 3rem);
  font-weight: 700;
  color: var(--jw-cream);
  margin: 0 0 10px;
  line-height: 1.1;
}

.hero-lede {
  font-size: 1rem;
  color: var(--jw-parchment);
  margin: 0;
  max-width: 36ch;
  margin-inline: auto;
  line-height: 1.5;
  opacity: 0.9;
}

/* ---------------------------------------------------------------------------
   Scene background
--------------------------------------------------------------------------- */
.scene-wrapper {
  position: relative;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: var(--jw-radius) var(--jw-radius) 0 0;
  background: var(--jw-wood-dark);
  min-height: 140px;
}

.scene-bg {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* ---------------------------------------------------------------------------
   Game container
--------------------------------------------------------------------------- */
.game-container {
  position: relative;
  max-width: 700px;
  margin: 0 auto;
  background: var(--jw-parchment);
  border-radius: 0 0 var(--jw-radius) var(--jw-radius);
  box-shadow: var(--jw-shadow);
  padding: 0 0 24px;
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
   Build strip
--------------------------------------------------------------------------- */
.build-strip {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 20px 8px;
  border-bottom: 1px solid var(--jw-parchment);
  background: var(--jw-wood);
  color: var(--jw-cream);
}

.build-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  font-family:
    "Inter",
    -apple-system,
    sans-serif;
  flex-shrink: 0;
}

.build-name {
  font-size: 1rem;
  font-weight: 600;
  font-family: "Newsreader", Georgia, serif;
}

/* ---------------------------------------------------------------------------
   Stage: Joseph + workbench + Jesus
--------------------------------------------------------------------------- */
.stage {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  padding: 20px 20px 12px;
  min-height: 200px;
}

/* Joseph sprite: background-position is set by JS */
.joseph-sprite {
  width: 128px;
  height: 128px;
  background-repeat: no-repeat;
  background-size: 100% 400%;
  flex-shrink: 0;
  transition: background-position 0.12s step-end;
}

/* Workbench */
.workbench {
  flex: 1;
  min-width: 100px;
  max-width: 160px;
  height: 80px;
  background: var(--jw-wood-light);
  border-radius: 4px 4px 0 0;
  border-top: 4px solid var(--jw-wood-dark);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.finished-object {
  position: absolute;
  top: -64px;
  left: 50%;
  transform: translateX(-50%);
  width: var(--jw-tool-size);
  height: var(--jw-tool-size);
  background-repeat: no-repeat;
  background-size: 100% 300%;
  transition: opacity 0.3s;
}

.finished-object.hidden {
  display: none;
}

.finished-object.materialize {
  animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.6);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

/* Jesus sprite */
.jesus-sprite {
  width: 96px;
  height: 96px;
  background-repeat: no-repeat;
  background-size: 100% 300%;
  flex-shrink: 0;
  transition: background-position 0.12s step-end;
}

/* ---------------------------------------------------------------------------
   Narration line
--------------------------------------------------------------------------- */
.narration-line {
  margin: 8px 20px 4px;
  padding: 12px 16px;
  background: var(--jw-cream);
  border-left: 3px solid var(--jw-gold);
  border-radius: 0 var(--jw-radius) var(--jw-radius) 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--jw-ink-soft);
  font-style: italic;
}

.narration-line.hidden {
  display: none;
}

/* ---------------------------------------------------------------------------
   Tool shelf
--------------------------------------------------------------------------- */
.tool-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: var(--jw-shelf-gap);
  justify-content: center;
  padding: 16px 20px;
  background: var(--jw-wood-dark);
  border-top: 3px solid var(--jw-wood);
  min-height: calc(var(--jw-tool-size) + 32px);
}

.tool-slot {
  width: var(--jw-tool-size);
  height: var(--jw-tool-size);
  min-width: 44px; /* WCAG minimum touch target */
  min-height: 44px;
  background-color: var(--jw-wood);
  border: 2px solid var(--jw-wood-light);
  border-radius: 8px;
  background-repeat: no-repeat;
  background-size: 400% 300%;
  cursor: grab;
  touch-action: none;
  position: relative;
  flex-shrink: 0;
  transition:
    box-shadow 0.1s,
    transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

.tool-slot:hover,
.tool-slot:focus {
  box-shadow: 0 0 0 3px var(--jw-gold-glow);
  outline: none;
}

.tool-slot.dragging {
  position: fixed;
  z-index: 999;
  cursor: grabbing;
  box-shadow: 0 8px 24px rgba(42, 26, 10, 0.4);
  transform: scale(1.1);
  pointer-events: none;
}

.tool-slot.bounce-back {
  animation: bounce-back 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

@keyframes bounce-back {
  0% {
    transform: scale(1.1);
  }
  30% {
    transform: scale(0.95) translateY(4px);
  }
  60% {
    transform: scale(1.05) translateY(-2px);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------------------------------------------------------------------------
   Drop zone (invisible, sized to cover Joseph area)
--------------------------------------------------------------------------- */
.drop-zone {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-80px);
  width: 160px;
  height: 180px;
  /* Uncomment for visual debug: border: 2px dashed red; */
  pointer-events: none;
}

/* ---------------------------------------------------------------------------
   Next button
--------------------------------------------------------------------------- */
.next-button {
  display: block;
  margin: 16px auto 0;
  padding: 14px 40px;
  min-height: 48px;
  font-size: 1rem;
  font-family: "Newsreader", Georgia, serif;
  font-weight: 600;
  background: var(--jw-gold);
  color: var(--jw-wood-dark);
  border: none;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(212, 168, 75, 0.4);
  transition:
    background 0.15s,
    transform 0.1s;
}

.next-button:hover,
.next-button:focus {
  background: var(--jw-gold-glow);
  transform: scale(1.03);
  outline: 2px solid var(--jw-wood-dark);
  outline-offset: 2px;
}

.next-button.hidden {
  display: none;
}

/* ---------------------------------------------------------------------------
   Final scene
--------------------------------------------------------------------------- */
.final-scene {
  padding: 24px 20px;
  text-align: center;
}

.final-scene.hidden {
  display: none;
}

.final-heading {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--jw-ink);
  margin: 0 0 16px;
}

.final-objects {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.final-object-img {
  width: 80px;
  height: 80px;
  background-color: var(--jw-cream);
  background-repeat: no-repeat;
  background-size: 100% 300%;
  border-radius: 8px;
  border: 2px solid var(--jw-wood-light);
}

.final-narration {
  font-style: italic;
  font-size: 0.95rem;
  color: var(--jw-ink-soft);
  max-width: 36ch;
  margin: 0 auto 20px;
  line-height: 1.55;
}

.restart-button {
  display: inline-block;
  padding: 12px 32px;
  min-height: 48px;
  font-size: 0.9rem;
  font-family: "Newsreader", Georgia, serif;
  font-weight: 600;
  background: transparent;
  color: var(--jw-wood-dark);
  border: 2px solid var(--jw-wood);
  border-radius: 24px;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.restart-button:hover,
.restart-button:focus {
  background: var(--jw-wood);
  color: var(--jw-cream);
  outline: none;
}

/* ---------------------------------------------------------------------------
   Back link
--------------------------------------------------------------------------- */
.back-link-wrap {
  text-align: center;
  padding: 20px 0 8px;
}

.back-link {
  color: var(--jw-gold);
  font-size: 0.875rem;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.back-link:hover,
.back-link:focus {
  opacity: 1;
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
   More to discover block
--------------------------------------------------------------------------- */
.discover-block {
  max-width: 700px;
  margin: 24px auto 0;
  padding: 20px 20px 28px;
  background: rgba(42, 26, 10, 0.45);
  border-radius: var(--jw-radius);
}

.discover-heading {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--jw-gold);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.discover-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.discover-list a {
  color: var(--jw-parchment);
  font-size: 0.9rem;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.discover-list a:hover,
.discover-list a:focus {
  opacity: 1;
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
   Footer
--------------------------------------------------------------------------- */
.workshop-footer {
  text-align: center;
  padding: 16px 20px;
  color: var(--jw-parchment);
  font-size: 0.78rem;
  opacity: 0.6;
}

/* ---------------------------------------------------------------------------
   Utility
--------------------------------------------------------------------------- */
.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------------------
   1024 px layout adjustments
--------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  .scene-wrapper,
  .game-container,
  .discover-block {
    max-width: 860px;
  }

  .stage {
    gap: 32px;
    min-height: 260px;
  }

  .joseph-sprite {
    width: 160px;
    height: 160px;
  }

  .jesus-sprite {
    width: 120px;
    height: 120px;
  }

  :root {
    --jw-tool-size: 80px;
  }
}
