{
  "schemaVersion": "1.0",
  "id": "child-task-detail",
  "title": "Gấp chăn, xếp gối",
  "purpose": "Own child instructions với submit, không adult completion hay sửa due.",
  "roles": [
    "child"
  ],
  "group": "members-children",
  "variantOf": null,
  "layout": {
    "canvas": {
      "width": 390,
      "height": 844
    },
    "responsive": {
      "minimumWidth": 360,
      "maximumWidth": 430,
      "scroll": "vertical",
      "safeAreaBottom": true,
      "fontScale": "native dynamic type; reflow without clipping",
      "keyboard": "composer sticky within resized viewport; dialog scrolls; no fixed keyboard overlay"
    },
    "regions": [
      {
        "id": "header",
        "order": 0,
        "type": "safe-area/header",
        "height": "intrinsic"
      },
      {
        "id": "content",
        "order": 1,
        "type": "purpose-specific child-occurrence",
        "componentIds": [
          "screen-header",
          "child-task-detail-0",
          "child-task-detail-1",
          "child-task-detail-2",
          "screen-actions",
          "primary-navigation"
        ]
      },
      {
        "id": "actions",
        "order": 2,
        "type": "one primary + secondary controls"
      },
      {
        "id": "navigation",
        "order": 3,
        "type": "child-two-tabs"
      }
    ]
  },
  "components": [
    {
      "id": "screen-header",
      "type": "Header",
      "props": {
        "homeLabel": "Bông",
        "scopeGate": "C assigned=self",
        "backTarget": "child-today",
        "settingsTarget": "child-settings"
      },
      "tokens": {
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Thanh đầu màn hình",
        "readingOrder": 0,
        "focusOrder": "back then settings"
      }
    },
    {
      "id": "child-task-detail-0",
      "type": "DetailList",
      "props": {
        "items": [
          [
            "Không gian",
            "Phòng khách"
          ],
          [
            "Công sức",
            "1 / 3"
          ],
          [
            "Trạng thái",
            "Chưa xong"
          ]
        ]
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Gấp chăn, xếp gối · DetailList",
        "readingOrder": 1,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "child-task-detail-1",
      "type": "ChildInstructions",
      "props": {
        "contentText": "Làm từng bước nhé   Gấp chăn vuông vắn.  Đặt gối về hai đầu ghế.  Nhìn lại ghế trước khi báo xong."
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Gấp chăn, xếp gối · ChildInstructions",
        "readingOrder": 2,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "child-task-detail-2",
      "type": "Notice",
      "props": {
        "text": "Con báo đã làm; phụ huynh xem rồi mới ghi nhận điểm.",
        "tone": ""
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Gấp chăn, xếp gối · Notice",
        "readingOrder": 3,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "child-submit",
            "label": "Con đã làm xong",
            "kind": "mutate",
            "target": null,
            "confirmationRequired": false
          },
          {
            "id": "navigate-1",
            "label": "Về việc của con",
            "kind": "navigate",
            "target": "child-today",
            "confirmationRequired": false
          },
          {
            "id": "link-child-settings",
            "label": "Tùy chọn của con",
            "kind": "navigate",
            "target": "child-settings",
            "confirmationRequired": false
          },
          {
            "id": "link-child-achievements",
            "label": "Thành tích của con",
            "kind": "navigate",
            "target": "child-achievements",
            "confirmationRequired": false
          }
        ],
        "primaryCount": 1
      },
      "tokens": {
        "lightBackground": "{component.light.button.background}",
        "lightForeground": "{component.light.button.foreground}",
        "darkBackground": "{component.dark.button.background}",
        "darkForeground": "{component.dark.button.foreground}",
        "height": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Hành động của màn hình",
        "keyboard": true,
        "focusVisible": true,
        "disabledOnlyLowContrast": true
      }
    },
    {
      "id": "primary-navigation",
      "type": "Navigation",
      "props": {
        "items": [
          [
            "child-today",
            "Việc của con",
            "check"
          ],
          [
            "child-achievements",
            "Thành tích",
            "history"
          ]
        ],
        "active": "child-today"
      },
      "tokens": {
        "activeBackground": "{semantic.light.sage}",
        "activeDarkBackground": "{semantic.dark.sage}",
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Điều hướng chính",
        "ariaCurrent": "page",
        "touchTarget": 48,
        "noColorOnly": true
      }
    }
  ],
  "fields": [],
  "states": [
    {
      "id": "open",
      "when": "Child own assignment",
      "visibleUI": "Submit -> awaiting_approval",
      "availableActions": [
        "child-submit",
        "navigate-1",
        "link-child-settings",
        "link-child-achievements"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "pending",
      "when": "Submission đã gửi",
      "visibleUI": "Disable gửi lại, không điểm",
      "availableActions": [
        "navigate-1",
        "link-child-settings",
        "link-child-achievements"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "redo",
      "when": "needs_redo",
      "visibleUI": "Hiển thị lý do và submit cycle mới",
      "availableActions": [
        "child-submit",
        "navigate-1",
        "link-child-settings",
        "link-child-achievements"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "offline",
      "when": "Own snapshot cached",
      "visibleUI": "Queue same command key, không điểm",
      "availableActions": [
        "child-submit",
        "navigate-1",
        "link-child-settings",
        "link-child-achievements"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "child-submit",
      "label": "Con đã làm xong",
      "kind": "mutate",
      "targetScreenId": null,
      "permission": "C assigned=self",
      "confirmationRequired": false,
      "contractRef": "POST /v1/households/{hid}/occurrences/{oid}/complete",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": "Stable actor/household/command key and canonical body; changed payload is a new confirmed intent."
    },
    {
      "id": "navigate-1",
      "label": "Về việc của con",
      "kind": "navigate",
      "targetScreenId": "child-today",
      "permission": "C assigned=self",
      "confirmationRequired": false,
      "contractRef": "local navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "link-child-settings",
      "label": "Tùy chọn của con",
      "kind": "navigate",
      "targetScreenId": "child-settings",
      "permission": "C assigned=self",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-child-achievements",
      "label": "Thành tích của con",
      "kind": "navigate",
      "targetScreenId": "child-achievements",
      "permission": "C assigned=self",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    }
  ],
  "dataBindings": [
    {
      "source": "POST /v1/households/{hid}/occurrences/{oid}/complete",
      "shape": {
        "occurrence_id": "opaque ID",
        "task_id": "opaque ID",
        "task_title": "string",
        "instructions": "string|null",
        "room_id": "opaque ID",
        "room_name": "string",
        "due_local_date": "date",
        "due_timezone": "IANA",
        "snoozed_until_local_date": "date|null",
        "effort_snapshot": "1|2|3",
        "status": "open|awaiting_approval|needs_redo|completed|cancelled",
        "version": "integer",
        "latest_submission_event_id": "opaque ID|null",
        "can_submit": "boolean"
      },
      "sample": {
        "occurrence_id": "occ-blanket",
        "task_id": "blanket",
        "task_title": "Gấp chăn, xếp gối",
        "instructions": "Gấp chăn rồi xếp gối.",
        "room_id": "living",
        "room_name": "Phòng khách",
        "due_local_date": "2026-10-14",
        "due_timezone": "Asia/Ho_Chi_Minh",
        "snoozed_until_local_date": null,
        "effort_snapshot": 1,
        "status": "open",
        "version": 1,
        "latest_submission_event_id": null,
        "can_submit": true
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Gấp chăn, xếp gối",
    "primary": "Con đã làm xong",
    "empty": null,
    "notices": [
      "Con báo đã làm; phụ huynh xem rồi mới ghi nhận điểm."
    ],
    "locale": "vi",
    "demoLabel": "Bản thiết kế · dữ liệu mẫu · không kết nối dịch vụ"
  },
  "implementation": {
    "nativeRoute": "/design/child-task-detail",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "apiRefs": [
      "POST /v1/households/{hid}/occurrences/{oid}/complete"
    ],
    "newContractRefs": [],
    "notes": [
      "Tất cả ví dụ là dữ liệu thiết kế, không bằng chứng native/API/store đã chạy.",
      "Native route dưới đây là đề xuất mapping cho agent, không tuyên bố route source đã tồn tại.",
      "Mọi mutation dùng envelope {data,version,household_revision,replayed}, stable Idempotency-Key và expected_version khi sửa.",
      "Accepted-day recurrence; occurrence due/effort snapshot bất biến; snooze không đổi anchor; pending không reassign; undo điều chỉnh ledger đúng một lần.",
      "Child DTO allowlist: own assignments/history + relevant room instructions; không adult contacts, invites, billing hoặc household aggregates."
    ],
    "integrationStatus": "design complete; local static/draft interactions; native/API adapters pending",
    "sourceAuthority": [
      "docs/product-brief.md",
      "plans/261013-1409-sweepy-vietnam-mobile/mobile-flows.md",
      "plans/261013-1409-sweepy-vietnam-mobile/api-contracts.md",
      "packages/domain/src/contracts/phase2.ts",
      "packages/domain/src/index.ts",
      "packages/domain/src/contracts/phase3.ts",
      "packages/domain/src/contracts/billing.ts",
      "apps/mobile/src/lib/api.ts"
    ],
    "capability": "C assigned=self",
    "errors": {
      "401": "Stop queue; adult login or child re-pair without parent account.",
      "403": "Do not retry lost capability. FEATURE_REQUIRED never grants Pro.",
      "409": "Fetch canonical scoped state; review/reconfirm new intent, do not rewrite old replay payload.",
      "422": "Field error with retained draft.",
      "429": "Respect Retry-After.",
      "503": "Backoff only retryable commands with original key."
    }
  }
}
