/* ============================================================
   activity-sheets.css — Activity Sheets feature styles
   ============================================================ */

/* ---- Jigsaw generation interstitial ---- */
.jigsaw-gen-card {
  text-align: center;
  min-width: 300px;
  max-width: 420px;
  width: 90%;
}

.jigsaw-gen-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
  animation: jigsawBounce 1s ease-in-out infinite alternate;
}

@keyframes jigsawBounce {
  from { transform: translateY(0) scale(1);    }
  to   { transform: translateY(-6px) scale(1.08); }
}

.jigsaw-gen-card h3 {
  font-family: 'Fraunces', serif;
  color: var(--green-dark);
  font-size: 1.2rem;
  margin: 0 0 6px;
}

.jigsaw-gen-card p {
  color: var(--green-muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
  line-height: 1.5;
}

.jigsaw-gen-progress-wrap {
  height: 10px;
  background: var(--green-pale, #e8f5ee);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}

.jigsaw-gen-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green-mid), #5dba80);
  border-radius: 99px;
  transition: width 0.35s ease-out;
}

.jigsaw-gen-pct {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green-muted);
  text-align: right;
}

/* ---- Output card (result after generation) ---- */
.output-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.output-title {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 16px;
  text-align: center;
}

/* ---- Action buttons (used in output cards & dashboard) ---- */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--green-mid);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn-action:hover { opacity: 0.88; }

.btn-action--secondary {
  background: var(--green-pale);
  color: var(--green-dark);
  border: 1px solid var(--green-border);
}

.btn-action--secondary:hover { background: var(--green-hover); opacity: 1; }

.btn-action-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--green-mid);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn-action-sm:hover { opacity: 0.88; }

.btn-action-sm--secondary {
  background: var(--green-pale);
  color: var(--green-dark);
  border: 1px solid var(--green-border);
}

.btn-action-sm--danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.btn-action-sm--danger:hover { background: #fecaca; opacity: 1; }

/* ---- Type selector cards ---- */
.activity-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.activity-type-card {
  background: white;
  border: 2px solid var(--green-border);
  border-radius: 16px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
  user-select: none;
}

.activity-type-card:hover {
  border-color: var(--green-mid);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.activity-type-card.selected {
  border-color: var(--green-mid);
  background: var(--green-pale);
  box-shadow: 0 4px 16px rgba(30, 102, 68, 0.18);
}

.activity-type-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  display: block;
}

.activity-type-label {
  font-weight: 600;
  font-size: 1rem;
  color: var(--green-dark);
  margin-bottom: 4px;
}

.activity-type-desc {
  font-size: 0.82rem;
  color: var(--green-muted);
  line-height: 1.4;
}

/* ---- Themes grid ---- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.theme-chip {
  background: var(--green-pale);
  border: 2px solid var(--green-border);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--green-dark);
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.theme-chip:hover {
  border-color: var(--green-mid);
  background: var(--green-hover);
}

.theme-chip.selected {
  border-color: var(--green-mid);
  background: var(--green-light);
  font-weight: 600;
}

.theme-chip-icon {
  font-size: 1.4rem;
  display: block;
  margin-bottom: 3px;
}

/* ---- Age style picker ---- */
.age-style-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ---- Coloring page sub-mode toggle (AI vs From Photo) ---- */
.mode-sub-btn {
  padding: 7px 16px;
  border-radius: 99px;
  border: 1.5px solid #c4b5fd;
  background: white;
  color: #6b21a8;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-sub-btn.active {
  background: #a78bfa;
  border-color: #a78bfa;
  color: white;
}

.mode-sub-btn:not(.active):hover {
  background: #f5f3ff;
}

.age-style-btn {
  flex: 1;
  min-width: 120px;
  background: var(--green-pale);
  border: 2px solid var(--green-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--green-dark);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}

.age-style-btn:hover {
  border-color: var(--green-mid);
  background: var(--green-hover);
  color: var(--green-dark);
}

.age-style-btn.selected {
  border-color: var(--green-mid);
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
}

/* ---- Result display ---- */
.result-area {
  margin-top: 24px;
  display: none;
}

.result-area.visible {
  display: block;
}

.result-image-wrap {
  text-align: center;
  margin-bottom: 20px;
}

.result-image-wrap img {
  max-width: 100%;
  max-height: 600px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}

.result-actions .btn-action,
.result-actions .btn-action--secondary,
.result-actions .ref-toggle-btn {
  padding: 6px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
  width: auto;
}

/* ---- Crossword grid ---- */
.crossword-grid-container {
  overflow-x: auto;
  margin: 16px 0;
}

.crossword-grid {
  display: inline-grid;
  gap: 2px;
  background: #999;
  border: 2px solid #999;
  border-radius: 4px;
}

.crossword-cell {
  width: 36px;
  height: 36px;
  background: white;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crossword-cell.black {
  background: #222;
}

.crossword-cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #444;
  line-height: 1;
}

.crossword-cell input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--green-dark);
  caret-color: var(--green-mid);
  outline: none;
  cursor: pointer;
  padding: 0;
}

.crossword-cell.highlighted {
  background: #cce8d4;
}

.crossword-cell.selected {
  background: #87d4a8;
}

.crossword-cell.correct {
  background: #d4edda;
}

.crossword-clues {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 20px;
}

.crossword-clues-section h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.crossword-clue-item {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.88rem;
  color: var(--green-text);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}

.crossword-clue-item:hover {
  background: var(--green-hover);
}

.crossword-clue-item.active {
  background: var(--green-light);
  font-weight: 600;
}

.crossword-clue-num {
  font-weight: 700;
  color: var(--green-mid);
  min-width: 20px;
}

/* ---- Word search grid ---- */

/* Shared container: side-by-side on desktop (create/dashboard), column on narrow */
.word-search-container {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-top: 16px;
}

/* Kids mode / mobile: stack grid above word list */
.word-search-container--stack,
.word-search-container--kids {
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

@media (max-width: 640px) {
  .word-search-container {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }
}

.word-search-grid {
  display: inline-grid;
  gap: 3px;
  flex-shrink: 0;
  max-width: 100%;
}

.ws-cell {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-dark);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
  text-transform: uppercase;
  border: 2px solid transparent;
}

.ws-cell:hover { background: var(--green-hover); }

.ws-cell.selected {
  background: #87d4a8;
  border-color: var(--green-mid);
}

.ws-cell.found {
  background: #d4edda;
  color: var(--green-mid);
  border-color: #a8d5b5;
}

/* Vertical word list (create / dashboard) */
.word-search-words {
  min-width: 160px;
}

.word-search-words h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ws-word-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green-text);
  margin-bottom: 4px;
}

.ws-word-item.found { color: var(--green-muted); opacity: 0.6; }

.ws-word-item.found span {
  text-decoration: line-through;
  text-decoration-color: var(--green-mid);
}

.ws-word-item::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-border);
  flex-shrink: 0;
}

.ws-word-item.found::before { background: var(--green-mid); }

/* Horizontal word chips (kids play mode) */
.ws-words-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 4px 0 8px;
}

.ws-word-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: white;
  border: 2px solid var(--green-border);
  border-radius: 20px;
  padding: 5px 12px 5px 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--green-dark);
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.ws-word-chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-border);
  flex-shrink: 0;
}

.ws-word-chip.found {
  background: var(--green-pale);
  border-color: var(--green-mid);
  opacity: 0.65;
}

.ws-word-chip.found::before { background: var(--green-mid); }

.ws-word-chip.found span {
  text-decoration: line-through;
  text-decoration-color: var(--green-mid);
}

/* Hint button */
.ws-hint-btn {
  background: none;
  border: 1.5px solid #fbbf24;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 1px 5px;
  line-height: 1.4;
  color: #92400e;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.ws-hint-btn:hover { opacity: 1; transform: scale(1.1); }
.ws-hint-btn:disabled { opacity: 0.25; cursor: default; transform: none; }
.ws-word-item.found .ws-hint-btn,
.ws-word-chip.found .ws-hint-btn { display: none; }

/* Hint flash animation */
.ws-cell.hint {
  background: #fef08a !important;
  border-color: #fbbf24 !important;
  animation: wsHintPulse 2s ease-out forwards;
}

@keyframes wsHintPulse {
  0%   { background: #fef08a; transform: scale(1.15); }
  40%  { background: #fef08a; transform: scale(1);    }
  100% { background: white;   transform: scale(1);    }
}

/* ---- Jigsaw puzzle (CSS-based, no canvas) ---- */
.jigsaw-board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  user-select: none;
}

.jigsaw-board {
  position: relative;
  background: var(--green-pale);
  border: 2px solid var(--green-border);
  border-radius: 12px;
  overflow: visible;
  touch-action: none;
}

.jigsaw-slot {
  position: absolute;
  border: 1px dashed var(--green-border);
  background: rgba(200,223,210,0.3);
  border-radius: 2px;
  pointer-events: none;
}

.jigsaw-slot.filled {
  border-color: transparent;
  background: transparent;
}

.jigsaw-piece {
  position: absolute;
  background-repeat: no-repeat;
  cursor: grab;
  border: 2px solid white;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  border-radius: 4px;
  transition: box-shadow 0.1s;
  touch-action: none;
  z-index: 1;
}

.jigsaw-piece:active { cursor: grabbing; box-shadow: 0 8px 24px rgba(0,0,0,0.35); z-index: 10; }

.jigsaw-piece.placed {
  cursor: default;
  box-shadow: none;
  border-color: transparent;
  z-index: 0;
  pointer-events: none;
}

.jigsaw-progress {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--green-muted);
  text-align: center;
}

.jigsaw-complete-banner {
  display: none;
  background: var(--green-light);
  border: 2px solid var(--green-mid);
  border-radius: 12px;
  padding: 16px 24px;
  text-align: center;
  margin-top: 16px;
  font-weight: 600;
  color: var(--green-dark);
  font-size: 1.1rem;
}

/* ---- Dashboard tabs ---- */
.activity-tabs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.activity-tabs-row .activity-tabs {
  flex: 1;
  margin-bottom: 0;
}

.dashboard-create-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--green-primary);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 10px;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
}
.dashboard-create-btn:hover { opacity: 0.88; transform: translateY(-1px); }

.activity-tabs {
  display: flex;
  gap: 4px;
  background: var(--green-pale);
  border-radius: 12px;
  padding: 4px;
  flex-wrap: wrap;
}

.activity-tab {
  flex: 1;
  min-width: 100px;
  padding: 8px 14px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--green-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-align: center;
}

.activity-tab:hover {
  background: var(--green-hover);
  color: var(--green-dark);
}

.activity-tab.active {
  background: white;
  color: var(--green-dark);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ---- Activity sheet cards ---- */
.activity-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.activity-card {
  background: white;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  transition: box-shadow 0.2s, transform 0.1s;
  cursor: pointer;
}

.activity-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.13);
  transform: translateY(-2px);
}

.activity-card-thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--green-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.activity-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.activity-card-body {
  padding: 12px 14px;
}

.activity-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--green-dark);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-card-meta {
  font-size: 0.78rem;
  color: var(--green-muted);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.activity-card-type-badge {
  background: var(--green-pale);
  border: 1px solid var(--green-border);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--green-text);
}

/* ---- Worksheet subtype selector ---- */
.subtype-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.subtype-chip {
  border: 2px solid var(--green-border);
  border-radius: 12px;
  padding: 10px 10px 8px;
  cursor: pointer;
  background: white;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}
.subtype-chip:hover { border-color: var(--green-mid); background: var(--green-hover); }
.subtype-chip.selected { border-color: var(--green-mid); background: var(--green-light); }
.subtype-chip-icon { font-size: 1.6rem; display: block; margin-bottom: 4px; }
.subtype-chip-label { font-size: 0.82rem; font-weight: 700; color: var(--green-dark); }
.subtype-chip-desc { font-size: 0.72rem; color: var(--green-muted); margin-top: 2px; line-height: 1.3; }

.activity-card-child-badge {
  background: #f0f4ff;
  border: 1px solid #c7d4f7;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #3b5bdb;
}

.activity-card-actions {
  display: flex;
  gap: 8px;
  padding: 8px 14px 12px;
  border-top: 1px solid var(--green-border);
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--green-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ---- Print styles ---- */
@media print {
  .header, .result-actions, .activity-tabs, .word-search-words,
  .crossword-clues, nav, button, .setup-card { display: none !important; }

  body { background: white !important; }

  .word-search-container { flex-direction: column; }

  .ws-cell {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }

  .crossword-cell {
    width: 28px;
    height: 28px;
  }

  .crossword-clues {
    display: block;
    margin-top: 24px;
  }

  .crossword-clues-section {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 20px;
  }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .crossword-clues {
    grid-template-columns: 1fr;
  }

  .word-search-container {
    flex-direction: column;
  }

  .activity-type-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .activity-tabs {
    overflow-x: auto;
  }
}
