/* ============================================================
   product-edit-basics.css  ·  t-004 (worker-4)
   Scope: .pe-section[data-section="basics"] only — Title /
   Description / Category / SKU.

   Rules of engagement (frozen_contract):
   • Reuses the shared .pe-field component owned by t-008
     (product-edit-fields.css). This file does NOT redefine
     field BASE styles (.pe-field__input padding/border/etc.).
     It only handles BASICS-section layout, the category select
     polish, helper-text tidy, and the live char-counter node.
   • Loads AFTER product-edit-fields.css and BEFORE polish, per
     the documented partial order.
   Brand tokens come from colors_and_type.css (--accent = terra-500,
   --canvas cream, --font-display Fraunces, --font-body DM Sans).
   ============================================================ */

/* ---- Section field rhythm ------------------------------------
   Stack the basics fields with a consistent vertical rhythm and
   align the Category | SKU pair on one row. .pe-grid--2 base may
   be defined upstream; this scoped block guarantees the basics
   row aligns cleanly regardless and stays single-column on small
   screens (macro breakpoints remain t-003's responsibility).      */
.pe-section[data-section="basics"] .pe-section__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.pe-section[data-section="basics"] .pe-grid--2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4) var(--space-5);
  align-items: start;            /* labels/inputs top-align even when
                                    one field has a hint and the other doesn't */
}

@media (max-width: 560px) {
  .pe-section[data-section="basics"] .pe-grid--2 {
    grid-template-columns: 1fr;
  }
}

/* ---- Label row: make room for the live char counter ----------
   Turn the label into a baseline-aligned row so the counter sits
   flush-right of the label text ("Title            108/120").
   Scoped to basics so other sections' labels are untouched.       */
.pe-section[data-section="basics"] .pe-field__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

/* ---- Live character counter (injected by the JS patch) -------- */
.pe-section[data-section="basics"] .pe-charcount {
  flex: 0 0 auto;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  color: var(--fg3);                 /* ink-muted — quiet by default */
  font-variant-numeric: tabular-nums;/* digits don't jitter while typing */
  letter-spacing: 0.01em;
  transition: color var(--dur-fast) var(--ease-out);
}
.pe-section[data-section="basics"] .pe-charcount--warn {
  color: var(--terra-600);           /* approaching the limit */
}
.pe-section[data-section="basics"] .pe-charcount--over {
  color: #B42318;                    /* over the hard limit — red */
  font-weight: 600;
}

/* ---- Description textarea: comfortable typing height ---------- */
.pe-section[data-section="basics"] textarea.pe-field__input {
  min-height: 7.5rem;
  resize: vertical;
  line-height: 1.55;
}

/* ---- Category select polish: custom caret --------------------
   Section-level enhancement only (not a base redefinition). If
   t-008's fields partial already draws a select caret, DELETE
   this block to avoid a double caret. The caret is a warm-ink
   chevron sized to the field, with right padding so long option
   labels never collide with it.                                   */
.pe-section[data-section="basics"] select.pe-field__input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: var(--space-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237A6F68' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  cursor: pointer;
}
/* Dim the placeholder option ("Choose category…") until a real
   category is picked, so the field reads as empty-but-optional.   */
.pe-section[data-section="basics"] select.pe-field__input:has(option[value=""]:checked) {
  color: var(--fg3);
}

/* ---- Helper text tidy ----------------------------------------
   Keep hints close to their input and quietly toned. Base hint
   styling is t-008's; this only nudges spacing inside basics.     */
.pe-section[data-section="basics"] .pe-field__hint {
  margin-top: var(--space-2);
}

/* SKU value reads better as monospace-ish — codes line up.        */
.pe-section[data-section="basics"] #pfSku.pe-field__input {
  font-feature-settings: "tnum" 1;
  letter-spacing: 0.02em;
}
