/* ============================================================
   100Media UI/UX Design Standards v3 — components.css
   Requires tokens.css. Every state matrix from the standard,
   implemented. No component ships without its full matrix.
   ============================================================ */

/* ============================================================
   BUTTONS
   [V 7:31] default / hover / active / disabled minimum, + loading
   [V 7:21] horizontal padding ~= 2x vertical
   [C @HarrisonEpperson] state changes are INSTANT, not animated
   ============================================================ */

.btn {
  --btn-py: var(--s-4);          /* 16px — annotated on screen [O 6:53] */
  --btn-px: var(--s-8);          /* 32px — exactly double. The ratio. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--tap-min);
  padding: var(--btn-py) var(--btn-px);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  position: relative;
  /* Instant. Animating hover/press adds perceived latency. */
  transition: background-color var(--t-instant) var(--ease-std),
              border-color     var(--t-instant) var(--ease-std),
              color            var(--t-instant) var(--ease-std);
}

/* --- Variants --- */
.btn--primary   { background: var(--brand-600); color: #fff; }
.btn--primary:hover  { background: var(--brand-700); }
.btn--primary:active { background: var(--brand-800); }

.btn--secondary { background: transparent; color: var(--brand-700); border-color: var(--border-str); }
.btn--secondary:hover  { background: var(--brand-50); border-color: var(--brand-400); }
.btn--secondary:active { background: var(--brand-100); }

/* [V 7:09] Sidebar links are just buttons with no background until hover. */
.btn--ghost     { background: transparent; color: var(--text-2); font-weight: 500; }
.btn--ghost:hover  { background: var(--surface-2); color: var(--text); }
.btn--ghost:active { background: var(--border); }

/* Raised tactile variant. Frames show the pressed state INVERTS the
   shadow stack rather than just darkening the fill, which is what makes
   the press read as physical. Use sparingly: a page of these fails the
   "if you noticed the shadow first" test. [V 6:44] */
.btn--raised    { background: var(--surface); color: var(--text); box-shadow: var(--e-raised); }
.btn--raised:hover  { background: var(--surface-2); }
.btn--raised:active { box-shadow: var(--e-pressed); transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { .btn--raised:active { transform: none; } }

.btn--danger    { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(0.92); }

/* --- Disabled: visible, explained, not hidden --- */
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.4);
}
.btn:disabled:hover { background: inherit; }

/* --- Loading: width locked so the row does not reflow --- */
.btn[data-loading="true"] {
  pointer-events: none;
  color: transparent;          /* label hidden, box preserved */
}
.btn[data-loading="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1em; height: 1em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--r-full);
  color: #fff;
  animation: spin 700ms linear infinite;
}
.btn--secondary[data-loading="true"]::after,
.btn--ghost[data-loading="true"]::after { color: var(--brand-700); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Under reduced motion the spinner stops; a static ring still reads as busy. */
@media (prefers-reduced-motion: reduce) {
  .btn[data-loading="true"]::after { animation: none; border-top-color: currentColor; opacity: 0.5; }
}

/* --- Success: only when the result is not otherwise visible --- */
.btn[data-state="success"] { background: var(--success); color: #fff; }

/* --sm is desktop-density only; the 390px block below restores the 44px floor. */
.btn--sm { --btn-py: var(--s-2); --btn-px: var(--s-4); min-height: var(--tap-min); font-size: var(--fs-sm); }
@media (hover: hover) and (pointer: fine) { .btn--sm { min-height: 36px; } }
.btn--lg { --btn-py: var(--s-4); --btn-px: var(--s-8); font-size: 20px; }

/* [V 7:15] The standard CTA pair. */
.cta-pair { display: flex; flex-wrap: wrap; gap: var(--s-3); }


/* ============================================================
   INPUTS  — "even more critical" than buttons [V 7:43]
   default / focus / filled / error / warning / disabled / validating
   ============================================================ */

.field { display: flex; flex-direction: column; gap: var(--s-2); }

/* Persistent visible label. A placeholder is not a label. */
.field__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  line-height: var(--lh-dense);
}
.field__req { color: var(--danger); margin-left: 2px; }

.field__wrap { position: relative; display: flex; align-items: center; }

.input {
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-str);
  border-radius: var(--r-md);
  font: inherit;
  font-size: var(--fs-body);     /* 16px — stops iOS zoom-on-focus */
  transition: border-color var(--t-instant) var(--ease-std),
              box-shadow   var(--t-instant) var(--ease-std);
}
.input::placeholder { color: var(--text-3); }

.input:focus-visible {
  outline: none;                                  /* replaced, not removed */
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px hsl(var(--brand-h) var(--brand-s) 50% / 0.22);
}

.input[data-filled="true"] { border-color: var(--border-str); background: var(--surface); }

/* Error = red border + icon + message. Border alone is color-only. */
.input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-bg); }
.input[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent);
}

.input[data-warning="true"] { border-color: var(--warning-br); background: var(--warning-bg); }

.input:disabled,
.input[readonly] {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
  border-color: var(--border);
}

/* Async validation spinner sits in the trailing slot. */
.field__spinner {
  position: absolute; right: var(--s-3);
  width: 16px; height: 16px;
  border: 2px solid var(--border-str);
  border-top-color: var(--brand-600);
  border-radius: var(--r-full);
  animation: spin 700ms linear infinite;
}

/* Messages: icon + text, never color alone. Bound via aria-describedby. */
.field__msg {
  display: flex; align-items: flex-start; gap: var(--s-2);
  font-size: var(--fs-sm);
  line-height: var(--lh-dense);
  color: var(--text-3);
}
.field__msg--error   { color: var(--danger); font-weight: 500; }
.field__msg--warning { color: var(--warning); font-weight: 500; }
.field__msg--success { color: var(--success); font-weight: 500; }
.field__msg .icon { width: 1em; height: 1em; margin-top: 0.2em; }


/* ============================================================
   CHIPS / BADGES  — semantic, with three depths each
   ============================================================ */

.chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-full);
  border: 1px solid;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: var(--lh-dense);
  white-space: nowrap;
}
.chip--neutral { background: var(--surface-2);  border-color: var(--border);     color: var(--text-2); }
.chip--info    { background: var(--info-bg);    border-color: var(--info-br);    color: var(--info); }
.chip--success { background: var(--success-bg); border-color: var(--success-br); color: var(--success); }
.chip--warning { background: var(--warning-bg); border-color: var(--warning-br); color: var(--warning); }
.chip--danger  { background: var(--danger-bg);  border-color: var(--danger-br);  color: var(--danger); }


/* ============================================================
   CARDS & ELEVATION  — max 4 levels
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--e-1);
  padding: var(--s-6);
}
.card--raised   { box-shadow: var(--e-2); }
.card--floating { box-shadow: var(--e-3); }   /* dropdowns, popovers */
.card--modal    { box-shadow: var(--e-4); }

/* Interactive cards animate an overlay, not box-shadow (repaint cost). */
.card--interactive { position: relative; cursor: pointer; transition: transform var(--t-state) var(--ease-out); }
.card--interactive::after {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit; box-shadow: var(--e-3);
  opacity: 0; transition: opacity var(--t-state) var(--ease-out);
  pointer-events: none;
}
.card--interactive:hover::after { opacity: 1; }
.card--interactive:hover { transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .card--interactive:hover { transform: none; } }


/* ============================================================
   IMAGE + TEXT OVERLAYS  [V 8:37]
   Gradient is the default. Solid scrim wastes the image.
   ============================================================ */

.overlay { position: relative; overflow: hidden; border-radius: var(--r-lg); isolation: isolate; }
.overlay > img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Default: gradient resolving into a readable base under the text. */
.overlay::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top,
    rgb(0 0 0 / 0.86) 0%,
    rgb(0 0 0 / 0.58) 32%,
    rgb(0 0 0 / 0.14) 58%,
    rgb(0 0 0 / 0)    78%);
}

/* Optional progressive blur on top. The gradient must carry contrast
   on its own, because backdrop-filter support is not universal. */
.overlay--blur .overlay__blur {
  position: absolute; inset: auto 0 0 0; height: 55%; z-index: 2;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  mask-image: linear-gradient(to top, #000 22%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, #000 22%, transparent 100%);
  pointer-events: none;
}

.overlay__content { position: absolute; inset: auto 0 0 0; z-index: 3; padding: var(--s-8); color: #fff; }
.overlay__content p { color: rgb(255 255 255 / 0.88); }


/* ============================================================
   MICRO-INTERACTIONS  [V 8:09]
   Required only when the result is invisible. Anchored to the
   trigger, auto-dismissing, never layout-shifting.
   ============================================================ */

.micro-host { position: relative; display: inline-flex; }

.micro-chip {
  position: absolute;
  bottom: calc(100% + var(--s-2));
  left: 50%;
  transform: translate(-50%, 6px);
  padding: var(--s-1) var(--s-3);
  background: var(--text);
  color: var(--text-inv);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-state) var(--ease-out),
              transform var(--t-state) var(--ease-out);
}
.micro-chip[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .micro-chip { transform: translate(-50%, 0); transition: opacity 0.01ms; }
}


/* ============================================================
   SKELETONS  — for waits over ~3s
   ============================================================ */

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--surface-2); }
}


/* ============================================================
   TOAST  — only when the result is NOT visible on screen
   ============================================================ */

.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-600);
  border-radius: var(--r-md);
  box-shadow: var(--e-3);
  max-width: 420px;
}
.toast--success { border-left-color: var(--success); }
.toast--danger  { border-left-color: var(--danger); }


/* ============================================================
   NAV  — ghost buttons at a different density [V 7:09]
   Active state uses color + weight + indicator, never color alone.
   ============================================================ */

.nav__link {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  position: relative;
  transition: background-color var(--t-instant) var(--ease-std);
}
.nav__link:hover { background: var(--surface-2); color: var(--text); }
.nav__link[aria-current="page"] {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 650;
}
.nav__link[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: var(--r-full); background: var(--brand-600);
}


/* ============================================================
   390px FLOOR
   ============================================================ */

@media (max-width: 480px) {
  body { overflow-x: hidden; }
  .container { padding-inline: var(--s-4); }
  .cta-pair { flex-direction: column; }
  .cta-pair .btn { width: 100%; }
  .card { padding: var(--s-5); }
  .overlay__content { padding: var(--s-5); }
  /* Touch targets: 44px minimum with 8px between. */
  .btn, .input, .nav__link { min-height: var(--tap-min); }
  .nav__link + .nav__link { margin-top: var(--s-2); }
}
