/* Interactive samples (#try) and reference tables on the app pages; loaded only by pages that have them.
   Without JavaScript the controls stay hidden and the sample shows its default state. */

.block-demo {
  background:
    linear-gradient(180deg, var(--tint), var(--white));
  border-block: 1px solid var(--line);
}

.block-demo .kicker {
  margin: 0 0 var(--s-2);
  color: var(--action);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.demo {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
}

@media (min-width: 960px) {
  .demo {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--s-7);
  }

  .demo[data-demo="export"] {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  }

  /* The controls stay in view while a long sample scrolls past. */
  .js .demo-panel {
    position: sticky;
    top: calc(var(--header-h) + var(--s-5));
  }
}

.demo + .next-step {
  margin-top: var(--s-7);
}

.demo-panel {
  display: none;
}

.js .demo-panel {
  display: grid;
  gap: var(--s-5);
  align-content: start;
}

.demo-seg {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.demo-seg legend {
  margin-bottom: var(--s-2);
  padding: 0;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.demo-seg-opts {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
}

@media (max-width: 559px) {
  .demo-seg button {
    padding-inline: 8px;
  }
}

.demo-seg-wrap .demo-seg-opts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  grid-auto-flow: row;
  width: 100%;
}

.demo-seg button {
  min-height: 44px;
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  line-height: 1.3;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.demo-seg button:hover {
  background: var(--tint-2);
  color: var(--ink);
}

.demo-seg button[aria-pressed="true"] {
  background: var(--navy);
  color: var(--white);
}

.demo-seg button:focus-visible,
.demo-chip:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.demo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-full);
  background: var(--white);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.demo-chip:has(input:checked) {
  border-color: var(--action);
  background: var(--tint-2);
  color: var(--ink);
}

.demo-chip input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--action);
}

.demo-hint {
  margin: 0;
  color: var(--ink-3);
  font-size: var(--fs-sm);
  line-height: 1.6;
}

.demo-panel p:last-child {
  margin: 0;
}

.demo-stage {
  position: relative;
}

.demo-stage .sample-body {
  transition: opacity 0.18s var(--ease);
}

.demo-stage.is-swapping .sample-body {
  opacity: 0.35;
}

/* Etiketto: the Food information block as a theme renders it. */
.lbl {
  display: grid;
  gap: var(--s-3);
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.lbl p {
  margin: 0;
}

.lbl-h {
  font-family: var(--font-head);
  font-size: var(--fs-md);
  font-weight: 600;
}

.lbl-k {
  font-weight: 600;
}

.lbl strong {
  font-weight: 700;
}

.lbl [data-v="ingredients"] strong {
  background: linear-gradient(rgb(var(--cyan-rgb) / 0.35), rgb(var(--cyan-rgb) / 0.35)) 0 100% / 100% 0.4em no-repeat;
}

.lbl-table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid var(--ink);
  font-size: var(--fs-sm);
}

.lbl-table caption {
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-bottom: 0;
  font-weight: 700;
  text-align: left;
}

.lbl-table th,
.lbl-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-2);
  text-align: left;
  font-weight: 500;
}

.lbl-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lbl-table thead th {
  text-align: right;
}

.lbl-table thead th,
.lbl-table thead td {
  border-bottom: 2px solid var(--ink);
  font-weight: 700;
}

.lbl-table .lbl-sub th {
  padding-left: 22px;
  color: var(--ink-2);
  font-weight: 400;
}

.lbl-table tbody tr:last-child > * {
  border-bottom: 0;
}

.lbl-raw {
  margin: var(--s-3) 0 0;
  padding: var(--s-3);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--soft);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.lbl-raw::before {
  content: "In the app";
  display: block;
  margin-bottom: 4px;
  color: var(--ink-3);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Columna: the export preview. */
.xp-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.xp-scroll:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.xp-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
}

.xp-table th,
.xp-table td {
  padding: 8px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.xp-table th:last-child,
.xp-table td:last-child {
  border-right: 0;
}

.xp-table thead th {
  background: var(--soft);
  color: var(--ink-2);
  font-family: var(--font-body);
  font-weight: 600;
}

.xp-table thead th.xp-prop {
  background: rgb(var(--cyan-rgb) / 0.16);
  color: var(--ink);
}

.xp-table td.xp-prop {
  background: rgb(var(--cyan-rgb) / 0.05);
}

.xp-table td.xp-cell {
  min-width: 260px;
  white-space: normal;
  color: var(--ink-2);
}

.xp-table tbody tr:last-child > * {
  border-bottom: 0;
}

.xp-table .is-new {
  animation: xp-in 0.45s var(--ease);
}

@keyframes xp-in {
  from {
    background-color: rgb(var(--cobalt-rgb) / 0.18);
  }
}

/* Scenario samples: plain tables, option lists and field lists. */
.xp-table-plain {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
}

.xp-table-plain th,
.xp-table-plain td {
  white-space: normal;
}

.xp-table-plain td {
  min-width: 80px;
}

.sc-options {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sc-option {
  display: grid;
  grid-template-columns: auto minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--s-3);
  align-items: center;
  min-height: 52px;
  padding: 10px var(--s-4);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 0.9375rem;
}

.sc-dot {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-2);
  border-radius: 50%;
}

.sc-opt-l {
  font-weight: 600;
}

.sc-opt-d {
  color: var(--ink-3);
  font-size: var(--fs-sm);
  text-align: right;
}

/* On a phone the detail goes under the label, so neither is squeezed into a narrow column. */
@media (max-width: 520px) {
  .sc-option {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 2px;
  }

  .sc-opt-d {
    grid-column: 2;
    text-align: left;
  }
}

.sc-option.is-first {
  border-color: var(--action);
  box-shadow: inset 0 0 0 1px var(--action);
}

.sc-option.is-first .sc-dot {
  border: 5px solid var(--action);
}

.sc-option.is-renamed .sc-opt-l {
  background: linear-gradient(rgb(var(--cyan-rgb) / 0.35), rgb(var(--cyan-rgb) / 0.35)) 0 100% / 100% 0.4em no-repeat;
}

.sc-option.is-hidden {
  border-style: dashed;
  background: var(--soft);
  color: var(--ink-3);
}

.sc-option.is-hidden .sc-opt-l {
  text-decoration: line-through;
  font-weight: 500;
}

.sc-fields {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}

.sc-fields > div {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: var(--s-3);
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.sc-fields > div:first-child {
  border-top: 0;
}

.sc-fields dt {
  color: var(--ink-3);
}

.sc-fields dd {
  margin: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.sc-note {
  margin: var(--s-3) 0 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

/* Reference blocks: the EU checklist and the column list. */
.ref-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.ref-table th,
.ref-table td {
  padding: 14px var(--s-4);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}

.ref-table thead th {
  background: var(--soft);
  color: var(--ink-3);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.ref-table tbody th {
  font-weight: 600;
}

.ref-table td:nth-child(2) {
  color: var(--ink-3);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.ref-table tbody tr:last-child > * {
  border-bottom: 0;
}

.ref-table tbody tr {
  transition: background-color 0.2s var(--ease);
}

.ref-table tbody tr:hover {
  background: var(--tint);
}

@media (max-width: 719px) {
  .ref-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .ref-table tr {
    display: grid;
    gap: 4px;
    padding: 14px var(--s-4);
    border-bottom: 1px solid var(--line);
  }

  .ref-table tbody tr:last-child {
    border-bottom: 0;
  }

  .ref-table th,
  .ref-table td {
    padding: 0;
    border: 0;
  }

  .ref-table td:nth-child(2) {
    white-space: normal;
  }
}

.ref-groups {
  columns: 1;
  column-gap: var(--s-5);
}

@media (min-width: 640px) {
  .ref-groups {
    columns: 2;
  }
}

@media (min-width: 1000px) {
  .ref-groups {
    columns: 3;
  }
}

.ref-group {
  break-inside: avoid;
  margin: 0 0 var(--s-5);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.ref-group h3 {
  margin: 0 0 var(--s-2);
  font-size: var(--fs-base);
}

.ref-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ref-group li {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.ref-group li:first-child {
  border-top: 0;
}

.ref-foot {
  max-width: var(--read);
  margin: var(--s-5) 0 0;
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

@media (prefers-reduced-motion: reduce) {
  .demo-stage .sample-body,
  .demo-seg button,
  .demo-chip,
  .ref-table tbody tr {
    transition: none;
  }

  .xp-table .is-new {
    animation: none;
  }
}
