/* ==========================================================================
   Input Fields — extracted from Figma section (32:7013)

   Sizes: L (64px), M (56px), S (48px), XS (40px)
   States: Calm, Hover, Focus, Focus-label, Filled, Filled-label,
           Error, Error-label, Disabled, Disabled-label

   Calm:    bg carbon-300 (#1d1d21), no border
   Hover:   bg carbon-300, border 1px carbon-400
   Focus:   bg carbon-100 (#070708), border 1px carbon-500 (#626266)
   Error:   border 1px rose-400 (#ff9c9c), bg transparent
   Disabled: opacity 0.4
   ========================================================================== */

/* ==========================================================================
   INPUT BASE
   ========================================================================== */

.input {
  display: flex;
  align-items: center;
  width: 100%;
  /* Dark: carbon-300 surface, no border (transparent).
     Light: bg-elevated near-white surface + 8% black hairline so the
     field still reads as a tangible input against a white page. */
  background-color: light-dark(var(--bg-elevated), var(--color-carbon-300));
  border: 1px solid light-dark(var(--border-default), transparent);
  border-radius: var(--radius-16);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.2;
  outline: none;
  transition: background-color var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
  caret-color: var(--color-purple-500);
}

.input::placeholder {
  /* text-tertiary (4.91:1 on black) keeps the placeholder visibly secondary
     without dropping below WCAG AA. white-40 alone was 3.6:1 and failed. */
  color: var(--text-tertiary);
}

/* Hover — border subtly strengthens. Dark: carbon-400; light: themed
   --border-strong (12% black) to stay tonally consistent. */
.input:hover:not(:focus):not(:disabled):not(.is-error) {
  border-color: light-dark(var(--border-strong), var(--color-carbon-400));
}

/* Focus — dark uses darker carbon chrome; light goes fully white with a
   purple-400 brand border to mark the active field. */
.input:focus,
.input.is-focus {
  background-color: light-dark(var(--color-white), var(--color-carbon-100));
  border-color: light-dark(var(--color-purple-400), var(--color-carbon-500));
}

/* Error */
.input.is-error,
.input:invalid:not(:placeholder-shown) {
  border-color: var(--color-rose-400);
  background-color: transparent;
}

/* Disabled */
.input:disabled,
.input.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ==========================================================================
   INPUT SIZES
   L=64 M=56 S=48 XS=40 — padding 12px horizontal
   Font sizes: L=18 M=16 S=14 XS=14
   ========================================================================== */

.input-l {
  height: 64px;
  padding: 0 12px;
  font-size: 18px;
}

.input-m {
  height: 56px;
  padding: 0 12px;
  font-size: 16px;
}

.input-s {
  height: 48px;
  padding: 0 12px;
  font-size: 14px;
}

.input-xs {
  height: 40px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: var(--radius-12);
}

/* ==========================================================================
   INPUT WITH FLOATING LABEL
   Label floats above the value when filled/focused.
   Label: 14px white/40%
   Value: 16px (L), 14px (M/S/XS) white
   ========================================================================== */

.input-field {
  position: relative;
  width: 100%;
}

.input-field .input {
  padding-top: 24px;
  padding-bottom: 6px;
}

.input-field .input-label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: 400;
  /* Input surface flips to a light bg in light theme, so the label must flip
     too. light-dark(dark, light) gives black-on-light (AA ~10:1) and
     white-on-dark (AA ~10:1). Passing both WCAG AA at 12px normal weight. */
  color: light-dark(rgba(0, 0, 0, 0.72), rgba(255, 255, 255, 0.72));
  pointer-events: none;
  transition: top var(--duration-base) var(--ease-out), font-size var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

/* Label floated up when input has value or is focused.
   top: 12px leaves ≥6px gap between label bottom (~22px) and text start (~28px). */
.input-field .input:focus + .input-label,
.input-field .input:not(:placeholder-shown) + .input-label,
.input-field .input.has-value + .input-label {
  top: 12px;
  transform: translateY(0);
  font-size: 12px;
}

/* Clear button for error state */
.input-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin-right: 4px;
  background: none;
  border: none;
  color: var(--color-white-40);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  transition: color var(--duration-base) var(--ease-out);
}

.input-clear:hover {
  color: var(--text-primary);
}

.input-clear svg {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   COPY BUTTON — trailing affordance for readonly inputs.
   Pair with <input readonly> inside an .input-wrap. Main.js handles the
   click: reads the input's value, writes to navigator.clipboard, and shows
   a 1.2s "copied" state (lime checkmark) as feedback.
   ========================================================================== */

.input-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  margin-right: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  transition: color var(--duration-base) var(--ease-out),
              background-color var(--duration-base) var(--ease-out);
}

.input-copy:hover {
  color: var(--text-primary);
  background-color: var(--color-white-8);
}

.input-copy:focus-visible {
  outline: 2px solid var(--color-purple-400);
  outline-offset: 2px;
}

.input-copy.is-copied {
  color: var(--color-electric-lime);
}

.input-copy svg,
.input-copy .input-copy-icon {
  width: 20px;
  height: 20px;
}

/* Library icon driven by `--icon: url(...)` — paints in currentColor so the
   button's existing `color: var(--text-secondary)` (and hover/copied states)
   theme it automatically. Use this instead of inline SVGs — the project rule
   is "icons come from /assets/icons/ only". */
.input-copy .input-copy-icon {
  display: inline-block;
  background-color: currentColor;
  mask-image: var(--icon);
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: var(--icon);
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

/* ==========================================================================
   INPUT WITH TITLE (external label above)
   ========================================================================== */

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.input-title {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
}

/* ==========================================================================
   ERROR & HELPER TEXT
   ========================================================================== */

.input-helper {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px 0;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.2;
  /* text-tertiary (white/black 56%) gives 4.91:1 and stays readable at 12px. */
  color: var(--text-tertiary);
}

.input-error-text {
  /* rose-400 (#ff9c9c) is only 2:1 on white — fails AA. accent-rose-text
     drops to rose-600 in light for the needed 4.77:1, and keeps rose-400
     in dark for 8.5:1 on #0a0a0a. */
  color: var(--accent-rose-text);
}

/* ==========================================================================
   INPUT WITH ICON / CLEAR BUTTON — wrapper
   ========================================================================== */

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-wrap .input {
  flex: 1;
  padding-right: 40px;
}

.input-wrap .input-clear,
.input-wrap .input-copy {
  position: absolute;
  right: 8px;
}

/* ==========================================================================
   TEXTAREA
   Same styling as input, auto-height
   ========================================================================== */

.textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 16px 12px;
  /* Theme swap mirrors .input above — carbon surface on dark, elevated
     white + hairline border on light. */
  background-color: light-dark(var(--bg-elevated), var(--color-carbon-300));
  border: 1px solid light-dark(var(--border-default), transparent);
  border-radius: var(--radius-16);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  resize: vertical;
  outline: none;
  transition: background-color var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
  caret-color: var(--color-purple-500);
  /* Prevent resize handle from clipping at rounded corners */
  overflow: hidden;
}

.textarea::placeholder {
  color: var(--text-tertiary);
}

.textarea:hover:not(:focus) {
  border-color: light-dark(var(--border-strong), var(--color-carbon-400));
}

.textarea:focus {
  background-color: light-dark(var(--color-white), var(--color-carbon-100));
  border-color: light-dark(var(--color-purple-400), var(--color-carbon-500));
}

/* Light-theme input + textarea styling is folded into each component's
   base rules above via light-dark(). The carbon backgrounds that work
   on dark don't read on a white page, so light swaps to an elevated
   surface + hairline border pattern; focus pops via purple-400 brand. */
