/**
 * a2ui-catalog-v1 — modern skins for A2UI Basic Catalog widgets
 * (Row, Column, Card, Text, TextField, Button, Tabs, …).
 *
 * DEMO / future paint attach: closed catalog widgets only — not freeform local UUID pages.
 * Live chrome (apps bar / dock) stays Manifest-driven.
 *
 * Visual: Design.MD — white canvas, #0C0C0C ink, accent only #E6FD10.
 * Type: Space Grotesk / Inter. Brand wordmark stays Nunito in the shell.
 */
:root,
[data-skin="a2ui-catalog-v1"] {
  --a2-ink: #0C0C0C;
  --a2-ink-soft: #0C0C0C;
  --a2-teal: #0C0C0C;
  --a2-mint: #FFFFFF;
  --a2-mint-deep: #E6FD10;
  --a2-canvas: #FFFFFF;
  --a2-canvas-deep: #F4F4F2;
  --a2-surface: #F4F4F2;
  --a2-surface-2: #FFFFFF;
  --a2-line: rgba(12, 12, 12, 0.12);
  --a2-line-strong: rgba(12, 12, 12, 0.22);
  --a2-muted: #707070;
  --a2-danger: #ba1a1a;
  --a2-ok: #0C0C0C;

  --a2-atmosphere: #FFFFFF;

  --a2-font-display: "Space Grotesk", sans-serif;
  --a2-font-body: Inter, sans-serif;

  --a2-xs: 0.6875rem;
  --a2-sm: 0.8125rem;
  --a2-md: 0.9375rem;
  --a2-lg: 1.125rem;
  --a2-xl: 1.5rem;
  --a2-2xl: clamp(1.7rem, 2.2vw, 2.15rem);

  --a2-space-1: 0.5rem;
  --a2-space-2: 0.75rem;
  --a2-space-3: 1.25rem;
  --a2-space-4: 2rem;
  --a2-radius: 16px;
  --a2-radius-lg: 28px;
  --a2-control-h: 2.55rem;
  --a2-shadow: none;
  --a2-focus: 2px solid #0C0C0C;
}

.a2ui-paint,
[data-a2ui-root] {
  font-family: var(--a2-font-body);
  color: var(--a2-ink);
  background: #ffffff;
  border-radius: var(--a2-radius-lg);
  padding: var(--a2-space-4) var(--a2-space-3);
  min-height: 20rem;
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
  position: relative;
  overflow-x: clip;
  overflow-y: visible;
  animation: a2ui-fade-in 420ms ease both;
}

.a2ui-paint > * { position: relative; z-index: 1; }

@keyframes a2ui-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes a2ui-tab-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes a2ui-modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Layout */
.a2-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 100%;
}
.a2-col {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.a2-gap-sm { gap: var(--a2-space-1); }
.a2-gap-md { gap: var(--a2-space-2); }
.a2-gap-lg { gap: var(--a2-space-3); }
.a2-align-start { align-items: flex-start; }
.a2-align-center { align-items: center; }
.a2-align-end { align-items: flex-end; }
.a2-align-stretch { align-items: stretch; }
.a2-justify-start { justify-content: flex-start; }
.a2-justify-center { justify-content: center; }
.a2-justify-end { justify-content: flex-end; }
.a2-justify-spaceBetween { justify-content: space-between; }
.a2-justify-spaceAround { justify-content: space-around; }

.a2-row > .a2-field,
.a2-row > .a2-choice {
  flex: 1 1 12rem;
  min-width: min(100%, 12rem);
}

/* Card */
.a2-card {
  background: var(--a2-surface);
  border: 1px solid var(--a2-line);
  border-radius: var(--a2-radius-lg);
  padding: var(--a2-space-3);
  box-shadow: none;
}
.a2-card:hover {
  border-color: #0C0C0C;
}

/* Text */
.a2-text { margin: 0; line-height: 1.45; }
.a2-text-h1 {
  font-family: var(--a2-font-display);
  font-size: var(--a2-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
}
.a2-text-h2, .a2-text-h3 {
  font-family: var(--a2-font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.a2-text-h2 { font-size: var(--a2-xl); }
.a2-text-h3 { font-size: var(--a2-lg); }
.a2-text-body { font-size: var(--a2-md); color: var(--a2-ink-soft); }
.a2-text-caption {
  font-size: var(--a2-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--a2-muted);
  font-weight: 600;
}
.a2-text-h4, .a2-text-h5 { font-weight: 600; font-size: var(--a2-md); }

/* Field */
.a2-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.a2-field > span {
  font-size: var(--a2-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--a2-muted);
}
.a2-field input,
.a2-field textarea,
.a2-choice select {
  height: var(--a2-control-h);
  border: 1px solid var(--a2-line-strong);
  border-radius: 12px;
  background: var(--a2-surface-2);
  padding: 0 0.85rem;
  font: 500 var(--a2-md)/1.2 var(--a2-font-body);
  color: var(--a2-ink);
  transition: border-color 150ms ease;
}
/* JOB OCC Ctrl+K finder — big-font display field (catalog usageHint=display) */
.a2-field-display input {
  height: auto;
  min-height: 3.25rem;
  padding: 0.85rem 1rem;
  font: 700 clamp(1.35rem, 3.2vw, 2rem)/1.15 var(--a2-font-display, var(--a2-font-body));
  letter-spacing: -0.02em;
}
.a2-field textarea { height: auto; min-height: 5rem; padding: 0.75rem 0.85rem; resize: vertical; }
.a2-field input:focus,
.a2-field textarea:focus,
.a2-choice select:focus {
  outline: none;
  border: 2px solid #0C0C0C;
}
.a2-field .req::after { content: " *"; color: var(--a2-danger); }

/* ChoicePicker */
.a2-choice { display: flex; flex-direction: column; gap: 0.35rem; }
.a2-choice > span {
  font-size: var(--a2-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--a2-muted);
}
.a2-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.a2-chip {
  border: 1px solid var(--a2-line-strong);
  background: var(--a2-surface-2);
  color: var(--a2-ink);
  border-radius: 9999px;
  padding: 0.45rem 0.85rem;
  font: 600 var(--a2-sm)/1 var(--a2-font-body);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.a2-chip[aria-pressed="true"] {
  background: #E6FD10;
  color: #0C0C0C;
  border-color: #E6FD10;
}
.a2-chip:hover { border-color: #0C0C0C; }

/* CheckBox / Slider / Date */
.a2-check {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: var(--a2-sm);
  font-weight: 500;
  cursor: pointer;
}
.a2-check input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--a2-teal);
}
.a2-slider {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.a2-slider > span {
  font-size: var(--a2-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--a2-muted);
  display: flex;
  justify-content: space-between;
}
.a2-slider input[type="range"] {
  width: 100%;
  accent-color: var(--a2-mint-deep);
}
.a2-datetime {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.a2-datetime > span {
  font-size: var(--a2-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--a2-muted);
}
.a2-datetime input {
  height: var(--a2-control-h);
  border: 1px solid var(--a2-line-strong);
  border-radius: 12px;
  background: var(--a2-surface-2);
  padding: 0 0.85rem;
  font: 500 var(--a2-md)/1.2 var(--a2-font-body);
}

/* Button */
.a2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--a2-control-h);
  padding: 0 1.15rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  font: 700 var(--a2-sm)/1 var(--a2-font-body);
  cursor: pointer;
}
.a2-btn-primary {
  background: #0C0C0C;
  color: #FFFFFF;
}
.a2-btn-primary:hover { background: #1E1E1E; }
.a2-btn-primary:active { transform: scale(0.98); }
.a2-btn-ghost {
  background: transparent;
  border-color: var(--a2-line-strong);
  color: var(--a2-ink);
}
.a2-btn-ghost:hover { background: #F4F4F2; }

/* Tabs */
.a2-tabs { width: 100%; }
.a2-tablist {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--a2-line);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: var(--a2-space-3);
}
.a2-tab {
  border: 0;
  background: transparent;
  color: var(--a2-muted);
  font: 700 var(--a2-sm)/1 var(--a2-font-body);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.a2-tab[aria-selected="true"] {
  background: #0C0C0C;
  color: #FFFFFF;
}
.a2-tabpanel {
  animation: a2ui-tab-in 280ms ease both;
}

/* List / Divider / Icon / Image */
.a2-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.a2-list-h { flex-direction: row; flex-wrap: wrap; }
.a2-list > li {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--a2-line);
  border-radius: var(--a2-radius);
  padding: 0.75rem 0.9rem;
}
/* Detail field rows: label and value stay on one line, not a nested card. */
.a2-list > li:has(> .a2-row) {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--a2-line);
  border-radius: 0;
  padding: 0.4rem 0;
}
.a2-row.a2-justify-spaceBetween:not(:has(.a2-field)):not(:has(.a2-choice)):not(:has(.a2-card)):not(:has(.a2-btn)) {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
}
.a2-row.a2-justify-spaceBetween:not(:has(.a2-field)) > .a2-text {
  min-width: 0;
}
.a2-row.a2-justify-spaceBetween:not(:has(.a2-field)) > .a2-text:last-child {
  text-align: end;
}
.a2-divider {
  border: 0;
  height: 1px;
  width: 100%;
  background: rgba(12, 12, 12, 0.12);
  margin: 0.25rem 0;
}
.a2-divider-v {
  width: 1px;
  height: auto;
  align-self: stretch;
  background: var(--a2-line-strong);
}
.a2-icon {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  border-radius: 16px;
  background: #F4F4F2;
  color: var(--a2-teal);
  flex: 0 0 auto;
}
.a2-icon svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.a2-image {
  display: block;
  border-radius: 16px;
  object-fit: cover;
  background: var(--a2-teal);
}
.a2-image-icon { width: 4.5rem; height: 4.5rem; }

/* Modal */
.a2-modal-root { display: inline-flex; }
.a2-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 12, 0.45);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 1rem;
}
.a2-modal-panel {
  width: min(28rem, 100%);
  background: var(--a2-surface-2);
  border: 1px solid var(--a2-line);
  border-radius: var(--a2-radius-lg);
  padding: var(--a2-space-3);
  box-shadow: var(--a2-shadow);
  animation: a2ui-modal-in 220ms ease both;
}

.a2-demo-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--a2-space-3);
  padding: 0.65rem 0.9rem;
  border-left: 3px solid #E6FD10;
  background: #F4F4F2;
  font-size: var(--a2-sm);
  color: var(--a2-muted);
  border-radius: 12px;
}
.a2-demo-banner strong { color: var(--a2-teal); }
.a2-demo-banner code {
  font-size: 0.75em;
  background: #F4F4F2;
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
}

/* AG2UI order-detail proof strip — unmistakable */
.a2-card-proof,
.a2-card[data-a2ui-id="proof_card"] {
  border: 2px solid #0C0C0C;
  background: #E6FD10;
  box-shadow: 4px 4px 0 #0C0C0C;
}
.a2-card-proof .a2-text-h3,
.a2-card[data-a2ui-id="proof_card"] .a2-text-h3 {
  color: #0C0C0C;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.a2-card-proof .a2-text,
.a2-card[data-a2ui-id="proof_card"] .a2-text {
  color: #0C0C0C;
}

.a2-login-gate {
  max-width: 36rem;
  margin: 1.5rem auto;
  padding: 1.5rem 1.25rem;
  border: 2px solid #0C0C0C;
  border-radius: 1rem;
  background: #F4F4F2;
  box-shadow: 6px 6px 0 #E6FD10;
}
.a2-login-gate-kicker {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #707070;
}
.a2-login-gate-title {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  color: #0C0C0C;
}
.a2-login-gate-body,
.a2-login-gate-oid {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: #0C0C0C;
}
.a2-login-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}
.a2-login-gate-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  background: #0C0C0C;
  color: #E6FD10;
  font-weight: 700;
  text-decoration: none;
}
.a2-login-gate-cta:hover { opacity: 0.88; }
.a2-login-gate-secondary {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  border: 1px solid #0C0C0C;
  color: #0C0C0C;
  font-weight: 600;
  text-decoration: none;
  background: #fff;
}
.a2-login-gate-secondary:hover { background: #E6FD10; }

/* ── Responsive: tablet (≤1023) / phone (≤767) ───────────────────────────
 * Breakpoints match shell chrome. Desktop ≥1024 stays dense / full-bleed.
 * Prefer @container paint so split panes respond to pane width, not viewport.
 */
@media (max-width: 1023px) {
  .a2ui-paint,
  [data-a2ui-root] {
    padding: var(--a2-space-3);
    border-radius: 20px;
    min-height: 12rem;
  }
  .a2-text-h1 { font-size: clamp(1.35rem, 4.2vw, 1.85rem); }
  .a2-card { padding: var(--a2-space-2) var(--a2-space-3); }
}

@media (max-width: 767px) {
  :root,
  [data-skin="a2ui-catalog-v1"] {
    --a2-control-h: 2.75rem; /* ≥44px touch */
    --a2-md: 1rem;
    --a2-sm: 0.875rem;
    --a2-space-4: 1.25rem;
    --a2-radius-lg: 18px;
  }

  .a2ui-paint,
  [data-a2ui-root] {
    padding: var(--a2-space-3) var(--a2-space-2);
    border-radius: 16px;
    min-height: 0;
  }

  /* Rows with fields/choices stack; keep chip rows wrapping. */
  .a2-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--a2-space-2);
  }
  .a2-row > .a2-field,
  .a2-row > .a2-choice,
  .a2-row > .a2-card,
  .a2-row > .a2-btn,
  .a2-row > .a2-datetime,
  .a2-row > .a2-slider,
  .a2-row > .a2-check {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }
  .a2-row.a2-justify-spaceBetween,
  .a2-row.a2-justify-spaceAround {
    flex-direction: column;
    align-items: stretch;
  }
  .a2-row > .a2-divider-v {
    width: 100%;
    height: 1px;
    align-self: stretch;
  }

  .a2-btn {
    min-height: 2.75rem;
    padding: 0 1.1rem;
    width: auto;
    max-width: 100%;
  }
  .a2-row > .a2-btn { width: 100%; }

  .a2-chip {
    min-height: 2.5rem;
    padding: 0.55rem 0.95rem;
    font-size: var(--a2-sm);
  }

  .a2-tablist {
    width: 100%;
    border-radius: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .a2-tablist::-webkit-scrollbar { display: none; }
  .a2-tab {
    min-height: 2.5rem;
    padding: 0.7rem 0.95rem;
    flex: 0 0 auto;
  }

  .a2-list { gap: 0.5rem; }
  .a2-list > li {
    padding: 0.85rem 0.95rem;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .a2-list-h {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }
  .a2-list-h > li {
    flex: 0 0 min(78%, 16rem);
    max-width: 16rem;
  }

  .a2-card {
    padding: var(--a2-space-2);
    border-radius: var(--a2-radius);
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .a2-field input,
  .a2-field textarea,
  .a2-choice select,
  .a2-datetime input {
    font-size: 1rem; /* iOS zoom guard */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .a2-modal-backdrop { padding: 0.75rem; align-items: end; }
  .a2-modal-panel {
    width: 100%;
    max-height: min(88dvh, 40rem);
    overflow-y: auto;
    border-radius: 20px 20px 12px 12px;
  }

  .a2-login-gate {
    margin: 0.75rem auto;
    padding: 1.15rem 1rem;
    max-width: none;
  }
  .a2-login-gate-actions { flex-direction: column; }
  .a2-login-gate-cta,
  .a2-login-gate-secondary { justify-content: center; width: 100%; }

  .a2-text,
  .a2-text-body { overflow-wrap: anywhere; }
  .a2-demo-banner { flex-direction: column; align-items: flex-start; }
}

/* Prefer paint-pane container width over viewport — desk panes stay dense. */
@container paint (max-width: 1023px) {
  .a2ui-paint,
  [data-a2ui-root] {
    padding: var(--a2-space-3);
    border-radius: 20px;
  }
}

@container paint (max-width: 767px) {
  .a2ui-paint,
  [data-a2ui-root] {
    padding: var(--a2-space-3) var(--a2-space-2);
    border-radius: 16px;
  }
  .a2-tablist { width: 100%; }
  .a2-row {
    flex-direction: column;
    align-items: stretch;
  }
  .a2-row > .a2-field,
  .a2-row > .a2-choice,
  .a2-row > .a2-card,
  .a2-row > .a2-btn {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }
}
