/* Component stylesheet for game.coap-message-builder. */
html.iot-component-frame body {
  margin: 0;
  padding: 0;
  background: transparent;
}

html.iot-component-frame main,
html.iot-component-frame .page-columns,
html.iot-component-frame .content,
html.iot-component-frame #quarto-content,
html.iot-component-frame #quarto-document-content {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

html.iot-component-frame h1.title,
html.iot-component-frame #interactive-game > h1,
html.iot-component-frame #interactive-game > h2,
html.iot-component-frame #reference-material > h2,
html.iot-component-frame #related-resources,
html.iot-component-frame header,
html.iot-component-frame .quarto-title-block,
html.iot-component-frame nav,
html.iot-component-frame .sidebar,
html.iot-component-frame .toc-active,
html.iot-component-frame #quarto-header {
  display: none !important;
}

html.iot-component-frame #coapGame,
html.iot-component-frame .coap-reference-material {
  max-width: 100%;
  margin-right: 0;
  margin-left: 0;
  box-shadow: none;
}

html.iot-resource-frame-standalone #coapGame {
  margin-bottom: 22px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

html.iot-resource-frame-standalone #coapGame .coap-hero {
  display: none;
}

#coapGame,
#coapGame * {
  box-sizing: border-box;
}

#coapGame {
  --coap-module-accent: #2e7d32;
  --coap-module-strong: #1b5e20;
  --coap-module-tint: #eef8ef;
  --coap-module-tint-strong: #dff1e1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto 28px;
  padding: 18px;
  color: #20343d;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #f4f8fb;
  border: 1px solid #d8e4ea;
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(24, 54, 68, 0.1);
}

#coapGame[data-iot-interactive-theme="flat"][data-iot-recolor-pilot="true"][data-iot-module="coap"] {
  background: var(--coap-module-tint);
  border-color: #d6e5d8;
  box-shadow: none;
}

#coapGame h2,
#coapGame h3,
#coapGame p {
  margin: 0;
}

.coap-hero {
  padding: 22px;
  margin-bottom: 16px;
  color: #ffffff;
  background: linear-gradient(135deg, #183d55 0%, #137a7f 62%, #b46b1d 100%);
  border-radius: 8px;
}

#coapGame[data-iot-interactive-theme="flat"][data-iot-recolor-pilot="true"][data-iot-module="coap"]
  .coap-hero {
  color: #20343d;
  background: var(--coap-module-tint);
  border: 1px solid #d6e5d8;
  border-left: 4px solid var(--coap-module-accent);
  box-shadow: none;
}

.coap-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.coap-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#coapGame[data-iot-interactive-theme="flat"][data-iot-recolor-pilot="true"][data-iot-module="coap"]
  .coap-pill {
  color: #20343d;
  background: #ffffff;
  border-color: #d6e5d8;
}

.coap-hero h2 {
  margin-bottom: 10px;
  color: #ffffff;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.coap-hero p {
  max-width: 780px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
}

#coapGame[data-iot-interactive-theme="flat"][data-iot-recolor-pilot="true"][data-iot-module="coap"]
  .coap-hero
  h2,
#coapGame[data-iot-interactive-theme="flat"][data-iot-recolor-pilot="true"][data-iot-module="coap"]
  .coap-hero
  p {
  color: #20343d;
}

.coap-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 600px;
  margin-top: 18px;
}

.coap-metric {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
}

.coap-metric strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1;
}

.coap-metric span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.72rem;
}

.coap-toolbar,
.coap-status {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.coap-toolbar {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.coap-progress-card,
.coap-stat {
  min-height: 78px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #d8e4ea;
  border-radius: 8px;
}

.coap-progress-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.coap-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.coap-progress-empty {
  color: #657982;
  font-size: 0.84rem;
  font-weight: 750;
}

.coap-progress-text {
  color: #657982;
  font-size: 0.82rem;
  font-weight: 800;
}

.coap-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid #cfdce2;
  border-radius: 999px;
  color: #566c76;
  background: #f2f7f9;
  font-size: 0.74rem;
  font-weight: 850;
}

.coap-dot.current {
  color: #ffffff;
  background: #166b95;
  border-color: #166b95;
  box-shadow: 0 0 0 3px rgba(22, 107, 149, 0.18);
}

.coap-dot.perfect {
  color: #ffffff;
  background: #237a57;
  border-color: #237a57;
}

.coap-dot.good {
  color: #ffffff;
  background: #4e8a39;
  border-color: #4e8a39;
}

.coap-dot.partial {
  color: #ffffff;
  background: #b46b1d;
  border-color: #b46b1d;
}

.coap-dot.miss {
  color: #ffffff;
  background: #b84a43;
  border-color: #b84a43;
}

.coap-status {
  grid-template-columns: 1.6fr repeat(3, minmax(96px, 1fr));
}

.coap-stat strong {
  display: block;
  color: #20343d;
  font-size: 1.55rem;
  line-height: 1;
}

.coap-stat span {
  display: block;
  margin-top: 7px;
  color: #657982;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.coap-btn {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #ffffff;
  background: #166b95;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 850;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

#coapGame[data-iot-interactive-theme="flat"][data-iot-recolor-pilot="true"][data-iot-module="coap"]
  .coap-btn:not(.secondary) {
  background: var(--coap-module-strong);
  border-color: var(--coap-module-strong);
}

.coap-btn:hover:not(:disabled) {
  background: #10587b;
  transform: translateY(-1px);
}

#coapGame[data-iot-interactive-theme="flat"][data-iot-recolor-pilot="true"][data-iot-module="coap"]
  .coap-btn:hover:not(:disabled):not(.secondary) {
  background: var(--coap-module-accent);
  border-color: var(--coap-module-accent);
}

.coap-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.coap-btn.secondary {
  color: #20343d;
  background: #ffffff;
  border-color: #c9d8df;
}

.coap-btn.secondary:hover:not(:disabled) {
  background: #f4f8fb;
}

.coap-empty,
.coap-scenario,
.coap-builder,
.coap-wire-card,
.coap-feedback,
.coap-final {
  background: #ffffff;
  border: 1px solid #d8e4ea;
  border-radius: 8px;
}

.coap-empty {
  padding: 28px;
  margin-bottom: 14px;
  text-align: center;
}

.coap-empty h3 {
  margin-bottom: 8px;
  color: #20343d;
  font-size: 1.2rem;
}

.coap-empty p {
  max-width: 640px;
  margin: 0 auto;
  color: #52666f;
  line-height: 1.55;
}

.coap-error {
  border-color: #e7b2ae;
  background: #fff7f6;
}

.coap-scenario {
  padding: 18px;
  margin-bottom: 14px;
  border-left: 5px solid #b46b1d;
}

.coap-scenario-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.coap-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid #d4bf9f;
  border-radius: 999px;
  color: #8a4f12;
  background: #fff5e8;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#coapGame[data-iot-interactive-theme="flat"][data-iot-recolor-pilot="true"][data-iot-module="coap"]
  .coap-tag {
  color: #20343d;
  background: #ffffff;
  border-color: #d6e5d8;
}

.coap-scenario h3 {
  margin-bottom: 9px;
  color: #20343d;
  font-size: 1.35rem;
  line-height: 1.2;
}

.coap-scenario p {
  color: #455d66;
  line-height: 1.58;
}

.coap-requirements {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.coap-requirement {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid #d5e1e6;
  border-radius: 999px;
  color: #20343d;
  background: #f7fbfc;
  font-size: 0.78rem;
  font-weight: 750;
}

.coap-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.82fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.coap-workspace.is-idle {
  display: none;
}

.coap-builder,
.coap-wire-card {
  padding: 16px;
}

.coap-builder-head,
.coap-wire-head,
.coap-option-head {
  margin-bottom: 12px;
}

.coap-builder-head h3,
.coap-wire-head strong,
.coap-option-head strong {
  display: block;
  color: #20343d;
  font-size: 1rem;
  font-weight: 850;
}

.coap-builder-head p,
.coap-wire-head span,
.coap-option-head span {
  display: block;
  margin-top: 3px;
  color: #60747d;
  font-size: 0.82rem;
  line-height: 1.4;
}

.coap-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.coap-field span {
  display: block;
  margin-bottom: 6px;
  color: #516872;
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.coap-field select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: #20343d;
  background: #ffffff;
  border: 1px solid #c9d8df;
  border-radius: 8px;
  font: inherit;
  font-weight: 750;
}

.coap-option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.coap-option-token {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid #c9d8df;
  border-radius: 999px;
  color: #20343d;
  background: #f7fbfc;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.coap-option-token:hover:not(:disabled) {
  border-color: #166b95;
}

.coap-option-token.is-selected {
  color: #ffffff;
  background: #137a7f;
  border-color: #137a7f;
}

.coap-option-token:disabled,
.coap-field select:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.coap-wire-card {
  min-width: 0;
}

.coap-wire-card.muted {
  opacity: 0.9;
}

.coap-wire-block {
  overflow-x: auto;
  padding: 14px;
  color: #cdeee1;
  background: #172732;
  border: 1px solid #2d4350;
  border-radius: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.6;
}

.coap-wire-block div + div {
  margin-top: 4px;
}

.coap-wire-block span {
  display: inline-block;
  min-width: 76px;
  margin-right: 8px;
  color: #8cc7ff;
  font-weight: 850;
}

.coap-feedback {
  display: none;
  padding: 16px;
  margin-bottom: 14px;
}

.coap-feedback.show {
  display: block;
}

.coap-feedback.correct {
  background: #effaf4;
  border-color: #94d2ae;
}

.coap-feedback.partial {
  background: #fff8ec;
  border-color: #e4bf84;
}

.coap-feedback.incorrect {
  background: #fff6f5;
  border-color: #e7b2ae;
}

.coap-feedback-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #20343d;
  font-size: 1rem;
  font-weight: 900;
}

.coap-feedback-title span {
  color: #166b95;
}

.coap-feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.coap-feedback-grid div {
  padding: 10px;
  border: 1px solid rgba(32, 52, 61, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.coap-feedback-grid strong,
.coap-feedback-grid span {
  display: block;
}

.coap-feedback-grid strong {
  margin-bottom: 4px;
  color: #52666f;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.coap-feedback-grid span,
.coap-feedback p {
  color: #405862;
  line-height: 1.5;
}

.coap-feedback p + p {
  margin-top: 7px;
}

.coap-feedback-note {
  color: #8a4f12 !important;
  font-weight: 750;
}

.coap-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.coap-final {
  padding: 30px;
  text-align: center;
}

.coap-final-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 10px;
  margin-bottom: 10px;
  border-radius: 999px;
  color: #166b95;
  background: #e8f2f7;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.coap-final strong {
  display: block;
  color: #166b95;
  font-size: 2.8rem;
  line-height: 1;
  font-weight: 900;
}

.coap-final h3 {
  margin: 10px 0 8px;
  color: #20343d;
  font-size: 1.35rem;
}

.coap-final p {
  margin-bottom: 16px;
  color: #52666f;
  line-height: 1.45;
}

.reference-intro {
  margin: 0 0 12px;
  color: #52666f;
  line-height: 1.5;
}

.coap-reference-material {
  display: block;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto 28px;
  color: #20343d;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

.reference-loading {
  padding: 16px;
  color: #60747d;
  background: #ffffff;
  border: 1px solid #d8e4ea;
  border-radius: 8px;
}

.reference-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.reference-map-item {
  padding: 12px;
  background: #ffffff;
  border: 1px solid #d8e4ea;
  border-radius: 8px;
}

.reference-map-item strong,
.reference-map-item span {
  display: block;
}

.reference-map-item strong {
  margin-bottom: 5px;
  color: #20343d;
  font-size: 0.9rem;
}

.reference-map-item span {
  color: #60747d;
  font-size: 0.82rem;
  line-height: 1.4;
}

.reference-section {
  margin-bottom: 10px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #d8e4ea;
  border-radius: 8px;
}

.reference-section[open] .reference-section-chevron {
  transform: rotate(90deg);
}

.reference-section-summary {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 18px;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}

.reference-section-summary::-webkit-details-marker {
  display: none;
}

.reference-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: #ffffff;
  background: #166b95;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
}

.reference-section-tip .reference-section-icon {
  background: #b46b1d;
}

.reference-section-summary span:nth-child(2) {
  color: #20343d;
  font-weight: 850;
}

.reference-section-chevron {
  color: #60747d;
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.reference-section-body {
  padding: 0 14px 14px;
}

.reference-mini-grid,
.reference-card-grid {
  display: grid;
  gap: 10px;
}

.reference-mini-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reference-mini,
.reference-card {
  padding: 12px;
  background: #f7fbfc;
  border: 1px solid #dbe7ec;
  border-radius: 8px;
}

.reference-mini strong,
.reference-mini span {
  display: block;
}

.reference-mini strong,
.reference-card h4 {
  margin: 0 0 5px;
  color: #20343d;
  font-size: 0.94rem;
}

.reference-mini span,
.reference-card li {
  color: #52666f;
  font-size: 0.84rem;
  line-height: 1.45;
}

.reference-scan {
  overflow-x: auto;
  border: 1px solid #dbe7ec;
  border-radius: 8px;
}

.reference-scan-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.reference-scan-table th,
.reference-scan-table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #dbe7ec;
}

.reference-scan-table th {
  color: #20343d;
  background: #edf4f7;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.reference-scan-table tr:last-child td {
  border-bottom: 0;
}

.reference-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reference-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.reference-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  color: #166b95;
  background: #e9f3f8;
  border: 1px solid #cce1eb;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 850;
}

.reference-card ul,
.reference-card ol {
  margin: 0;
  padding-left: 18px;
}

.reference-card li + li {
  margin-top: 5px;
}

@media (max-width: 840px) {
  #coapGame {
    padding: 14px;
  }

  .coap-toolbar,
  .coap-status,
  .coap-workspace,
  .reference-map,
  .reference-card-grid {
    grid-template-columns: 1fr;
  }

  .coap-toolbar {
    align-items: stretch;
  }

  .coap-btn {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .coap-hero {
    padding: 18px;
  }

  .coap-hero h2 {
    font-size: 1.55rem;
  }

  .coap-metrics,
  .coap-fields,
  .coap-feedback-grid,
  .reference-mini-grid {
    grid-template-columns: 1fr;
  }

  .coap-wire-block {
    font-size: 0.78rem;
  }

  .coap-final strong {
    font-size: 2.25rem;
  }

  .reference-scan-table {
    min-width: 520px;
  }
}
