/* ─────────────────────────────────────────────────────────────────────────
   BB-98649 compact-input prototypes — shared styles

   Sourced from:
     - ../../src/tokens/tokens.css  (parent design-system token set)
     - docs/prototypes/compact-inputs-prototype-v2.html  (validated bg4-input
       visual system from Phase 3)

   Visual treatment for the new compact-input family (bg4-input, bg4-stack,
   bg4-row, bg4-group, error-indicator) is recreated here because Phase 4
   React implementation has not started yet. Everything else (buttons, page
   chrome typography) follows AF-Home conventions.

   Token caveat: the BB-98649 spec references --af-color-contrast-subtle
   (#f3eee4) for the Optional-tag border. That value is not yet in
   tokens.css. Declared locally below; remove when Phase 4 lands it upstream.
   ───────────────────────────────────────────────────────────────────── */

/* AF-Home Mylius Modern. Fonts are bundled inside prototypes/shared/fonts/
   so the prototype folder is self-contained and portable (drag to Netlify
   Drop, copy to a friend, etc.). For the canonical source see
   src/tokens/fonts.css; updates flow downstream by copying the .woff files
   over manually. */

@font-face {
  font-family: 'Mylius Modern';
  src: url('fonts/mylius-modern-extlig.woff') format('woff');
  font-weight: 200; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Mylius Modern';
  src: url('fonts/mylius-modern-lt.woff') format('woff');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Mylius Modern';
  src: url('fonts/mylius-modern-reg.woff') format('woff');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Mylius Modern';
  src: url('fonts/mylius-modern-bold.woff') format('woff');
  font-weight: 700; font-style: normal; font-display: swap;
}

/* AF-Home tokens (mirrored from src/tokens/tokens.css). Inlined rather than
   @imported because file:// browsers (Safari, Firefox) treat each file as
   its own origin and block cross-directory @import. */
:root {
  /* Midnight */
  --af-color-midnight-700:  #01122c;
  --af-color-midnight-600:  #021737;
  --af-color-midnight-500:  #021b41;
  --af-color-midnight-400:  #8692a4;
  --af-color-midnight-300:  #aeb6c2;
  --af-color-midnight-200:  #d7dbe1;

  /* Blue */
  --af-color-blue-700:      #234776;
  --af-color-blue-600:      #2c5791;
  --af-color-blue-500:      #3468ad;
  --af-color-blue-400:      #9eb7d8;
  --af-color-blue-300:      #becfe5;
  --af-color-blue-200:      #dfe7f2;

  /* Grey */
  --af-color-grey-700:      #70758f;
  --af-color-grey-500:      #b7b9c6;
  --af-color-grey-400:      #cfd0d9;
  --af-color-grey-300:      #e7e8ec;
  --af-color-grey-200:      #f9f9fa;

  /* Red */
  --af-color-red-700:       #8c160a;
  --af-color-red-600:       #ad1c0d;
  --af-color-red-500:       #ce210f;
  --af-color-red-400:       #e7948c;
  --af-color-red-200:       #f7dbd9;

  /* Green */
  --af-color-green-700:     #00573c;
  --af-color-green-600:     #006c4a;
  --af-color-green-500:     #008058;
  --af-color-green-400:     #85c2af;
  --af-color-green-200:     #d6ebe4;

  /* White */
  --af-color-white:         #ffffff;

  /* Semantic */
  --af-color-text-default:        var(--af-color-midnight-500);
  --af-color-text-subtle:         var(--af-color-grey-700);
  --af-color-border:              var(--af-color-grey-300);
  --af-color-surface:             var(--af-color-white);
  --af-color-surface-subtle:      var(--af-color-grey-200);
  --af-color-primary:             var(--af-color-blue-500);
  --af-color-primary-hover:       var(--af-color-blue-600);
  --af-color-primary-text:        var(--af-color-white);
  --af-color-focus-ring:          var(--af-color-blue-500);
  --af-color-error-default:       var(--af-color-red-500);
  --af-color-success-default:     var(--af-color-green-500);

  /* Typography */
  --af-font-heading:        'Mylius Modern', sans-serif;
  --af-font-body:           'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --af-font-weight-light:   300;
  --af-font-weight-regular: 400;
  --af-font-weight-semibold: 600;

  --af-font-size-xs:        0.75rem;
  --af-font-size-body:      1rem;
  --af-font-size-summary:   1.25rem;
  --af-font-size-lg:        1.5rem;
  --af-font-size-xl:        2.25rem;
  --af-font-size-2xl:       2.75rem;
  --af-font-size-3xl:       3.5rem;

  --af-line-height-xs:           1.25rem;
  --af-line-height-xxs-header:   1.5rem;
  --af-line-height-body:         1.5rem;
  --af-line-height-xs-header:    1.75rem;
  --af-line-height-summary:      2rem;
  --af-line-height-lg:           2.25rem;
  --af-line-height-xl:           3rem;
  --af-line-height-2xl:          3.5rem;
  --af-line-height-3xl:          4.25rem;

  --af-letter-spacing-heading: 0.012em;
  --af-letter-spacing-summary: 0.014em;
  --af-letter-spacing-body:    0.004em;
  --af-letter-spacing-xs:      0.004em;

  --af-line-height-button: 1.5rem;

  /* Spacing */
  --af-space-1:  4px;
  --af-space-2:  8px;
  --af-space-3:  12px;
  --af-space-4:  16px;
  --af-space-5:  20px;
  --af-space-6:  24px;
  --af-space-8:  32px;
  --af-space-10: 40px;
  --af-space-12: 48px;

  /* Radius */
  --af-radius-sm:   4px;
  --af-radius-md:   8px;
  --af-radius-lg:   12px;
  --af-radius-full: 9999px;

  /* Shadow */
  --af-shadow-sm:           0 1px 3px rgba(0, 77, 178, 0.15);
  --af-shadow-md:           0 2px 6px rgba(2, 27, 65, 0.15);
  --af-shadow-button:       0 1px 3.5px rgba(0, 77, 178, 0.25);
  --af-shadow-button-inset: inset 0 0.5px 0.5px rgba(255, 255, 255, 0.5);

  /* Motion */
  --af-duration-fast:   150ms;
  --af-duration-normal: 250ms;
  --af-duration-slow:   400ms;
  --af-easing-standard: cubic-bezier(0.4, 0, 0.2, 1);

  /* Button shorthand */
  --af-button-radius:    var(--af-radius-md);
  --af-button-px:        var(--af-space-6);
  --af-button-py:        var(--af-space-4);
  --af-button-font-size: var(--af-font-size-body);

  /* Local stand-in until Phase 4 adds it to tokens.css */
  --af-color-contrast-subtle: #f3eee4;

  /* Prototype-only chrome */
  --proto-page-bg:          var(--af-color-surface-subtle);
  --proto-card-bg:          var(--af-color-surface);
  --proto-card-border:      var(--af-color-border);
  --proto-card-radius:      12px;
  --proto-card-px:          32px;
  --proto-card-py:          32px;

  /* Compact-input geometry (lifted from v2 prototype, validated in Phase 3) */
  --bg4-field-px:           12px;
  --bg4-field-py:           8px;
  --bg4-field-px-with-tag:  8px;
  --bg4-field-row-gap:      4px;
  --bg4-field-label-gap:    8px;
  --bg4-error-height:       64px;
}

/* ─── Reset + page chrome ──────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-body);
  line-height: var(--af-line-height-body);
  letter-spacing: var(--af-letter-spacing-body);
  color: var(--af-color-text-default);
  background: var(--proto-page-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--af-color-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--af-color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--af-radius-sm);
}

.proto-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.proto-page__back {
  display: inline-flex;
  align-items: center;
  gap: var(--af-space-1);
  font-family: var(--af-font-body);
  font-size: var(--af-font-size-xs);
  color: var(--af-color-text-subtle);
  margin-bottom: var(--af-space-6);
}

.proto-page__back::before {
  content: '\2190'; /* leftward arrow */
  font-size: 14px;
}

.proto-page__title {
  font-family: var(--af-font-heading);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-xl);
  line-height: var(--af-line-height-xl);
  letter-spacing: var(--af-letter-spacing-heading);
  color: var(--af-color-text-default);
  margin: 0 0 var(--af-space-2);
}

.proto-page__subtitle {
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-body);
  line-height: var(--af-line-height-body);
  color: var(--af-color-text-subtle);
  max-width: 64ch;
  margin: 0 0 var(--af-space-8);
}

@media (max-width: 640px) {
  .proto-page { padding: 32px 16px 80px; }
  .proto-page__title { font-size: var(--af-font-size-lg); line-height: var(--af-line-height-lg); }
}

/* ─── Form card ────────────────────────────────────────────────────────── */

.proto-card {
  background: var(--proto-card-bg);
  border: 1px solid var(--proto-card-border);
  border-radius: var(--proto-card-radius);
  padding: var(--proto-card-py) var(--proto-card-px);
}

@media (max-width: 640px) {
  .proto-card { padding: 24px 20px; border-radius: 8px; }
}

.proto-form {
  display: flex;
  flex-direction: column;
  gap: var(--af-space-6);
  max-width: 480px;
  margin: 0 auto;
}

.proto-form--wide { max-width: 640px; }

.proto-section + .proto-section { margin-top: var(--af-space-8); }

.proto-section__heading {
  font-family: var(--af-font-heading);
  font-weight: var(--af-font-weight-regular);
  font-size: var(--af-font-size-summary);
  line-height: var(--af-line-height-summary);
  letter-spacing: var(--af-letter-spacing-summary);
  color: var(--af-color-text-default);
  margin: 0 0 var(--af-space-4);
}

.proto-fields {
  display: flex;
  flex-direction: column;
  gap: var(--af-space-3);
}

/* Side-by-side pair of standalone fields (e.g. City + Postcode).
   The two children keep their own borders + radii; merging is reserved
   for .bg4-row inside .bg4-stack (the merged-variant prototypes). */
.proto-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--af-space-3);
}

@media (max-width: 480px) {
  .proto-pair { grid-template-columns: 1fr; }
}

/* ─── bg4-input: the compact field ──────────────────────────────────────
   Static label-above-value pattern per the BB-98649 Phase 3 design.
   Wrap the whole thing in <label> so clicking the label area focuses
   the value input without manual for/id wiring. Error state uses a
   non-labelled <div> (markup swap on validation).
   ───────────────────────────────────────────────────────────────────── */

.bg4-input {
  background: var(--af-color-surface);
  border: 1px solid var(--af-color-border);
  border-radius: var(--af-radius-md);
  padding: var(--bg4-field-py) var(--bg4-field-px);
  display: flex;
  flex-direction: column;
  gap: var(--bg4-field-row-gap);
  width: 100%;
  position: relative;
  outline: none; /* we draw our own ring via box-shadow */
  transition: border-color var(--af-duration-fast) var(--af-easing-standard),
              box-shadow   var(--af-duration-fast) var(--af-easing-standard);
}

.bg4-input--has-tag {
  padding-right: var(--bg4-field-px-with-tag);
}

.bg4-input__label-row {
  display: flex;
  align-items: flex-start;
  gap: var(--bg4-field-label-gap);
  width: 100%;
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  letter-spacing: var(--af-letter-spacing-body);
}

.bg4-input__label {
  font-weight: var(--af-font-weight-light);
  color: var(--af-color-text-default);
  white-space: nowrap;
  flex-shrink: 0;
}

.bg4-input__hint {
  font-weight: var(--af-font-weight-light);
  color: var(--af-color-text-subtle);
  flex: 1 0 0;
  min-width: 0;
  text-align: right;
}

.bg4-input__tag {
  flex-shrink: 0;
  align-self: flex-start;
  /* Pin the tag to the far right of the label row, regardless of whether
     a hint sits between it and the label. When a hint IS present the
     hint's `flex: 1 0 0` already fills the space; the auto margin is
     harmless then. When no hint is present the auto margin pushes the
     tag from beside the label to the row's right edge (matches Figma). */
  margin-left: auto;
  border: 1px solid var(--af-color-contrast-subtle);
  border-radius: var(--af-radius-md);
  padding: 0 var(--af-space-2);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  color: var(--af-color-text-default);
  background: transparent;
}

.bg4-input__value {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0;
  /* Mylius Modern 16/28, matching the existing InputText component
     and the bg4-input Figma reference. */
  font-family: var(--af-font-heading);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-body);
  line-height: var(--af-line-height-xs-header);
  letter-spacing: var(--af-letter-spacing-heading);
  color: var(--af-color-text-default);
  appearance: none;
  -webkit-appearance: none;
}

.bg4-input__value::placeholder {
  color: var(--af-color-text-subtle);
  opacity: 1;
}

/* Focus state — keyboard only (focus-visible).
   Border swaps to primary blue + 2px outer ring. z-index: 3 so the ring
   sits above both default neighbours (auto) and errored neighbours
   (z-index: 2) inside merged groups. */
.bg4-input:focus-within {
  border-color: var(--af-color-focus-ring);
  box-shadow: 0 0 0 2px var(--af-color-focus-ring);
  z-index: 3;
}

.bg4-input:has(.bg4-input__value:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── bg4-input: trailing affordance (show/hide, etc.) ─────────────────── */

.bg4-input__value-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: var(--af-space-2);
}

.bg4-input__trailing {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-regular);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  color: var(--af-color-primary);
  cursor: pointer;
  letter-spacing: var(--af-letter-spacing-body);
}

.bg4-input__trailing:hover { color: var(--af-color-primary-hover); text-decoration: underline; }
.bg4-input__trailing:focus-visible {
  outline: 2px solid var(--af-color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--af-radius-sm);
}

/* ─── bg4-input: error state ─────────────────────────────────────────────
   Two-section pattern from the current Figma (v2 errored, Section A.2):
     1. Top section — original label-row (dot + label + hint + tag), all in
        red, plus an invisible value placeholder that preserves the field's
        height so errored fields align with default fields in merged stacks.
     2. 1px grey-300 divider.
     3. Error strip — grey-200 background, red dot + label-prefixed error
        message ("Address line 1: Enter a building number or name").
   The whole field has a red border + red-200 background. Inside merged
   groups (stack/row) the corners flatten via the existing border-radius: 0
   rules; nothing else changes.
   ───────────────────────────────────────────────────────────────────── */

.bg4-input--error {
  background: var(--af-color-red-200);
  border-color: var(--af-color-error-default);
  /* Reset the editable-state layout — sections handle their own padding. */
  padding: 0;
  gap: 0;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  /* z-index promotes the red border above sibling grey borders inside a
     merged group, so the error visually wins on all sides. */
  z-index: 2;
}

.bg4-input--error:hover { filter: brightness(0.97); }

.bg4-input--error .bg4-input__value,
.bg4-input--error .bg4-input__value-row { display: none; }

/* Top section: same label-row layout as the editable state, but the
   label and hint render in red. The Optional tag stays neutral (white
   with grey border) per the Figma. */
.bg4-input__top-section {
  display: flex;
  flex-direction: column;
  gap: var(--bg4-field-row-gap);
  padding: var(--bg4-field-py) var(--bg4-field-px);
  width: 100%;
  overflow: hidden;
}

.bg4-input--error .bg4-input__top-section .bg4-input__label,
.bg4-input--error .bg4-input__top-section .bg4-input__hint {
  color: var(--af-color-error-default);
}

/* Invisible value-row placeholder. Preserves the field's full height so
   errored fields don't shrink inside merged stacks. Matches the editable
   value's Mylius 16/28 line-height. */
.bg4-input__value-placeholder {
  height: var(--af-line-height-xs-header);
  opacity: 0;
  visibility: hidden;
  user-select: none;
  pointer-events: none;
}

/* 1px divider between top section and error strip. */
.bg4-input__divider {
  height: 1px;
  width: 100%;
  background: var(--af-color-border);
  flex-shrink: 0;
}

/* Error strip: grey-200 background, red dot + red error message,
   12/20 small-print typography, 4/12 padding. */
.bg4-input__error-strip {
  display: flex;
  align-items: center;
  gap: var(--af-space-2);
  padding: var(--af-space-1) var(--bg4-field-px);
  background: var(--af-color-grey-200);
  width: 100%;
}

.bg4-input__error-message {
  flex: 1 0 0;
  min-width: 0;
  margin: 0;
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  letter-spacing: var(--af-letter-spacing-body);
  color: var(--af-color-error-default);
}

.bg4-input__validation-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--af-color-error-default);
  flex-shrink: 0;
  /* No margin-top — the dot sits inside flex containers using
     `align-items: center`, so it centres optically with the 12/20
     small-print text automatically. */
}

/* Shape variants for multi-error disambiguation. Match the Figma
   error-indicator component (184:509). The dot keeps the same 8x8
   bounding box; clip-path / radii change the rendered shape. */
.bg4-input__validation-dot--circle {
  border-radius: 50%;
}
.bg4-input__validation-dot--triangle {
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
.bg4-input__validation-dot--inverted-triangle {
  border-radius: 0;
  clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
}
.bg4-input__validation-dot--diamond {
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.bg4-input__validation-dot--square {
  border-radius: 0;
}
.bg4-input__validation-dot--pentagon {
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}

/* Sub-groups within the errored top-section label-row. */
.bg4-input__left-group {
  display: flex;
  align-items: center;
  gap: var(--af-space-2);
  flex-shrink: 0;
  min-width: 0;
}
.bg4-input__right-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--af-space-2);
  flex: 1 0 0;
  min-width: 0;
}
.bg4-input__right-group .bg4-input__hint {
  flex: 1 0 0;
  min-width: 0;
}

/* When focused (Tab onto the error banner), keep the red border but draw
   the focus ring so it's obviously focusable. */
.bg4-input--error:focus-visible {
  box-shadow: 0 0 0 2px var(--af-color-focus-ring);
}

/* ─── bg4-stack: vertical merged group ─────────────────────────────────
   Each child shares its border with siblings. Top child rounds top
   corners, bottom child rounds bottom. Errored children inside a stack
   drop their radius so the error sits as a flat band continuous with
   the group's outer border.
   ───────────────────────────────────────────────────────────────────── */

.bg4-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.bg4-stack > .bg4-input { border-radius: 0; }
.bg4-stack > .bg4-input + .bg4-input { margin-top: -1px; }

.bg4-stack > .bg4-input:first-child {
  border-top-left-radius: var(--af-radius-md);
  border-top-right-radius: var(--af-radius-md);
}

.bg4-stack > .bg4-input:last-child {
  border-bottom-left-radius: var(--af-radius-md);
  border-bottom-right-radius: var(--af-radius-md);
}

.bg4-stack > .bg4-input--error { border-radius: 0; }

/* ─── bg4-row: horizontal merged group ─────────────────────────────────
   Same shared-border idea rotated.
   ───────────────────────────────────────────────────────────────────── */

.bg4-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  width: 100%;
}

.bg4-row > .bg4-input { border-radius: 0; }
/* The shared divider is the first cell's right border; the second cell
   (and any subsequent) drop their left border. Using border-left: 0
   instead of a -1px negative margin keeps each cell pinned to its grid
   column, so the row's cells line up flush with sibling fields above
   and below. (The -1px margin trick shaved a pixel off the row's right
   edge and caused visible "extra pixel" misalignments in stacks.) */
.bg4-row > .bg4-input + .bg4-input { border-left: 0; }

.bg4-row > .bg4-input:first-child {
  border-top-left-radius: var(--af-radius-md);
  border-bottom-left-radius: var(--af-radius-md);
}

.bg4-row > .bg4-input:last-child {
  border-top-right-radius: var(--af-radius-md);
  border-bottom-right-radius: var(--af-radius-md);
}

/* Errored cell INSIDE a horizontal merged row.
   Per Section E.2 / InputGroup-horizontal-with-error: the cell shows
   ONLY dot + label (no divider, no internal strip). The error message
   lives in a sibling .bg4-row__error-strip placed BELOW the row, full
   width, sharing the same red border. */
.bg4-row > .bg4-input--error .bg4-input__divider,
.bg4-row > .bg4-input--error .bg4-input__error-strip {
  display: none;
}

/* When the row has a sibling error strip below, flatten the row's
   bottom corners so the row + strip read as one bordered unit. */
.bg4-row:has(+ .bg4-row__error-strip) > .bg4-input:first-child {
  border-bottom-left-radius: 0;
}
.bg4-row:has(+ .bg4-row__error-strip) > .bg4-input:last-child {
  border-bottom-right-radius: 0;
}

/* Row-level error strip — sibling of .bg4-row. Carries the same red
   border on the sides + bottom; the top edge merges with the row's
   bottom edge via a -1px overlap (matches the stack/row collapsed
   border pattern). Default has rounded bottom corners for standalone
   use; inside a bg4-stack the bottoms are flattened (see below) so the
   strip can collapse with the field below it. */
.bg4-row__error-strip {
  background: var(--af-color-grey-200);
  border: 1px solid var(--af-color-error-default);
  border-bottom-left-radius: var(--af-radius-md);
  border-bottom-right-radius: var(--af-radius-md);
  padding: var(--af-space-1) var(--bg4-field-px);
  margin-top: -1px;
  display: flex;
  flex-direction: column;
  gap: var(--af-space-1);
  width: 100%;
  position: relative;
  z-index: 2;
}

/* When the strip sits inside a bg4-stack and isn't the final child,
   flatten its bottom corners and collapse its bottom border with the
   following field. The stack's own :last-child rules take care of
   rounding the actual bottom of the group. */
.bg4-stack > .bg4-row__error-strip:not(:last-child) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.bg4-stack > .bg4-row__error-strip + .bg4-input,
.bg4-stack > .bg4-row__error-strip + .bg4-row {
  margin-top: -1px;
}

.bg4-row__error-strip-item {
  display: flex;
  align-items: center;
  gap: var(--af-space-2);
}

.bg4-row__error-strip-item .bg4-input__error-message {
  margin: 0;
}

/* Mixed grid: rows of horizontal sub-rows in a stack */
.bg4-stack > .bg4-row > .bg4-input { border-radius: 0; }
.bg4-stack > .bg4-row + .bg4-row { margin-top: -1px; }
.bg4-stack > .bg4-row + .bg4-input { margin-top: -1px; }
.bg4-stack > .bg4-input + .bg4-row { margin-top: -1px; }

.bg4-stack > .bg4-row:first-child > .bg4-input:first-child {
  border-top-left-radius: var(--af-radius-md);
}
.bg4-stack > .bg4-row:first-child > .bg4-input:last-child {
  border-top-right-radius: var(--af-radius-md);
}
.bg4-stack > .bg4-row:last-child > .bg4-input:first-child {
  border-bottom-left-radius: var(--af-radius-md);
}
.bg4-stack > .bg4-row:last-child > .bg4-input:last-child {
  border-bottom-right-radius: var(--af-radius-md);
}

/* Container query: merged horizontal rows collapse to vertical stacks
   below 320px container inline-size (ADR-0001 fallback). */
.bg4-row {
  container-type: inline-size;
}

@container (inline-size < 320px) {
  .bg4-row {
    grid-auto-flow: row;
    grid-auto-columns: auto;
  }
  .bg4-row > .bg4-input + .bg4-input {
    margin-left: 0;
    margin-top: -1px;
  }
  .bg4-row > .bg4-input:first-child {
    border-top-right-radius: var(--af-radius-md);
    border-bottom-left-radius: 0;
  }
  .bg4-row > .bg4-input:last-child {
    border-bottom-left-radius: var(--af-radius-md);
    border-top-right-radius: 0;
  }
}

/* ─── bg4-group: outer wrapper providing role="group" and group label ─── */

.bg4-group {
  display: flex;
  flex-direction: column;
  gap: var(--af-space-2);
  width: 100%;
}

.bg4-group__label {
  font-family: var(--af-font-body);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  font-weight: var(--af-font-weight-semibold);
  color: var(--af-color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Submit button (matches src/components/Button/Button.css primary) ─── */

.proto-submit {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--af-space-2);
  padding: var(--af-button-py) var(--af-button-px);
  border: none;
  border-radius: var(--af-button-radius);
  font-family: var(--af-font-heading);
  font-size: var(--af-button-font-size);
  font-weight: var(--af-font-weight-regular);
  line-height: var(--af-line-height-button);
  letter-spacing: var(--af-letter-spacing-body);
  text-align: center;
  cursor: pointer;
  background: var(--af-color-primary);
  color: var(--af-color-primary-text);
  box-shadow: var(--af-shadow-button), var(--af-shadow-button-inset);
  transition:
    background var(--af-duration-fast) var(--af-easing-standard),
    box-shadow var(--af-duration-fast) var(--af-easing-standard);
  margin-top: var(--af-space-4);
  align-self: stretch;
}

.proto-submit:hover:not(:disabled) { background: var(--af-color-primary-hover); }
.proto-submit:active:not(:disabled) { background: var(--af-color-blue-600); box-shadow: none; }
.proto-submit:focus-visible {
  outline: 2px solid var(--af-color-focus-ring);
  outline-offset: 3px;
}
.proto-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Inline form-level message + success state ─────────────────────────
   Matches the AF-Home Message component pattern: bordered, padded, icon
   placeholder via coloured dot.
   ───────────────────────────────────────────────────────────────────── */

.proto-message {
  display: flex;
  gap: var(--af-space-3);
  align-items: flex-start;
  padding: var(--af-space-3) var(--af-space-4);
  border: 1px solid var(--af-color-border);
  border-radius: var(--af-radius-md);
  background: var(--af-color-surface);
  font-size: var(--af-font-size-body);
  line-height: var(--af-line-height-body);
  color: var(--af-color-text-default);
}

.proto-message--success {
  border-color: var(--af-color-green-500);
  background: var(--af-color-green-200);
}

.proto-message--error {
  border-color: var(--af-color-error-default);
  background: var(--af-color-red-200);
}

.proto-message__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 8px;
  background: currentColor;
}

.proto-message--success .proto-message__dot { background: var(--af-color-green-500); }
.proto-message--error   .proto-message__dot { background: var(--af-color-error-default); }

.proto-message__title {
  font-family: var(--af-font-heading);
  font-weight: var(--af-font-weight-regular);
  margin: 0 0 var(--af-space-1);
}

.proto-message__body {
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-light);
  margin: 0;
  color: var(--af-color-text-subtle);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
}

/* ─── Header strip ─────────────────────────────────────────────────────── */

.proto-header {
  background: var(--af-color-surface);
  border-bottom: 1px solid var(--af-color-border);
  padding: var(--af-space-4) var(--af-space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.proto-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--af-space-2);
}

.proto-header__wordmark {
  font-family: var(--af-font-heading);
  font-weight: var(--af-font-weight-regular);
  font-size: var(--af-font-size-summary);
  letter-spacing: var(--af-letter-spacing-summary);
  color: var(--af-color-text-default);
}

.proto-header__crumb {
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-xs);
  color: var(--af-color-text-subtle);
}

/* ─── Reduced motion ───────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ─── Visually hidden (used for the error-prefix announcement) ─────────── */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────────────────
   Default-density input visuals
   Mirrored from src/components/InputText/InputText.css and
   src/components/InputPassword/InputPassword.css. Used by the
   default-density prototypes (cell A of the user test). Field
   structure is: label-row → hint → error-message → input → toggle
   (toggle is password-only).
   ────────────────────────────────────────────────────────────────── */

.af-input {
  display: flex;
  flex-direction: column;
  gap: var(--af-space-1);
  width: 100%;
  /* AF-Home's React InputText caps at 593px; the prototype form has its
     own max-width (480 for sign-up, 640 for checkout) and we want every
     field — single or in a pair — to end at the same right edge, so the
     per-field cap is removed here. */
}

.af-input__label-row {
  display: flex;
  align-items: center;
  gap: var(--af-space-2);
}

.af-input__label {
  font-family: var(--af-font-heading);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-body);
  line-height: var(--af-line-height-xs-header);
  letter-spacing: var(--af-letter-spacing-heading);
  color: var(--af-color-text-default);
  white-space: nowrap;
}

.af-input__optional {
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  letter-spacing: var(--af-letter-spacing-xs);
  color: var(--af-color-text-subtle);
}

.af-input__hint {
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  letter-spacing: var(--af-letter-spacing-xs);
  color: var(--af-color-text-subtle);
  margin: 0;
}

.af-input__error-message {
  font-family: var(--af-font-body);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  letter-spacing: var(--af-letter-spacing-xs);
  color: var(--af-color-error-default);
  margin: 0;
}

.af-input__input {
  background: var(--af-color-surface);
  border: 1px solid var(--af-color-grey-700);
  border-radius: var(--af-radius-md);
  padding: var(--af-space-3) var(--af-space-4);
  width: 100%;
  font-family: var(--af-font-heading);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-body);
  line-height: var(--af-line-height-xs-header);
  letter-spacing: var(--af-letter-spacing-heading);
  color: var(--af-color-text-default);
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  transition:
    border-color var(--af-duration-fast) var(--af-easing-standard),
    outline-color var(--af-duration-fast) var(--af-easing-standard);
}

.af-input__input::placeholder {
  color: var(--af-color-text-subtle);
}

.af-input__input:focus { outline: none; }

.af-input__input:focus-visible {
  outline: 2px solid var(--af-color-focus-ring);
  outline-offset: 2px;
}

.af-input__input--error {
  border-color: var(--af-color-error-default);
}

.af-input__input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Show/hide toggle for password fields - lifted from
   InputPassword.css. Renders below the input as a small text-link. */
.af-input__toggle {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--af-font-heading);
  font-weight: var(--af-font-weight-light);
  font-size: var(--af-font-size-xs);
  line-height: var(--af-line-height-xs);
  letter-spacing: var(--af-letter-spacing-xs);
  color: var(--af-color-primary);
  text-decoration: underline;
  margin-top: var(--af-space-1);
}

.af-input__toggle:focus { outline: none; }

.af-input__toggle:focus-visible {
  outline: 2px solid var(--af-color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--af-radius-sm);
}

.af-input__toggle:hover {
  color: var(--af-color-primary-hover);
}

/* Default-density fields stack vertically with normal spacing; no
   merged/group treatment exists for default density. */
.proto-fields--default {
  display: flex;
  flex-direction: column;
  gap: var(--af-space-5);
}

/* Side-by-side pair in default density (e.g. City + Postcode,
   Expiry + CVC). Same responsive collapse threshold as the compact
   .proto-pair. */
.proto-pair--default {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--af-space-5);
}

@media (max-width: 480px) {
  .proto-pair--default { grid-template-columns: 1fr; }
}
