/**
 * Child Application Styles - Playful & Child-Friendly
 * Target audience: Ages 5-10
 * Design principles: Large touch targets, bright colors, rounded corners, fun fonts
 * Branding: Westwood/PlayTimeRX colors
 */

:root {
  --child-primary: #F47920;      /* Logo orange */
  --child-secondary: #2490cc;    /* Logo blue (dark) */
  --child-success: #4CAF50;      /* Bright green for completion */
  --child-accent: #3AADE8;       /* Logo blue (light) */
  --child-warning: #FFD700;      /* Gold */
  --child-bg: #FFFFFF;           /* White background */
  --child-text: #1e78ab;         /* Logo blue darkened for AA text contrast */
  --child-text-muted: #767676;   /* Was #aaa (2.3:1); now 4.5:1 on white */
  --child-primary-text: #b95b18; /* Orange darkened for text on white */
  --child-white: #FFFFFF;
  --child-aged-brass: #D7D2C4;   /* Neutral brass */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  font-family: 'Baloo 2', 'Comic Sans MS', cursive, sans-serif;
  background: var(--child-bg);
  color: var(--child-text);
  font-size: 18px;
  overflow: hidden;
  /* Mobile optimizations */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
}

/* Scrollable area below the map — isolated from ArcGIS touch handlers */
.child-scroll-content {
  flex: 1;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding-bottom: 70px;
}

/* Headings use playful font */
h1, h2, h3, h4, h5, h6,
.activity-equipment-name,
.activity-title,
.section-title,
.free-play-title,
.category-name,
.brand-child {
  font-family: 'Fredoka One', 'Baloo 2', cursive, sans-serif;
}

/* Progress Header (Sticky) */
.progress-header {
  background: #ffffff;
  padding: 15px 20px;
  color: var(--child-text);
  flex-shrink: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.brand-child {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
  opacity: 0.98;
  text-transform: uppercase;
}

.progress-bar-container {
  width: 100%;
  height: 30px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 100%);
  transition: width 0.5s ease;
  border-radius: 15px;
  width: 0%;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
}

.progress-emoji {
  font-size: 24px;
}

/* Map View */
.child-map {
  width: calc(100% - 30px);
  height: 400px;
  flex-shrink: 0;
  border: 4px solid var(--child-primary);
  border-radius: 12px;
  margin: 15px auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Current Activity Card */
.current-activity-card {
  background: var(--child-white);
  border-radius: 16px;
  padding: 20px;
  margin: 15px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border: 3px solid var(--child-primary);
}

.activity-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 15px;
  color: var(--child-primary);
}

.activity-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Current Activity Photo */
.current-activity-photo {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.activity-equipment-name {
  font-size: 32px;
  font-weight: 800;
  color: var(--child-text);
  margin-bottom: 10px;
}

.activity-description {
  font-size: 20px;
  line-height: 1.6;
  color: var(--child-text);
  margin-bottom: 15px;
}

.activity-actions {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.btn-big {
  padding: 20px 40px;
  font-size: 24px;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #F47920 0%, #2490cc 100%);
  color: var(--child-white);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(244, 121, 32, 0.4);
  transition: all 0.2s ease;
  font-family: 'Baloo 2', cursive, sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-big:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(244, 121, 32, 0.5);
  background: linear-gradient(135deg, #2490cc 0%, #F47920 100%);
}

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

.btn-success {
  background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-success:hover {
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
}

.btn-next {
  width: 100%;
  background: linear-gradient(135deg, #2490cc 0%, #3AADE8 100%);
  box-shadow: 0 4px 12px rgba(36, 144, 204, 0.4);
  margin-top: 10px;
}

.btn-next:hover {
  box-shadow: 0 6px 16px rgba(36, 144, 204, 0.5);
}

.btn-icon {
  font-size: 28px;
}

/* Activities List */
.activities-list {
  padding: 20px 15px;
}

.section-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 15px;
  color: var(--child-text);
}

.activities-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  background: var(--child-white);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.activity-item.completed {
  opacity: 0.7;
  background: #E8F5E9;
}

.activity-item.current {
  border: 3px solid var(--child-primary);
  box-shadow: 0 4px 12px rgba(244, 121, 32, 0.3);
}

/* Activity Thumbnail */
.activity-thumbnail {
  width: 80px;
  height: 80px;
  min-width: 80px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Activity Checkbox */
.activity-checkbox {
  width: 60px;
  height: 60px;
  min-width: 60px;
  border: 4px solid var(--child-primary);
  border-radius: 50%;
  background: var(--child-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  transition: all 0.3s ease;
  user-select: none;
  color: var(--child-aged-brass); /* Grey checkmark by default */
}

.activity-checkbox:hover {
  transform: scale(1.05);
  border-color: var(--child-secondary);
}

.activity-checkbox.completed {
  background: var(--child-success);
  border-color: var(--child-success);
  transform: scale(1.1);
  color: var(--child-white); /* White checkmark when completed */
}

.activity-info {
  flex: 1;
}

.activity-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.activity-status {
  font-size: 16px;
  font-weight: 600;
  opacity: 0.8;
}

.activity-item.completed .activity-name {
  text-decoration: line-through;
  opacity: 0.7;
}

/* Audio Controls */
.audio-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 999;
}

.audio-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid var(--child-primary);
  background: var(--child-white);
  box-shadow: 0 4px 12px rgba(244, 121, 32, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: all 0.2s ease;
}

.audio-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(244, 121, 32, 0.4);
  background: var(--child-primary);
}

.audio-btn:active {
  transform: scale(0.95);
}

.audio-btn.active {
  background: var(--child-success);
  border-color: var(--child-success);
}

.audio-btn.muted {
  background: var(--child-aged-brass);
  border-color: var(--child-aged-brass);
  opacity: 0.6;
}

/* Celebration Overlay */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.celebration-overlay.hidden {
  display: none;
}

.celebration-content {
  text-align: center;
  color: var(--child-white);
  padding: 40px;
  /* The choice buttons make this tall enough to overflow a phone in landscape */
  max-height: 100%;
  overflow-y: auto;
}

.celebration-emoji {
  font-size: 120px;
  animation: pulse 1s ease infinite;
}

.celebration-title {
  font-size: 64px;
  font-weight: 800;
  margin: 20px 0;
  animation: shake 0.5s ease;
}

.celebration-message {
  font-size: 28px;
  font-weight: 600;
}

/* "What next?" choices on the all-tasks-complete screen */
.completion-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  margin: 28px auto 0;
}

.completion-choices.hidden {
  display: none;
}

.btn-completion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  border: none;
  border-radius: 14px;
  background: var(--btn-color, var(--child-primary));
  color: var(--child-white);
  font-size: 20px;
  font-weight: 800;
  font-family: 'Baloo 2', cursive, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-completion:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.btn-completion:active {
  transform: scale(0.97);
}

.btn-completion.hidden {
  display: none;
}

.btn-completion--again { --btn-color: var(--child-primary); }
.btn-completion--free  { --btn-color: var(--child-accent); }
.btn-completion--done  { --btn-color: var(--child-success); }

.btn-completion-icon {
  font-size: 24px;
}

/* Skipped prescribed steps — visibly set aside, not failed */
.activity-item.skipped {
  opacity: 0.65;
}

.activity-item.skipped .activity-name {
  text-decoration: line-through;
  text-decoration-color: rgba(0, 0, 0, 0.3);
}

.activity-checkbox.skipped {
  background: #9e9e9e;
  border-color: #9e9e9e;
  color: var(--child-white);
}

/* Bonus play — activities the child added themselves */
.bonus-item {
  position: relative;
}

.bonus-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  color: var(--child-text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bonus-remove:hover {
  background: rgba(0, 0, 0, 0.22);
}

#bonusSection.hidden {
  display: none;
}

.btn-add-activity {
  display: block;
  width: calc(100% - 30px);
  margin: 0 15px 20px;
  padding: 16px;
  border: 3px dashed var(--child-accent);
  border-radius: 16px;
  background: transparent;
  color: var(--child-secondary);
  font-size: 19px;
  font-weight: 800;
  font-family: 'Baloo 2', cursive, sans-serif;
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-add-activity:hover {
  background: rgba(58, 173, 232, 0.1);
}

.btn-skip-activity {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #f0f0f0;
  color: #6b7b85;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Baloo 2', cursive, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-skip-activity:hover {
  background: #e4e4e4;
}

/* Shared child-facing modal shell (skip reason, add activity) */
.child-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  padding: 16px;
}

.child-modal.hidden {
  display: none;
}

.child-modal-content {
  background: var(--child-white);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.child-modal-content--wide {
  max-width: 640px;
}

.child-modal-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--child-primary);
  margin-bottom: 6px;
}

.child-modal-subtitle {
  font-size: 17px;
  font-weight: 600;
  color: var(--child-text);
  margin-bottom: 18px;
}

.child-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.skip-reason-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-skip-reason {
  padding: 16px 12px;
  border: none;
  border-radius: 12px;
  background: var(--child-accent);
  color: var(--child-white);
  font-size: 16px;
  font-weight: 700;
  font-family: 'Baloo 2', cursive, sans-serif;
  cursor: pointer;
  transition: transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-skip-reason:active {
  transform: scale(0.97);
}

.add-activity-search {
  width: 100%;
  padding: 12px;
  margin-bottom: 14px;
  border: 2px solid var(--child-aged-brass);
  border-radius: 10px;
  font-size: 16px;
  font-family: 'Baloo 2', cursive, sans-serif;
  color: var(--child-text);
}

.add-activity-search:focus {
  outline: none;
  border-color: var(--child-accent);
}

.add-activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  max-height: 46vh;
  overflow-y: auto;
}

.add-activity-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #f7f7f7;
  cursor: pointer;
  font-family: 'Baloo 2', cursive, sans-serif;
  transition: border-color 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.add-activity-tile:hover:not(:disabled) {
  border-color: var(--child-accent);
}

.add-activity-tile:active:not(:disabled) {
  transform: scale(0.97);
}

.add-activity-tile.added {
  opacity: 0.55;
  cursor: default;
}

.add-activity-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
}

.add-activity-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--child-text);
  text-align: center;
}

@media (max-width: 480px) {
  .add-activity-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .skip-reason-options {
    grid-template-columns: 1fr;
  }
}

/* Send-to-therapist panel (opened from "All Done") */
.ot-report-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.ot-report-panel.hidden {
  display: none;
}

.ot-report-content {
  background: var(--child-white);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.ot-report-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--child-primary);
  margin-bottom: 6px;
}

.ot-report-summary {
  font-size: 16px;
  font-weight: 600;
  color: var(--child-text);
  margin-bottom: 18px;
}

.ot-report-label {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--child-text);
  margin-bottom: 6px;
}

.ot-report-input {
  width: 100%;
  padding: 12px;
  margin-bottom: 14px;
  border: 2px solid var(--child-aged-brass);
  border-radius: 10px;
  font-size: 16px;
  font-family: 'Baloo 2', cursive, sans-serif;
  color: var(--child-text);
  background: var(--child-white);
}

.ot-report-input:focus {
  outline: none;
  border-color: var(--child-accent);
}

.ot-report-error {
  font-size: 15px;
  font-weight: 700;
  color: #c62828;
  margin-bottom: 12px;
}

.ot-report-error.hidden {
  display: none;
}

.ot-report-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-report-secondary {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: #f0f0f0;
  color: var(--child-text);
  font-size: 16px;
  font-weight: 700;
  font-family: 'Baloo 2', cursive, sans-serif;
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-report-secondary:hover {
  background: #e0e0e0;
}

.ot-report-privacy {
  margin-top: 16px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7b85;
  text-align: center;
}

/* While the choices are up, the artwork gives way to the buttons — otherwise
   the third one falls below the fold on a phone. */
.celebration-overlay.choosing .celebration-content {
  padding: 20px;
}

.celebration-overlay.choosing .celebration-emoji {
  display: none;
}

.celebration-overlay.choosing .celebration-video {
  max-width: 200px;
  margin-bottom: 8px;
}

.celebration-overlay.choosing .celebration-title {
  font-size: 40px;
  margin: 8px 0 4px;
}

.celebration-overlay.choosing .celebration-message {
  font-size: 20px;
}

.celebration-overlay.choosing .completion-choices {
  margin-top: 18px;
}

/* Error Message */
.error-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--child-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.error-message.hidden {
  display: none;
}

.error-content {
  text-align: center;
  max-width: 500px;
}

.error-icon {
  font-size: 100px;
  margin-bottom: 20px;
}

.error-title {
  font-size: 48px;
  font-weight: 800;
  color: var(--child-primary);
  margin-bottom: 15px;
}

.error-text {
  font-size: 24px;
  line-height: 1.5;
  color: var(--child-text);
}

/* Loading State */
.loading-text,
.empty-state {
  font-size: 20px;
  text-align: center;
  padding: 40px 20px;
  color: var(--child-text);
  opacity: 0.7;
}

/* Responsive Design - Mobile First */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .child-map {
    height: 320px;
    margin: 10px auto;
    width: calc(100% - 20px);
  }

  .progress-header {
    padding: 12px 15px;
  }

  .progress-bar-container {
    height: 25px;
  }

  .progress-text {
    font-size: 16px;
  }

  .activity-title {
    font-size: 24px;
  }

  .activity-equipment-name {
    font-size: 26px;
  }

  .activity-description {
    font-size: 18px;
  }

  .btn-big {
    padding: 18px 30px;
    font-size: 20px;
    min-height: 60px;
  }

  .current-activity-photo {
    height: 180px;
  }

  .activity-thumbnail {
    width: 70px;
    height: 70px;
    min-width: 70px;
  }

  .activity-name {
    font-size: 20px;
  }

  .activity-checkbox {
    width: 55px;
    height: 55px;
    min-width: 55px;
    font-size: 32px;
  }

  .activity-item {
    padding: 12px;
  }

  .current-activity-card {
    margin: 10px;
    padding: 15px;
  }

  .activities-list {
    padding: 15px 10px;
  }

  .section-title {
    font-size: 24px;
  }

  .celebration-title {
    font-size: 48px;
  }

  .celebration-emoji {
    font-size: 100px;
  }

  .audio-controls {
    bottom: 15px;
    right: 15px;
  }

  .audio-btn {
    width: 55px;
    height: 55px;
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .child-map {
    height: 260px;
  }

  .progress-header {
    padding: 10px 12px;
  }

  .progress-text {
    font-size: 14px;
  }

  .brand-child {
    font-size: 14px;
    margin-bottom: 6px;
  }

  .activity-title {
    font-size: 20px;
  }

  .activity-equipment-name {
    font-size: 22px;
  }

  .activity-description {
    font-size: 16px;
    line-height: 1.5;
  }

  .activity-actions {
    flex-direction: column;
  }

  .btn-big {
    width: 100%;
    justify-content: center;
    padding: 16px 24px;
    font-size: 18px;
    min-height: 56px;
  }

  .current-activity-photo {
    height: 150px;
  }

  .activity-thumbnail {
    width: 60px;
    height: 60px;
    min-width: 60px;
  }

  .activity-name {
    font-size: 18px;
  }

  .activity-status {
    font-size: 14px;
  }

  .activity-checkbox {
    width: 50px;
    height: 50px;
    min-width: 50px;
    font-size: 28px;
  }

  .activity-item {
    padding: 10px;
  }

  .current-activity-card {
    margin: 8px;
    padding: 12px;
  }

  .activities-list {
    padding: 12px 8px;
  }

  .section-title {
    font-size: 22px;
  }

  .celebration-title {
    font-size: 36px;
  }

  .celebration-message {
    font-size: 20px;
  }

  .celebration-emoji {
    font-size: 80px;
  }

  .completion-choices {
    margin-top: 20px;
    gap: 10px;
  }

  .btn-completion {
    padding: 14px 20px;
    font-size: 18px;
  }

  .audio-controls {
    bottom: 10px;
    right: 10px;
  }

  .audio-btn {
    width: 50px;
    height: 50px;
    font-size: 22px;
  }

  .error-icon {
    font-size: 80px;
  }

  .error-title {
    font-size: 36px;
  }

  .error-text {
    font-size: 18px;
  }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .child-map {
    height: 220px;
  }

  .progress-header {
    padding: 8px 12px;
  }

  .current-activity-card {
    margin: 8px;
    padding: 12px;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets for touch devices */
  .activity-checkbox {
    min-width: 60px;
    min-height: 60px;
  }

  .btn-big {
    min-height: 60px;
  }

  .audio-btn {
    min-width: 55px;
    min-height: 55px;
  }

  /* Prevent text selection on touch */
  .activity-checkbox,
  .btn-big,
  .audio-btn {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    user-select: none;
    -webkit-user-select: none;
  }
}

/* Safe area padding for notched devices (iPhone X, etc.) */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .audio-controls {
    bottom: calc(10px + env(safe-area-inset-bottom));
    right: calc(10px + env(safe-area-inset-right));
  }
}

/* iOS specific optimizations */
@supports (-webkit-touch-callout: none) {
  body {
    /* Prevent iOS rubber band scrolling */
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  html {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Enable momentum scrolling for containers */
  .activities-list,
  .activity-content {
    -webkit-overflow-scrolling: touch;
  }
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Disable pull-to-refresh on Chrome mobile */
body {
  overscroll-behavior-y: contain;
}

/* ============================================
   Character Images & Mascots
   ============================================ */

/* Brand logo in child header */
.brand-child {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-child .brand-logo-wrap {
  background: white;
  padding: 8px 12px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-child .brand-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* Cheerleader row between map and activity card */
.character-row {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 0 30px;
  margin: -8px 0 -8px;
}

.character-row-img {
  width: 95px;
  height: 95px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
}

/* Inline character in card/section titles */
.title-character,
.section-character {
  width: 50px;
  height: 50px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 6px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

/* Celebration overlay character (replaces 🎉 emoji) */
.celebration-character {
  width: 200px;
  height: 200px;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.3));
}

/* Error state character (replaces 😕 emoji) */
.error-character {
  width: 160px;
  height: 160px;
  object-fit: contain;
}

/* Celebration overlay video */
.celebration-video {
  width: 100%;
  max-width: 380px;
  border-radius: 16px;
  margin-bottom: 15px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

/* Welcome video modal */
.video-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  animation: fadeIn 0.3s ease;
  cursor: pointer;
}

.video-modal.hidden {
  display: none;
}

.video-modal-content {
  width: 100%;
  max-width: 640px;
  padding: 0 20px;
  text-align: center;
}

.modal-video {
  width: 100%;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  display: block;
}

.video-tap-hint {
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px;
  margin-top: 12px;
  font-family: 'Baloo 2', cursive, sans-serif;
}

/* Image Lightbox - mobile optimised */
.child-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 25000;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Safe areas for notched phones */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.child-lightbox.hidden {
  display: none;
}

.child-lightbox-img-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 70px 16px 24px;
}

.child-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  display: block;
}

/* Large tap target for close — min 48×48 per mobile guidelines */
.child-lightbox-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  min-width: 56px;
  min-height: 56px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-radius: 50%;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  /* Prevent accidental zoom on double-tap */
  touch-action: manipulation;
}

.child-lightbox-close:active {
  background: rgba(255, 255, 255, 0.4);
}

/* Tap-to-expand hint on the activity photo */
.current-activity-photo-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.current-activity-photo-wrap .tap-hint {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Scale down characters on tablet */
@media (max-width: 768px) {
  .brand-mascot {
    width: 30px;
    height: 30px;
  }

  .character-row-img {
    width: 75px;
    height: 75px;
  }

  .title-character,
  .section-character {
    width: 40px;
    height: 40px;
  }

  .celebration-character {
    width: 160px;
    height: 160px;
  }

  .error-character {
    width: 130px;
    height: 130px;
  }
}

/* Scale down characters on phone */
@media (max-width: 480px) {
  .brand-mascot {
    width: 24px;
    height: 24px;
  }

  .character-row-img {
    width: 60px;
    height: 60px;
  }

  .title-character,
  .section-character {
    width: 32px;
    height: 32px;
  }

  .celebration-character {
    width: 130px;
    height: 130px;
  }

  .error-character {
    width: 110px;
    height: 110px;
  }
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Free Play Mode */
.free-play-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: var(--child-bg);
  overflow-y: auto;
  z-index: 2000;
  padding: 20px;
}

.free-play-header {
  text-align: center;
  padding: 20px 20px 30px;
  background: #ffffff;
  border-radius: 16px;
  margin-bottom: 30px;
}

.free-play-logo {
  height: 90px;
  width: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px;
}

.free-play-title {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 10px;
  /* Brand orange at 2.8:1 on white failed AA; the darker text variant keeps
     the same hue at 4.6:1 (#20957). */
  color: var(--child-primary-text);
}

.free-play-subtitle {
  font-size: 20px;
  font-weight: 600;
  color: var(--child-secondary);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.category-card {
  background: var(--child-white);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.category-photo {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.category-info {
  padding: 20px;
  flex: 1;
}

.category-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--child-text);
  margin-bottom: 8px;
}

.category-count {
  font-size: 16px;
  color: var(--child-text);
  opacity: 0.7;
  font-weight: 600;
}

.btn-category {
  width: 100%;
  padding: 18px;
  border: none;
  background: linear-gradient(135deg, #F47920 0%, #2490cc 100%);
  color: var(--child-white);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Baloo 2', cursive, sans-serif;
}

.btn-category:hover {
  background: linear-gradient(135deg, #2490cc 0%, #F47920 100%);
  transform: translateY(-2px);
}

.btn-category:active {
  transform: scale(0.98);
}

/* Preset Prescription Selection */
.age-section {
  max-width: 1200px;
  margin: 0 auto 30px;
}

.age-section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-radius: 14px 14px 0 0;
  color: #fff;
}

.age-section-emoji {
  font-size: 40px;
  line-height: 1;
}

.age-section-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.6);
  flex-shrink: 0;
}

.age-section-name {
  font-size: 24px;
  font-weight: 800;
  font-family: 'Baloo 2', cursive;
}

.age-section-range {
  font-size: 15px;
  font-weight: 600;
  opacity: 0.9;
}

.prescription-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  background: #f4f6f8;
  border-radius: 0 0 14px 14px;
  padding: 20px;
}

.prescription-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px 0 20px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.prescription-emoji {
  font-size: 44px;
  line-height: 1;
}

.prescription-img {
  width: calc(100% - 24px);
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.prescription-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--child-text);
  line-height: 1.3;
  flex: 1;
  padding: 0 16px;
}

.prescription-count {
  font-size: 14px;
  color: #888;
  font-weight: 600;
}

.btn-prescription {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--btn-color, #F47920);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Baloo 2', cursive, sans-serif;
  margin-top: auto;
}

.btn-prescription:hover {
  filter: brightness(0.88);
  transform: translateY(-2px);
}

.btn-prescription:active {
  transform: scale(0.97);
}

/* Free Play Responsive */
@media (max-width: 768px) {
  .free-play-container {
    padding: 15px;
  }

  .free-play-title {
    font-size: 28px;
  }

  .free-play-subtitle {
    font-size: 18px;
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .prescription-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .age-section-name {
    font-size: 20px;
  }

  .category-photo {
    height: 180px;
  }

  .category-name {
    font-size: 22px;
  }

  .btn-category {
    padding: 16px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .free-play-header {
    padding: 15px 15px 25px;
    margin-bottom: 20px;
  }

  .free-play-title {
    font-size: 24px;
  }

  .free-play-subtitle {
    font-size: 16px;
  }

  .category-photo {
    height: 150px;
  }

  .category-info {
    padding: 15px;
  }

  .category-name {
    font-size: 20px;
  }

  .category-count {
    font-size: 14px;
  }
}

/* Basemap Switcher Styling for Child App */
.esri-expand {
  background-color: var(--child-white);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 2px solid var(--child-primary);
}

.esri-expand__icon {
  color: var(--child-primary);
  font-size: 22px;
}

.esri-basemap-gallery {
  border-radius: 8px;
}

.esri-basemap-gallery__item {
  border-radius: 8px;
  overflow: hidden;
  border-width: 3px;
}

.esri-basemap-gallery__item-title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 14px;
}

.esri-basemap-gallery__item--selected {
  border-color: var(--child-primary);
  box-shadow: 0 0 0 3px var(--child-primary);
}

/* Responsive basemap gallery for child app */
@media (max-width: 768px) {
  .esri-expand {
    width: auto;
  }

  .esri-basemap-gallery {
    max-width: 85vw;
  }

  .esri-basemap-gallery__item {
    min-width: 100px;
  }
}

@media (max-width: 480px) {
  .esri-expand__icon {
    font-size: 18px;
  }

  .esri-basemap-gallery {
    max-width: 90vw;
  }

  .esri-basemap-gallery__item {
    min-width: 90px;
  }

  .esri-basemap-gallery__item-title {
    font-size: 12px;
  }
}

.app-footer {
  text-align: center;
  font-size: 11px;
  color: var(--child-text-muted);
  padding: 8px 16px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.9);
  z-index: 100;
}

.free-play-footer {
  text-align: center;
  font-size: 11px;
  color: var(--child-text-muted);
  padding: 16px;
  margin-top: 24px;
}

/* Prominent park name on park free-play screens */
.free-play-park-name {
  font-family: 'Fredoka One', 'Baloo 2', cursive, sans-serif;
  font-size: clamp(26px, 7vw, 40px);
  font-weight: 700;
  color: #F47920;
  text-align: center;
  line-height: 1.15;
  margin: 6px 0 2px;
}

/* Park picker (bare child.html) + QR prompt */
.park-qr-hint {
  font-family: 'Baloo 2', cursive, sans-serif;
  font-size: 18px;
  color: var(--child-text);
  text-align: center;
  margin-top: 12px;
}

.park-picker {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
  margin: 8px auto 0;
  padding: 0 20px 20px;
}

.park-picker-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'Baloo 2', cursive, sans-serif;
  font-size: 18px;
  color: #333;
}

.park-picker-field select {
  padding: 12px 14px;
  font-size: 18px;
  border: 2px solid #F47920;
  border-radius: 12px;
  background: #fff;
}

/* "Wrong park? Choose another" escape hatch on park free-play screens */
.switch-park-wrap {
  text-align: center;
  padding: 4px 20px 12px;
}

.btn-switch-park {
  display: inline-block;
  font-family: 'Baloo 2', cursive, sans-serif;
  font-size: 16px;
  color: var(--child-text);
  text-decoration: none;
  background: #fff;
  border: 2px solid var(--child-text);
  border-radius: 12px;
  padding: 10px 18px;
}

.btn-switch-park:hover {
  background: var(--child-text);
  color: #fff;
}

/* Age group picker — step 1 */
.age-group-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 0 20px 20px;
}

@media (max-width: 400px) {
  .age-group-picker {
    grid-template-columns: 1fr;
  }
}

.btn-age-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 16px;
  border: none;
  border-radius: 20px;
  background: var(--section-color, #F47920);
  color: #fff;
  cursor: pointer;
  font-family: 'Baloo 2', cursive, sans-serif;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-age-group:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.btn-age-group:active {
  transform: scale(0.97);
}

.age-group-img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
}

.age-group-name {
  font-size: 22px;
  font-weight: 800;
  font-family: 'Fredoka One', cursive;
}

.age-group-range {
  font-size: 15px;
  font-weight: 600;
  opacity: 0.9;
}

/* Back button — step 2 */
.btn-back-ages {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  margin: 0 20px 16px;
  border: none;
  border-radius: 10px;
  background: #f0f0f0;
  color: var(--child-text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Baloo 2', cursive, sans-serif;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-back-ages:hover {
  background: #e0e0e0;
}

/* Prescription grid on step 2 — no outer age-section wrapper */
.prescription-grid--full {
  margin: 0 20px;
  border-radius: 14px;
}

/* Route notice — shown when some prescribed stops are no longer at the park
   (#20956). Sits above the adventure, dismissible, high contrast. */
.route-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 12px 16px;
  background: #fff4d6;
  color: #5a3b00;
  border-bottom: 3px solid #e8a33d;
  font-size: 1rem;
  font-weight: 600;
}

.route-notice-text { flex: 1; }

.route-notice-dismiss {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: #5a3b00;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}

.route-notice-dismiss:hover,
.route-notice-dismiss:focus-visible { background: #f6e3b8; }

/* ── Accessibility (#20957) ───────────────────────────────────────────────── */

/* The step control is a <button> now, not a div: reset the UA button styling
   the rest of .activity-checkbox assumes. */
.activity-checkbox {
  font-family: inherit;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

/* A visible focus ring everywhere a keyboard can land. */
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #1e78ab;
  outline-offset: 2px;
  border-radius: 6px;
}

/* Honour the system "reduce motion" setting: keep the celebration, drop the
   spinning, bouncing and confetti that can be overwhelming. Transforms are
   neutralised so nothing is left mid-animation off-screen. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .confetti-piece,
  .celebration-confetti {
    display: none !important;
  }
}
