/*
 * Feld-Baustein "Beschriftung im Feld" (Stil B Weiß, Eigentümer 2026-11-17).
 * Shared by the guest pages and the dashboard: every surface sets the --fb-* tokens itself
 * (light and dark); this file only holds fallbacks, no :root values.
 *
 *   div.fblock                      one block: frame, radius, fill
 *     div.frow  [style="--cols:…"]  one line of cells, divider above the next line
 *       label.fcell                 one field: label on top inside the field, the real control below
 *         span.fcell-label          "Name" (+ em "optional")
 *         input | select | textarea
 *         span.fcell-unit           "€", "Min." … at the end of the field
 *   p.fblock-note / .fblock-error   hint or error under the block
 *
 * The label is always visible and never a placeholder. While a text field is empty and not focused the label
 * sits where the value would be (16 px) and moves up when the guest types or focuses; it is a transform, so
 * nothing around it moves (D-142), and reduced motion turns the movement off. In a text area the empty label
 * stands top left instead, as far from the top as from the left (D-249).
 */
.fblock {
  --fb-r: var(--fb-radius, 14px);
  position: relative;
  display: grid;
  min-width: 0;
  border: 1px solid var(--fb-border, rgb(16 16 19 / .16));
  border-radius: var(--fb-r);
  background: var(--fb-bg, #fff);
  color: var(--fb-ink, #101013);
  font-family: var(--fb-font, inherit);
}
.fblock[hidden], .frow[hidden], .fcell[hidden] { display: none; }
.frow { display: grid; grid-template-columns: var(--cols, 1fr); min-width: 0; }
.frow + .frow { border-top: 1px solid var(--fb-divider, rgb(16 16 19 / .1)); }
.fcell {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 62px;
  margin: 0;
  padding: 10px 16px 9px;
  box-sizing: border-box;
  cursor: text;
  -webkit-tap-highlight-color: transparent;
}
.fcell + .fcell { border-left: 1px solid var(--fb-divider, rgb(16 16 19 / .1)); }
/* Cells take the block's corners, so focus and error frames follow them. */
.frow:first-child > .fcell:first-child { border-top-left-radius: var(--fb-r); }
.frow:first-child > .fcell:last-child { border-top-right-radius: var(--fb-r); }
.frow:last-child > .fcell:first-child { border-bottom-left-radius: var(--fb-r); }
.frow:last-child > .fcell:last-child { border-bottom-right-radius: var(--fb-r); }

.fblock .fcell > .fcell-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  color: var(--fb-label, #6b6b74);
  font-family: var(--fb-font, inherit); font-size: 12.5px; font-weight: 500; line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform-origin: left center;
  transition: transform .16s ease, color .16s ease;
  pointer-events: none;
}
.fblock .fcell > .fcell-label em { font-style: normal; font-weight: 400; opacity: .78; }

/* The real control, stripped of every page-wide input look (app.css, order-themes.css, dashboard.css). */
.fblock .fcell > :is(input, select, textarea) {
  display: block;
  width: 100%;
  min-width: 0;
  height: auto !important;
  min-height: 0 !important;
  margin: 4px 0 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  color: var(--fb-ink, #101013) !important;
  font-family: var(--fb-font, inherit); font-size: 16px; font-weight: 400; line-height: 1.35;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  -webkit-appearance: none;
  appearance: none;
}
.fblock .fcell > textarea { resize: none; min-height: 3.9em !important; line-height: 1.45; }
.fblock .fcell > :is(input, textarea)::placeholder { color: var(--fb-label, #6b6b74); opacity: .7; }
.fblock .fcell > select { padding-right: 22px !important; cursor: pointer; text-overflow: ellipsis; }
.fcell:has(> select)::before {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  background: var(--fb-label, #6b6b74);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}
.fcell:has(> select) { cursor: pointer; }
.fcell:has(> textarea) { justify-content: flex-start; padding-top: 12px; }

/* Unit at the end of the field: the value and the unit share one line. */
.fcell:has(> .fcell-unit) { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-content: center; }
.fcell:has(> .fcell-unit) > .fcell-label { grid-column: 1 / -1; }
.fblock .fcell > .fcell-unit { align-self: end; margin-top: 4px; color: var(--fb-label, #6b6b74); font-family: var(--fb-font, inherit); font-size: 16px; font-weight: 400; line-height: 1.35; pointer-events: none; }

/* Empty and not focused: the label stands where the value goes. Needs placeholder=" " on the control. */
/* The label grows by 1.28 from its left edge; its box is narrowed by the same factor, so it still ends at the
   field's edge. Without that the grown box stuck out and made phone pages wider than the screen (2026-11-17). */
.fcell:not(:focus-within):has(> :is(input, textarea):placeholder-shown) > .fcell-label { transform: translateY(13px) scale(1.28); width: calc(100% / 1.28); }
/* Text areas (D-249): the empty label stands top left, as far from the top as from the left, in every size. */
.fcell:has(> textarea:placeholder-shown):not(:focus-within) > .fcell-label { transform: translateY(5px) scale(1.28); }
.fcell:not(:focus-within):has(> :is(input, textarea):placeholder-shown) > .fcell-unit { opacity: 0; }

/* Focus: the field turns white (dark designs: one step lighter) with a 2 px frame in the text colour. */
.fcell:focus-within { background: var(--fb-bg-focus, #fff); z-index: 1; }
.fcell:focus-within::after, .fcell.is-error::after, .fcell:has(> [aria-invalid="true"])::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 2px solid var(--fb-focus, #101013);
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
}
.fcell.is-error, .fcell:has(> [aria-invalid="true"]) { background: color-mix(in srgb, var(--fb-error, #c4320a) 7%, var(--fb-bg, #fff)); }
.fcell.is-error::after, .fcell:has(> [aria-invalid="true"])::after { border-color: var(--fb-error, #c4320a); border-width: 1.5px; }
.fcell:focus-within:has(> [aria-invalid="true"])::after { border-width: 2px; }
.fblock .fcell:is(.is-error, :has(> [aria-invalid="true"])) > .fcell-label { color: var(--fb-error, #c4320a); }
.fcell:has(> :disabled) { cursor: default; }
.fblock .fcell:has(> :disabled) > :is(.fcell-label, input, select, textarea) { opacity: .55; }

.fblock-note, .fblock-error { margin: 8px 2px 0; font-size: 13px; line-height: 1.4; color: var(--fb-label, #6b6b74); }
.fblock-error { display: flex; gap: 7px; align-items: flex-start; color: var(--fb-error, #c4320a); }

@media (max-width: 560px) {
  .frow.frow-stack { grid-template-columns: 1fr; }
  .frow.frow-stack > .fcell + .fcell { border-left: 0; border-top: 1px solid var(--fb-divider, rgb(16 16 19 / .1)); }
  .frow.frow-stack > .fcell { border-radius: 0; }
  .frow.frow-stack:first-child > .fcell:first-child { border-radius: var(--fb-r) var(--fb-r) 0 0; }
  .frow.frow-stack:last-child > .fcell:last-child { border-radius: 0 0 var(--fb-r) var(--fb-r); }
  .fcell { padding-inline: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .fblock .fcell > .fcell-label { transition: none; }
}

/*
 * Autofill (Eigentümer 2026-11-20): Chrome, Safari and password managers paint filled fields blue or yellow
 * (Chrome dark: a blue bar behind the text). On every page the field keeps its own look: the browser's fill
 * colour is held back by a transition that never ends, the text stays in the field's ink, the caret too.
 * Two rules, because a browser that does not know one of the pseudo-classes drops the whole rule.
 */
input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-text-fill-color: var(--fb-ink, CanvasText);
  caret-color: var(--fb-ink, CanvasText);
  transition: background-color 600000s 0s, color 600000s 0s !important;
}
input:autofill, textarea:autofill, select:autofill {
  -webkit-text-fill-color: var(--fb-ink, CanvasText);
  caret-color: var(--fb-ink, CanvasText);
  transition: background-color 600000s 0s, color 600000s 0s !important;
}

/* Rows that open on demand (Als Firma bestellen) stand at the end of a block: while they are hidden, the last row the
   guest sees takes the bottom corners, so focus and error frames follow the block. */
.frow:not([hidden]):not(:has(~ .frow:not([hidden]))) > .fcell:first-child { border-bottom-left-radius: var(--fb-r); }
.frow:not([hidden]):not(:has(~ .frow:not([hidden]))) > .fcell:last-child { border-bottom-right-radius: var(--fb-r); }
